[PATCH 0/6] iomap, xfs: improve zero range flushing and lookup

Brian Foster
2025-10-16T18:58:49Z

Hi all,

Now that the folio_batch bits are headed into -next here is the next
phase of cleanups. Most of this has been previously discussed at one
point or another. Zhang Yi had reported a couple outstanding issues
related to the conversion of ext4 over to iomap. One had to do with the
context of the folio_batch dynamic allocation and another is the flush
in the the non-unwritten mapping case can cause problems.

This series attempts to address the former issue in patch 1 by using a
stack allocated folio_batch and iomap flag, eliminating the need for the
dynamic allocation. The non-unwritten flush case only exists as a
band-aid for wonky XFS behavior, so patches 2-6 lift this logic into XFS
and work on it from there. Ultimately, the flush is relocated to insert
range where it appears to be needed and the iomap begin usage is
replaced with another use of the folio batch mechanism.

This has survived testing so far on XFS in a handful of different
configs and arches. WRT patch 3, I would have liked to reorder the
existing insert range truncate and flush in either direction rather than
introduce a new flush just for EOF, but neither seemed obviously clean
enough to me as I was looking at it with the current code factoring. So
rather than go back and forth on that on my own I opted to keep the
patch simple to start and maybe see what the folks on the XFS list
think.

Note that this applies on top of the pending folio_batch series [1].
Thoughts, reviews, flames appreciated.

Brian

[1] https://lore.kernel.org/linux-fsdevel/20251003134642.604736-1-bfoster@redhat.com/

Brian Foster (6):
iomap: replace folio_batch allocation with stack allocation
iomap, xfs: lift zero range hole mapping flush into xfs
xfs: flush eof folio before insert range size update
xfs: look up cow fork extent earlier for buffered iomap_begin
xfs: only flush when COW fork blocks overlap data fork holes
xfs: replace zero range flush with folio batch

fs/iomap/buffered-io.c | 49 +++++++++++++--------
fs/iomap/iter.c | 6 +--
fs/xfs/xfs_file.c | 17 ++++++++
fs/xfs/xfs_iomap.c | 98 +++++++++++++++++++++++++++++-------------
include/linux/iomap.h | 8 +++-
5 files changed, 125 insertions(+), 53 deletions(-)

--
2.51.0