diff options
author | Ojaswin Mujoo <ojaswin@linux.ibm.com> | 2023-11-01 22:08:11 +0530 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2024-01-04 23:28:47 -0500 |
commit | c6bfd724098457a1162a7b9fef07af176720055b (patch) | |
tree | 0449013b4357346efed3edee3dd0d0bdc201e1d1 /fs/ext4/inode.c | |
parent | 92573369144f40397e8514440afdf59f24905b40 (diff) | |
download | linux-stable-c6bfd724098457a1162a7b9fef07af176720055b.tar.gz linux-stable-c6bfd724098457a1162a7b9fef07af176720055b.tar.bz2 linux-stable-c6bfd724098457a1162a7b9fef07af176720055b.zip |
ext4: clarify handling of unwritten bh in __ext4_block_zero_page_range()
As an optimization, I was trying to work on exiting early from this
function if dealing with unwritten extent since they anyways read 0.
However, it was realised that there are certain code paths that can
end up calling ext4_block_zero_page_range() for an unwritten bh that
might still have data in pagecache. In this case, we can't exit early
and we do require to process the bh and zero out the pagecache to ensure
that a writeback can't kick in at a later time and flush the stale
pagecache to disk.
Since, adding the logic to exit early for unwritten bh was turning out
to be much more nuanced and the current code already handles it well,
just add a comment to explicitly document this behavior.
Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/d859b7ae5fe42e6626479b91ed9f4da3aae4c597.1698856309.git.ojaswin@linux.ibm.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 61277f7f8722..96d3211508a0 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3630,6 +3630,12 @@ void ext4_set_aops(struct inode *inode) inode->i_mapping->a_ops = &ext4_aops; } +/* + * Here we can't skip an unwritten buffer even though it usually reads zero + * because it might have data in pagecache (eg, if called from ext4_zero_range, + * ext4_punch_hole, etc) which needs to be properly zeroed out. Otherwise a + * racing writeback can come later and flush the stale pagecache to disk. + */ static int __ext4_block_zero_page_range(handle_t *handle, struct address_space *mapping, loff_t from, loff_t length) { |