]> git.ipfire.org Git - thirdparty/linux.git/commit
iomap: support invalidating partial folios
authorZhang Yi <yi.zhang@huawei.com>
Tue, 14 Jul 2026 08:23:22 +0000 (16:23 +0800)
committerChristian Brauner <brauner@kernel.org>
Thu, 23 Jul 2026 09:26:27 +0000 (11:26 +0200)
commit562d192c43459d70d955775e8a17eebd995539d4
treeceff7dfaa6c015985a47c2452ae829959bc886f2
parent88c26515313169806a412a362b32a1eca53d21bd
iomap: support invalidating partial folios

Current iomap_invalidate_folio() can only invalidate an entire folio. If
we truncate a partial folio on a filesystem where the block size is
smaller than the folio size, it will leave behind dirty bits for the
truncated or punched blocks. During the write-back process, it will
attempt to map the invalid hole range. Fortunately, this has not caused
any real problems so far because the ->writeback_range() function
corrects the length.

However, the implementation of FALLOC_FL_ZERO_RANGE in ext4 depends on
the support for invalidating partial folios. When ext4 partially zeroes
out a dirty and unwritten folio, it does not perform a flush first like
XFS. Therefore, if the dirty bits of the corresponding area cannot be
cleared, the zeroed area after writeback remains in the written state
rather than reverting to the unwritten state. Fix this by supporting
invalidation of partial folios.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Link: https://patch.msgid.link/20260714082325.325163-3-yi.zhang@huaweicloud.com
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Joanne Koong <joannelkoong@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/iomap/buffered-io.c