Skip to content

Commit d37a7dd

Browse files
LiBaokun96tytso
authored andcommitted
ext4: make ext4_punch_hole() support large block size
When preparing for bs > ps support, clean up unnecessary PAGE_SIZE references in ext4_punch_hole(). Previously, when a hole extended beyond i_size, we aligned the hole end upwards to PAGE_SIZE to handle partial folio invalidation. Now that truncate_inode_pages_range() already handles partial folio invalidation correctly, this alignment is no longer required. However, to save pointless tail block zeroing, we still keep rounding up to the block size here. In addition, as Honza pointed out, when the hole end equals i_size, it should also be rounded up to the block size. This patch fixes that as well. Suggested-by: Jan Kara <jack@suse.cz> Signed-off-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: Zhang Yi <yi.zhang@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com> Message-ID: <20251121090654.631996-5-libaokun@huaweicloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent afa6d5a commit d37a7dd

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

fs/ext4/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4408,10 +4408,10 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
44084408

44094409
/*
44104410
* If the hole extends beyond i_size, set the hole to end after
4411-
* the page that contains i_size.
4411+
* the block that contains i_size to save pointless tail block zeroing.
44124412
*/
4413-
if (end > inode->i_size)
4414-
end = round_up(inode->i_size, PAGE_SIZE);
4413+
if (end >= inode->i_size)
4414+
end = round_up(inode->i_size, sb->s_blocksize);
44154415
if (end > max_end)
44164416
end = max_end;
44174417
length = end - offset;

0 commit comments

Comments
 (0)