From: Zhang Yi <yi.zhang@xxxxxxxxxx> Increase i_size in iomap_zero_range() looks not needed, the caller should handle it. Especially, when truncate partial block, we should not increase i_size beyond the new EOF here. It dosn't affect xfs and gfs2 now because they reset the new file size after zero out, it doesn't matter that a brief increase in i_size. But it will affect ext4 because it set file size before truncate, so avoid increasing if it's not a write path. Signed-off-by: Zhang Yi <yi.zhang@xxxxxxxxxx> --- fs/iomap/buffered-io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index fd4d43bafd1b..3b9ba390dd1b 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -852,13 +852,13 @@ static size_t iomap_write_end(struct iomap_iter *iter, loff_t pos, size_t len, * cache. It's up to the file system to write the updated size to disk, * preferably after I/O completion so that no stale data is exposed. */ - if (pos + ret > old_size) { + if ((iter->flags & IOMAP_WRITE) && pos + ret > old_size) { i_size_write(iter->inode, pos + ret); iter->iomap.flags |= IOMAP_F_SIZE_CHANGED; } __iomap_put_folio(iter, pos, ret, folio); - if (old_size < pos) + if ((iter->flags & IOMAP_WRITE) && old_size < pos) pagecache_isize_extended(iter->inode, old_size, pos); if (ret < len) iomap_write_failed(iter->inode, pos + ret, len - ret); -- 2.39.2