iomap: convert to in-iter iomap_next() model
Subsystems (19)
v5 cover iomap: convert to in-iter iomap_next() model
This series implements a suggestion by Christoph for finishing the conversion of iomap to an iterator model. This revives Matthew's previous RFC [1], which had the same intention.
Every iomap operation currently drives its iteration through a struct iomap_ops, which contains two callbacks, ->iomap_begin() and ->iomap_end(). iomap_iter() only ever sees these as pointers, so every step of every iteration is an indirect call, including on the hottest paths.
This series replaces the begin/end pair with a single ->iomap_next() callback that finishes the previous mapping (if any) and produces the next one. Collapsing to one callback lets a performance-critical caller inline its iteration loop and pass its ->iomap_next() function as a compile-time constant, where the compiler can devirtualize the callback into a direct and inlineable call rather than an indirect one. It also allows future callers more flexibility in expressing custom logic in the IO path for driving the iteration forward.
This series has no functional changes intended. The patches are broken down as follows:
1) Patch 1: Brian's fix for folio batch release on iomap callback failures. The bug was reported by Sashiko and is an unlikely/second order error scenario
[2] that doesn't need backporting to stable.
2) Patch 2: refactors existing iomap_iter() logic into an iomap_iter_next() function. Sets up DEFINE_IOMAP_ITER_NEXT/DEFINE_IOMAP_ITER_NEXT_END macro.
3) Patch 3 and 4: Christoph's patches for decoupling simple direct i/o reads from iomap_dio_rw and improvement for using GFP_NOWAIT for non-blocking iocbs
[3]
4) Patch 5: Adds ->iomap_next() callback as an iomap op
5) Patches 6 to 19: converts each filesystem to ->iomap_next() model
6) Patch 20: Removes the legacy ->iomap_begin()/->iomap_end() path
7) Patch 21: At this point, struct iomap_ops only has one item in it, the ->iomap_next() callback. Gets rid of struct iomap_ops and passes iomap_iter_next_fn directly.
8) Patch 22: Updates the iomap documentation to match.
This series is submitted against the vfs tree on top of the vfs-7.3.iomap branch (head commit f166f2d0a0ae "Merge patch series "iomap/fuse: add helper to keep..."). The changes can also be found in this github link [4]. This series was run through an ai review system for additional sanity-checking.
As discussed in v2 about the merge logistics [5], the plan is for patches 1 to 19 to be merged in the v7.3-rc1 cycle and for patches 20 to 22 to be merged after v7.3-rc1 has been tagged, in order to minimize disruption to filesystems that are currently landing iomap conversions during the 7.3 merge window. Patches 20 to 22 are included in this series for upstream review, so that they can be approved / all ready to go when the 7.3 merge window closes.
Thanks,
Joanne
[1] https://lore.kernel.org/linux-fsdevel/[email protected]/T/#u
[2] https://lore.kernel.org/linux-fsdevel/amjztG-DisHYbV9W@bfoster/
[3] https://lore.kernel.org/linux-fsdevel/[email protected]/
[4] https://github.com/joannekoong/linux/tree/iomap_iter_next_v5
[5] https://lore.kernel.org/linux-fsdevel/20260703-nachrangig-gegeben-befestigen-8219a53648c7@brauner/
Changelog
---------
v4: https://lore.kernel.org/linux-fsdevel/[email protected]/
v4 -> v5:
* Add Brian's release batch fix, modify patch 2 ("split iomap_iter() logic into...") to work with this
* Add DECLARE_IOMAP_ITER_NEXT macro to patch 21 for forward declarations (Darrick)
* Kept reviewed-bys for the patches changed, but Darrick/Christoph/Fengnan, if you don't like the change and want to revoke your name, please let me know
* Add Reviewed-bys from Darrick and Fengnan
v3: https://lore.kernel.org/linux-fsdevel/[email protected]/
v3 -> v4:
* Fold in Christoph's "decouple simple direct I/O reads from iomap_dio_rw v2" series and drop v3's simple dio patch/changes
* Add reviewed-bys
v2: https://lore.kernel.org/linux-fsdevel/[email protected]/
v2 -> v3:
* Rename iomap_next_fn to iomap_iter_next_fn and iomap_process() to iomap_iter_next() (Darrick)
* Add integration with dio simple path, add Fengnan's patch
* Reconstruct patch that adds iomap_iter_next() logic as a refactoring of existing code (Christoph)
* Add DEFINE_IOMAP_ITER_NEXT{_END} macro, which nicely simplifies things (Christoph)
* Make documentation wording changes and a rename from dops -> next (Darrick)
* Update tracepoint in patch 19 to reflect taking iomap_iter_next_fn instead of ops. iomap tracepoints are explicitly called out as non-stable ABI so I kept Christoph's reviewed-by for this, but if that should be revoked, please let me know
* Add reviewed-bys
v1: https://lore.kernel.org/linux-fsdevel/[email protected]/
v1 -> v2:
* Implement conversion for all callers
Brian Foster (1):
iomap: release the folio batch on iomap callback failures
Christoph Hellwig (2):
iomap: decouple simple direct I/O reads from iomap_dio_rw
iomap: use GFP_NOWAIT when application for iomap_dio_simple
allocations
Joanne Koong (19):
iomap: split iomap_iter() logic into iomap_iter_next()
iomap: add ->iomap_next()
xfs: convert iomap ops to ->iomap_next()
btrfs: convert iomap ops to ->iomap_next()
ntfs3: convert iomap ops to ->iomap_next()
ntfs: convert iomap ops to ->iomap_next()
ext4: convert iomap ops to ->iomap_next()
erofs: convert iomap ops to ->iomap_next()
zonefs: convert iomap ops to ->iomap_next()
ext2: convert iomap ops to ->iomap_next()
block: convert iomap ops to ->iomap_next()
f2fs: convert iomap ops to ->iomap_next()
gfs2: convert iomap ops to ->iomap_next()
hpfs: convert iomap ops to ->iomap_next()
fuse: convert iomap ops to ->iomap_next()
exfat: convert iomap ops to ->iomap_next()
iomap: remove ->iomap_begin()/->iomap_end() legacy path
iomap: pass iomap_iter_next_fn directly instead of struct iomap_ops
Documentation: iomap: update docs to reflect iomap_iter_next model
Documentation/filesystems/iomap/design.rst | 140 ++++++++--- .../filesystems/iomap/operations.rst | 68 +++--- Documentation/filesystems/iomap/porting.rst | 16 +- block/fops.c | 10 +- fs/btrfs/direct-io.c | 10 +- fs/dax.c | 48 ++-- fs/erofs/data.c | 30 ++- fs/erofs/internal.h | 2 +- fs/erofs/zmap.c | 4 +- fs/exfat/file.c | 18 +- fs/exfat/inode.c | 6 +- fs/exfat/iomap.c | 12 +- fs/exfat/iomap.h | 6 +- fs/ext2/ext2.h | 3 +- fs/ext2/file.c | 4 +- fs/ext2/inode.c | 7 +- fs/ext4/ext4.h | 8 +- fs/ext4/extents.c | 8 +- fs/ext4/file.c | 16 +- fs/ext4/inode.c | 16 +- fs/f2fs/data.c | 4 +- fs/f2fs/f2fs.h | 3 +- fs/f2fs/file.c | 4 +- fs/fuse/dax.c | 12 +- fs/fuse/file.c | 10 +- fs/fuse/virtio_fs.c | 3 +- fs/gfs2/aops.c | 6 +- fs/gfs2/bmap.c | 7 +- fs/gfs2/bmap.h | 2 +- fs/gfs2/file.c | 6 +- fs/gfs2/inode.c | 6 +- fs/hpfs/file.c | 6 +- fs/internal.h | 1 - fs/iomap/buffered-io.c | 40 +-- fs/iomap/direct-io.c | 219 +++++------------ fs/iomap/fiemap.c | 8 +- fs/iomap/iter.c | 123 +++++----- fs/iomap/seek.c | 8 +- fs/iomap/swapfile.c | 4 +- fs/iomap/trace.h | 12 +- fs/ntfs/aops.c | 6 +- fs/ntfs/file.c | 24 +- fs/ntfs/inode.c | 2 +- fs/ntfs/iomap.c | 34 +-- fs/ntfs/iomap.h | 10 +- fs/ntfs3/file.c | 16 +- fs/ntfs3/inode.c | 11 +- fs/ntfs3/ntfs_fs.h | 3 +- fs/remap_range.c | 6 +- fs/xfs/xfs_aops.c | 8 +- fs/xfs/xfs_file.c | 58 ++--- fs/xfs/xfs_iomap.c | 50 ++-- fs/xfs/xfs_iomap.h | 20 +- fs/xfs/xfs_iops.c | 4 +- fs/xfs/xfs_reflink.c | 6 +- fs/zonefs/file.c | 23 +- include/linux/dax.h | 18 +- include/linux/fs.h | 7 +- include/linux/iomap.h | 231 ++++++++++++++---- 59 files changed, 771 insertions(+), 682 deletions(-)
Signature · 1 line
2.52.0
PATCH v5 1/22 iomap: release the folio batch on iomap callback failures
From: Brian Foster <[email protected]>
A sashiko review of an unrelated patch points out that the folio batch mechanism used for iomap zero range fails to release the batch in a couple error scenarios. If either calls to ->iomap_end() or ->iomap_begin() fail, the direct return paths bypass the batch cleanup.
The ->iomap_end() case is not a practical issue at the moment because there is no user of the mechanism that returns an error from this path. The ->iomap_begin() case is theoretically possible because XFS can invoke the fill helper and error out at various points thereafter. This subtly complicates things because XFS does not transfer iomap_flags to the iomap data structure in the error path.
To deal with both of these issues, first make sure to invoke the cleanup helper in the error path for either fs callback. Second, update the helper to clear the flag unconditionally and release the batch so long as it is populated. This more clearly delineates the purpose of the flag to control the I/O path and not necessarily the status of the fbatch, so add a comment around this as well.
--- fs/iomap/iter.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
fs/iomap/iter.c +14 -4
@@ -6,12 +6,18 @@#include <linux/iomap.h> #include "trace.h" +/* +* Release the iter folio batch. Note that the iomap flag is meant to control +* the I/O path for the mapping and may not be set in error situations. +*/ static inline void iomap_iter_clean_fbatch (struct iomap_iter *iter) { -if (iter->iomap.flags &IOMAP_F_FOLIO_BATCH ) { +if (!iter->fbatch) +return ; + iter->iomap.flags &= ~IOMAP_F_FOLIO_BATCH ; +if (folio_batch_count (iter->fbatch)) {folio_batch_release (iter->fbatch);folio_batch_reinit (iter->fbatch); - iter->iomap.flags &= ~IOMAP_F_FOLIO_BATCH ; } }
@@ -79,7 +85,7 @@ int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops) olen), advanced, iter->flags, &iter->iomap);if (ret <0 && !advanced) -return ret; + goto error; }/* detect old return semantics where this would advance */
@@ -110,7 +116,11 @@ int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops) ret = ops->iomap_begin (iter->inode, iter->pos, iter->len, iter->flags, &iter->iomap, &iter->srcmap);if (ret <0 ) -return ret; + goto error;iomap_iter_done (iter);return 1 ; + +error: +iomap_iter_clean_fbatch (iter); +return ret; }
Signature · 1 line
2.52.0
Re: [PATCH v5 01/22] iomap: release the folio batch on iomap callback failures
Quoted 23 lines · Joanne Koong
From: Brian Foster <[email protected]>
A sashiko review of an unrelated patch points out that the folio batch mechanism used for iomap zero range fails to release the batch in a couple error scenarios. If either calls to ->iomap_end() or ->iomap_begin() fail, the direct return paths bypass the batch cleanup.
The ->iomap_end() case is not a practical issue at the moment because there is no user of the mechanism that returns an error from this path. The ->iomap_begin() case is theoretically possible because XFS can invoke the fill helper and error out at various points thereafter. This subtly complicates things because XFS does not transfer
iomap_flagsto the iomap data structure in the error path.To deal with both of these issues, first make sure to invoke the cleanup helper in the error path for either fs callback. Second, update the helper to clear the flag unconditionally and release the batch so long as it is populated. This more clearly delineates the purpose of the flag to control the I/O path and not necessarily the status of the fbatch, so add a comment around this as well.
Quoted 4 lines
Reported-by Sashiko <[email protected]>Assisted-by LLMFixes 395ed1ef0012 ("iomap: optional zero range dirty folio processing")Signed-off-by Brian Foster <[email protected]>
Seems reasonable to me,
--D
Quoted 55 lines
--- fs/iomap/iter.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)fs/iomap/iter.c +14
-4@@ -6,12 +6,18 @@#include <linux/iomap.h> #include "trace.h" +/* +* Release the iter folio batch. Note that the iomap flag is meant to control +* the I/O path for the mapping and may not be set in error situations. +*/ static inline void iomap_iter_clean_fbatch (struct iomap_iter *iter) { -if (iter->iomap.flags &IOMAP_F_FOLIO_BATCH ) { +if (!iter->fbatch) +return ; + iter->iomap.flags &= ~IOMAP_F_FOLIO_BATCH ; +if (folio_batch_count (iter->fbatch)) {folio_batch_release (iter->fbatch);folio_batch_reinit (iter->fbatch); - iter->iomap.flags &= ~IOMAP_F_FOLIO_BATCH ; } }@@ -79,7 +85,7 @@ int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops) olen), advanced, iter->flags, &iter->iomap);if (ret <0 && !advanced) -return ret; + goto error; }/* detect old return semantics where this would advance */ @@ -110,7 +116,11 @@ int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops) ret = ops->iomap_begin (iter->inode, iter->pos, iter->len, iter->flags, &iter->iomap, &iter->srcmap);if (ret <0 ) -return ret; + goto error;iomap_iter_done (iter);return 1 ; + +error: +iomap_iter_clean_fbatch (iter); +return ret; }Signature · 1 line
2.52.0
Re: [PATCH v5 01/22] iomap: release the folio batch on iomap callback failures
In reply to Joanne KoongLooks good:
PATCH v5 2/22 iomap: split iomap_iter() logic into iomap_iter_next()
In reply to Joanne KoongIn preparation for changing iomap to use an in-iter (->iomap_next()) model, move the iomap_iter() logic out into the new iomap_iter_next() helper function.
iomap_iter_next() is added as an inlined helper so it can be called directly by ->iomap_next() implementations where the begin()/end() callbacks can be direct calls.
The DEFINE_IOMAP_ITER_NEXT() and DEFINE_IOMAP_ITER_NEXT_END() macros are also provided to generate the boilerplate ->iomap_next() wrapper functions that simply forward to iomap_iter_next() with the appropriate begin/end callbacks. DEFINE_IOMAP_ITER_NEXT() is for the common case where there is no end() callback. DEFINE_IOMAP_ITER_NEXT_END() is for the case where there is an explicit end() callback.
No functional change intended. The one would-be behavioral difference is that on the iomap_end() error path (ret < 0 && !advanced), the old code returned with iter.status left as the caller's last value whereas the new code zeroes it, but this is not observable in practice as there are no in-tree callers that read iter.status after the iteration loop.
--- fs/iomap/iter.c | 116 ++++++++++++++++++++++-------------------- include/linux/iomap.h | 102 ++++++++++++++++++++++++++++++------- 2 files changed, 145 insertions(+), 73 deletions(-)
fs/iomap/iter.c +60 -56
@@ -10,11 +10,12 @@* Release the iter folio batch. Note that the iomap flag is meant to control * the I/O path for the mapping and may not be set in error situations. */ -static inline void iomap_iter_clean_fbatch (struct iomap_iter *iter) +static inline void iomap_iter_clean_fbatch (const struct iomap_iter *iter, +struct iomap *iomap) {if (!iter->fbatch)return ; - iter->iomap.flags &= ~IOMAP_F_FOLIO_BATCH ; + iomap->flags &= ~IOMAP_F_FOLIO_BATCH ;if (folio_batch_count (iter->fbatch)) {folio_batch_release (iter->fbatch);folio_batch_reinit (iter->fbatch);
@@ -46,51 +47,27 @@ static inline void iomap_iter_done(struct iomap_iter *iter) }/** -* iomap_iter - iterate over a ranges in a file -* @iter: iteration structue -* @ops: iomap ops provided by the file system +* iomap_iter_continue - decide whether iteration should continue +* @iter: iteration structure +* @iomap: the mapping that was just processed +* @srcmap: the source mapping that was just processed * -* Iterate over filesystem-provided space mappings for the provided file range. +* Helper normally called via iomap_iter_next(). Called after the previous +* mapping has been finished to determine whether there is more of the file +* range left to process. * -* This function handles cleanup of resources acquired for iteration when the -* filesystem indicates there are no more space mappings, which means that this -* function must be called in a loop that continues as long it returns a -* positive value. If 0 or a negative value is returned, the caller must not -* return to the loop body. Within a loop body, there are two ways to break out -* of the loop body: leave @iter.status unchanged, or set it to a negative -* errno. +* Returns 1 if there is more work to do, in which case @iomap and @srcmap are +* cleared so the caller can produce the next mapping; zero if the range is +* fully consumed; or a negative errno on error. */ -int iomap_iter (struct iomap_iter *iter,const struct iomap_ops *ops) +int iomap_iter_continue (const struct iomap_iter *iter,struct iomap *iomap, +struct iomap *srcmap,int ret) { -bool stale = iter->iomap.flags &IOMAP_F_STALE ; -ssize_t advanced; -u64 olen; -int ret; - -trace_iomap_iter (iter, ops, _RET_IP_); +const bool stale = iomap->flags &IOMAP_F_STALE ; +const ssize_t advanced = iter->pos - iter->iter_start_pos; -if (!iter->iomap.length) - goto begin; - -/* -* Calculate how far the iter was advanced and the original length bytes -* for ->iomap_end(). -*/ - advanced = iter->pos - iter->iter_start_pos; - olen = iter->len + advanced; - -if (ops->iomap_end) { - ret = ops->iomap_end (iter->inode, iter->iter_start_pos, -iomap_length_trim (iter, iter->iter_start_pos, - olen), - advanced, iter->flags, &iter->iomap); -if (ret <0 && !advanced) - goto error; - } - -/* detect old return semantics where this would advance */ -if (WARN_ON_ONCE (iter->status >0 )) - iter->status = -EIO ; +if (ret <0 && !advanced) +return ret;/* * Use iter->len to determine whether to continue onto the next mapping.
@@ -98,29 +75,56 @@ int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)* advanced at all (i.e. no work was done for some reason) unless the * mapping has been marked stale and needs to be reprocessed. */ -if (iter->status <0 ) +if (WARN_ON_ONCE (iter->status >0 )) +/* detect old return semantics where this would advance */ + ret = -EIO ; +else if (iter->status <0 ) ret = iter->status;else if (iter->len ==0 || (!advanced && !stale)) ret =0 ;else ret =1 ; -iomap_iter_clean_fbatch (iter); - iter->status =0 ; + +iomap_iter_clean_fbatch (iter, iomap); +if (ret <=0 )return ret; -memset (&iter->iomap,0 ,sizeof (iter->iomap)); -memset (&iter->srcmap,0 ,sizeof (iter->srcmap)); +memset (iomap,0 ,sizeof (*iomap)); +memset (srcmap,0 ,sizeof (*srcmap)); -begin: - ret = ops->iomap_begin (iter->inode, iter->pos, iter->len, iter->flags, - &iter->iomap, &iter->srcmap); -if (ret <0 ) - goto error; -iomap_iter_done (iter); -return 1 ; +return ret; +} +EXPORT_SYMBOL_GPL (iomap_iter_continue); + +/** +* iomap_iter - iterate over ranges in a file +* @iter: iteration structure +* @ops: iomap ops provided by the filesystem +* +* Iterate over filesystem-provided space mappings for the provided file range. +* +* This function handles cleanup of resources acquired for iteration when the +* filesystem indicates there are no more space mappings, which means that this +* function must be called in a loop that continues as long it returns a +* positive value. If 0 or a negative value is returned, the caller must not +* return to the loop body. Within a loop body, there are two ways to break out +* of the loop body: leave @iter.status unchanged, or set it to a negative +* errno. +*/ +int iomap_iter (struct iomap_iter *iter,const struct iomap_ops *ops) +{ +int ret; + +trace_iomap_iter (iter, ops, _RET_IP_); + + ret =iomap_iter_next (iter, &iter->iomap, &iter->srcmap, + ops->iomap_begin, ops->iomap_end); + iter->status =0 ; +if (ret >0 ) +iomap_iter_done (iter); +else if (ret <0 ) +iomap_iter_clean_fbatch (iter, &iter->iomap); -error: -iomap_iter_clean_fbatch (iter);return ret; }
include/linux/iomap.h +85 -17
115 lines not on this page · raw message
Signature · 1 line
2.52.0
PATCH v5 3/22 iomap: decouple simple direct I/O reads from iomap_dio_rw
In reply to Joanne KoongFrom: Christoph Hellwig <[email protected]>
The pending iomap_iter_next conversion creates performance issues for the new simple direct I/O read fast path, because it assumes a model where the iterator must be advanced at the end, which the direct I/O read fast path tries to avoid.
Side step this by splitting the simple path from iomap_dio_rw, and require the file systems to call into it explicitly, and pass only a ->begin callback. This allows to drop various checks for incompatible features while creating a requirement for the file system to only call the simple path for cases that it can handle.
As a side-benefit we can now inline the initial part of the simple direct I/O read fast path and let the compiler convert the indirect call to ->begin into a direct call.
--- fs/ext4/ext4.h | 3 + fs/ext4/file.c | 4 +- fs/ext4/inode.c | 2 +- fs/iomap/direct-io.c | 208 ++++++++++-------------------------------- fs/xfs/xfs_file.c | 14 +-- fs/xfs/xfs_iomap.c | 2 +- fs/xfs/xfs_iomap.h | 4 + include/linux/iomap.h | 66 ++++++++++++++ 8 files changed, 136 insertions(+), 167 deletions(-)
fs/ext4/ext4.h +3 -0
@@ -4007,6 +4007,9 @@ static inline void ext4_clear_io_unwritten_flag(ext4_io_end_t *io_end)extern const struct iomap_ops ext4_iomap_ops;extern const struct iomap_ops ext4_iomap_report_ops; +int ext4_iomap_begin (struct inode *inode,loff_t offset,loff_t length, +unsigned flags,struct iomap *iomap,struct iomap *srcmap); +static inline int ext4_buffer_uptodate (struct buffer_head *bh) {/*
fs/ext4/file.c +3 -1
@@ -91,7 +91,9 @@ static ssize_t ext4_dio_read_iter(struct kiocb *iocb, struct iov_iter *to)return generic_file_read_iter (iocb, to); } - ret =iomap_dio_rw (iocb, to, &ext4_iomap_ops,NULL ,0 ,NULL ,0 ); + ret =iomap_dio_read_simple (iocb, to, ext4_iomap_begin); +if (ret == -ENOTBLK ) + ret =iomap_dio_rw (iocb, to, &ext4_iomap_ops,NULL ,0 ,NULL ,0 );inode_unlock_shared (inode);file_accessed (iocb->ki_filp);
fs/ext4/inode.c +1 -1
@@ -3771,7 +3771,7 @@ static int ext4_iomap_alloc(struct inode *inode, struct ext4_map_blocks *map, } -static int ext4_iomap_begin (struct inode *inode,loff_t offset,loff_t length, +int ext4_iomap_begin (struct inode *inode,loff_t offset,loff_t length,unsigned flags,struct iomap *iomap,struct iomap *srcmap) {int ret;
fs/iomap/direct-io.c +50 -158
267 lines not on this page · raw message
fs/xfs/xfs_file.c +8 -6
@@ -251,8 +251,6 @@ xfs_file_dio_read( struct iov_iter *to) {struct xfs_inode *ip =XFS_I (file_inode (iocb->ki_filp)); -unsigned int dio_flags =0 ; -const struct iomap_dio_ops *dio_ops =NULL ;ssize_t ret;trace_xfs_file_direct_read (iocb, to);
@@ -266,11 +264,15 @@ xfs_file_dio_read(if (ret)return ret;if (mapping_stable_writes (iocb->ki_filp->f_mapping)) { - dio_ops = &xfs_dio_read_bounce_ops; - dio_flags |=IOMAP_DIO_BOUNCE ; + ret =iomap_dio_rw (iocb, to, &xfs_read_iomap_ops, + &xfs_dio_read_bounce_ops,IOMAP_DIO_BOUNCE , +NULL ,0 ); + }else { + ret =iomap_dio_read_simple (iocb, to, xfs_read_iomap_begin); +if (ret == -ENOTBLK ) + ret =iomap_dio_rw (iocb, to, &xfs_read_iomap_ops,NULL , +0 ,NULL ,0 ); } - ret =iomap_dio_rw (iocb, to, &xfs_read_iomap_ops, dio_ops, dio_flags, -NULL ,0 );xfs_iunlock (ip,XFS_IOLOCK_SHARED );return ret;
fs/xfs/xfs_iomap.c +1 -1
@@ -2173,7 +2173,7 @@ const struct iomap_ops xfs_buffered_write_iomap_ops = { .iomap_end = xfs_buffered_write_iomap_end, }; -static int +int xfs_read_iomap_begin( struct inode *inode, loff_t offset,
fs/xfs/xfs_iomap.h +4 -0
@@ -49,6 +49,10 @@ xfs_aligned_fsb_count(return count_fsb; } +int xfs_read_iomap_begin (struct inode *inode,loff_t offset, +loff_t length,unsigned flags,struct iomap *iomap, +struct iomap *srcmap); +extern const struct iomap_ops xfs_buffered_write_iomap_ops;extern const struct iomap_ops xfs_direct_write_iomap_ops;extern const struct iomap_ops xfs_zoned_direct_write_iomap_ops;
include/linux/iomap.h +66 -0
78 lines not on this page · raw message
Signature · 1 line
2.52.0
PATCH v5 4/22 iomap: use GFP_NOWAIT when application for iomap_dio_simple allocations
In reply to Joanne KoongFrom: Christoph Hellwig <[email protected]>
For non-blocking iocbs we should avoid blocking allocation where possible, so switch to a GFP_NOWAIT allocation here.
--- fs/iomap/direct-io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/iomap/direct-io.c +6 -1
@@ -986,6 +986,7 @@ static void iomap_dio_simple_end_io(struct bio *bio)ssize_t __iomap_dio_read_simple (struct kiocb *iocb,struct iov_iter *iter,struct iomap_iter *iomi) { +gfp_t gfp = (iomi->flags &IOMAP_NOWAIT ) ?GFP_NOWAIT :GFP_KERNEL ;struct iomap_dio_simple *sr;unsigned int alignment;struct bio *bio;
@@ -1015,7 +1016,11 @@ ssize_t __iomap_dio_read_simple(struct kiocb *iocb, struct iov_iter *iter, bio =bio_alloc_bioset (iomi->iomap.bdev,bio_iov_vecs_to_alloc (iter,BIO_MAX_VECS ), -REQ_OP_READ ,GFP_KERNEL , &iomap_dio_simple_pool); +REQ_OP_READ , gfp, &iomap_dio_simple_pool); +if (!bio) { + ret = -EAGAIN ; + goto out_dio_end; + } sr = container_of(bio, struct iomap_dio_simple, bio); sr->iocb = iocb; sr->dio_flags =0 ;
Signature · 1 line
2.52.0
PATCH v5 5/22 iomap: add ->iomap_next()
In reply to Joanne KoongHave one ->iomap_next() callback instead of ->iomap_begin() and ->iomap_end(). ->iomap_next() finishes the previous mapping if needed, and produces the next mapping.
Collapsing to a single callback lets a performance-critical caller inline its iteration loop and pass its ->iomap_next() function as a compile-time constant, so the compiler can devirtualize that callback into a direct call instead of an indirect call through a function pointer.
iomap_iter() uses ->iomap_next() when the filesystem provides that callback and otherwise falls back to the ->iomap_begin()/->iomap_end() path, so filesystems can be converted one at a time.
--- fs/iomap/iter.c | 8 ++++++-- include/linux/iomap.h | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-)
fs/iomap/iter.c +6 -2
@@ -118,8 +118,12 @@ int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)trace_iomap_iter (iter, ops, _RET_IP_); - ret =iomap_iter_next (iter, &iter->iomap, &iter->srcmap, - ops->iomap_begin, ops->iomap_end); +if (ops->iomap_next) + ret = ops->iomap_next (iter, &iter->iomap, &iter->srcmap); +else + ret =iomap_iter_next (iter, &iter->iomap, &iter->srcmap, + ops->iomap_begin, ops->iomap_end); + iter->status =0 ;if (ret >0 )iomap_iter_done (iter);
include/linux/iomap.h +9 -0
@@ -231,9 +231,18 @@ typedef int (*iomap_iter_begin_fn)(struct inode *inode, loff_t pos,typedef int (*iomap_iter_end_fn )(struct inode *inode,loff_t pos,loff_t length,ssize_t written,unsigned flags,struct iomap *iomap); +/* +* Produce the next mapping (finishing the previous one if needed). +* Return 1 to continue iterating, 0 if the range is fully consumed, or a +* negative error on failure. +*/ +typedef int (*iomap_iter_next_fn )(const struct iomap_iter *iter, +struct iomap *iomap,struct iomap *srcmap); +struct iomap_ops {iomap_iter_begin_fn iomap_begin;iomap_iter_end_fn iomap_end; +iomap_iter_next_fn iomap_next; };/**
Signature · 1 line
2.52.0
PATCH v5 6/22 xfs: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert xfs iomap_ops to the new ->iomap_next() callback. Each callback is generated with the DEFINE_IOMAP_ITER_NEXT()/DEFINE_IOMAP_ITER_NEXT_END() macros, which wrap the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- fs/xfs/xfs_file.c | 4 ++-- fs/xfs/xfs_iomap.c | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 12 deletions(-)
fs/xfs/xfs_file.c +2 -2
@@ -859,9 +859,9 @@ xfs_file_dio_write_atomic( NULL, 0);/* -* The retry mechanism is based on the ->iomap_begin method returning +* The retry mechanism is based on the ->iomap_next method returning * -ENOPROTOOPT, which would be when the REQ_ATOMIC-based write is not -* possible. The REQ_ATOMIC-based method typically not be possible if +* possible. The REQ_ATOMIC-based method is typically not possible if * the write spans multiple extents or the disk blocks are misaligned. */ if (ret == -ENOPROTOOPT && dops == &xfs_direct_write_iomap_ops) {
fs/xfs/xfs_iomap.c +29 -10
@@ -1037,8 +1037,11 @@ xfs_direct_write_iomap_begin(return error; } +static DEFINE_IOMAP_ITER_NEXT(xfs_direct_write_iomap_next, + xfs_direct_write_iomap_begin); +const struct iomap_ops xfs_direct_write_iomap_ops = { - .iomap_begin = xfs_direct_write_iomap_begin, + .iomap_next = xfs_direct_write_iomap_next, };#ifdef CONFIG_XFS_RT
@@ -1089,8 +1092,11 @@ xfs_zoned_direct_write_iomap_begin(return 0 ; } +static DEFINE_IOMAP_ITER_NEXT(xfs_zoned_direct_write_iomap_next, + xfs_zoned_direct_write_iomap_begin); +const struct iomap_ops xfs_zoned_direct_write_iomap_ops = { - .iomap_begin = xfs_zoned_direct_write_iomap_begin, + .iomap_next = xfs_zoned_direct_write_iomap_next, };#endif /* CONFIG_XFS_RT */
@@ -1274,8 +1280,11 @@ xfs_atomic_write_cow_iomap_begin(return error; } +static DEFINE_IOMAP_ITER_NEXT(xfs_atomic_write_cow_iomap_next, + xfs_atomic_write_cow_iomap_begin); +const struct iomap_ops xfs_atomic_write_cow_iomap_ops = { - .iomap_begin = xfs_atomic_write_cow_iomap_begin, + .iomap_next = xfs_atomic_write_cow_iomap_next, }; static int
@@ -1298,9 +1307,11 @@ xfs_dax_write_iomap_end(return xfs_reflink_end_cow (ip, pos, written); } +static DEFINE_IOMAP_ITER_NEXT_END(xfs_dax_write_iomap_next, + xfs_direct_write_iomap_begin, xfs_dax_write_iomap_end); +const struct iomap_ops xfs_dax_write_iomap_ops = { - .iomap_begin = xfs_direct_write_iomap_begin, - .iomap_end = xfs_dax_write_iomap_end, + .iomap_next = xfs_dax_write_iomap_next, };/*
@@ -2168,9 +2179,11 @@ xfs_buffered_write_iomap_end(return 0 ; } +static DEFINE_IOMAP_ITER_NEXT_END(xfs_buffered_write_iomap_next, + xfs_buffered_write_iomap_begin, xfs_buffered_write_iomap_end); +const struct iomap_ops xfs_buffered_write_iomap_ops = { - .iomap_begin = xfs_buffered_write_iomap_begin, - .iomap_end = xfs_buffered_write_iomap_end, + .iomap_next = xfs_buffered_write_iomap_next, };int
@@ -2214,8 +2227,10 @@ xfs_read_iomap_begin( shared ? IOMAP_F_SHARED : 0, seq); } +static DEFINE_IOMAP_ITER_NEXT(xfs_read_iomap_next, xfs_read_iomap_begin); +const struct iomap_ops xfs_read_iomap_ops = { - .iomap_begin = xfs_read_iomap_begin, + .iomap_next = xfs_read_iomap_next, }; static int
@@ -2302,8 +2317,10 @@ xfs_seek_iomap_begin(return error; } +static DEFINE_IOMAP_ITER_NEXT(xfs_seek_iomap_next, xfs_seek_iomap_begin); +const struct iomap_ops xfs_seek_iomap_ops = { - .iomap_begin = xfs_seek_iomap_begin, + .iomap_next = xfs_seek_iomap_next, }; static int
@@ -2349,8 +2366,10 @@ xfs_xattr_iomap_begin(return xfs_bmbt_to_iomap (ip, iomap, &imap, flags,IOMAP_F_XATTR , seq); } +static DEFINE_IOMAP_ITER_NEXT(xfs_xattr_iomap_next, xfs_xattr_iomap_begin); +const struct iomap_ops xfs_xattr_iomap_ops = { - .iomap_begin = xfs_xattr_iomap_begin, + .iomap_next = xfs_xattr_iomap_next, };int
Signature · 1 line
2.52.0
PATCH v5 7/22 btrfs: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert btrfs iomap_ops to the new ->iomap_next() callback. The callback is generated with the DEFINE_IOMAP_ITER_NEXT_END() macro, which wraps the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- fs/btrfs/direct-io.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/btrfs/direct-io.c +4 -2
@@ -798,9 +798,11 @@ static void btrfs_dio_submit_io(const struct iomap_iter *iter, struct bio *bio,btrfs_submit_bbio (bbio,0 ); } +static DEFINE_IOMAP_ITER_NEXT_END(btrfs_dio_iomap_next, btrfs_dio_iomap_begin, + btrfs_dio_iomap_end); +static const struct iomap_ops btrfs_dio_iomap_ops = { - .iomap_begin = btrfs_dio_iomap_begin, - .iomap_end = btrfs_dio_iomap_end, + .iomap_next = btrfs_dio_iomap_next, };static const struct iomap_dio_ops btrfs_dio_ops = {
Signature · 1 line
2.52.0
PATCH v5 8/22 ntfs3: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert ntfs3 iomap_ops to the new ->iomap_next() callback. The callback is generated with the DEFINE_IOMAP_ITER_NEXT_END() macro, which wraps the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- fs/ntfs3/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ntfs3/inode.c +4 -2
@@ -2101,9 +2101,11 @@ const struct address_space_operations ntfs_aops_cmpr = { .invalidate_folio = iomap_invalidate_folio, }; +static DEFINE_IOMAP_ITER_NEXT_END(ntfs_iomap_next, ntfs_iomap_begin, + ntfs_iomap_end); +const struct iomap_ops ntfs_iomap_ops = { - .iomap_begin = ntfs_iomap_begin, - .iomap_end = ntfs_iomap_end, + .iomap_next = ntfs_iomap_next, };const struct iomap_write_ops ntfs_iomap_folio_ops = {
Signature · 1 line
2.52.0
PATCH v5 9/22 ntfs: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert ntfs iomap_ops to the new ->iomap_next() callback. Each callback is generated with the DEFINE_IOMAP_ITER_NEXT()/DEFINE_IOMAP_ITER_NEXT_END() macros, which wrap the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- fs/ntfs/iomap.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
fs/ntfs/iomap.c +22 -10
@@ -277,8 +277,10 @@ static int ntfs_read_iomap_begin(struct inode *inode, loff_t offset, loff_t leng srcmap, true); } +static DEFINE_IOMAP_ITER_NEXT(ntfs_read_iomap_next, ntfs_read_iomap_begin); +const struct iomap_ops ntfs_read_iomap_ops = { - .iomap_begin = ntfs_read_iomap_begin, + .iomap_next = ntfs_read_iomap_next, };/*
@@ -329,13 +331,17 @@ static int ntfs_zero_read_iomap_end(struct inode *inode, loff_t pos, loff_t lengreturn written; } +static DEFINE_IOMAP_ITER_NEXT_END(ntfs_zero_read_iomap_next, + ntfs_seek_iomap_begin, ntfs_zero_read_iomap_end); +static const struct iomap_ops ntfs_zero_read_iomap_ops = { - .iomap_begin = ntfs_seek_iomap_begin, - .iomap_end = ntfs_zero_read_iomap_end, + .iomap_next = ntfs_zero_read_iomap_next, }; +static DEFINE_IOMAP_ITER_NEXT(ntfs_seek_iomap_next, ntfs_seek_iomap_begin); +const struct iomap_ops ntfs_seek_iomap_ops = { - .iomap_begin = ntfs_seek_iomap_begin, + .iomap_next = ntfs_seek_iomap_next, };int ntfs_dio_zero_range (struct inode *inode,loff_t offset,loff_t length)
@@ -764,9 +770,11 @@ static int ntfs_write_iomap_end(struct inode *inode, loff_t pos, loff_t length,return written; } +static DEFINE_IOMAP_ITER_NEXT_END(ntfs_write_iomap_next, + ntfs_write_iomap_begin, ntfs_write_iomap_end); +const struct iomap_ops ntfs_write_iomap_ops = { - .iomap_begin = ntfs_write_iomap_begin, - .iomap_end = ntfs_write_iomap_end, + .iomap_next = ntfs_write_iomap_next, }; static int ntfs_page_mkwrite_iomap_begin(struct inode *inode, loff_t offset,
@@ -777,9 +785,11 @@ static int ntfs_page_mkwrite_iomap_begin(struct inode *inode, loff_t offset, NTFS_IOMAP_FLAGS_MKWRITE); } +static DEFINE_IOMAP_ITER_NEXT_END(ntfs_page_mkwrite_iomap_next, + ntfs_page_mkwrite_iomap_begin, ntfs_write_iomap_end); +const struct iomap_ops ntfs_page_mkwrite_iomap_ops = { - .iomap_begin = ntfs_page_mkwrite_iomap_begin, - .iomap_end = ntfs_write_iomap_end, + .iomap_next = ntfs_page_mkwrite_iomap_next, }; static int ntfs_dio_iomap_begin(struct inode *inode, loff_t offset,
@@ -790,9 +800,11 @@ static int ntfs_dio_iomap_begin(struct inode *inode, loff_t offset, NTFS_IOMAP_FLAGS_DIO); } +static DEFINE_IOMAP_ITER_NEXT_END(ntfs_dio_iomap_next, + ntfs_dio_iomap_begin, ntfs_write_iomap_end); +const struct iomap_ops ntfs_dio_iomap_ops = { - .iomap_begin = ntfs_dio_iomap_begin, - .iomap_end = ntfs_write_iomap_end, + .iomap_next = ntfs_dio_iomap_next, }; static ssize_t ntfs_writeback_range(struct iomap_writepage_ctx *wpc,
Signature · 1 line
2.52.0
PATCH v5 10/22 ext4: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert ext4 iomap_ops to the new ->iomap_next() callback. Each callback is generated with the DEFINE_IOMAP_ITER_NEXT() macro, which wraps the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- fs/ext4/extents.c | 4 +++- fs/ext4/inode.c | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-)
fs/ext4/extents.c +3 -1
@@ -5171,8 +5171,10 @@ static int ext4_iomap_xattr_begin(struct inode *inode, loff_t offset,return error; } +static DEFINE_IOMAP_ITER_NEXT(ext4_iomap_xattr_next, ext4_iomap_xattr_begin); +static const struct iomap_ops ext4_iomap_xattr_ops = { - .iomap_begin = ext4_iomap_xattr_begin, + .iomap_next = ext4_iomap_xattr_next, };static int ext4_fiemap_check_ranges (struct inode *inode,u64 start,u64 *len)
fs/ext4/inode.c +6 -2
@@ -3850,8 +3850,10 @@ int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,return 0 ; } +static DEFINE_IOMAP_ITER_NEXT(ext4_iomap_next, ext4_iomap_begin); +const struct iomap_ops ext4_iomap_ops = { - .iomap_begin = ext4_iomap_begin, + .iomap_next = ext4_iomap_next, }; static int ext4_iomap_begin_report(struct inode *inode, loff_t offset,
@@ -3905,8 +3907,10 @@ static int ext4_iomap_begin_report(struct inode *inode, loff_t offset,return 0 ; } +static DEFINE_IOMAP_ITER_NEXT(ext4_iomap_next_report, ext4_iomap_begin_report); +const struct iomap_ops ext4_iomap_report_ops = { - .iomap_begin = ext4_iomap_begin_report, + .iomap_next = ext4_iomap_next_report, };/*
Signature · 1 line
2.52.0
PATCH v5 11/22 erofs: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert erofs iomap_ops to the new ->iomap_next() callback. Each callback is generated with the DEFINE_IOMAP_ITER_NEXT() and DEFINE_IOMAP_ITER_NEXT_END() macros, which wrap the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- fs/erofs/data.c | 6 ++++-- fs/erofs/zmap.c | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-)
fs/erofs/data.c +4 -2
@@ -380,9 +380,11 @@ static int erofs_iomap_end(struct inode *inode, loff_t pos, loff_t length,return written; } +static DEFINE_IOMAP_ITER_NEXT_END(erofs_iomap_next, erofs_iomap_begin, + erofs_iomap_end); +static const struct iomap_ops erofs_iomap_ops = { - .iomap_begin = erofs_iomap_begin, - .iomap_end = erofs_iomap_end, + .iomap_next = erofs_iomap_next, }; int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
fs/erofs/zmap.c +4 -1
@@ -821,6 +821,9 @@ static int z_erofs_iomap_begin_report(struct inode *inode, loff_t offset,return 0 ; } +static DEFINE_IOMAP_ITER_NEXT(z_erofs_iomap_next_report, + z_erofs_iomap_begin_report); +const struct iomap_ops z_erofs_iomap_report_ops = { - .iomap_begin = z_erofs_iomap_begin_report, + .iomap_next = z_erofs_iomap_next_report, };
Signature · 1 line
2.52.0
PATCH v5 12/22 zonefs: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert zonefs iomap_ops to the new ->iomap_next() callback. Each callback is generated with the DEFINE_IOMAP_ITER_NEXT() macro, which wraps the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- fs/zonefs/file.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/zonefs/file.c +7 -2
@@ -57,8 +57,10 @@ static int zonefs_read_iomap_begin(struct inode *inode, loff_t offset,return 0 ; } +static DEFINE_IOMAP_ITER_NEXT(zonefs_read_iomap_next, zonefs_read_iomap_begin); +static const struct iomap_ops zonefs_read_iomap_ops = { - .iomap_begin = zonefs_read_iomap_begin, + .iomap_next = zonefs_read_iomap_next, }; static int zonefs_write_iomap_begin(struct inode *inode, loff_t offset,
@@ -106,8 +108,11 @@ static int zonefs_write_iomap_begin(struct inode *inode, loff_t offset,return 0 ; } +static DEFINE_IOMAP_ITER_NEXT(zonefs_write_iomap_next, + zonefs_write_iomap_begin); +static const struct iomap_ops zonefs_write_iomap_ops = { - .iomap_begin = zonefs_write_iomap_begin, + .iomap_next = zonefs_write_iomap_next, };static int zonefs_read_folio (struct file *unused,struct folio *folio)
Signature · 1 line
2.52.0
PATCH v5 13/22 ext2: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert ext2 iomap_ops to the new ->iomap_next() callback. The callback is generated with the DEFINE_IOMAP_ITER_NEXT_END() macro, which wraps the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- fs/ext2/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ext2/inode.c +4 -2
@@ -860,9 +860,11 @@ ext2_iomap_end(struct inode *inode, loff_t offset, loff_t length,return 0 ; } +static DEFINE_IOMAP_ITER_NEXT_END(ext2_iomap_next, ext2_iomap_begin, + ext2_iomap_end); +const struct iomap_ops ext2_iomap_ops = { - .iomap_begin = ext2_iomap_begin, - .iomap_end = ext2_iomap_end, + .iomap_next = ext2_iomap_next, }; int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
Signature · 1 line
2.52.0
PATCH v5 14/22 block: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert block iomap_ops to the new ->iomap_next() callback. The callback is generated with the DEFINE_IOMAP_ITER_NEXT() macro, which wraps the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- block/fops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
block/fops.c +3 -1
@@ -453,8 +453,10 @@ static int blkdev_iomap_begin(struct inode *inode, loff_t offset, loff_t length,return 0 ; } +static DEFINE_IOMAP_ITER_NEXT(blkdev_iomap_next, blkdev_iomap_begin); +static const struct iomap_ops blkdev_iomap_ops = { - .iomap_begin = blkdev_iomap_begin, + .iomap_next = blkdev_iomap_next, };#ifdef CONFIG_BUFFER_HEAD
Signature · 1 line
2.52.0
PATCH v5 15/22 f2fs: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert f2fs iomap_ops to the new ->iomap_next() callback. The callback is generated with the DEFINE_IOMAP_ITER_NEXT() macro, which wraps the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- fs/f2fs/data.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/data.c +3 -1
@@ -4653,6 +4653,8 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,return 0 ; } +static DEFINE_IOMAP_ITER_NEXT(f2fs_iomap_next, f2fs_iomap_begin); +const struct iomap_ops f2fs_iomap_ops = { - .iomap_begin = f2fs_iomap_begin, + .iomap_next = f2fs_iomap_next, };
Signature · 1 line
2.52.0
PATCH v5 16/22 gfs2: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert gfs2 iomap_ops to the new ->iomap_next() callback. The callback is generated with the DEFINE_IOMAP_ITER_NEXT_END() macro, which wraps the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- fs/gfs2/bmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/gfs2/bmap.c +4 -2
@@ -1200,9 +1200,11 @@ static int gfs2_iomap_end(struct inode *inode, loff_t pos, loff_t length,return 0 ; } +static DEFINE_IOMAP_ITER_NEXT_END(gfs2_iomap_next, gfs2_iomap_begin, + gfs2_iomap_end); +const struct iomap_ops gfs2_iomap_ops = { - .iomap_begin = gfs2_iomap_begin, - .iomap_end = gfs2_iomap_end, + .iomap_next = gfs2_iomap_next, };/**
Signature · 1 line
2.52.0
PATCH v5 17/22 hpfs: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert hpfs iomap_ops to the new ->iomap_next() callback. The callback is generated with the DEFINE_IOMAP_ITER_NEXT() macro, which wraps the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- fs/hpfs/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/hpfs/file.c +3 -1
@@ -156,8 +156,10 @@ static int hpfs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,return 0 ; } +static DEFINE_IOMAP_ITER_NEXT(hpfs_iomap_next, hpfs_iomap_begin); +static const struct iomap_ops hpfs_iomap_ops = { - .iomap_begin = hpfs_iomap_begin, + .iomap_next = hpfs_iomap_next, };static int hpfs_read_folio (struct file *file,struct folio *folio)
Signature · 1 line
2.52.0
PATCH v5 18/22 fuse: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert fuse iomap_ops to the new ->iomap_next() callback. Each callback is generated with the DEFINE_IOMAP_ITER_NEXT()/DEFINE_IOMAP_ITER_NEXT_END() macros, which wrap the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- fs/fuse/dax.c | 6 ++++-- fs/fuse/file.c | 4 +++- fs/fuse/virtio_fs.c | 3 +-- 3 files changed, 8 insertions(+), 5 deletions(-)
fs/fuse/dax.c +4 -2
@@ -653,9 +653,11 @@ static int fuse_iomap_end(struct inode *inode, loff_t pos, loff_t length,return 0 ; } +static DEFINE_IOMAP_ITER_NEXT_END(fuse_iomap_next, fuse_iomap_begin, + fuse_iomap_end); +static const struct iomap_ops fuse_iomap_ops = { - .iomap_begin = fuse_iomap_begin, - .iomap_end = fuse_iomap_end, + .iomap_next = fuse_iomap_next, };static void fuse_wait_dax_page (struct inode *inode)
fs/fuse/file.c +3 -1
@@ -890,8 +890,10 @@ static int fuse_iomap_begin(struct inode *inode, loff_t offset, loff_t length,return 0 ; } +static DEFINE_IOMAP_ITER_NEXT(fuse_iomap_next, fuse_iomap_begin); +static const struct iomap_ops fuse_iomap_ops = { - .iomap_begin = fuse_iomap_begin, + .iomap_next = fuse_iomap_next, };struct fuse_fill_read_data {
fs/fuse/virtio_fs.c +1 -2
@@ -1024,8 +1024,7 @@ static void virtio_fs_cleanup_vqs(struct virtio_device *vdev) }/* Map a window offset to a page frame number. The window offset will have -* been produced by .iomap_begin(), which maps a file offset to a window -* offset. +* been produced by .iomap_next(), which maps a file offset to a window offset. */ static long virtio_fs_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, enum dax_access_mode mode,
Signature · 1 line
2.52.0
PATCH v5 19/22 exfat: convert iomap ops to ->iomap_next()
In reply to Joanne KoongConvert exfat iomap_ops to the new ->iomap_next() callback. Each callback is generated with the DEFINE_IOMAP_ITER_NEXT() and DEFINE_IOMAP_ITER_NEXT_END() macros, which wrap the iomap_iter_next() helper to finish the previous mapping if needed and produce the next one. No functional changes are intended.
--- fs/exfat/iomap.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/exfat/iomap.c +7 -3
@@ -151,8 +151,10 @@ static int exfat_write_iomap_begin(struct inode *inode, loff_t offset, loff_t lereturn __exfat_iomap_begin (inode, offset, length, flags, iomap, true); } +static DEFINE_IOMAP_ITER_NEXT(exfat_iomap_next, exfat_iomap_begin); +const struct iomap_ops exfat_iomap_ops = { - .iomap_begin = exfat_iomap_begin, + .iomap_next = exfat_iomap_next, };/*
@@ -186,9 +188,11 @@ static int exfat_write_iomap_end(struct inode *inode, loff_t pos, loff_t length,return written; } +static DEFINE_IOMAP_ITER_NEXT_END(exfat_write_iomap_next, + exfat_write_iomap_begin, exfat_write_iomap_end); +const struct iomap_ops exfat_write_iomap_ops = { - .iomap_begin = exfat_write_iomap_begin, - .iomap_end = exfat_write_iomap_end, + .iomap_next = exfat_write_iomap_next, };/*
Signature · 1 line
2.52.0
PATCH v5 20/22 iomap: remove ->iomap_begin()/->iomap_end() legacy path
In reply to Joanne KoongWith all in-tree filesystems implementing ->iomap_next(), drop the ->iomap_begin()/->iomap_end() path.
--- fs/iomap/iter.c | 6 +----- include/linux/iomap.h | 6 ++---- 2 files changed, 3 insertions(+), 9 deletions(-)
fs/iomap/iter.c +1 -5
@@ -118,11 +118,7 @@ int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)trace_iomap_iter (iter, ops, _RET_IP_); -if (ops->iomap_next) - ret = ops->iomap_next (iter, &iter->iomap, &iter->srcmap); -else - ret =iomap_iter_next (iter, &iter->iomap, &iter->srcmap, - ops->iomap_begin, ops->iomap_end); + ret = ops->iomap_next (iter, &iter->iomap, &iter->srcmap); iter->status =0 ;if (ret >0 )
include/linux/iomap.h +2 -4
@@ -195,7 +195,7 @@ struct iomap_write_ops { };/* -* Flags for iomap_begin / iomap_end. No flag implies a read. +* Flags for iomap_next. No flag implies a read. */ #define IOMAP_WRITE (1 << 0)/* writing, must allocate blocks */ #define IOMAP_ZERO (1 << 1)/* zeroing operation, may skip holes */
@@ -240,8 +240,6 @@ typedef int (*iomap_iter_next_fn)(const struct iomap_iter *iter, struct iomap *iomap, struct iomap *srcmap);struct iomap_ops { -iomap_iter_begin_fn iomap_begin; -iomap_iter_end_fn iomap_end;iomap_iter_next_fn iomap_next; };
@@ -256,7 +254,7 @@ struct iomap_ops {* incremental iter advance. * @status: Status of the most recent iteration. Zero on success or a negative * errno on error. -* @flags: Zero or more of the iomap_begin flags above. +* @flags: Zero or more of the iomap_next flags above. * @iomap: Map describing the I/O iteration * @srcmap: Source map for COW operations */
Signature · 1 line
2.52.0
PATCH v5 21/22 iomap: pass iomap_iter_next_fn directly instead of struct iomap_ops
In reply to Joanne KoongNow that all filesystems implement ->iomap_next() and the legacy ->iomap_begin()/->iomap_end() fallback is gone, struct iomap_ops only wraps a single iomap_next function pointer. Drop the struct entirely and pass the iomap_iter_next_fn directly to iomap_iter() and all the iomap/dax entry points. Filesystems pass their iomap_iter_next_fn callback directly instead of an ops struct. Several iomap_iter_next_fn callbacks become non-static and gain header declarations since callers now reference them directly.
The iomap_iter tracepoint's ops field is renamed to next to match. These tracepoints are explicitly not stable ABI (see the note in iomap/trace.h).
No functional change intended other than the tracepoint field rename noted above.
--- block/fops.c | 10 ++----- fs/btrfs/direct-io.c | 8 ++---- fs/dax.c | 48 ++++++++++++++++---------------- fs/erofs/data.c | 28 ++++++++----------- fs/erofs/internal.h | 2 +- fs/erofs/zmap.c | 7 +---- fs/exfat/file.c | 18 ++++++------ fs/exfat/inode.c | 6 ++-- fs/exfat/iomap.c | 16 +++-------- fs/exfat/iomap.h | 6 ++-- fs/ext2/ext2.h | 3 +- fs/ext2/file.c | 4 +-- fs/ext2/inode.c | 9 ++---- fs/ext4/ext4.h | 5 ++-- fs/ext4/extents.c | 8 ++---- fs/ext4/file.c | 14 +++++----- fs/ext4/inode.c | 18 ++++-------- fs/f2fs/data.c | 6 +--- fs/f2fs/f2fs.h | 3 +- fs/f2fs/file.c | 4 +-- fs/fuse/dax.c | 10 ++----- fs/fuse/file.c | 10 ++----- fs/gfs2/aops.c | 6 ++-- fs/gfs2/bmap.c | 9 ++---- fs/gfs2/bmap.h | 2 +- fs/gfs2/file.c | 6 ++-- fs/gfs2/inode.c | 6 ++-- fs/hpfs/file.c | 6 +--- fs/internal.h | 1 - fs/iomap/buffered-io.c | 40 +++++++++++++-------------- fs/iomap/direct-io.c | 8 +++--- fs/iomap/fiemap.c | 8 +++--- fs/iomap/iter.c | 9 +++--- fs/iomap/seek.c | 8 +++--- fs/iomap/swapfile.c | 4 +-- fs/iomap/trace.h | 12 ++++---- fs/ntfs/aops.c | 6 ++-- fs/ntfs/file.c | 24 ++++++++-------- fs/ntfs/inode.c | 2 +- fs/ntfs/iomap.c | 40 ++++++--------------------- fs/ntfs/iomap.h | 10 +++---- fs/ntfs3/file.c | 16 +++++------ fs/ntfs3/inode.c | 13 +++------ fs/ntfs3/ntfs_fs.h | 3 +- fs/remap_range.c | 6 ++-- fs/xfs/xfs_aops.c | 8 +++--- fs/xfs/xfs_file.c | 44 +++++++++++++++--------------- fs/xfs/xfs_iomap.c | 55 ++++++++----------------------------- fs/xfs/xfs_iomap.h | 16 +++++------ fs/xfs/xfs_iops.c | 4 +-- fs/xfs/xfs_reflink.c | 6 ++-- fs/zonefs/file.c | 22 +++++---------- include/linux/dax.h | 18 ++++++------ include/linux/fs.h | 7 +++-- include/linux/iomap.h | 62 ++++++++++++++++++++++-------------------- 55 files changed, 305 insertions(+), 425 deletions(-)
block/fops.c +3 -7
@@ -455,10 +455,6 @@ static int blkdev_iomap_begin(struct inode *inode, loff_t offset, loff_t length, static DEFINE_IOMAP_ITER_NEXT(blkdev_iomap_next, blkdev_iomap_begin); -static const struct iomap_ops blkdev_iomap_ops = { - .iomap_next = blkdev_iomap_next, -}; -#ifdef CONFIG_BUFFER_HEAD static int blkdev_get_block (struct inode *inode,sector_t iblock,struct buffer_head *bh,int create)
@@ -512,13 +508,13 @@ const struct address_space_operations def_blk_aops = {#else /* CONFIG_BUFFER_HEAD */ static int blkdev_read_folio (struct file *file,struct folio *folio) { -iomap_bio_read_folio (folio, &blkdev_iomap_ops); +iomap_bio_read_folio (folio, blkdev_iomap_next);return 0 ; }static void blkdev_readahead (struct readahead_control *rac) { -iomap_bio_readahead (rac, &blkdev_iomap_ops); +iomap_bio_readahead (rac, blkdev_iomap_next); } static ssize_t blkdev_writeback_range(struct iomap_writepage_ctx *wpc,
@@ -709,7 +705,7 @@ blkdev_direct_write(struct kiocb *iocb, struct iov_iter *from)static ssize_t blkdev_buffered_write (struct kiocb *iocb,struct iov_iter *from) { -return iomap_file_buffered_write (iocb, from, &blkdev_iomap_ops,NULL , +return iomap_file_buffered_write (iocb, from, blkdev_iomap_next,NULL ,NULL ); }
fs/btrfs/direct-io.c +2 -6
@@ -801,10 +801,6 @@ static void btrfs_dio_submit_io(const struct iomap_iter *iter, struct bio *bio, static DEFINE_IOMAP_ITER_NEXT_END(btrfs_dio_iomap_next, btrfs_dio_iomap_begin, btrfs_dio_iomap_end); -static const struct iomap_ops btrfs_dio_iomap_ops = { - .iomap_next = btrfs_dio_iomap_next, -}; -static const struct iomap_dio_ops btrfs_dio_ops = { .submit_io = btrfs_dio_submit_io, .bio_set = &btrfs_dio_bioset,
@@ -815,7 +811,7 @@ static ssize_t btrfs_dio_read(struct kiocb *iocb, struct iov_iter *iter, {struct btrfs_dio_data data = {0 }; -return iomap_dio_rw (iocb, iter, &btrfs_dio_iomap_ops, &btrfs_dio_ops, +return iomap_dio_rw (iocb, iter, btrfs_dio_iomap_next, &btrfs_dio_ops,IOMAP_DIO_PARTIAL |IOMAP_DIO_FSBLOCK_ALIGNED , &data, done_before); }
@@ -824,7 +820,7 @@ static struct iomap_dio *btrfs_dio_write(struct kiocb *iocb, struct iov_iter *it {struct btrfs_dio_data data = {0 }; -return __iomap_dio_rw (iocb, iter, &btrfs_dio_iomap_ops, &btrfs_dio_ops, +return __iomap_dio_rw (iocb, iter, btrfs_dio_iomap_next, &btrfs_dio_ops,IOMAP_DIO_PARTIAL |IOMAP_DIO_FSBLOCK_ALIGNED , &data, done_before); }
fs/dax.c +25 -23
166 lines not on this page · raw message
fs/erofs/data.c +12 -16
@@ -383,10 +383,6 @@ static int erofs_iomap_end(struct inode *inode, loff_t pos, loff_t length, static DEFINE_IOMAP_ITER_NEXT_END(erofs_iomap_next, erofs_iomap_begin, erofs_iomap_end); -static const struct iomap_ops erofs_iomap_ops = { - .iomap_next = erofs_iomap_next, -}; -int erofs_fiemap (struct inode *inode,struct fiemap_extent_info *fieinfo,u64 start,u64 len) {
@@ -394,9 +390,9 @@ int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,if (!IS_ENABLED (CONFIG_EROFS_FS_ZIP ))return -EOPNOTSUPP ;return iomap_fiemap (inode, fieinfo, start, len, - &z_erofs_iomap_report_ops); + z_erofs_iomap_next_report); } -return iomap_fiemap (inode, fieinfo, start, len, &erofs_iomap_ops); +return iomap_fiemap (inode, fieinfo, start, len, erofs_iomap_next); }/*
@@ -415,7 +411,7 @@ static int erofs_read_folio(struct file *file, struct folio *folio) };trace_erofs_read_folio (iter_ctx.realinode, folio, true); -iomap_read_folio (&erofs_iomap_ops, &read_ctx, &iter_ctx); +iomap_read_folio (erofs_iomap_next, &read_ctx, &iter_ctx);if (need_iput)iput (iter_ctx.realinode);return 0 ;
@@ -434,14 +430,14 @@ static void erofs_readahead(struct readahead_control *rac)trace_erofs_readahead (iter_ctx.realinode,readahead_index (rac),readahead_count (rac), true); -iomap_readahead (&erofs_iomap_ops, &read_ctx, &iter_ctx); +iomap_readahead (erofs_iomap_next, &read_ctx, &iter_ctx);if (need_iput)iput (iter_ctx.realinode); }static sector_t erofs_bmap (struct address_space *mapping,sector_t block) { -return iomap_bmap (mapping, block, &erofs_iomap_ops); +return iomap_bmap (mapping, block, erofs_iomap_next); }static ssize_t erofs_file_read_iter (struct kiocb *iocb,struct iov_iter *to)
@@ -453,14 +449,14 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)return 0 ;if (IS_ENABLED (CONFIG_FS_DAX ) &&IS_DAX (inode)) -return dax_iomap_rw (iocb, to, &erofs_iomap_ops); +return dax_iomap_rw (iocb, to, erofs_iomap_next);if ((iocb->ki_flags &IOCB_DIRECT ) && inode->i_sb->s_bdev) {struct erofs_iomap_iter_ctx iter_ctx = { .realinode = inode, }; -return iomap_dio_rw (iocb, to, &erofs_iomap_ops, +return iomap_dio_rw (iocb, to, erofs_iomap_next,NULL ,0 , &iter_ctx,0 ); }return filemap_read (iocb, to,0 );
@@ -480,7 +476,7 @@ const struct address_space_operations erofs_aops = {static vm_fault_t erofs_dax_huge_fault (struct vm_fault *vmf,unsigned int order) { -return dax_iomap_fault (vmf, order,NULL ,NULL , &erofs_iomap_ops); +return dax_iomap_fault (vmf, order,NULL ,NULL , erofs_iomap_next); }static vm_fault_t erofs_dax_fault (struct vm_fault *vmf)
@@ -512,18 +508,18 @@ static int erofs_file_mmap_prepare(struct vm_area_desc *desc)static loff_t erofs_file_llseek (struct file *file,loff_t offset,int whence) {struct inode *inode = file->f_mapping->host; -const struct iomap_ops *ops = &erofs_iomap_ops; +iomap_iter_next_fn next = erofs_iomap_next;if (erofs_inode_is_data_compressed (EROFS_I (inode)->datalayout)) {if (!IS_ENABLED (CONFIG_EROFS_FS_ZIP ))return generic_file_llseek (file, offset, whence); - ops = &z_erofs_iomap_report_ops; + next = z_erofs_iomap_next_report; }if (whence ==SEEK_HOLE ) - offset =iomap_seek_hole (inode, offset, ops); + offset =iomap_seek_hole (inode, offset, next);else if (whence ==SEEK_DATA ) - offset =iomap_seek_data (inode, offset, ops); + offset =iomap_seek_data (inode, offset, next);else return generic_file_llseek (file, offset, whence);
fs/erofs/internal.h +1 -1
@@ -397,7 +397,7 @@ extern const struct file_operations erofs_file_fops;extern const struct file_operations erofs_dir_fops;extern const struct file_operations erofs_ishare_fops; -extern const struct iomap_ops z_erofs_iomap_report_ops; +DECLARE_IOMAP_ITER_NEXT (z_erofs_iomap_next_report);void *erofs_read_metadata (struct super_block *sb,struct erofs_buf *buf,erofs_off_t *offset,int *lengthp);
fs/erofs/zmap.c +1 -6
@@ -821,9 +821,4 @@ static int z_erofs_iomap_begin_report(struct inode *inode, loff_t offset,return 0 ; } -static DEFINE_IOMAP_ITER_NEXT(z_erofs_iomap_next_report, - z_erofs_iomap_begin_report); - -const struct iomap_ops z_erofs_iomap_report_ops = { - .iomap_next = z_erofs_iomap_next_report, -}; +DEFINE_IOMAP_ITER_NEXT (z_erofs_iomap_next_report, z_erofs_iomap_begin_report);
fs/exfat/file.c +9 -9
@@ -668,7 +668,7 @@ static int exfat_extend_valid_size(struct inode *inode, loff_t new_valid_size) ret =iomap_zero_range (inode, old_valid_size, new_valid_size - old_valid_size,NULL , - &exfat_write_iomap_ops,NULL ,NULL ); + exfat_write_iomap_next,NULL ,NULL );if (ret) {truncate_setsize (inode, old_valid_size);exfat_truncate (inode);
@@ -687,7 +687,7 @@ static ssize_t exfat_fallback_buffered_write(struct kiocb *iocb, iocb->ki_flags &= ~IOCB_DIRECT ; - written =iomap_file_buffered_write (iocb, from, &exfat_write_iomap_ops, + written =iomap_file_buffered_write (iocb, from, exfat_write_iomap_next,NULL ,NULL );if (written <0 )return written;
@@ -709,7 +709,7 @@ static ssize_t exfat_dio_write_iter(struct kiocb *iocb, struct iov_iter *from) {ssize_t ret; - ret =iomap_dio_rw (iocb, from, &exfat_write_iomap_ops, + ret =iomap_dio_rw (iocb, from, exfat_write_iomap_next, &exfat_write_dio_ops,0 ,NULL ,0 );if (ret == -ENOTBLK ) ret =0 ;
@@ -773,7 +773,7 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter) ret =exfat_dio_write_iter (iocb, iter); else ret =iomap_file_buffered_write (iocb, iter, - &exfat_write_iomap_ops,NULL ,NULL ); + exfat_write_iomap_next,NULL ,NULL );if (ret <0 ) goto unlock;
@@ -809,7 +809,7 @@ static ssize_t exfat_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)if (iocb->ki_flags &IOCB_DIRECT ) {file_accessed (iocb->ki_filp); - ret =iomap_dio_rw (iocb, iter, &exfat_iomap_ops,NULL ,0 , + ret =iomap_dio_rw (iocb, iter, exfat_iomap_next,NULL ,0 ,NULL ,0 ); }else { ret =generic_file_read_iter (iocb, iter);
@@ -850,7 +850,7 @@ static vm_fault_t exfat_page_mkwrite(struct vm_fault *vmf)*/ err =iomap_zero_range (inode, ei->zeroed_size, mmap_valid_size - ei->zeroed_size,NULL , - &exfat_iomap_ops,NULL ,NULL ); + exfat_iomap_next,NULL ,NULL );if (err <0 ) {inode_unlock (inode);return vmf_fs_error (err);
@@ -866,7 +866,7 @@ static vm_fault_t exfat_page_mkwrite(struct vm_fault *vmf)file_update_time (vmf->vma->vm_file);filemap_invalidate_lock_shared (inode->i_mapping); - ret =iomap_page_mkwrite (vmf, &exfat_write_iomap_ops,NULL ); + ret =iomap_page_mkwrite (vmf, exfat_write_iomap_next,NULL );filemap_invalidate_unlock_shared (inode->i_mapping);sb_end_pagefault (inode->i_sb);inode_unlock (inode);
@@ -939,12 +939,12 @@ static loff_t exfat_file_llseek(struct file *file, loff_t offset, int whence)switch (whence) {case SEEK_HOLE :inode_lock_shared (inode); - offset =iomap_seek_hole (inode, offset, &exfat_iomap_ops); + offset =iomap_seek_hole (inode, offset, exfat_iomap_next);inode_unlock_shared (inode);break ;case SEEK_DATA :inode_lock_shared (inode); - offset =iomap_seek_data (inode, offset, &exfat_iomap_ops); + offset =iomap_seek_data (inode, offset, exfat_iomap_next);inode_unlock_shared (inode);break ;default :
fs/exfat/inode.c +3 -3
@@ -248,7 +248,7 @@ static int exfat_read_folio(struct file *file, struct folio *folio) .ops = &exfat_iomap_bio_read_ops, }; -iomap_read_folio (&exfat_iomap_ops, &ctx,NULL ); +iomap_read_folio (exfat_iomap_next, &ctx,NULL );return 0 ; }
@@ -269,7 +269,7 @@ static void exfat_readahead(struct readahead_control *rac) ei->valid_size < pos + readahead_length(rac)) return; -iomap_readahead (&exfat_iomap_ops, &ctx,NULL ); +iomap_readahead (exfat_iomap_next, &ctx,NULL ); } static int exfat_writepages(struct address_space *mapping,
@@ -293,7 +293,7 @@ static sector_t exfat_aop_bmap(struct address_space *mapping, sector_t block)/* exfat_get_cluster() assumes the requested blocknr isn't truncated. */ down_read (&EXFAT_I (mapping->host)->truncate_lock); - blocknr =iomap_bmap (mapping, block, &exfat_iomap_ops); + blocknr =iomap_bmap (mapping, block, exfat_iomap_next);up_read (&EXFAT_I (mapping->host)->truncate_lock);return blocknr; }
fs/exfat/iomap.c +4 -12
@@ -151,11 +151,7 @@ static int exfat_write_iomap_begin(struct inode *inode, loff_t offset, loff_t lereturn __exfat_iomap_begin (inode, offset, length, flags, iomap, true); } -static DEFINE_IOMAP_ITER_NEXT(exfat_iomap_next, exfat_iomap_begin); - -const struct iomap_ops exfat_iomap_ops = { - .iomap_next = exfat_iomap_next, -}; +DEFINE_IOMAP_ITER_NEXT (exfat_iomap_next, exfat_iomap_begin);/* * exfat_write_iomap_end - Update the state after write
@@ -188,12 +184,8 @@ static int exfat_write_iomap_end(struct inode *inode, loff_t pos, loff_t length,return written; } -static DEFINE_IOMAP_ITER_NEXT_END(exfat_write_iomap_next, - exfat_write_iomap_begin, exfat_write_iomap_end); - -const struct iomap_ops exfat_write_iomap_ops = { - .iomap_next = exfat_write_iomap_next, -}; +DEFINE_IOMAP_ITER_NEXT_END (exfat_write_iomap_next, exfat_write_iomap_begin, + exfat_write_iomap_end);/* * exfat_writeback_range - Map folio during writeback
@@ -271,5 +263,5 @@ const struct iomap_read_ops exfat_iomap_bio_read_ops = {int exfat_iomap_swap_activate (struct swap_info_struct *sis,struct file *file,sector_t *span) { -return iomap_swapfile_activate (sis, file, span, &exfat_iomap_ops); +return iomap_swapfile_activate (sis, file, span, exfat_iomap_next); }
fs/exfat/iomap.h +4 -2
@@ -6,9 +6,11 @@#ifndef _LINUX_EXFAT_IOMAP_H#define _LINUX_EXFAT_IOMAP_H +#include <linux/iomap.h> +extern const struct iomap_dio_ops exfat_write_dio_ops; -extern const struct iomap_ops exfat_iomap_ops; -extern const struct iomap_ops exfat_write_iomap_ops; +DECLARE_IOMAP_ITER_NEXT (exfat_iomap_next); +DECLARE_IOMAP_ITER_NEXT (exfat_write_iomap_next);extern const struct iomap_writeback_ops exfat_writeback_ops;extern const struct iomap_read_ops exfat_iomap_bio_read_ops;
fs/ext2/ext2.h +2 -1
@@ -18,6 +18,7 @@#include <linux/rbtree.h> #include <linux/mm.h> #include <linux/highmem.h> +#include <linux/iomap.h> /* XXX Here for now... not interested in restructing headers JUST now */
@@ -780,7 +781,7 @@ extern const struct file_operations ext2_file_operations;/* inode.c */ extern void ext2_set_file_ops (struct inode *inode);extern const struct address_space_operations ext2_aops; -extern const struct iomap_ops ext2_iomap_ops; +DECLARE_IOMAP_ITER_NEXT (ext2_iomap_next);/* namei.c */ extern const struct inode_operations ext2_dir_inode_operations;
fs/ext2/file.c +2 -2
@@ -70,7 +70,7 @@ static ssize_t ext2_dio_read_iter(struct kiocb *iocb, struct iov_iter *to)trace_ext2_dio_read_begin (iocb, to,0 );inode_lock_shared (inode); - ret =iomap_dio_rw (iocb, to, &ext2_iomap_ops,NULL ,0 ,NULL ,0 ); + ret =iomap_dio_rw (iocb, to, ext2_iomap_next,NULL ,0 ,NULL ,0 );inode_unlock_shared (inode);trace_ext2_dio_read_end (iocb, to, ret);
@@ -134,7 +134,7 @@ static ssize_t ext2_dio_write_iter(struct kiocb *iocb, struct iov_iter *from) (!IS_ALIGNED(iocb->ki_pos | iov_iter_alignment(from), blocksize))) flags |=IOMAP_DIO_FORCE_WAIT ; - ret =iomap_dio_rw (iocb, from, &ext2_iomap_ops, &ext2_dio_write_ops, + ret =iomap_dio_rw (iocb, from, ext2_iomap_next, &ext2_dio_write_ops, flags,NULL ,0 );/* ENOTBLK is magic return value for fallback to buffered-io */
fs/ext2/inode.c +2 -7
@@ -860,12 +860,7 @@ ext2_iomap_end(struct inode *inode, loff_t offset, loff_t length,return 0 ; } -static DEFINE_IOMAP_ITER_NEXT_END(ext2_iomap_next, ext2_iomap_begin, - ext2_iomap_end); - -const struct iomap_ops ext2_iomap_ops = { - .iomap_next = ext2_iomap_next, -}; +DEFINE_IOMAP_ITER_NEXT_END (ext2_iomap_next, ext2_iomap_begin, ext2_iomap_end);int ext2_fiemap (struct inode *inode,struct fiemap_extent_info *fieinfo,u64 start,u64 len)
@@ -884,7 +879,7 @@ int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,if (i_size ==0 ) i_size =1 ; len =min_t (u64, len, i_size); - ret =iomap_fiemap (inode, fieinfo, start, len, &ext2_iomap_ops); + ret =iomap_fiemap (inode, fieinfo, start, len, ext2_iomap_next);inode_unlock (inode);return ret;
fs/ext4/ext4.h +3 -2
@@ -20,6 +20,7 @@#include <linux/refcount.h> #include <linux/types.h> #include <linux/blkdev.h> +#include <linux/iomap.h> #include <linux/magic.h> #include <linux/jbd2.h> #include <linux/quota.h>
@@ -4004,8 +4005,8 @@ static inline void ext4_clear_io_unwritten_flag(ext4_io_end_t *io_end) io_end->flag &= ~EXT4_IO_END_UNWRITTEN ; } -extern const struct iomap_ops ext4_iomap_ops; -extern const struct iomap_ops ext4_iomap_report_ops; +DECLARE_IOMAP_ITER_NEXT (ext4_iomap_next); +DECLARE_IOMAP_ITER_NEXT (ext4_iomap_next_report);int ext4_iomap_begin (struct inode *inode,loff_t offset,loff_t length,unsigned flags,struct iomap *iomap,struct iomap *srcmap);
fs/ext4/extents.c +2 -6
@@ -5173,10 +5173,6 @@ static int ext4_iomap_xattr_begin(struct inode *inode, loff_t offset, static DEFINE_IOMAP_ITER_NEXT(ext4_iomap_xattr_next, ext4_iomap_xattr_begin); -static const struct iomap_ops ext4_iomap_xattr_ops = { - .iomap_next = ext4_iomap_xattr_next, -}; -static int ext4_fiemap_check_ranges (struct inode *inode,u64 start,u64 *len) {u64 maxbytes =ext4_get_maxbytes (inode);
@@ -5219,10 +5215,10 @@ int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,if (fieinfo->fi_flags &FIEMAP_FLAG_XATTR ) { fieinfo->fi_flags &= ~FIEMAP_FLAG_XATTR ; error =iomap_fiemap (inode, fieinfo, start, len, - &ext4_iomap_xattr_ops); + ext4_iomap_xattr_next); }else { error =iomap_fiemap (inode, fieinfo, start, len, - &ext4_iomap_report_ops); + ext4_iomap_next_report); } unlock:inode_unlock_shared (inode);
fs/ext4/file.c +7 -7
@@ -93,7 +93,7 @@ static ssize_t ext4_dio_read_iter(struct kiocb *iocb, struct iov_iter *to) ret =iomap_dio_read_simple (iocb, to, ext4_iomap_begin);if (ret == -ENOTBLK ) - ret =iomap_dio_rw (iocb, to, &ext4_iomap_ops,NULL ,0 ,NULL ,0 ); + ret =iomap_dio_rw (iocb, to, ext4_iomap_next,NULL ,0 ,NULL ,0 );inode_unlock_shared (inode);file_accessed (iocb->ki_filp);
@@ -121,7 +121,7 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to)/* Fallback to buffered IO in case we cannot support DAX */ return generic_file_read_iter (iocb, to); } - ret =dax_iomap_rw (iocb, to, &ext4_iomap_ops); + ret =dax_iomap_rw (iocb, to, ext4_iomap_next);inode_unlock_shared (inode);file_accessed (iocb->ki_filp);
@@ -591,7 +591,7 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from) goto out; } - ret =iomap_dio_rw (iocb, from, &ext4_iomap_ops, &ext4_dio_write_ops, + ret =iomap_dio_rw (iocb, from, ext4_iomap_next, &ext4_dio_write_ops, dio_flags,NULL ,0 );if (ret == -ENOTBLK ) ret =0 ;
@@ -690,7 +690,7 @@ ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from)ext4_journal_stop (handle); } - ret =dax_iomap_rw (iocb, from, &ext4_iomap_ops); + ret =dax_iomap_rw (iocb, from, ext4_iomap_next);if (extend) { ret =ext4_handle_inode_extension (inode, offset, ret, count);
@@ -778,7 +778,7 @@ static vm_fault_t ext4_dax_huge_fault(struct vm_fault *vmf, unsigned int order) }else {filemap_invalidate_lock_shared (mapping); } - result =dax_iomap_fault (vmf, order, &pfn, &error, &ext4_iomap_ops); + result =dax_iomap_fault (vmf, order, &pfn, &error, ext4_iomap_next);if (write) {ext4_journal_stop (handle);
@@ -957,13 +957,13 @@ loff_t ext4_llseek(struct file *file, loff_t offset, int whence)case SEEK_HOLE :inode_lock_shared (inode); offset =iomap_seek_hole (inode, offset, - &ext4_iomap_report_ops); + ext4_iomap_next_report);inode_unlock_shared (inode);break ;case SEEK_DATA :inode_lock_shared (inode); offset =iomap_seek_data (inode, offset, - &ext4_iomap_report_ops); + ext4_iomap_next_report);inode_unlock_shared (inode);break ; }
fs/ext4/inode.c +5 -13
@@ -3391,7 +3391,7 @@ static sector_t ext4_bmap(struct address_space *mapping, sector_t block)filemap_write_and_wait (mapping); } - ret =iomap_bmap (mapping, block, &ext4_iomap_ops); + ret =iomap_bmap (mapping, block, ext4_iomap_next); out:inode_unlock_shared (inode);
@@ -3850,11 +3850,7 @@ int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,return 0 ; } -static DEFINE_IOMAP_ITER_NEXT(ext4_iomap_next, ext4_iomap_begin); - -const struct iomap_ops ext4_iomap_ops = { - .iomap_next = ext4_iomap_next, -}; +DEFINE_IOMAP_ITER_NEXT (ext4_iomap_next, ext4_iomap_begin); static int ext4_iomap_begin_report(struct inode *inode, loff_t offset, loff_t length, unsigned int flags,
@@ -3907,11 +3903,7 @@ static int ext4_iomap_begin_report(struct inode *inode, loff_t offset,return 0 ; } -static DEFINE_IOMAP_ITER_NEXT(ext4_iomap_next_report, ext4_iomap_begin_report); - -const struct iomap_ops ext4_iomap_report_ops = { - .iomap_next = ext4_iomap_next_report, -}; +DEFINE_IOMAP_ITER_NEXT (ext4_iomap_next_report, ext4_iomap_begin_report);/* * For data=journal mode, folio should be marked dirty only when it was
@@ -3948,7 +3940,7 @@ static int ext4_iomap_swap_activate(struct swap_info_struct *sis, struct file *file, sector_t *span) { return iomap_swapfile_activate(sis, file, span, - &ext4_iomap_report_ops); +ext4_iomap_next_report ); } static const struct address_space_operations ext4_aops = {
@@ -4195,7 +4187,7 @@ static int ext4_block_zero_range(struct inode *inode,if (IS_DAX (inode)) {return dax_zero_range (inode, from, length, did_zero, - &ext4_iomap_ops); + ext4_iomap_next); }else if (ext4_should_journal_data (inode)) {return ext4_block_journalled_zero_range (inode, from, length, did_zero);
fs/f2fs/data.c +1 -5
@@ -4653,8 +4653,4 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,return 0 ; } -static DEFINE_IOMAP_ITER_NEXT(f2fs_iomap_next, f2fs_iomap_begin); - -const struct iomap_ops f2fs_iomap_ops = { - .iomap_next = f2fs_iomap_next, -}; +DEFINE_IOMAP_ITER_NEXT (f2fs_iomap_next, f2fs_iomap_begin);
fs/f2fs/f2fs.h +2 -1
@@ -25,6 +25,7 @@#include <linux/quotaops.h> #include <linux/part_stat.h> #include <linux/rw_hint.h> +#include <linux/iomap.h> #include <linux/fscrypt.h> #include <linux/fsverity.h>
@@ -4216,7 +4217,7 @@ int f2fs_init_post_read_processing(void);void f2fs_destroy_post_read_processing (void );int f2fs_init_wq (struct f2fs_sb_info *sbi);void f2fs_destroy_wq (struct f2fs_sb_info *sbi); -extern const struct iomap_ops f2fs_iomap_ops; +DECLARE_IOMAP_ITER_NEXT (f2fs_iomap_next);/* * gc.c
fs/f2fs/file.c +2 -2
@@ -4884,7 +4884,7 @@ static ssize_t f2fs_dio_read_iter(struct kiocb *iocb, struct iov_iter *to)* F2FS_DIO_READ counter will be decremented correctly in all cases. */ inc_page_count (sbi,F2FS_DIO_READ ); - dio =__iomap_dio_rw (iocb, to, &f2fs_iomap_ops, + dio =__iomap_dio_rw (iocb, to, f2fs_iomap_next, &f2fs_iomap_dio_read_ops,0 ,NULL ,0 );if (IS_ERR_OR_NULL (dio)) { ret =PTR_ERR_OR_ZERO (dio);
@@ -5220,7 +5220,7 @@ static ssize_t f2fs_dio_write_iter(struct kiocb *iocb, struct iov_iter *from, dio_flags =0 ;if (pos + count > inode->i_size) dio_flags |=IOMAP_DIO_FORCE_WAIT ; - dio =__iomap_dio_rw (iocb, from, &f2fs_iomap_ops, + dio =__iomap_dio_rw (iocb, from, f2fs_iomap_next, &f2fs_iomap_dio_write_ops, dio_flags, iocb,0 );if (IS_ERR_OR_NULL (dio)) { ret =PTR_ERR_OR_ZERO (dio);
fs/fuse/dax.c +3 -7
@@ -656,10 +656,6 @@ static int fuse_iomap_end(struct inode *inode, loff_t pos, loff_t length, static DEFINE_IOMAP_ITER_NEXT_END(fuse_iomap_next, fuse_iomap_begin, fuse_iomap_end); -static const struct iomap_ops fuse_iomap_ops = { - .iomap_next = fuse_iomap_next, -}; -static void fuse_wait_dax_page (struct inode *inode) {filemap_invalidate_unlock (inode->i_mapping);
@@ -687,7 +683,7 @@ ssize_t fuse_dax_read_iter(struct kiocb *iocb, struct iov_iter *to)inode_lock_shared (inode); } - ret =dax_iomap_rw (iocb, to, &fuse_iomap_ops); + ret =dax_iomap_rw (iocb, to, fuse_iomap_next);inode_unlock_shared (inode);/* TODO file_accessed(iocb->f_filp) */
@@ -742,7 +738,7 @@ ssize_t fuse_dax_write_iter(struct kiocb *iocb, struct iov_iter *from)if (file_extending_write (iocb, from)) ret =fuse_dax_direct_write (iocb, from);else - ret =dax_iomap_rw (iocb, from, &fuse_iomap_ops); + ret =dax_iomap_rw (iocb, from, fuse_iomap_next); out:inode_unlock (inode);
@@ -777,7 +773,7 @@ static vm_fault_t __fuse_dax_fault(struct vm_fault *vmf, unsigned int order,* to populate page cache or access memory we are trying to free. */ filemap_invalidate_lock_shared (inode->i_mapping); - ret =dax_iomap_fault (vmf, order, &pfn, &error, &fuse_iomap_ops); + ret =dax_iomap_fault (vmf, order, &pfn, &error, fuse_iomap_next);if ((ret &VM_FAULT_ERROR ) && error == -EAGAIN ) { error =0 ; retry = true;
fs/fuse/file.c +3 -7
@@ -892,10 +892,6 @@ static int fuse_iomap_begin(struct inode *inode, loff_t offset, loff_t length, static DEFINE_IOMAP_ITER_NEXT(fuse_iomap_next, fuse_iomap_begin); -static const struct iomap_ops fuse_iomap_ops = { - .iomap_next = fuse_iomap_next, -}; -struct fuse_fill_read_data {struct file *file;
@@ -1016,7 +1012,7 @@ static int fuse_read_folio(struct file *file, struct folio *folio)return -EIO ; } -iomap_read_folio (&fuse_iomap_ops, &ctx,NULL ); +iomap_read_folio (fuse_iomap_next, &ctx,NULL );fuse_invalidate_atime (inode);return 0 ; }
@@ -1117,7 +1113,7 @@ static void fuse_readahead(struct readahead_control *rac)if (fuse_is_bad (inode))return ; -iomap_readahead (&fuse_iomap_ops, &ctx,NULL ); +iomap_readahead (fuse_iomap_next, &ctx,NULL ); }static ssize_t fuse_cache_read_iter (struct kiocb *iocb,struct iov_iter *to)
@@ -1533,7 +1529,7 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from)* and granular dirty tracking for large folios. */ written =iomap_file_buffered_write (iocb, from, - &fuse_iomap_ops, + fuse_iomap_next, &fuse_iomap_write_ops, file); }else {
fs/gfs2/aops.c +3 -3
@@ -425,7 +425,7 @@ static int gfs2_read_folio(struct file *file, struct folio *folio)if (!gfs2_is_jdata (ip) || (i_blocksize (inode) ==PAGE_SIZE && !folio_buffers (folio))) { -iomap_bio_read_folio (folio, &gfs2_iomap_ops); +iomap_bio_read_folio (folio, gfs2_iomap_next); }else if (gfs2_is_stuffed (ip)) { error =stuffed_read_folio (ip, folio); }else {
@@ -500,7 +500,7 @@ static void gfs2_readahead(struct readahead_control *rac)else if (gfs2_is_jdata (ip))mpage_readahead (rac, gfs2_block_map);else -iomap_bio_readahead (rac, &gfs2_iomap_ops); +iomap_bio_readahead (rac, gfs2_iomap_next); }/**
@@ -571,7 +571,7 @@ static sector_t gfs2_bmap(struct address_space *mapping, sector_t lblock)return 0 ;if (!gfs2_is_stuffed (ip)) - dblock =iomap_bmap (mapping, lblock, &gfs2_iomap_ops); + dblock =iomap_bmap (mapping, lblock, gfs2_iomap_next);gfs2_glock_dq_uninit (&i_gh);
fs/gfs2/bmap.c +2 -7
@@ -1200,12 +1200,7 @@ static int gfs2_iomap_end(struct inode *inode, loff_t pos, loff_t length,return 0 ; } -static DEFINE_IOMAP_ITER_NEXT_END(gfs2_iomap_next, gfs2_iomap_begin, - gfs2_iomap_end); - -const struct iomap_ops gfs2_iomap_ops = { - .iomap_next = gfs2_iomap_next, -}; +DEFINE_IOMAP_ITER_NEXT_END (gfs2_iomap_next, gfs2_iomap_begin, gfs2_iomap_end);/** * gfs2_block_map - Map one or more blocks of an inode to a disk block
@@ -1320,7 +1315,7 @@ static int gfs2_block_zero_range(struct inode *inode, loff_t from, loff_t lengthif (from >= inode->i_size)return 0 ; length =min (length, inode->i_size - from); -return iomap_zero_range (inode, from, length,NULL , &gfs2_iomap_ops, +return iomap_zero_range (inode, from, length,NULL , gfs2_iomap_next, &gfs2_iomap_write_ops,NULL ); }
fs/gfs2/bmap.h +1 -1
@@ -43,7 +43,7 @@ static inline void gfs2_write_calc_reserv(const struct gfs2_inode *ip, } } -extern const struct iomap_ops gfs2_iomap_ops; +DECLARE_IOMAP_ITER_NEXT (gfs2_iomap_next);extern const struct iomap_write_ops gfs2_iomap_write_ops;extern const struct iomap_writeback_ops gfs2_writeback_ops;
fs/gfs2/file.c +3 -3
@@ -844,7 +844,7 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to, goto out_uninit;pagefault_disable (); to->nofault = true; - ret =iomap_dio_rw (iocb, to, &gfs2_iomap_ops,NULL , + ret =iomap_dio_rw (iocb, to, gfs2_iomap_next,NULL ,IOMAP_DIO_PARTIAL ,NULL , read); to->nofault = false;pagefault_enable ();
@@ -910,7 +910,7 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from, goto out_unlock; from->nofault = true; - ret =iomap_dio_rw (iocb, from, &gfs2_iomap_ops,NULL , + ret =iomap_dio_rw (iocb, from, gfs2_iomap_next,NULL ,IOMAP_DIO_PARTIAL ,NULL , written); from->nofault = false;if (ret <=0 ) {
@@ -1062,7 +1062,7 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb, goto out_unlock;pagefault_disable (); - ret =iomap_file_buffered_write (iocb, from, &gfs2_iomap_ops, + ret =iomap_file_buffered_write (iocb, from, gfs2_iomap_next, &gfs2_iomap_write_ops,NULL );pagefault_enable ();if (ret >0 )
fs/gfs2/inode.c +3 -3
@@ -2217,7 +2217,7 @@ static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, goto out;pagefault_disable (); - ret =iomap_fiemap (inode, fieinfo, start, len, &gfs2_iomap_ops); + ret =iomap_fiemap (inode, fieinfo, start, len, gfs2_iomap_next);pagefault_enable ();gfs2_glock_dq_uninit (&gh);
@@ -2242,7 +2242,7 @@ loff_t gfs2_seek_data(struct file *file, loff_t offset)inode_lock_shared (inode); ret =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,0 , &gh);if (!ret) - ret =iomap_seek_data (inode, offset, &gfs2_iomap_ops); + ret =iomap_seek_data (inode, offset, gfs2_iomap_next);gfs2_glock_dq_uninit (&gh);inode_unlock_shared (inode);
@@ -2261,7 +2261,7 @@ loff_t gfs2_seek_hole(struct file *file, loff_t offset)inode_lock_shared (inode); ret =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,0 , &gh);if (!ret) - ret =iomap_seek_hole (inode, offset, &gfs2_iomap_ops); + ret =iomap_seek_hole (inode, offset, gfs2_iomap_next);gfs2_glock_dq_uninit (&gh);inode_unlock_shared (inode);
fs/hpfs/file.c +1 -5
@@ -158,10 +158,6 @@ static int hpfs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, static DEFINE_IOMAP_ITER_NEXT(hpfs_iomap_next, hpfs_iomap_begin); -static const struct iomap_ops hpfs_iomap_ops = { - .iomap_next = hpfs_iomap_next, -}; -static int hpfs_read_folio (struct file *file,struct folio *folio) {return mpage_read_folio (folio, hpfs_get_block);
@@ -238,7 +234,7 @@ static int hpfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,inode_lock (inode); len =min_t (u64, len,i_size_read (inode)); - ret =iomap_fiemap (inode, fieinfo, start, len, &hpfs_iomap_ops); + ret =iomap_fiemap (inode, fieinfo, start, len, hpfs_iomap_next);inode_unlock (inode);return ret;
fs/internal.h +0 -1
@@ -8,7 +8,6 @@struct super_block ;struct file_system_type ;struct iomap ; -struct iomap_ops ;struct linux_binprm ;struct path ;struct mount ;
fs/iomap/buffered-io.c +20 -20
@@ -624,8 +624,8 @@ static int iomap_read_folio_iter(struct iomap_iter *iter,return 0 ; } -void iomap_read_folio (const struct iomap_ops *ops, -struct iomap_read_folio_ctx *ctx,void *private) +void iomap_read_folio (iomap_iter_next_fn next,struct iomap_read_folio_ctx *ctx, +void *private) {struct folio *folio = ctx->cur_folio;struct iomap_iter iter = {
@@ -648,7 +648,7 @@ void iomap_read_folio(const struct iomap_ops *ops,fsverity_readahead (ctx->vi, folio->index,folio_nr_pages (folio)); -while ((ret =iomap_iter (&iter, ops)) >0 ) +while ((ret =iomap_iter (&iter, next)) >0 ) iter.status =iomap_read_folio_iter (&iter, ctx, &bytes_submitted);
@@ -687,22 +687,22 @@ static int iomap_readahead_iter(struct iomap_iter *iter,/** * iomap_readahead - Attempt to read pages from a file. -* @ops: The operations vector for the filesystem. +* @next: The iomap iteration function for the filesystem. * @ctx: The ctx used for issuing readahead. * @private: The filesystem-specific information for issuing iomap_iter. * * This function is for filesystems to call to implement their readahead * address_space operation. * -* Context: The @ops callbacks may submit I/O (eg to read the addresses of +* Context: The @next callback may submit I/O (eg to read the addresses of * blocks from disc), and may wait for it. The caller may be trying to * access a different page, and so sleeping excessively should be avoided. * It may allocate memory, but should avoid costly allocations. This * function is called with memalloc_nofs set, so allocations will not cause * the filesystem to be reentered. */ -void iomap_readahead (const struct iomap_ops *ops, -struct iomap_read_folio_ctx *ctx,void *private) +void iomap_readahead (iomap_iter_next_fn next,struct iomap_read_folio_ctx *ctx, +void *private) {struct readahead_control *rac = ctx->rac;struct iomap_iter iter = {
@@ -724,7 +724,7 @@ void iomap_readahead(const struct iomap_ops *ops,fsverity_readahead (ctx->vi,readahead_index (rac),readahead_count (rac)); -while (iomap_iter (&iter, ops) >0 ) +while (iomap_iter (&iter, next) >0 ) iter.status =iomap_readahead_iter (&iter, ctx, &cur_bytes_submitted);
@@ -1268,7 +1268,7 @@ static int iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i,ssize_t iomap_file_buffered_write (struct kiocb *iocb,struct iov_iter *i, -const struct iomap_ops *ops, +iomap_iter_next_fn next,const struct iomap_write_ops *write_ops,void *private) {struct iomap_iter iter = {
@@ -1285,7 +1285,7 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i,if (iocb->ki_flags &IOCB_DONTCACHE ) iter.flags |=IOMAP_DONTCACHE ; -while ((ret =iomap_iter (&iter, ops)) >0 ) +while ((ret =iomap_iter (&iter, next)) >0 ) iter.status =iomap_write_iter (&iter, i, write_ops);if (unlikely (iter.pos == iocb->ki_pos))
@@ -1297,7 +1297,7 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i,EXPORT_SYMBOL_GPL (iomap_file_buffered_write);int iomap_fsverity_write (struct file *file,loff_t pos,size_t length, -const void *buf,const struct iomap_ops *ops, +const void *buf,iomap_iter_next_fn next,const struct iomap_write_ops *write_ops) {int ret;
@@ -1314,7 +1314,7 @@ int iomap_fsverity_write(struct file *file, loff_t pos, size_t length,iov_iter_kvec (&iiter,WRITE , &kvec,1 , length); - ret =iomap_file_buffered_write (&iocb, &iiter, ops, write_ops,NULL ); + ret =iomap_file_buffered_write (&iocb, &iiter, next, write_ops,NULL );if (ret <0 )return ret;return ret == length ?0 : -EIO ;
@@ -1586,7 +1586,7 @@ static int iomap_unshare_iter(struct iomap_iter *iter,int iomap_file_unshare (struct inode *inode,loff_t pos,loff_t len, -const struct iomap_ops *ops, +iomap_iter_next_fn next,const struct iomap_write_ops *write_ops) {struct iomap_iter iter = {
@@ -1601,7 +1601,7 @@ iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len,return 0 ; iter.len =min (len, size - pos); -while ((ret =iomap_iter (&iter, ops)) >0 ) +while ((ret =iomap_iter (&iter, next)) >0 ) iter.status =iomap_unshare_iter (&iter, write_ops);return ret; }
@@ -1710,7 +1710,7 @@ EXPORT_SYMBOL_GPL(iomap_fill_dirty_folios);int iomap_zero_range (struct inode *inode,loff_t pos,loff_t len,bool *did_zero, -const struct iomap_ops *ops, +iomap_iter_next_fn next,const struct iomap_write_ops *write_ops,void *private) {struct folio_batch fbatch;
@@ -1735,7 +1735,7 @@ iomap_zero_range(struct inode *inode, loff_t pos, loff_t len, bool *did_zero,*/ range_dirty =filemap_range_needs_writeback (mapping, iter.pos, iter.pos + iter.len -1 ); -while ((ret =iomap_iter (&iter, ops)) >0 ) { +while ((ret =iomap_iter (&iter, next)) >0 ) {const struct iomap *srcmap =iomap_iter_srcmap (&iter); if (!(iter.iomap.flags & IOMAP_F_FOLIO_BATCH) &&
@@ -1761,7 +1761,7 @@ EXPORT_SYMBOL_GPL(iomap_zero_range);int iomap_truncate_page (struct inode *inode,loff_t pos,bool *did_zero, -const struct iomap_ops *ops, +iomap_iter_next_fn next,const struct iomap_write_ops *write_ops,void *private) {unsigned int blocksize =i_blocksize (inode);
@@ -1770,7 +1770,7 @@ iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero,/* Block boundary? Nothing to do */ if (!off)return 0 ; -return iomap_zero_range (inode, pos, blocksize - off, did_zero, ops, +return iomap_zero_range (inode, pos, blocksize - off, did_zero, next, write_ops, private); }EXPORT_SYMBOL_GPL (iomap_truncate_page);
@@ -1795,7 +1795,7 @@ static int iomap_folio_mkwrite_iter(struct iomap_iter *iter,return iomap_iter_advance (iter, length); } -vm_fault_t iomap_page_mkwrite (struct vm_fault *vmf,const struct iomap_ops *ops, +vm_fault_t iomap_page_mkwrite (struct vm_fault *vmf,iomap_iter_next_fn next,void *private) {struct iomap_iter iter = {
@@ -1812,7 +1812,7 @@ vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops, goto out_unlock; iter.pos =folio_pos (folio); iter.len = ret; -while ((ret =iomap_iter (&iter, ops)) >0 ) +while ((ret =iomap_iter (&iter, next)) >0 ) iter.status =iomap_folio_mkwrite_iter (&iter, folio);if (ret <0 )
fs/iomap/direct-io.c +4 -4
@@ -682,7 +682,7 @@ static int iomap_dio_iter(struct iomap_iter *iter, struct iomap_dio *dio)*/ struct iomap_dio *__iomap_dio_rw (struct kiocb *iocb,struct iov_iter *iter, -const struct iomap_ops *ops,const struct iomap_dio_ops *dops, +iomap_iter_next_fn next,const struct iomap_dio_ops *dops,unsigned int dio_flags,void *private,size_t done_before) {struct inode *inode =file_inode (iocb->ki_filp);
@@ -806,7 +806,7 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,inode_dio_begin (inode);blk_start_plug (&plug); -while ((ret =iomap_iter (&iomi, ops)) >0 ) { +while ((ret =iomap_iter (&iomi, next)) >0 ) { iomi.status =iomap_dio_iter (&iomi, dio);/*
@@ -896,12 +896,12 @@ EXPORT_SYMBOL_GPL(__iomap_dio_rw);ssize_t iomap_dio_rw (struct kiocb *iocb,struct iov_iter *iter, -const struct iomap_ops *ops,const struct iomap_dio_ops *dops, +iomap_iter_next_fn next,const struct iomap_dio_ops *dops,unsigned int dio_flags,void *private,size_t done_before) {struct iomap_dio *dio; - dio =__iomap_dio_rw (iocb, iter, ops, dops, dio_flags, private, + dio =__iomap_dio_rw (iocb, iter, next, dops, dio_flags, private, done_before);if (IS_ERR_OR_NULL (dio))return PTR_ERR_OR_ZERO (dio);
fs/iomap/fiemap.c +4 -4
@@ -56,7 +56,7 @@ static int iomap_fiemap_iter(struct iomap_iter *iter, }int iomap_fiemap (struct inode *inode,struct fiemap_extent_info *fi, -u64 start,u64 len,const struct iomap_ops *ops) +u64 start,u64 len,iomap_iter_next_fn next) {struct iomap_iter iter = { .inode = inode,
@@ -73,7 +73,7 @@ int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fi,if (ret)return ret; -while ((ret =iomap_iter (&iter, ops)) >0 ) +while ((ret =iomap_iter (&iter, next)) >0 ) iter.status =iomap_fiemap_iter (&iter, fi, &prev);if (prev.type !=IOMAP_HOLE ) {
@@ -92,7 +92,7 @@ EXPORT_SYMBOL_GPL(iomap_fiemap);/* legacy ->bmap interface. 0 is the error return (!) */ sector_t iomap_bmap (struct address_space *mapping,sector_t bno, -const struct iomap_ops *ops) +iomap_iter_next_fn next) {struct iomap_iter iter = { .inode = mapping->host,
@@ -107,7 +107,7 @@ iomap_bmap(struct address_space *mapping, sector_t bno,return 0 ; bno =0 ; -while ((ret =iomap_iter (&iter, ops)) >0 ) { +while ((ret =iomap_iter (&iter, next)) >0 ) {if (iter.iomap.type ==IOMAP_MAPPED ) bno =iomap_sector (&iter.iomap, iter.pos) >> blkshift;/* leave iter.status unset to abort loop */
fs/iomap/iter.c +4 -5
@@ -100,7 +100,7 @@ EXPORT_SYMBOL_GPL(iomap_iter_continue);/** * iomap_iter - iterate over ranges in a file * @iter: iteration structure -* @ops: iomap ops provided by the filesystem +* @next: the iomap iteration function for the filesystem * * Iterate over filesystem-provided space mappings for the provided file range. *
@@ -112,14 +112,13 @@ EXPORT_SYMBOL_GPL(iomap_iter_continue);* of the loop body: leave @iter.status unchanged, or set it to a negative * errno. */ -int iomap_iter (struct iomap_iter *iter,const struct iomap_ops *ops) +int iomap_iter (struct iomap_iter *iter,iomap_iter_next_fn next) {int ret; -trace_iomap_iter (iter, ops, _RET_IP_); - - ret = ops->iomap_next (iter, &iter->iomap, &iter->srcmap); +trace_iomap_iter (iter, next, _RET_IP_); + ret =next (iter, &iter->iomap, &iter->srcmap); iter->status =0 ;if (ret >0 )iomap_iter_done (iter);
fs/iomap/seek.c +4 -4
@@ -27,7 +27,7 @@ static int iomap_seek_hole_iter(struct iomap_iter *iter, }loff_t -iomap_seek_hole (struct inode *inode,loff_t pos,const struct iomap_ops *ops) +iomap_seek_hole (struct inode *inode,loff_t pos,iomap_iter_next_fn next) {loff_t size =i_size_read (inode);struct iomap_iter iter = {
@@ -42,7 +42,7 @@ iomap_seek_hole(struct inode *inode, loff_t pos, const struct iomap_ops *ops)return -ENXIO ; iter.len = size - pos; -while ((ret =iomap_iter (&iter, ops)) >0 ) +while ((ret =iomap_iter (&iter, next)) >0 ) iter.status =iomap_seek_hole_iter (&iter, &pos);if (ret <0 )return ret;
@@ -73,7 +73,7 @@ static int iomap_seek_data_iter(struct iomap_iter *iter, }loff_t -iomap_seek_data (struct inode *inode,loff_t pos,const struct iomap_ops *ops) +iomap_seek_data (struct inode *inode,loff_t pos,iomap_iter_next_fn next) {loff_t size =i_size_read (inode);struct iomap_iter iter = {
@@ -88,7 +88,7 @@ iomap_seek_data(struct inode *inode, loff_t pos, const struct iomap_ops *ops)return -ENXIO ; iter.len = size - pos; -while ((ret =iomap_iter (&iter, ops)) >0 ) +while ((ret =iomap_iter (&iter, next)) >0 ) iter.status =iomap_seek_data_iter (&iter, &pos);if (ret <0 )return ret;
fs/iomap/swapfile.c +2 -2
@@ -139,7 +139,7 @@ static int iomap_swapfile_iter(struct iomap_iter *iter,*/ int iomap_swapfile_activate (struct swap_info_struct *sis,struct file *swap_file,sector_t *pagespan, -const struct iomap_ops *ops) +iomap_iter_next_fn next) {struct inode *inode = swap_file->f_mapping->host;struct iomap_iter iter = {
@@ -163,7 +163,7 @@ int iomap_swapfile_activate(struct swap_info_struct *sis,if (ret)return ret; -while ((ret =iomap_iter (&iter, ops)) >0 ) +while ((ret =iomap_iter (&iter, next)) >0 ) iter.status =iomap_swapfile_iter (&iter, &iter.iomap, &isi);if (ret <0 )return ret;
fs/iomap/trace.h +6 -6
@@ -218,9 +218,9 @@ TRACE_EVENT(iomap_add_to_ioend, ); TRACE_EVENT(iomap_iter, - TP_PROTO(struct iomap_iter *iter, const void *ops, + TP_PROTO(struct iomap_iter *iter, const void *next, unsigned long caller), - TP_ARGS(iter, ops, caller), + TP_ARGS(iter, next, caller), TP_STRUCT__entry( __field(dev_t, dev) __field(u64, ino)
@@ -228,7 +228,7 @@ TRACE_EVENT(iomap_iter, __field(u64, length) __field(int, status) __field(unsigned int, flags) - __field(const void *, ops) + __field(const void *, next) __field(unsigned long, caller) ), TP_fast_assign(
@@ -238,10 +238,10 @@ TRACE_EVENT(iomap_iter, __entry->length =iomap_length (iter); __entry->status = iter->status; __entry->flags = iter->flags; - __entry->ops = ops; + __entry->next = next; __entry->caller = caller; ), - TP_printk("dev %d:%d ino 0x%llx pos 0x%llx length 0x%llx status %d flags %s (0x%x) ops %ps caller %pS", + TP_printk("dev %d:%d ino 0x%llx pos 0x%llx length 0x%llx status %d flags %s (0x%x) next %ps caller %pS", MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, __entry->pos,
@@ -249,7 +249,7 @@ TRACE_EVENT(iomap_iter, __entry->status,__print_flags (__entry->flags,"|" ,IOMAP_FLAGS_STRINGS ), __entry->flags, - __entry->ops, + __entry->next, (void *)__entry->caller) );
fs/ntfs/aops.c +3 -3
@@ -97,7 +97,7 @@ static int ntfs_read_folio(struct file *file, struct folio *folio)return ntfs_read_compressed_block (folio); } -iomap_read_folio (&ntfs_read_iomap_ops, &ctx,NULL ); +iomap_read_folio (ntfs_read_iomap_next, &ctx,NULL );return 0 ; }
@@ -238,7 +238,7 @@ static void ntfs_readahead(struct readahead_control *rac)*/ if (!NInoNonResident (ni) ||NInoCompressed (ni))return ; -iomap_readahead (&ntfs_read_iomap_ops, &ctx,NULL ); +iomap_readahead (ntfs_read_iomap_next, &ctx,NULL ); } static int ntfs_writepages(struct address_space *mapping,
@@ -274,7 +274,7 @@ static int ntfs_swap_activate(struct swap_info_struct *sis, struct file *swap_file, sector_t *span) { return iomap_swapfile_activate(sis, swap_file, span, - &ntfs_read_iomap_ops); +ntfs_read_iomap_next ); } const struct address_space_operations ntfs_aops = {
fs/ntfs/file.c +12 -12
@@ -281,7 +281,7 @@ static int ntfs_setattr_size(struct inode *vi, struct iattr *attr)round_up (old_size,PAGE_SIZE ) - old_size, attr->ia_size - old_size); err =iomap_zero_range (vi, old_size, len, -NULL , &ntfs_seek_iomap_ops, +NULL , ntfs_seek_iomap_next, &ntfs_iomap_folio_ops,NULL ); }
@@ -417,12 +417,12 @@ static loff_t ntfs_file_llseek(struct file *file, loff_t offset, int whence)switch (whence) {case SEEK_HOLE :inode_lock_shared (inode); - offset =iomap_seek_hole (inode, offset, &ntfs_seek_iomap_ops); + offset =iomap_seek_hole (inode, offset, ntfs_seek_iomap_next);inode_unlock_shared (inode);break ;case SEEK_DATA :inode_lock_shared (inode); - offset =iomap_seek_data (inode, offset, &ntfs_seek_iomap_ops); + offset =iomap_seek_data (inode, offset, ntfs_seek_iomap_next);inode_unlock_shared (inode);break ;default :
@@ -458,7 +458,7 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) }file_accessed (iocb->ki_filp); - ret =iomap_dio_rw (iocb, to, &ntfs_read_iomap_ops,NULL ,0 , + ret =iomap_dio_rw (iocb, to, ntfs_read_iomap_next,NULL ,0 ,NULL ,0 ); }else { ret =generic_file_read_iter (iocb, to);
@@ -496,7 +496,7 @@ static ssize_t ntfs_dio_write_iter(struct kiocb *iocb, struct iov_iter *from) {ssize_t ret; - ret =iomap_dio_rw (iocb, from, &ntfs_dio_iomap_ops, + ret =iomap_dio_rw (iocb, from, ntfs_dio_iomap_next, &ntfs_write_dio_ops,0 ,NULL ,0 );if (ret == -ENOTBLK ) ret =0 ;
@@ -511,7 +511,7 @@ static ssize_t ntfs_dio_write_iter(struct kiocb *iocb, struct iov_iter *from) offset = iocb->ki_pos; iocb->ki_flags &= ~IOCB_DIRECT ; written =iomap_file_buffered_write (iocb, from, - &ntfs_write_iomap_ops, &ntfs_iomap_folio_ops, + ntfs_write_iomap_next, &ntfs_iomap_folio_ops,NULL );if (written <0 ) { ret = written;
@@ -594,7 +594,7 @@ static ssize_t ntfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)if (NInoNonResident (ni) && iocb->ki_flags &IOCB_DIRECT ) ret =ntfs_dio_write_iter (iocb, from);else - ret =iomap_file_buffered_write (iocb, from, &ntfs_write_iomap_ops, + ret =iomap_file_buffered_write (iocb, from, ntfs_write_iomap_next, &ntfs_iomap_folio_ops,NULL ); out:if (ret <0 && ret != -EIOCBQUEUED ) {
@@ -623,7 +623,7 @@ static vm_fault_t ntfs_filemap_page_mkwrite(struct vm_fault *vmf)sb_start_pagefault (inode->i_sb);file_update_time (vmf->vma->vm_file); - ret =iomap_page_mkwrite (vmf, &ntfs_page_mkwrite_iomap_ops,NULL ); + ret =iomap_page_mkwrite (vmf, ntfs_page_mkwrite_iomap_next,NULL );sb_end_pagefault (inode->i_sb);return ret; }
@@ -670,7 +670,7 @@ static int ntfs_file_mmap_prepare(struct vm_area_desc *desc)static int ntfs_fiemap (struct inode *inode,struct fiemap_extent_info *fieinfo,u64 start,u64 len) { -return iomap_fiemap (inode, fieinfo, start, len, &ntfs_read_iomap_ops); +return iomap_fiemap (inode, fieinfo, start, len, ntfs_read_iomap_next); } static const char *ntfs_get_link(struct dentry *dentry, struct inode *inode,
@@ -911,7 +911,7 @@ static int ntfs_punch_hole(struct ntfs_inode *ni, int mode, loff_t offset,ntfs_cluster_to_bytes (vol, start_vcn +1 ), end_offset); err =iomap_zero_range (vi, offset, to - offset, -NULL , &ntfs_seek_iomap_ops, +NULL , ntfs_seek_iomap_next, &ntfs_iomap_folio_ops,NULL );if (err <0 ) goto out;
@@ -927,7 +927,7 @@ static int ntfs_punch_hole(struct ntfs_inode *ni, int mode, loff_t offset, from =ntfs_cluster_to_bytes (vol, end_vcn -1 );if (from < ni->initialized_size) { err =iomap_zero_range (vi, from, end_offset - from, -NULL , &ntfs_seek_iomap_ops, +NULL , ntfs_seek_iomap_next, &ntfs_iomap_folio_ops,NULL );if (err <0 ) goto out;
@@ -1131,7 +1131,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t offset, loff_t leround_up (old_size,PAGE_SIZE ) - old_size, offset - old_size); err =iomap_zero_range (vi, old_size, len,NULL , - &ntfs_seek_iomap_ops, + ntfs_seek_iomap_next, &ntfs_iomap_folio_ops,NULL ); }NInoSetFileNameDirty (ni);
fs/ntfs/inode.c +1 -1
@@ -2415,7 +2415,7 @@ int ntfs_extend_initialized_size(struct inode *vi, const loff_t offset,if (!NInoCompressed (ni) && old_init_size < offset) { err =iomap_zero_range (vi, old_init_size, offset - old_init_size, -NULL , &ntfs_seek_iomap_ops, +NULL , ntfs_seek_iomap_next, &ntfs_iomap_folio_ops,NULL );if (err)return err;
fs/ntfs/iomap.c +8 -32
@@ -277,11 +277,7 @@ static int ntfs_read_iomap_begin(struct inode *inode, loff_t offset, loff_t leng srcmap, true); } -static DEFINE_IOMAP_ITER_NEXT(ntfs_read_iomap_next, ntfs_read_iomap_begin); - -const struct iomap_ops ntfs_read_iomap_ops = { - .iomap_next = ntfs_read_iomap_next, -}; +DEFINE_IOMAP_ITER_NEXT (ntfs_read_iomap_next, ntfs_read_iomap_begin);/* * Check that the cached iomap still matches the NTFS runlist before
@@ -334,15 +330,7 @@ static int ntfs_zero_read_iomap_end(struct inode *inode, loff_t pos, loff_t leng static DEFINE_IOMAP_ITER_NEXT_END(ntfs_zero_read_iomap_next, ntfs_seek_iomap_begin, ntfs_zero_read_iomap_end); -static const struct iomap_ops ntfs_zero_read_iomap_ops = { - .iomap_next = ntfs_zero_read_iomap_next, -}; - -static DEFINE_IOMAP_ITER_NEXT(ntfs_seek_iomap_next, ntfs_seek_iomap_begin); - -const struct iomap_ops ntfs_seek_iomap_ops = { - .iomap_next = ntfs_seek_iomap_next, -}; +DEFINE_IOMAP_ITER_NEXT (ntfs_seek_iomap_next, ntfs_seek_iomap_begin);int ntfs_dio_zero_range (struct inode *inode,loff_t offset,loff_t length) {
@@ -361,7 +349,7 @@ static int ntfs_zero_range(struct inode *inode, loff_t offset, loff_t length)return iomap_zero_range (inode, offset, length,NULL , - &ntfs_zero_read_iomap_ops, + ntfs_zero_read_iomap_next, &ntfs_zero_iomap_folio_ops,NULL ); }
@@ -770,12 +758,8 @@ static int ntfs_write_iomap_end(struct inode *inode, loff_t pos, loff_t length,return written; } -static DEFINE_IOMAP_ITER_NEXT_END(ntfs_write_iomap_next, - ntfs_write_iomap_begin, ntfs_write_iomap_end); - -const struct iomap_ops ntfs_write_iomap_ops = { - .iomap_next = ntfs_write_iomap_next, -}; +DEFINE_IOMAP_ITER_NEXT_END (ntfs_write_iomap_next, ntfs_write_iomap_begin, + ntfs_write_iomap_end); static int ntfs_page_mkwrite_iomap_begin(struct inode *inode, loff_t offset, loff_t length, unsigned int flags,
@@ -785,13 +769,9 @@ static int ntfs_page_mkwrite_iomap_begin(struct inode *inode, loff_t offset, NTFS_IOMAP_FLAGS_MKWRITE); } -static DEFINE_IOMAP_ITER_NEXT_END(ntfs_page_mkwrite_iomap_next, +DEFINE_IOMAP_ITER_NEXT_END (ntfs_page_mkwrite_iomap_next, ntfs_page_mkwrite_iomap_begin, ntfs_write_iomap_end); -const struct iomap_ops ntfs_page_mkwrite_iomap_ops = { - .iomap_next = ntfs_page_mkwrite_iomap_next, -}; -static int ntfs_dio_iomap_begin (struct inode *inode,loff_t offset,loff_t length,unsigned int flags,struct iomap *iomap,struct iomap *srcmap)
@@ -800,12 +780,8 @@ static int ntfs_dio_iomap_begin(struct inode *inode, loff_t offset, NTFS_IOMAP_FLAGS_DIO); } -static DEFINE_IOMAP_ITER_NEXT_END(ntfs_dio_iomap_next, - ntfs_dio_iomap_begin, ntfs_write_iomap_end); - -const struct iomap_ops ntfs_dio_iomap_ops = { - .iomap_next = ntfs_dio_iomap_next, -}; +DEFINE_IOMAP_ITER_NEXT_END (ntfs_dio_iomap_next, ntfs_dio_iomap_begin, + ntfs_write_iomap_end);static ssize_t ntfs_writeback_range (struct iomap_writepage_ctx *wpc,struct folio *folio,u64 offset,unsigned int len,u64 end_pos)
fs/ntfs/iomap.h +5 -5
@@ -12,11 +12,11 @@#include "volume.h" #include "inode.h" -extern const struct iomap_ops ntfs_write_iomap_ops; -extern const struct iomap_ops ntfs_read_iomap_ops; -extern const struct iomap_ops ntfs_seek_iomap_ops; -extern const struct iomap_ops ntfs_page_mkwrite_iomap_ops; -extern const struct iomap_ops ntfs_dio_iomap_ops; +DECLARE_IOMAP_ITER_NEXT (ntfs_write_iomap_next); +DECLARE_IOMAP_ITER_NEXT (ntfs_read_iomap_next); +DECLARE_IOMAP_ITER_NEXT (ntfs_seek_iomap_next); +DECLARE_IOMAP_ITER_NEXT (ntfs_page_mkwrite_iomap_next); +DECLARE_IOMAP_ITER_NEXT (ntfs_dio_iomap_next);extern const struct iomap_writeback_ops ntfs_writeback_ops;extern const struct iomap_write_ops ntfs_iomap_folio_ops;extern int ntfs_dio_zero_range (struct inode *inode,loff_t offset,loff_t length);
fs/ntfs3/file.c +8 -8
@@ -315,7 +315,7 @@ static int ntfs_extend_initialized_size(struct file *file, } err =iomap_zero_range (inode, valid, new_valid - valid,NULL , - &ntfs_iomap_ops, &ntfs_iomap_folio_ops,NULL ); + ntfs_iomap_next, &ntfs_iomap_folio_ops,NULL );if (err) { ni->i_valid = valid; ntfs_inode_warn(inode,
@@ -554,7 +554,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)/* Zero head of punch. */ if (tmp > from) { err =iomap_zero_range (inode, from, tmp - from,NULL , - &ntfs_iomap_ops, + ntfs_iomap_next, &ntfs_iomap_folio_ops,NULL );if (err) goto out;
@@ -572,7 +572,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)/* Zero tail of punch. */ if (vbo < end_a && end_a < end) { err =iomap_zero_range (inode, end_a, end - end_a,NULL , - &ntfs_iomap_ops, + ntfs_iomap_next, &ntfs_iomap_folio_ops,NULL );if (err) goto out;
@@ -872,7 +872,7 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) goto out; } - err =iomap_dio_rw (iocb, iter, &ntfs_iomap_ops,NULL , dio_flags, + err =iomap_dio_rw (iocb, iter, ntfs_iomap_next,NULL , dio_flags,NULL ,0 );if (err <=0 )
@@ -1286,7 +1286,7 @@ static ssize_t ntfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) !ntfs_should_use_dio(iocb, from)) { iocb->ki_flags &= ~IOCB_DIRECT ; - ret =iomap_file_buffered_write (iocb, from, &ntfs_iomap_ops, + ret =iomap_file_buffered_write (iocb, from, ntfs_iomap_next, &ntfs_iomap_folio_ops,NULL );inode_unlock (inode);
@@ -1303,7 +1303,7 @@ static ssize_t ntfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) goto out; } - ret =iomap_dio_rw (iocb, from, &ntfs_iomap_ops,NULL , + ret =iomap_dio_rw (iocb, from, ntfs_iomap_next,NULL ,IOMAP_DIO_FORCE_WAIT ,NULL ,0 );if (ret == -ENOTBLK ) {
@@ -1316,7 +1316,7 @@ static ssize_t ntfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) vbo = iocb->ki_pos; iocb->ki_flags &= ~IOCB_DIRECT ; - err =iomap_file_buffered_write (iocb, from, &ntfs_iomap_ops, + err =iomap_file_buffered_write (iocb, from, ntfs_iomap_next, &ntfs_iomap_folio_ops,NULL );if (err <0 ) { ret = err;
@@ -1465,7 +1465,7 @@ int ntfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,inode_lock_shared (inode); - err =iomap_fiemap (inode, fieinfo, start, len, &ntfs_iomap_ops); + err =iomap_fiemap (inode, fieinfo, start, len, ntfs_iomap_next);inode_unlock_shared (inode);return err;
fs/ntfs3/inode.c +4 -9
@@ -576,7 +576,7 @@ static sector_t ntfs_bmap(struct address_space *mapping, sector_t block)ni_allocate_da_blocks (ni); } -return iomap_bmap (mapping, block, &ntfs_iomap_ops); +return iomap_bmap (mapping, block, ntfs_iomap_next); }static void ntfs_iomap_read_end_io (struct bio *bio)
@@ -649,7 +649,7 @@ static int ntfs_read_folio(struct file *file, struct folio *folio)return err; } -iomap_read_folio (&ntfs_iomap_ops, &ctx,NULL ); +iomap_read_folio (ntfs_iomap_next, &ctx,NULL );return 0 ; }
@@ -673,7 +673,7 @@ static void ntfs_readahead(struct readahead_control *rac)return ; } -iomap_readahead (&ntfs_iomap_ops, &ctx,NULL ); +iomap_readahead (ntfs_iomap_next, &ctx,NULL ); }int ntfs_set_size (struct inode *inode,u64 new_size)
@@ -2101,12 +2101,7 @@ const struct address_space_operations ntfs_aops_cmpr = { .invalidate_folio = iomap_invalidate_folio, }; -static DEFINE_IOMAP_ITER_NEXT_END(ntfs_iomap_next, ntfs_iomap_begin, - ntfs_iomap_end); - -const struct iomap_ops ntfs_iomap_ops = { - .iomap_next = ntfs_iomap_next, -}; +DEFINE_IOMAP_ITER_NEXT_END (ntfs_iomap_next, ntfs_iomap_begin, ntfs_iomap_end);const struct iomap_write_ops ntfs_iomap_folio_ops = { .put_folio = ntfs_iomap_put_folio,
fs/ntfs3/ntfs_fs.h +2 -1
@@ -12,6 +12,7 @@#include <linux/blkdev.h> #include <linux/buffer_head.h> #include <linux/fs.h> +#include <linux/iomap.h> #include <linux/highmem.h> #include <linux/kernel.h> #include <linux/hex.h>
@@ -785,7 +786,7 @@ int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,int ntfs_link_inode (struct inode *inode,struct dentry *dentry);int ntfs_unlink_inode (struct inode *dir,const struct dentry *dentry);void ntfs_evict_inode (struct inode *inode); -extern const struct iomap_ops ntfs_iomap_ops; +DECLARE_IOMAP_ITER_NEXT (ntfs_iomap_next);extern const struct iomap_write_ops ntfs_iomap_folio_ops;extern const struct inode_operations ntfs_link_inode_operations;extern const struct address_space_operations ntfs_aops;
fs/remap_range.c +3 -3
@@ -277,7 +277,7 @@ int __generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, loff_t *len, unsigned int remap_flags, - const struct iomap_ops *dax_read_ops) + iomap_iter_next_fn dax_read_next) { struct inode *inode_in = file_inode(file_in);struct inode *inode_out =file_inode (file_out);
@@ -340,10 +340,10 @@ __generic_remap_file_range_prep(struct file *file_in, loff_t pos_in,if (!IS_DAX (inode_in)) ret =vfs_dedupe_file_range_compare (file_in, pos_in, file_out, pos_out, *len, &is_same); -else if (dax_read_ops) +else if (dax_read_next) ret =dax_dedupe_file_range_compare (inode_in, pos_in, inode_out, pos_out, *len, &is_same, - dax_read_ops); + dax_read_next);else return -EINVAL ;if (ret)
fs/xfs/xfs_aops.c +4 -4
@@ -752,7 +752,7 @@ xfs_vm_bmap(*/ if (xfs_is_cow_inode (ip) ||XFS_IS_REALTIME_INODE (ip))return 0 ; -return iomap_bmap (mapping, block, &xfs_read_iomap_ops); +return iomap_bmap (mapping, block, xfs_read_iomap_next); } static void
@@ -793,7 +793,7 @@ xfs_vm_read_folio(struct iomap_read_folio_ctx ctx = { .cur_folio = folio }; ctx.ops =xfs_get_iomap_read_ops (folio->mapping); -iomap_read_folio (&xfs_read_iomap_ops, &ctx,NULL ); +iomap_read_folio (xfs_read_iomap_next, &ctx,NULL );return 0 ; }
@@ -804,7 +804,7 @@ xfs_vm_readahead(struct iomap_read_folio_ctx ctx = { .rac = rac }; ctx.ops =xfs_get_iomap_read_ops (rac->mapping), -iomap_readahead (&xfs_read_iomap_ops, &ctx,NULL ); +iomap_readahead (xfs_read_iomap_next, &ctx,NULL ); } static int
@@ -850,7 +850,7 @@ xfs_vm_swap_activate( sis->bdev =xfs_inode_buftarg (ip)->bt_bdev;return iomap_swapfile_activate (sis, swap_file, span, - &xfs_read_iomap_ops); + xfs_read_iomap_next); }const struct address_space_operations xfs_address_space_operations = {
fs/xfs/xfs_file.c +22 -22
155 lines not on this page · raw message
fs/xfs/xfs_iomap.c +12 -43
126 lines not on this page · raw message
fs/xfs/xfs_iomap.h +8 -8
@@ -53,14 +53,14 @@ int xfs_read_iomap_begin(struct inode *inode, loff_t offset, loff_t length, unsigned flags, struct iomap *iomap, struct iomap *srcmap); -extern const struct iomap_ops xfs_buffered_write_iomap_ops; -extern const struct iomap_ops xfs_direct_write_iomap_ops; -extern const struct iomap_ops xfs_zoned_direct_write_iomap_ops; -extern const struct iomap_ops xfs_read_iomap_ops; -extern const struct iomap_ops xfs_seek_iomap_ops; -extern const struct iomap_ops xfs_xattr_iomap_ops; -extern const struct iomap_ops xfs_dax_write_iomap_ops; -extern const struct iomap_ops xfs_atomic_write_cow_iomap_ops; +DECLARE_IOMAP_ITER_NEXT (xfs_buffered_write_iomap_next); +DECLARE_IOMAP_ITER_NEXT (xfs_direct_write_iomap_next); +DECLARE_IOMAP_ITER_NEXT (xfs_zoned_direct_write_iomap_next); +DECLARE_IOMAP_ITER_NEXT (xfs_read_iomap_next); +DECLARE_IOMAP_ITER_NEXT (xfs_seek_iomap_next); +DECLARE_IOMAP_ITER_NEXT (xfs_xattr_iomap_next); +DECLARE_IOMAP_ITER_NEXT (xfs_dax_write_iomap_next); +DECLARE_IOMAP_ITER_NEXT (xfs_atomic_write_cow_iomap_next);extern const struct iomap_write_ops xfs_iomap_write_ops;#endif /* __XFS_IOMAP_H__*/
fs/xfs/xfs_iops.c +2 -2
@@ -1239,10 +1239,10 @@ xfs_vn_fiemap(if (fieinfo->fi_flags &FIEMAP_FLAG_XATTR ) { fieinfo->fi_flags &= ~FIEMAP_FLAG_XATTR ; error =iomap_fiemap (inode, fieinfo, start, length, - &xfs_xattr_iomap_ops); + xfs_xattr_iomap_next); }else { error =iomap_fiemap (inode, fieinfo, start, length, - &xfs_read_iomap_ops); + xfs_read_iomap_next); }xfs_iunlock (XFS_I (inode),XFS_IOLOCK_SHARED );
fs/xfs/xfs_reflink.c +3 -3
@@ -1683,7 +1683,7 @@ xfs_reflink_remap_prep( pos_out, len, remap_flags); else ret =dax_remap_file_range_prep (file_in, pos_in, file_out, - pos_out, len, remap_flags, &xfs_read_iomap_ops); + pos_out, len, remap_flags, xfs_read_iomap_next);if (ret || *len ==0 ) goto out_unlock;
@@ -1878,10 +1878,10 @@ xfs_reflink_unshare(if (IS_DAX (inode)) error =dax_file_unshare (inode, offset, len, - &xfs_dax_write_iomap_ops); + xfs_dax_write_iomap_next);else error =iomap_file_unshare (inode, offset, len, - &xfs_buffered_write_iomap_ops, + xfs_buffered_write_iomap_next, &xfs_iomap_write_ops);if (error) goto out;
fs/zonefs/file.c +7 -15
@@ -59,10 +59,6 @@ static int zonefs_read_iomap_begin(struct inode *inode, loff_t offset, static DEFINE_IOMAP_ITER_NEXT(zonefs_read_iomap_next, zonefs_read_iomap_begin); -static const struct iomap_ops zonefs_read_iomap_ops = { - .iomap_next = zonefs_read_iomap_next, -}; -static int zonefs_write_iomap_begin (struct inode *inode,loff_t offset,loff_t length,unsigned int flags,struct iomap *iomap,struct iomap *srcmap)
@@ -111,19 +107,15 @@ static int zonefs_write_iomap_begin(struct inode *inode, loff_t offset, static DEFINE_IOMAP_ITER_NEXT(zonefs_write_iomap_next, zonefs_write_iomap_begin); -static const struct iomap_ops zonefs_write_iomap_ops = { - .iomap_next = zonefs_write_iomap_next, -}; -static int zonefs_read_folio (struct file *unused,struct folio *folio) { -iomap_bio_read_folio (folio, &zonefs_read_iomap_ops); +iomap_bio_read_folio (folio, zonefs_read_iomap_next);return 0 ; }static void zonefs_readahead (struct readahead_control *rac) { -iomap_bio_readahead (rac, &zonefs_read_iomap_ops); +iomap_bio_readahead (rac, zonefs_read_iomap_next); }/*
@@ -184,7 +176,7 @@ static int zonefs_swap_activate(struct swap_info_struct *sis, }return iomap_swapfile_activate (sis, swap_file, span, - &zonefs_read_iomap_ops); + zonefs_read_iomap_next); }const struct address_space_operations zonefs_file_aops = {
@@ -314,7 +306,7 @@ static vm_fault_t zonefs_filemap_page_mkwrite(struct vm_fault *vmf)/* Serialize against truncates */ filemap_invalidate_lock_shared (inode->i_mapping); - ret =iomap_page_mkwrite (vmf, &zonefs_write_iomap_ops,NULL ); + ret =iomap_page_mkwrite (vmf, zonefs_write_iomap_next,NULL );filemap_invalidate_unlock_shared (inode->i_mapping);sb_end_pagefault (inode->i_sb);
@@ -530,7 +522,7 @@ static ssize_t zonefs_file_dio_write(struct kiocb *iocb, struct iov_iter *from)* page invalidation. Overwrite that error code with EBUSY so that * the user can make sense of the error. */ - ret =iomap_dio_rw (iocb, from, &zonefs_write_iomap_ops, + ret =iomap_dio_rw (iocb, from, zonefs_write_iomap_next, &zonefs_write_dio_ops,0 ,NULL ,0 );if (ret == -ENOTBLK ) ret = -EBUSY ;
@@ -580,7 +572,7 @@ static ssize_t zonefs_file_buffered_write(struct kiocb *iocb,if (ret <=0 ) goto inode_unlock; - ret =iomap_file_buffered_write (iocb, from, &zonefs_write_iomap_ops, + ret =iomap_file_buffered_write (iocb, from, zonefs_write_iomap_next,NULL ,NULL );if (ret == -EIO )zonefs_io_error (inode, true);
@@ -675,7 +667,7 @@ static ssize_t zonefs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) goto inode_unlock; }file_accessed (iocb->ki_filp); - ret =iomap_dio_rw (iocb, to, &zonefs_read_iomap_ops, + ret =iomap_dio_rw (iocb, to, zonefs_read_iomap_next, &zonefs_read_dio_ops,0 ,NULL ,0 ); }else { ret =generic_file_read_iter (iocb, to);
include/linux/dax.h +8 -10
@@ -3,6 +3,7 @@#define _LINUX_DAX_H#include <linux/fs.h> +#include <linux/iomap.h> #include <linux/mm.h> #include <linux/radix-tree.h>
@@ -10,9 +11,6 @@ typedef unsigned long dax_entry_t;struct dax_device ;struct gendisk ; -struct iomap_ops ; -struct iomap_iter ; -struct iomap ;enum dax_access_mode {DAX_ACCESS ,
@@ -213,11 +211,11 @@ static inline void dax_unlock_mapping_entry(struct address_space *mapping,#endif int dax_file_unshare (struct inode *inode,loff_t pos,loff_t len, -const struct iomap_ops *ops); +iomap_iter_next_fn next);int dax_zero_range (struct inode *inode,loff_t pos,loff_t len,bool *did_zero, -const struct iomap_ops *ops); +iomap_iter_next_fn next);int dax_truncate_page (struct inode *inode,loff_t pos,bool *did_zero, -const struct iomap_ops *ops); +iomap_iter_next_fn next);static inline bool dax_page_is_idle (struct page *page) {
@@ -266,10 +264,10 @@ int dax_holder_notify_failure(struct dax_device *dax_dev, u64 off, u64 len,void dax_flush (struct dax_device *dax_dev,void *addr,size_t size);ssize_t dax_iomap_rw (struct kiocb *iocb,struct iov_iter *iter, -const struct iomap_ops *ops); +iomap_iter_next_fn next);vm_fault_t dax_iomap_fault (struct vm_fault *vmf,unsigned int order,unsigned long *pfnp,int *errp, -const struct iomap_ops *ops); +iomap_iter_next_fn next);vm_fault_t dax_finish_sync_fault (struct vm_fault *vmf,unsigned int order,unsigned long pfn);int dax_delete_mapping_entry (struct address_space *mapping,pgoff_t index);
@@ -288,11 +286,11 @@ void dax_break_layout_final(struct inode *inode);int dax_dedupe_file_range_compare (struct inode *src,loff_t srcoff,struct inode *dest,loff_t destoff,loff_t len,bool *is_same, -const struct iomap_ops *ops); +iomap_iter_next_fn next);int dax_remap_file_range_prep (struct file *file_in,loff_t pos_in,struct file *file_out,loff_t pos_out,loff_t *len,unsigned int remap_flags, -const struct iomap_ops *ops); +iomap_iter_next_fn next);static inline bool dax_mapping (struct address_space *mapping) {return mapping->host &&IS_DAX (mapping->host);
include/linux/fs.h +5 -2
@@ -70,7 +70,8 @@ struct fsnotify_mark_connector;struct fs_context ;struct fs_parameter_spec ;struct file_kattr ; -struct iomap_ops ; +struct iomap_iter ; +struct iomap ;struct delegated_inode ;extern void __init inode_init (void );
@@ -2079,7 +2080,9 @@ int remap_verify_area(struct file *file, loff_t pos, loff_t len, bool write);int __generic_remap_file_range_prep (struct file *file_in,loff_t pos_in,struct file *file_out,loff_t pos_out,loff_t *len,unsigned int remap_flags, -const struct iomap_ops *dax_read_ops); +int (*dax_read_next)(const struct iomap_iter *iter, +struct iomap *iomap, +struct iomap *srcmap));int generic_remap_file_range_prep (struct file *file_in,loff_t pos_in,struct file *file_out,loff_t pos_out,loff_t *count,unsigned int remap_flags);
include/linux/iomap.h +33 -29
159 lines not on this page · raw message
Signature · 1 line
2.52.0
PATCH v5 22/22 Documentation: iomap: update docs to reflect iomap_iter_next model
In reply to Joanne KoongFilesystems no longer pass a struct iomap_ops with separate ->iomap_begin() and ->iomap_end() callbacks. Instead, every iomap operation takes a single iomap_iter_next() callback directly. iomap_iter_next() finishes the previous mapping (if any) and produces the next one. Most filesystems build it from begin and end helpers via the iomap_iter_next() helper.
Update the iomap documentation to match this change.
--- Documentation/filesystems/iomap/design.rst | 140 +++++++++++++----- .../filesystems/iomap/operations.rst | 68 ++++----- Documentation/filesystems/iomap/porting.rst | 16 +- 3 files changed, 151 insertions(+), 73 deletions(-)
Documentation/filesystems/iomap/design.rst +105 -35
@@ -75,7 +75,10 @@ At a high level, an iomap operation `looks like this 1. For each byte in the operation range... - 1. Obtain a space mapping via ``->iomap_begin`` + 1. Obtain the next space mapping via the ``iomap_iter_next_fn`` callback. + From the second iteration onwards this same callback first finishes + the previous mapping (committing or unreserving space as needed) + and then produces the next one. 2. For each sub-unit of work...
@@ -86,7 +89,13 @@ At a high level, an iomap operation `looks like this 3. Increment operation cursor - 4. Release the mapping via ``->iomap_end``, if necessary +iomap repeats this until the range is fully consumed. The ``iomap_iter_next_fn`` +callback returns ``1`` while there is more of the range left to process, +``0`` once it is fully consumed, or a negative errno on error. +Filesystems rarely implement this callback by hand. The ``iomap_iter_next`` +helper implements the finish-then-produce sequence in terms of two smaller +callbacks, ``begin`` and ``end``. See `The Mapping Callback`_ below for more +info. Each iomap operation will be covered in more detail below. This library was covered previously by an `LWN article
@@ -189,7 +198,7 @@ The fields are as follows: * **IOMAP_DELALLOC**: A promise to allocate space at a later time ("delayed allocation"). If the filesystem returns IOMAP_F_NEW here and the write fails, the - ``->iomap_end`` function must delete the reservation. + ``end`` function must delete the reservation. The ``addr`` field must be set to ``IOMAP_NULL_ADDR``. * **IOMAP_MAPPED**: The file range maps to specific space on the
@@ -208,12 +217,11 @@ The fields are as follows: * **IOMAP_INLINE**: The file range maps to the memory buffer specified by ``inline_data``. - For write operation, the ``->iomap_end`` function presumably - handles persisting the data. + For write operation, the ``end`` function must persist the data. The ``addr`` field must be set to ``IOMAP_NULL_ADDR``. * ``flags`` describe the status of the space mapping. - These flags should be set by the filesystem in ``->iomap_begin``: + These flags should be set by the filesystem in ``begin``: * **IOMAP_F_NEW**: The space under the mapping is newly allocated. Areas that will not be written to must be zeroed.
@@ -262,15 +270,15 @@ The fields are as follows: update. These flags can be set by iomap itself during file operations. - The filesystem should supply an ``->iomap_end`` function if it needs + The filesystem should supply an ``end`` function if it needs to observe these flags: * **IOMAP_F_SIZE_CHANGED**: The file size has changed as a result of using this mapping. * **IOMAP_F_STALE**: The mapping was found to be stale. - iomap will call ``->iomap_end`` on this mapping and then - ``->iomap_begin`` to obtain a new mapping. + iomap will call ``end`` on this mapping and then ``begin`` to obtain a + new mapping. Currently, these flags are only set by pagecache operations.
@@ -289,41 +297,103 @@ The fields are as follows: * ``private`` is a pointer to `filesystem-private information <https://lore.kernel.org/all/[email protected]/>`_. - This value will be passed unchanged to ``->iomap_end``. + This value will be passed unchanged to ``end``. * ``validity_cookie`` is a magic freshness value set by the filesystem that should be used to detect stale mappings. For pagecache operations this is critical for correct operation because page faults can occur, which implies that filesystem locks - should not be held between ``->iomap_begin`` and ``->iomap_end``. + should not be held between ``begin`` and ``end``. Filesystems with completely static mappings need not set this value. Only pagecache operations revalidate mappings; see the section about ``iomap_valid`` for details. -``struct iomap_ops`` +The Mapping Callback -------------------- -Every iomap function requires the filesystem to pass an operations -structure to obtain a mapping and (optionally) to release the mapping: +Every iomap operation takes an ``iomap_iter_next_fn`` callback from the +filesystem. iomap calls it once per iteration of the file range: .. code-block:: c - struct iomap_ops { - int (*iomap_begin)(struct inode *inode, loff_t pos, loff_t length, - unsigned flags, struct iomap *iomap, - struct iomap *srcmap); + typedef int (*iomap_iter_next_fn)(const struct iomap_iter *iter, + struct iomap *iomap, struct iomap *srcmap); - int (*iomap_end)(struct inode *inode, loff_t pos, loff_t length, - ssize_t written, unsigned flags, - struct iomap *iomap); - }; +``iomap_iter_next_fn`` +~~~~~~~~~~~~~~~~~~~~~~ + +This must finish the previous mapping, if any, and then produce the next +mapping for the current iteration position described by ``iter``. +The mapping is returned through ``iomap`` (and through ``srcmap`` for +operations that read from one mapping while writing to another; see +``begin`` below). + +The callback returns ``1`` to continue iterating, ``0`` once the file +range has been fully consumed, or a negative errno on error. + +Most filesystems are not expected to implement all of these behaviors +in this callback themselves. They should instead call ``iomap_iter_next`` as +described below. + +``iomap_iter_next`` +~~~~~~~~~~~~~~~~~~~ + +Filesystems rarely need a hand-written ``iomap_iter_next_fn`` callback. The +``iomap_iter_next`` helper implements the finish-then-produce sequence in +terms of two smaller callbacks, ``begin`` and ``end``, so most +``iomap_iter_next_fn`` implementations are simply: + +.. code-block:: c + + static int my_iomap_next(const struct iomap_iter *iter, + struct iomap *iomap, struct iomap *srcmap) + { + return iomap_iter_next(iter, iomap, srcmap, + my_iomap_begin, my_iomap_end); + } + +This boilerplate is normally generated with the ``DEFINE_IOMAP_ITER_NEXT()`` +and ``DEFINE_IOMAP_ITER_NEXT_END()`` macros rather than written by hand. Use +``DEFINE_IOMAP_ITER_NEXT()`` for the common case with no ``end`` callback, and +``DEFINE_IOMAP_ITER_NEXT_END()`` when an ``end`` callback is needed: + +.. code-block:: c + + /* no end() callback */ + static DEFINE_IOMAP_ITER_NEXT(my_iomap_next, my_iomap_begin); + + /* with an end() callback */ + static DEFINE_IOMAP_ITER_NEXT_END(my_iomap_next, my_iomap_begin, + my_iomap_end); + +The macro generates a function with external linkage. Prefix the invocation +with ``static`` for a file-local callback, or leave it non-``static`` and add +a matching declaration to a header when the callback is referenced from +another file. + +``end`` may be ``NULL`` when the filesystem has nothing to finish. +The two callbacks have these prototypes: + +.. code-block:: c + + typedef int (*iomap_begin_fn)(struct inode *inode, loff_t pos, + loff_t length, unsigned flags, + struct iomap *iomap, struct iomap *srcmap); + + typedef int (*iomap_end_fn)(struct inode *inode, loff_t pos, + loff_t length, ssize_t written, + unsigned flags, struct iomap *iomap); + +``iomap_iter_next`` is an inline helper, so when it is called with fixed +``begin`` and ``end`` functions the compiler can inline both into the +filesystem's ``iomap_iter_next_fn`` callback, keeping indirect calls out of the +iteration hot path. The two callbacks are described next. -``->iomap_begin`` -~~~~~~~~~~~~~~~~~ +``begin`` +~~~~~~~~~ -iomap operations call ``->iomap_begin`` to obtain one file mapping for -the range of bytes specified by ``pos`` and ``length`` for the file -``inode``. +The ``begin`` callback obtains one file mapping for the range of bytes +specified by ``pos`` and ``length`` for the file ``inode``. This mapping should be returned through the ``iomap`` pointer. The mapping must cover at least the first byte of the supplied file range, but it does not need to cover the entire requested range.
@@ -377,18 +447,18 @@ information via ``srcmap``. Only pagecache and fsdax operations support reading from one mapping and writing to another. -``->iomap_end`` -~~~~~~~~~~~~~~~ +``end`` +~~~~~~~ -After the operation completes, the ``->iomap_end`` function, if present, -is called to signal that iomap is finished with a mapping. +After the operation completes, the ``end`` callback, if present, is called to +signal that iomap is finished with a mapping. Typically, implementations will use this function to tear down any -context that were set up in ``->iomap_begin``. +context that was set up in ``begin``. For example, a write might wish to commit the reservations for the bytes that were operated upon and unreserve any space that was not operated upon. ``written`` might be zero if no bytes were touched. -``flags`` will contain the same value passed to ``->iomap_begin``. +``flags`` will contain the same value passed to ``begin``. iomap ops for reads are not likely to need to supply this function. Both functions should return a negative errno code on error, or zero on
@@ -421,8 +491,8 @@ iomap is concerned: accessing the folio until writeback is underway. * The **lower** level primitive is taken by the filesystem in the - ``->iomap_begin`` and ``->iomap_end`` functions to coordinate - access to the file space mapping information. + ``begin`` and ``end`` functions to coordinate access to the file space + mapping information. The fields of the iomap object should be filled out while holding this primitive. The upper level synchronization primitive, if any, remains held
Documentation/filesystems/iomap/operations.rst +35 -33
211 lines not on this page · raw message
Documentation/filesystems/iomap/porting.rst +11 -5
@@ -50,8 +50,14 @@ Build the kernel, run fstests with the ``-g all`` option across a wide variety of your filesystem's supported configurations to build a baseline of which tests pass and which ones fail. -The recommended approach is first to implement ``->iomap_begin`` (and -``->iomap_end`` if necessary) to allow iomap to obtain a read-only +Every iomap operation is driven by an ``iomap_iter_next_fn`` callback. +Filesystems normally do not write one by hand: implement ``begin`` +(and ``end`` if necessary) and generate the callback with the +``DEFINE_IOMAP_ITER_NEXT()`` macro, or ``DEFINE_IOMAP_ITER_NEXT_END()`` if an +``end`` callback is needed. + +The recommended approach is first to implement ``begin`` (and +``end`` if necessary) to allow iomap to obtain a read-only mapping of a file range. In most cases, this is a relatively trivial conversion of the existing ``get_block()`` function for read-only mappings.
@@ -62,7 +68,7 @@ If FIEMAP is returning the correct information, it's a good sign that other read-only mapping operations will do the right thing. Next, modify the filesystem's ``get_block(create = false)`` -implementation to use the new ``->iomap_begin`` implementation to map +implementation to use the new ``begin`` implementation to map file space for selected read operations. Hide behind a debugging knob the ability to switch on the iomap mapping functions for selected call paths.
@@ -82,14 +88,14 @@ I/O path because of bufferheads. The buffered read I/O paths doesn't need to be converted yet, though the direct I/O read path should be converted in this phase. -At this point, you should look over your ``->iomap_begin`` function. +At this point, you should look over your ``begin`` function. If it switches between large blocks of code based on dispatching of the ``flags`` argument, you should consider breaking it up into per-operation iomap ops with smaller, more cohesive functions. XFS is a good example of this. The next thing to do is implement ``get_blocks(create == true)`` -functionality in the ``->iomap_begin``/``->iomap_end`` methods. +functionality in the ``begin``/``end`` methods. It is strongly recommended to create separate mapping functions and iomap ops for write operations. Then convert the direct I/O write path to iomap, and start running fsx
Signature · 1 line
2.52.0
Re: (subset) [PATCH v5 00/22] iomap: convert to in-iter iomap_next() model
In reply to Joanne KoongQuoted 6 lines · Joanne Koong
iomap: convert to in-iter
iomap_next()modelThis series implements a suggestion by Christoph for finishing the conversion of iomap to an iterator model. This revives Matthew's previous RFC [1], which had the same intention.
Quoted 6 lines
Every iomap operation currently drives its iteration through a struct
iomap_ops, which contains two callbacks, ->iomap_begin() and ->iomap_end().iomap_iter()only ever sees these as pointers, so every step of every iteration is an indirect call, including on the hottest paths.[...]
Applied to the vfs-7.3.iomap branch of the vfs/vfs.git tree. Patches in the vfs-7.3.iomap branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-7.3.iomap
[01/22] iomap: release the folio batch on iomap callback failures
https://git.kernel.org/vfs/vfs/c/c02d8298c979 [02/22] iomap: split iomap_iter() logic into iomap_iter_next() https://git.kernel.org/vfs/vfs/c/78c9e6b07ffe [03/22] iomap: decouple simple direct I/O reads from iomap_dio_rw https://git.kernel.org/vfs/vfs/c/59389c7d3068 [04/22] iomap: use GFP_NOWAIT when application for iomap_dio_simple allocations https://git.kernel.org/vfs/vfs/c/98aa16d184b7 [05/22] iomap: add ->iomap_next() https://git.kernel.org/vfs/vfs/c/e93eeed8ce74 [06/22] xfs: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/c807f6c9de95 [07/22] btrfs: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/8a5cf58dc6c6 [08/22] ntfs3: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/2d53882bcb18 [09/22] ntfs: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/4d9ea94adc0d [10/22] ext4: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/e85fe93027cf [11/22] erofs: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/9b0cef67d4e0 [12/22] zonefs: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/4b9de085c9a2 [13/22] ext2: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/cfcfc6724b0a [14/22] block: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/cb372ea04331 [15/22] f2fs: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/c034d0d0bcd0 [16/22] gfs2: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/1096941fd797 [17/22] hpfs: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/7e8aad7196b1 [18/22] fuse: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/a9032fd59a40 [19/22] exfat: convert iomap ops to ->iomap_next() https://git.kernel.org/vfs/vfs/c/332f88127cfa [20/22] iomap: remove ->iomap_begin()/->iomap_end() legacy path https://git.kernel.org/vfs/vfs/c/0210c4ba2547
Christian Brauner
maintainerRe: (subset) [PATCH v5 00/22] iomap: convert to in-iter iomap_next() model
Quoted 2 lines
[20/22] iomap: remove ->iomap_begin()/->iomap_end() legacy path
https://git.kernel.org/vfs/vfs/c/0210c4ba2547
That accidently slipped in. I have not dropped this from the v7.3 merge window. I'll get a v7.3-rc1.iomap ready with the last three patches.
Re: (subset) [PATCH v5 00/22] iomap: convert to in-iter iomap_next() model
Quoted 7 lines · Christian Brauner
Quoted 3 lines
[20/22] iomap: remove ->iomap_begin()/->iomap_end() legacy path
https://git.kernel.org/vfs/vfs/c/0210c4ba2547That accidently slipped in. I have not dropped this from the v7.3 merge window. I'll get a v7.3-rc1.iomap ready with the last three patches.
Hi Christian,
Hope you're having a great week so far. I'm not seeing the last 3 patches as part of v7.3-rc1. Do you think it would make more sense to have it be included in rc2 or to have it be part of v7.4? I'm happy with either, just wanted to flag this in case I'm missing something.
Thanks,
Joanne
Christian Brauner
maintainerRe: (subset) [PATCH v5 00/22] iomap: convert to in-iter iomap_next() model
Quoted 9 lines · Joanne Koong
Quoted 7 lines · Christian Brauner
Quoted 3 lines
[20/22] iomap: remove ->iomap_begin()/->iomap_end() legacy path
https://git.kernel.org/vfs/vfs/c/0210c4ba2547That accidently slipped in. I have not dropped this from the v7.3 merge window. I'll get a v7.3-rc1.iomap ready with the last three patches.
Quoted 6 lines
Hi Christian,
Hope you're having a great week so far. I'm not seeing the last 3 patches as part of v7.3-rc1. Do you think it would make more sense to have it be included in rc2 or to have it be part of v7.4? I'm happy with either, just wanted to flag this in case I'm missing something.
No, we can still try and send it for -rc2. I'll pick them up in a second.
Re: (subset) [PATCH v5 00/22] iomap: convert to in-iter iomap_next() model
In reply to Joanne KoongQuoted 10 lines · Joanne Koong
This series implements a suggestion by Christoph for finishing the conversion of iomap to an iterator model. This revives Matthew's previous RFC [1], which had the same intention.
Every iomap operation currently drives its iteration through a struct
iomap_ops, which contains two callbacks, ->iomap_begin() and ->iomap_end().iomap_iter()only ever sees these as pointers, so every step of every iteration is an indirect call, including on the hottest paths.[...]
Applied to the vfs-7.3.iomap.final branch of the vfs/vfs.git tree. Patches in the vfs-7.3.iomap.final branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-7.3.iomap.final
[20/22] iomap: remove ->iomap_begin()/->iomap_end() legacy path
https://git.kernel.org/vfs/vfs/c/71864822ce32 [21/22] iomap: pass iomap_iter_next_fn directly instead of struct iomap_ops https://git.kernel.org/vfs/vfs/c/2a3b6fe7a17f [22/22] Documentation: iomap: update docs to reflect iomap_iter_next model https://git.kernel.org/vfs/vfs/c/e16ceb1b6c03