From: Zhang Yi FALLOC_FL_WRITE_ZEROES is mutually exclusive with FALLOC_FL_KEEP_SIZE. In ext4_zero_range(), when end > i_disksize, new_size is always set to end for WRITE_ZEROES, so the i_disksize update should not be lost. The ext4_update_disksize_before_punch() call is only needed for the ZERO_RANGE path in ext4_zero_range(), as it handles the case where KEEP_SIZE may preserve the original disk size. Skip it for WRITE_ZEROES to avoid unnecessary work and potential confusion. Signed-off-by: Zhang Yi --- fs/ext4/extents.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index c083703bf704..38753c2ef910 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4748,9 +4748,11 @@ static long ext4_zero_range(struct file *file, loff_t offset, return ret; } - ret = ext4_update_disksize_before_punch(inode, offset, len); - if (ret) - return ret; + if (mode & FALLOC_FL_ZERO_RANGE) { + ret = ext4_update_disksize_before_punch(inode, offset, len); + if (ret) + return ret; + } /* Now release the pages and zero block aligned part of pages */ ret = ext4_truncate_page_cache_block_range(inode, offset, end); -- 2.53.0