Skip to content

iomap: zero range folio batch support

Brian Foster linux-fsdevel linux-mm linux-xfs 5 versions – Applied

Status from this message: Applied to the vfs-6.19.iomap branch of the vfs/vfs.git tree.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest7 patches 6 repliesApplied
  2. v47 patches 0 repliesSuperseded
  3. v37 patches 29 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v27 patches8 repliesSuperseded
v17 patches31 repliesSuperseded

Changes in v5 from the cover letter · 22 lines

- Rebased across XFS errortag mechanism rework.
v4: https://lore.kernel.org/linux-fsdevel/[email protected]/
- Update commit log description in patch 3.
- Added remaining R-b tags.
v3: https://lore.kernel.org/linux-fsdevel/[email protected]/
- Update commit log description in patch 2.
- Improve comments in patch 7.
v2: https://lore.kernel.org/linux-fsdevel/[email protected]/
- Move filemap patch to top. Add some comments and drop export.
- Drop unnecessary BUG_ON()s from iomap_write_begin() instead of moving.
- Added folio mapping check to batch codepath, improved comments.
v1: https://lore.kernel.org/linux-fsdevel/[email protected]/
- Dropped most prep patches from previous version (merged separately).
- Reworked dirty folio lookup to use find_get_entry() loop (new patch
for filemap helper).
- Misc. bug fixes, code cleanups, comments, etc.
- Added (RFC) prospective patch for wider zero range test coverage.
RFCv2: https://lore.kernel.org/linux-fsdevel/[email protected]/
- Port onto incremental advance, drop patch 1 from RFCv1.
- Moved batch into iomap_iter, dynamically allocate and drop flag.
- Tweak XFS patch to always trim zero range on EOF boundary.
RFCv1: https://lore.kernel.org/linux-fsdevel/[email protected]/

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/7filemap: add helper to look up dirty folios in a rangeinclude/linux/pagemap.h mm/filemap.c+60 -00 replies
2/7iomap: remove pos+len BUG_ON() to after folio lookupfs/iomap/buffered-io.c+1 -40 replies
3/7iomap: optional zero range dirty folio processingfs/iomap/buffered-io.c fs/iomap/iter.c include/linux/iomap.h+94 -50 replies
4/7xfs: always trim mapping to requested range for zero rangefs/xfs/xfs_iomap.c+8 -90 replies
5/7xfs: fill dirty folios on zero range of unwritten mappingsfs/xfs/xfs_iomap.c+23 -03 replies
6/7iomap: remove old partial eof zeroing optimizationfs/iomap/buffered-io.c+0 -250 replies
7/7xfs: error tag to force zeroing on debug kernelsfs/xfs/libxfs/xfs_errortag.h fs/xfs/xfs_file.c+26 -90 replies

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by.

PatchChristoph HellwigDarrick J. Wong
1/7R-b R-b
2/7R-b R-b
3/7R-b R-b
4/7R-b R-b
5/7R-b R-b
6/7R-b R-b
7/7R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/7] iomap: zero range folio batch support

Hi all,

Only minor changes in v5 to the XFS errortag patch. I've kept the R-b tags because the fundamental logic is the same, but the errortag mechanism has been reworked and so that one needed a rebase (which turns out much simpler). A second look certainly couldn't hurt, but otherwise the associated fstest still works as expected.

Note that the force zeroing fstests test has since been merged as xfs/131. Otherwise I still have some followup patches to this work re:
the ext4 on iomap work, but it would be nice to move this along before getting too far ahead with that.

Brian

--- Original cover letter ---

Hi all,

Here's a first real v1 of folio batch support for iomap. This initially only targets zero range, the use case being zeroing of dirty folios over unwritten mappings. There is potential to support other operations in the future: iomap seek data/hole has similar raciness issues as zero range, the prospect of using this for buffered write has been raised for granular locking purposes, etc.

The one major caveat with this zero range implementation is that it doesn't look at iomap_folio_state to determine whether to zero a sub-folio portion of the folio. Instead it just relies on whether the folio was dirty or not. This means that spurious zeroing of unwritten ranges is possible if a folio is dirty but the target range includes a subrange that is not.

The reasoning is that this is essentially a complexity tradeoff. The current use cases for iomap_zero_range() are limited mostly to partial block zeroing scenarios. It's relatively harmless to zero an unwritten block (i.e. not a correctness issue), and this is something that filesystems have done in the past without much notice or issue. The advantage is less code and this makes it a little easier to use a filemap lookup function for the batch rather than open coding more logic in iomap. That said, this can probably be enhanced to look at ifs in the future if the use case expands and/or other operations justify it.

WRT testing, I've tested with and without a local hack to redirect fallocate zero range calls to iomap_zero_range() in XFS. This helps test beyond the partial block/folio use case, i.e. to cover boundary conditions like full folio batch handling, etc. I recently added patch 7 in spirit of that, which turns this logic into an XFS errortag. Further comments on that are inline with patch 7.

Thoughts, reviews, flames appreciated.

Brian

v5:
- Rebased across XFS errortag mechanism rework.
v4: https://lore.kernel.org/linux-fsdevel/[email protected]/
- Update commit log description in patch 3.
- Added remaining R-b tags.
v3: https://lore.kernel.org/linux-fsdevel/[email protected]/
- Update commit log description in patch 2.
- Improve comments in patch 7.
v2: https://lore.kernel.org/linux-fsdevel/[email protected]/
- Move filemap patch to top. Add some comments and drop export.
- Drop unnecessary BUG_ON()s from iomap_write_begin() instead of moving.
- Added folio mapping check to batch codepath, improved comments.
v1: https://lore.kernel.org/linux-fsdevel/[email protected]/
- Dropped most prep patches from previous version (merged separately).
- Reworked dirty folio lookup to use find_get_entry() loop (new patch
for filemap helper).
- Misc. bug fixes, code cleanups, comments, etc.
- Added (RFC) prospective patch for wider zero range test coverage.
RFCv2: https://lore.kernel.org/linux-fsdevel/[email protected]/
- Port onto incremental advance, drop patch 1 from RFCv1.
- Moved batch into iomap_iter, dynamically allocate and drop flag.
- Tweak XFS patch to always trim zero range on EOF boundary.
RFCv1: https://lore.kernel.org/linux-fsdevel/[email protected]/

Brian Foster (7):
filemap: add helper to look up dirty folios in a range
iomap: remove pos+len BUG_ON() to after folio lookup
iomap: optional zero range dirty folio processing
xfs: always trim mapping to requested range for zero range
xfs: fill dirty folios on zero range of unwritten mappings
iomap: remove old partial eof zeroing optimization
xfs: error tag to force zeroing on debug kernels

 fs/iomap/buffered-io.c       | 117 +++++++++++++++++++++++++----------
 fs/iomap/iter.c              |   6 ++
 fs/xfs/libxfs/xfs_errortag.h |   6 +-
 fs/xfs/xfs_file.c            |  29 ++++++---
 fs/xfs/xfs_iomap.c           |  38 +++++++++---
 include/linux/iomap.h        |   4 ++
 include/linux/pagemap.h      |   2 +
 mm/filemap.c                 |  58 +++++++++++++++++
 8 files changed, 210 insertions(+), 50 deletions(-)
Signature · 1 line
2.51.0