From: Baokun Li Since the block size may be greater than the page size, when a hole extends beyond i_size, we need to align the hole's end upwards to the larger of PAGE_SIZE and blocksize. This is to prevent the issues seen in commit 2be4751b21ae ("ext4: fix 2nd xfstests 127 punch hole failure") from reappearing after BS > PS is supported. Signed-off-by: Baokun Li Reviewed-by: Zhang Yi --- fs/ext4/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 4c04af7e51c9..a63513a3db53 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4401,7 +4401,8 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length) * the page that contains i_size. */ if (end > inode->i_size) - end = round_up(inode->i_size, PAGE_SIZE); + end = round_up(inode->i_size, + umax(PAGE_SIZE, sb->s_blocksize)); if (end > max_end) end = max_end; length = end - offset; -- 2.46.1