* don't build bios/contexts over multiple iomaps v3 @ 2026-06-25 12:07 Christoph Hellwig 2026-06-25 12:07 ` [PATCH 1/2] iomap: consolidate bio submission Christoph Hellwig 2026-06-25 12:07 ` [PATCH 2/2] iomap: submit read bio after each extent Christoph Hellwig 0 siblings, 2 replies; 15+ messages in thread From: Christoph Hellwig @ 2026-06-25 12:07 UTC (permalink / raw) To: Christian Brauner, Darrick J. Wong Cc: Kelu Ye, Yifan Zhao, Ritesh Harjani, Joanne Koong, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel Hi all, this patch changes how iomap submits bios for reads. The old behavior to build up bios across iomap was already considered problematic for a while, but we now ran into a erofs bug because of it, so it's time to finally fix it. It would be great to get the fix into 7.2 as the fixed bug can be triggered by users. Changes since v2: - drop an unused argument - make sure we submit for the same iteration to not leave a landmine for future changes Changes since v1: - don't submit fuse context after each iteration - consolidate some code to support the above - fix a bug in the fs PI support found while doing the above ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/2] iomap: consolidate bio submission 2026-06-25 12:07 don't build bios/contexts over multiple iomaps v3 Christoph Hellwig @ 2026-06-25 12:07 ` Christoph Hellwig 2026-06-25 17:27 ` Darrick J. Wong 2026-06-25 12:07 ` [PATCH 2/2] iomap: submit read bio after each extent Christoph Hellwig 1 sibling, 1 reply; 15+ messages in thread From: Christoph Hellwig @ 2026-06-25 12:07 UTC (permalink / raw) To: Christian Brauner, Darrick J. Wong Cc: Kelu Ye, Yifan Zhao, Ritesh Harjani, Joanne Koong, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel Add a iomap_bio_submit_read_endio helper factored out of iomap_bio_submit_read to that all ->submit_read implementations for iomap_read_ops that use iomap_bio_read_folio_range can shared the logic. Right now that logic is mostly trivial, but already has a bug for XFS because the XFS version is too trivial: file system integrity validation needs a workqueue context and thus can't happen from the default iomap bi_end_io I/O handler. Unfortunately the iomap refactoring just before fs integrity landed moved code around here and the call go misplaced, meaning it never got called. The PI information still is verified by the block layer, but the offloading is less efficient (and the future userspace interface can't get at it). Fixes: 0b10a370529c ("iomap: support T10 protection information") Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/exfat/iomap.c | 5 +---- fs/iomap/bio.c | 13 ++++++++++--- fs/ntfs/aops.c | 6 ++---- fs/ntfs3/inode.c | 5 +---- fs/xfs/xfs_aops.c | 3 +-- include/linux/iomap.h | 2 ++ 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/fs/exfat/iomap.c b/fs/exfat/iomap.c index 1aac38e63fe6..190fc6471f84 100644 --- a/fs/exfat/iomap.c +++ b/fs/exfat/iomap.c @@ -253,10 +253,7 @@ static void exfat_iomap_read_end_io(struct bio *bio) static void exfat_iomap_bio_submit_read(const struct iomap_iter *iter, struct iomap_read_folio_ctx *ctx) { - struct bio *bio = ctx->read_ctx; - - bio->bi_end_io = exfat_iomap_read_end_io; - submit_bio(bio); + iomap_bio_submit_read_endio(iter, ctx, exfat_iomap_read_end_io); } const struct iomap_read_ops exfat_iomap_bio_read_ops = { diff --git a/fs/iomap/bio.c b/fs/iomap/bio.c index 4504f4633f17..0f31e35567b4 100644 --- a/fs/iomap/bio.c +++ b/fs/iomap/bio.c @@ -78,15 +78,23 @@ u32 iomap_finish_ioend_buffered_read(struct iomap_ioend *ioend) return __iomap_read_end_io(&ioend->io_bio, ioend->io_error); } -static void iomap_bio_submit_read(const struct iomap_iter *iter, - struct iomap_read_folio_ctx *ctx) +void iomap_bio_submit_read_endio(const struct iomap_iter *iter, + struct iomap_read_folio_ctx *ctx, bio_end_io_t end_io) { struct bio *bio = ctx->read_ctx; + bio->bi_end_io = end_io; if (iter->iomap.flags & IOMAP_F_INTEGRITY) fs_bio_integrity_alloc(bio); submit_bio(bio); } +EXPORT_SYMBOL_GPL(iomap_bio_submit_read_endio); + +static void iomap_bio_submit_read(const struct iomap_iter *iter, + struct iomap_read_folio_ctx *ctx) +{ + return iomap_bio_submit_read_endio(iter, ctx, iomap_read_end_io); +} static struct bio_set *iomap_read_bio_set(struct iomap_read_folio_ctx *ctx) { @@ -127,7 +135,6 @@ static void iomap_read_alloc_bio(const struct iomap_iter *iter, if (ctx->rac) bio->bi_opf |= REQ_RAHEAD; bio->bi_iter.bi_sector = iomap_sector(iomap, iter->pos); - bio->bi_end_io = iomap_read_end_io; bio_add_folio_nofail(bio, folio, plen, offset_in_folio(folio, iter->pos)); ctx->read_ctx = bio; diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 1fbf832ad165..f2bb56506046 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -38,11 +38,9 @@ static void ntfs_iomap_read_end_io(struct bio *bio) } static void ntfs_iomap_bio_submit_read(const struct iomap_iter *iter, - struct iomap_read_folio_ctx *ctx) + struct iomap_read_folio_ctx *ctx) { - struct bio *bio = ctx->read_ctx; - bio->bi_end_io = ntfs_iomap_read_end_io; - submit_bio(bio); + iomap_bio_submit_read_endio(iter, ctx, ntfs_iomap_read_end_io); } static const struct iomap_read_ops ntfs_iomap_bio_read_ops = { diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 42af1abe17f8..f9600aba1548 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -609,10 +609,7 @@ static void ntfs_iomap_read_end_io(struct bio *bio) static void ntfs_iomap_bio_submit_read(const struct iomap_iter *iter, struct iomap_read_folio_ctx *ctx) { - struct bio *bio = ctx->read_ctx; - - bio->bi_end_io = ntfs_iomap_read_end_io; - submit_bio(bio); + iomap_bio_submit_read_endio(iter, ctx, ntfs_iomap_read_end_io); } static const struct iomap_read_ops ntfs_iomap_bio_read_ops = { diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 2a0c54256e93..51293b6f331f 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -764,8 +764,7 @@ xfs_bio_submit_read( /* defer read completions to the ioend workqueue */ iomap_init_ioend(iter->inode, bio, ctx->read_ctx_file_offset, 0); - bio->bi_end_io = xfs_end_bio; - submit_bio(bio); + iomap_bio_submit_read_endio(iter, ctx, xfs_end_bio); } static const struct iomap_read_ops xfs_iomap_read_ops = { diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 3582ed1fe236..56b43d594e6e 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -622,6 +622,8 @@ extern struct bio_set iomap_ioend_bioset; #ifdef CONFIG_BLOCK int iomap_bio_read_folio_range(const struct iomap_iter *iter, struct iomap_read_folio_ctx *ctx, size_t plen); +void iomap_bio_submit_read_endio(const struct iomap_iter *iter, + struct iomap_read_folio_ctx *ctx, bio_end_io_t end_io); extern const struct iomap_read_ops iomap_bio_read_ops; -- 2.53.0 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 1/2] iomap: consolidate bio submission 2026-06-25 12:07 ` [PATCH 1/2] iomap: consolidate bio submission Christoph Hellwig @ 2026-06-25 17:27 ` Darrick J. Wong 2026-06-26 4:30 ` Christoph Hellwig 0 siblings, 1 reply; 15+ messages in thread From: Darrick J. Wong @ 2026-06-25 17:27 UTC (permalink / raw) To: Christoph Hellwig Cc: Christian Brauner, Kelu Ye, Yifan Zhao, Ritesh Harjani, Joanne Koong, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel On Thu, Jun 25, 2026 at 02:07:56PM +0200, Christoph Hellwig wrote: > Add a iomap_bio_submit_read_endio helper factored out of > iomap_bio_submit_read to that all ->submit_read implementations for > iomap_read_ops that use iomap_bio_read_folio_range can shared the > logic. > > Right now that logic is mostly trivial, but already has a bug for XFS > because the XFS version is too trivial: file system integrity validation > needs a workqueue context and thus can't happen from the default iomap > bi_end_io I/O handler. Unfortunately the iomap refactoring just before > fs integrity landed moved code around here and the call go misplaced, > meaning it never got called. The PI information still is verified by > the block layer, but the offloading is less efficient (and the future > userspace interface can't get at it). > > Fixes: 0b10a370529c ("iomap: support T10 protection information") > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- > fs/exfat/iomap.c | 5 +---- > fs/iomap/bio.c | 13 ++++++++++--- > fs/ntfs/aops.c | 6 ++---- > fs/ntfs3/inode.c | 5 +---- > fs/xfs/xfs_aops.c | 3 +-- > include/linux/iomap.h | 2 ++ > 6 files changed, 17 insertions(+), 17 deletions(-) > > diff --git a/fs/exfat/iomap.c b/fs/exfat/iomap.c > index 1aac38e63fe6..190fc6471f84 100644 > --- a/fs/exfat/iomap.c > +++ b/fs/exfat/iomap.c > @@ -253,10 +253,7 @@ static void exfat_iomap_read_end_io(struct bio *bio) > static void exfat_iomap_bio_submit_read(const struct iomap_iter *iter, > struct iomap_read_folio_ctx *ctx) > { > - struct bio *bio = ctx->read_ctx; > - > - bio->bi_end_io = exfat_iomap_read_end_io; > - submit_bio(bio); > + iomap_bio_submit_read_endio(iter, ctx, exfat_iomap_read_end_io); > } > > const struct iomap_read_ops exfat_iomap_bio_read_ops = { > diff --git a/fs/iomap/bio.c b/fs/iomap/bio.c > index 4504f4633f17..0f31e35567b4 100644 > --- a/fs/iomap/bio.c > +++ b/fs/iomap/bio.c > @@ -78,15 +78,23 @@ u32 iomap_finish_ioend_buffered_read(struct iomap_ioend *ioend) > return __iomap_read_end_io(&ioend->io_bio, ioend->io_error); > } > > -static void iomap_bio_submit_read(const struct iomap_iter *iter, > - struct iomap_read_folio_ctx *ctx) > +void iomap_bio_submit_read_endio(const struct iomap_iter *iter, > + struct iomap_read_folio_ctx *ctx, bio_end_io_t end_io) > { > struct bio *bio = ctx->read_ctx; > > + bio->bi_end_io = end_io; > if (iter->iomap.flags & IOMAP_F_INTEGRITY) > fs_bio_integrity_alloc(bio); Ah, so the bug here is that all the pagecache readers should have been allocating integrity information for the bio before submitting it? And because it doesn't, iomap_finish_ioend won't do the read verification? So the block layer does it for us, and that's why we don't use the ioend chaining? And (I guess) the future userspace interface won't have any means to get at the integrity data? If the answers to all four questions is "yes" then I've understood this fix well enough to declare Cc: <stable@vger.kernel.org> # v7.1 Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > submit_bio(bio); > } > +EXPORT_SYMBOL_GPL(iomap_bio_submit_read_endio); > + > +static void iomap_bio_submit_read(const struct iomap_iter *iter, > + struct iomap_read_folio_ctx *ctx) > +{ > + return iomap_bio_submit_read_endio(iter, ctx, iomap_read_end_io); > +} > > static struct bio_set *iomap_read_bio_set(struct iomap_read_folio_ctx *ctx) > { > @@ -127,7 +135,6 @@ static void iomap_read_alloc_bio(const struct iomap_iter *iter, > if (ctx->rac) > bio->bi_opf |= REQ_RAHEAD; > bio->bi_iter.bi_sector = iomap_sector(iomap, iter->pos); > - bio->bi_end_io = iomap_read_end_io; > bio_add_folio_nofail(bio, folio, plen, > offset_in_folio(folio, iter->pos)); > ctx->read_ctx = bio; > diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c > index 1fbf832ad165..f2bb56506046 100644 > --- a/fs/ntfs/aops.c > +++ b/fs/ntfs/aops.c > @@ -38,11 +38,9 @@ static void ntfs_iomap_read_end_io(struct bio *bio) > } > > static void ntfs_iomap_bio_submit_read(const struct iomap_iter *iter, > - struct iomap_read_folio_ctx *ctx) > + struct iomap_read_folio_ctx *ctx) > { > - struct bio *bio = ctx->read_ctx; > - bio->bi_end_io = ntfs_iomap_read_end_io; > - submit_bio(bio); > + iomap_bio_submit_read_endio(iter, ctx, ntfs_iomap_read_end_io); > } > > static const struct iomap_read_ops ntfs_iomap_bio_read_ops = { > diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c > index 42af1abe17f8..f9600aba1548 100644 > --- a/fs/ntfs3/inode.c > +++ b/fs/ntfs3/inode.c > @@ -609,10 +609,7 @@ static void ntfs_iomap_read_end_io(struct bio *bio) > static void ntfs_iomap_bio_submit_read(const struct iomap_iter *iter, > struct iomap_read_folio_ctx *ctx) > { > - struct bio *bio = ctx->read_ctx; > - > - bio->bi_end_io = ntfs_iomap_read_end_io; > - submit_bio(bio); > + iomap_bio_submit_read_endio(iter, ctx, ntfs_iomap_read_end_io); > } > > static const struct iomap_read_ops ntfs_iomap_bio_read_ops = { > diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c > index 2a0c54256e93..51293b6f331f 100644 > --- a/fs/xfs/xfs_aops.c > +++ b/fs/xfs/xfs_aops.c > @@ -764,8 +764,7 @@ xfs_bio_submit_read( > > /* defer read completions to the ioend workqueue */ > iomap_init_ioend(iter->inode, bio, ctx->read_ctx_file_offset, 0); > - bio->bi_end_io = xfs_end_bio; > - submit_bio(bio); > + iomap_bio_submit_read_endio(iter, ctx, xfs_end_bio); > } > > static const struct iomap_read_ops xfs_iomap_read_ops = { > diff --git a/include/linux/iomap.h b/include/linux/iomap.h > index 3582ed1fe236..56b43d594e6e 100644 > --- a/include/linux/iomap.h > +++ b/include/linux/iomap.h > @@ -622,6 +622,8 @@ extern struct bio_set iomap_ioend_bioset; > #ifdef CONFIG_BLOCK > int iomap_bio_read_folio_range(const struct iomap_iter *iter, > struct iomap_read_folio_ctx *ctx, size_t plen); > +void iomap_bio_submit_read_endio(const struct iomap_iter *iter, > + struct iomap_read_folio_ctx *ctx, bio_end_io_t end_io); > > extern const struct iomap_read_ops iomap_bio_read_ops; > > -- > 2.53.0 > > ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/2] iomap: consolidate bio submission 2026-06-25 17:27 ` Darrick J. Wong @ 2026-06-26 4:30 ` Christoph Hellwig 0 siblings, 0 replies; 15+ messages in thread From: Christoph Hellwig @ 2026-06-26 4:30 UTC (permalink / raw) To: Darrick J. Wong Cc: Christoph Hellwig, Christian Brauner, Kelu Ye, Yifan Zhao, Ritesh Harjani, Joanne Koong, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel On Thu, Jun 25, 2026 at 10:27:40AM -0700, Darrick J. Wong wrote: > > > > + bio->bi_end_io = end_io; > > if (iter->iomap.flags & IOMAP_F_INTEGRITY) > > fs_bio_integrity_alloc(bio); > > Ah, so the bug here is that all the pagecache readers should have been > allocating integrity information for the bio before submitting it? Well, all the ones that set IOMAP_F_INTEGRITY, which really is just XFS at the momen. And because if the iomap refactoring for fuse XFS is now using it's own submit callback and does not get it.. > And > because it doesn't, iomap_finish_ioend won't do the read verification? Yeah. > So the block layer does it for us, and that's why we don't use the ioend > chaining? And (I guess) the future userspace interface won't have any > means to get at the integrity data? Yeah. ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 2/2] iomap: submit read bio after each extent 2026-06-25 12:07 don't build bios/contexts over multiple iomaps v3 Christoph Hellwig 2026-06-25 12:07 ` [PATCH 1/2] iomap: consolidate bio submission Christoph Hellwig @ 2026-06-25 12:07 ` Christoph Hellwig 2026-06-25 17:47 ` Darrick J. Wong 1 sibling, 1 reply; 15+ messages in thread From: Christoph Hellwig @ 2026-06-25 12:07 UTC (permalink / raw) To: Christian Brauner, Darrick J. Wong Cc: Kelu Ye, Yifan Zhao, Ritesh Harjani, Joanne Koong, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel Currently the iomap buffered read path tries to build up read context (i.e. bios for the typical block based case) over multiple iomaps as long as the sector matches. This does not take into account files that can map to multiple different devices. While this could be fixed by a bdev check in iomap_bio_read_folio_range, the building up of I/O over iomaps actually was a problem for the not yet merged ext2 iomap port, as that does want to send out I/O at the end of an indirect block mapped range. So instead of adding more checks move over to a model where a bio only spans a single iomap. Change ->submit_read to be called after each iteration, and pass a force argument to indicate that the bio must be submitted set on the last iteration. Switch the bio based users to always submit, while keeping the single submit for fuse. Fixes: dfeab2e95a75 ("erofs: add multiple device support") Reported-by: Kelu Ye <yekelu1@huawei.com> Reported-by: Yifan Zhao <zhaoyifan28@huawei.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Yifan Zhao <zhaoyifan28@huawei.com> --- fs/exfat/iomap.c | 2 +- fs/fuse/file.c | 6 +++++- fs/iomap/bio.c | 6 ++++-- fs/iomap/buffered-io.c | 21 +++++++++++++-------- fs/ntfs/aops.c | 2 +- fs/ntfs3/inode.c | 2 +- fs/xfs/xfs_aops.c | 3 ++- include/linux/iomap.h | 2 +- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/fs/exfat/iomap.c b/fs/exfat/iomap.c index 190fc6471f84..c428a949120e 100644 --- a/fs/exfat/iomap.c +++ b/fs/exfat/iomap.c @@ -251,7 +251,7 @@ static void exfat_iomap_read_end_io(struct bio *bio) } static void exfat_iomap_bio_submit_read(const struct iomap_iter *iter, - struct iomap_read_folio_ctx *ctx) + struct iomap_read_folio_ctx *ctx, bool force) { iomap_bio_submit_read_endio(iter, ctx, exfat_iomap_read_end_io); } diff --git a/fs/fuse/file.c b/fs/fuse/file.c index e052a0d44dee..6fa3b1f55c95 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -982,13 +982,17 @@ static int fuse_iomap_read_folio_range_async(const struct iomap_iter *iter, } static void fuse_iomap_submit_read(const struct iomap_iter *iter, - struct iomap_read_folio_ctx *ctx) + struct iomap_read_folio_ctx *ctx, bool force) { struct fuse_fill_read_data *data = ctx->read_ctx; + if (!force) + return; + if (data->ia) fuse_send_readpages(data->ia, data->file, data->nr_bytes, data->fc->async_read); + ctx->read_ctx = NULL; } static const struct iomap_read_ops fuse_iomap_read_ops = { diff --git a/fs/iomap/bio.c b/fs/iomap/bio.c index 0f31e35567b4..6aca1cd0622c 100644 --- a/fs/iomap/bio.c +++ b/fs/iomap/bio.c @@ -87,11 +87,13 @@ void iomap_bio_submit_read_endio(const struct iomap_iter *iter, if (iter->iomap.flags & IOMAP_F_INTEGRITY) fs_bio_integrity_alloc(bio); submit_bio(bio); + + ctx->read_ctx = NULL; } EXPORT_SYMBOL_GPL(iomap_bio_submit_read_endio); static void iomap_bio_submit_read(const struct iomap_iter *iter, - struct iomap_read_folio_ctx *ctx) + struct iomap_read_folio_ctx *ctx, bool force) { return iomap_bio_submit_read_endio(iter, ctx, iomap_read_end_io); } @@ -116,7 +118,7 @@ static void iomap_read_alloc_bio(const struct iomap_iter *iter, /* Submit the existing range if there was one. */ if (ctx->read_ctx) - ctx->ops->submit_read(iter, ctx); + ctx->ops->submit_read(iter, ctx, true); /* Same as readahead_gfp_mask: */ if (ctx->rac) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 8d4806dc46d4..b1c3da8a97dc 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -524,6 +524,13 @@ static void iomap_read_end(struct folio *folio, size_t bytes_submitted) } } +static void iomap_submit_read(struct iomap_iter *iter, + struct iomap_read_folio_ctx *ctx, bool force) +{ + if (ctx->read_ctx && ctx->ops->submit_read) + ctx->ops->submit_read(iter, ctx, force); +} + static int iomap_read_folio_iter(struct iomap_iter *iter, struct iomap_read_folio_ctx *ctx, size_t *bytes_submitted) { @@ -642,12 +649,11 @@ 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, ops)) > 0) { iter.status = iomap_read_folio_iter(&iter, ctx, &bytes_submitted); - - if (ctx->read_ctx && ctx->ops->submit_read) - ctx->ops->submit_read(&iter, ctx); + iomap_submit_read(&iter, ctx, !iter.iomap.length); + } if (ctx->cur_folio) iomap_read_end(ctx->cur_folio, bytes_submitted); @@ -718,12 +724,11 @@ 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, ops) > 0) { iter.status = iomap_readahead_iter(&iter, ctx, &cur_bytes_submitted); - - if (ctx->read_ctx && ctx->ops->submit_read) - ctx->ops->submit_read(&iter, ctx); + iomap_submit_read(&iter, ctx, !iter.iomap.length); + } if (ctx->cur_folio) iomap_read_end(ctx->cur_folio, cur_bytes_submitted); diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index f2bb56506046..f7bd55275d8c 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -38,7 +38,7 @@ static void ntfs_iomap_read_end_io(struct bio *bio) } static void ntfs_iomap_bio_submit_read(const struct iomap_iter *iter, - struct iomap_read_folio_ctx *ctx) + struct iomap_read_folio_ctx *ctx, bool force) { iomap_bio_submit_read_endio(iter, ctx, ntfs_iomap_read_end_io); } diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index f9600aba1548..cd05faebb806 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -607,7 +607,7 @@ static void ntfs_iomap_read_end_io(struct bio *bio) } static void ntfs_iomap_bio_submit_read(const struct iomap_iter *iter, - struct iomap_read_folio_ctx *ctx) + struct iomap_read_folio_ctx *ctx, bool force) { iomap_bio_submit_read_endio(iter, ctx, ntfs_iomap_read_end_io); } diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 51293b6f331f..1b9a55e2f4a7 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -758,7 +758,8 @@ xfs_vm_bmap( static void xfs_bio_submit_read( const struct iomap_iter *iter, - struct iomap_read_folio_ctx *ctx) + struct iomap_read_folio_ctx *ctx, + bool force) { struct bio *bio = ctx->read_ctx; diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 56b43d594e6e..4d8893b02aaf 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -528,7 +528,7 @@ struct iomap_read_ops { * This is optional. */ void (*submit_read)(const struct iomap_iter *iter, - struct iomap_read_folio_ctx *ctx); + struct iomap_read_folio_ctx *ctx, bool force); /* * Optional, allows filesystem to specify own bio_set, so new bio's -- 2.53.0 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] iomap: submit read bio after each extent 2026-06-25 12:07 ` [PATCH 2/2] iomap: submit read bio after each extent Christoph Hellwig @ 2026-06-25 17:47 ` Darrick J. Wong 2026-06-25 18:32 ` Joanne Koong 2026-06-26 4:31 ` Christoph Hellwig 0 siblings, 2 replies; 15+ messages in thread From: Darrick J. Wong @ 2026-06-25 17:47 UTC (permalink / raw) To: Christoph Hellwig Cc: Christian Brauner, Kelu Ye, Yifan Zhao, Ritesh Harjani, Joanne Koong, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel On Thu, Jun 25, 2026 at 02:07:57PM +0200, Christoph Hellwig wrote: > Currently the iomap buffered read path tries to build up read context > (i.e. bios for the typical block based case) over multiple iomaps as > long as the sector matches. This does not take into account files > that can map to multiple different devices. While this could be fixed > by a bdev check in iomap_bio_read_folio_range, the building up of I/O > over iomaps actually was a problem for the not yet merged ext2 iomap > port, as that does want to send out I/O at the end of an indirect > block mapped range. This really puts the onus on block-mapped filesystems (e.g. ext2) to merge adjacent maps into extents. Granted they *probably* already have been doing that. > So instead of adding more checks move over to a model where a bio only > spans a single iomap. Change ->submit_read to be called after each > iteration, and pass a force argument to indicate that the bio must > be submitted set on the last iteration. Switch the bio based users > to always submit, while keeping the single submit for fuse. Is fuse the sole reason for the "force" parameter to exist? I wonder if fuse could drop its submit_read function and call fuse_send_readpages after the iomap_read{ahead,folio} function returns? --D > Fixes: dfeab2e95a75 ("erofs: add multiple device support") > Reported-by: Kelu Ye <yekelu1@huawei.com> > Reported-by: Yifan Zhao <zhaoyifan28@huawei.com> > Signed-off-by: Christoph Hellwig <hch@lst.de> > Tested-by: Yifan Zhao <zhaoyifan28@huawei.com> > --- > fs/exfat/iomap.c | 2 +- > fs/fuse/file.c | 6 +++++- > fs/iomap/bio.c | 6 ++++-- > fs/iomap/buffered-io.c | 21 +++++++++++++-------- > fs/ntfs/aops.c | 2 +- > fs/ntfs3/inode.c | 2 +- > fs/xfs/xfs_aops.c | 3 ++- > include/linux/iomap.h | 2 +- > 8 files changed, 28 insertions(+), 16 deletions(-) > > diff --git a/fs/exfat/iomap.c b/fs/exfat/iomap.c > index 190fc6471f84..c428a949120e 100644 > --- a/fs/exfat/iomap.c > +++ b/fs/exfat/iomap.c > @@ -251,7 +251,7 @@ static void exfat_iomap_read_end_io(struct bio *bio) > } > > static void exfat_iomap_bio_submit_read(const struct iomap_iter *iter, > - struct iomap_read_folio_ctx *ctx) > + struct iomap_read_folio_ctx *ctx, bool force) > { > iomap_bio_submit_read_endio(iter, ctx, exfat_iomap_read_end_io); > } > diff --git a/fs/fuse/file.c b/fs/fuse/file.c > index e052a0d44dee..6fa3b1f55c95 100644 > --- a/fs/fuse/file.c > +++ b/fs/fuse/file.c > @@ -982,13 +982,17 @@ static int fuse_iomap_read_folio_range_async(const struct iomap_iter *iter, > } > > static void fuse_iomap_submit_read(const struct iomap_iter *iter, > - struct iomap_read_folio_ctx *ctx) > + struct iomap_read_folio_ctx *ctx, bool force) > { > struct fuse_fill_read_data *data = ctx->read_ctx; > > + if (!force) > + return; > + > if (data->ia) > fuse_send_readpages(data->ia, data->file, data->nr_bytes, > data->fc->async_read); > + ctx->read_ctx = NULL; > } > > static const struct iomap_read_ops fuse_iomap_read_ops = { > diff --git a/fs/iomap/bio.c b/fs/iomap/bio.c > index 0f31e35567b4..6aca1cd0622c 100644 > --- a/fs/iomap/bio.c > +++ b/fs/iomap/bio.c > @@ -87,11 +87,13 @@ void iomap_bio_submit_read_endio(const struct iomap_iter *iter, > if (iter->iomap.flags & IOMAP_F_INTEGRITY) > fs_bio_integrity_alloc(bio); > submit_bio(bio); > + > + ctx->read_ctx = NULL; > } > EXPORT_SYMBOL_GPL(iomap_bio_submit_read_endio); > > static void iomap_bio_submit_read(const struct iomap_iter *iter, > - struct iomap_read_folio_ctx *ctx) > + struct iomap_read_folio_ctx *ctx, bool force) > { > return iomap_bio_submit_read_endio(iter, ctx, iomap_read_end_io); > } > @@ -116,7 +118,7 @@ static void iomap_read_alloc_bio(const struct iomap_iter *iter, > > /* Submit the existing range if there was one. */ > if (ctx->read_ctx) > - ctx->ops->submit_read(iter, ctx); > + ctx->ops->submit_read(iter, ctx, true); > > /* Same as readahead_gfp_mask: */ > if (ctx->rac) > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c > index 8d4806dc46d4..b1c3da8a97dc 100644 > --- a/fs/iomap/buffered-io.c > +++ b/fs/iomap/buffered-io.c > @@ -524,6 +524,13 @@ static void iomap_read_end(struct folio *folio, size_t bytes_submitted) > } > } > > +static void iomap_submit_read(struct iomap_iter *iter, > + struct iomap_read_folio_ctx *ctx, bool force) > +{ > + if (ctx->read_ctx && ctx->ops->submit_read) > + ctx->ops->submit_read(iter, ctx, force); > +} > + > static int iomap_read_folio_iter(struct iomap_iter *iter, > struct iomap_read_folio_ctx *ctx, size_t *bytes_submitted) > { > @@ -642,12 +649,11 @@ 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, ops)) > 0) { > iter.status = iomap_read_folio_iter(&iter, ctx, > &bytes_submitted); > - > - if (ctx->read_ctx && ctx->ops->submit_read) > - ctx->ops->submit_read(&iter, ctx); > + iomap_submit_read(&iter, ctx, !iter.iomap.length); > + } > > if (ctx->cur_folio) > iomap_read_end(ctx->cur_folio, bytes_submitted); > @@ -718,12 +724,11 @@ 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, ops) > 0) { > iter.status = iomap_readahead_iter(&iter, ctx, > &cur_bytes_submitted); > - > - if (ctx->read_ctx && ctx->ops->submit_read) > - ctx->ops->submit_read(&iter, ctx); > + iomap_submit_read(&iter, ctx, !iter.iomap.length); > + } > > if (ctx->cur_folio) > iomap_read_end(ctx->cur_folio, cur_bytes_submitted); > diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c > index f2bb56506046..f7bd55275d8c 100644 > --- a/fs/ntfs/aops.c > +++ b/fs/ntfs/aops.c > @@ -38,7 +38,7 @@ static void ntfs_iomap_read_end_io(struct bio *bio) > } > > static void ntfs_iomap_bio_submit_read(const struct iomap_iter *iter, > - struct iomap_read_folio_ctx *ctx) > + struct iomap_read_folio_ctx *ctx, bool force) > { > iomap_bio_submit_read_endio(iter, ctx, ntfs_iomap_read_end_io); > } > diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c > index f9600aba1548..cd05faebb806 100644 > --- a/fs/ntfs3/inode.c > +++ b/fs/ntfs3/inode.c > @@ -607,7 +607,7 @@ static void ntfs_iomap_read_end_io(struct bio *bio) > } > > static void ntfs_iomap_bio_submit_read(const struct iomap_iter *iter, > - struct iomap_read_folio_ctx *ctx) > + struct iomap_read_folio_ctx *ctx, bool force) > { > iomap_bio_submit_read_endio(iter, ctx, ntfs_iomap_read_end_io); > } > diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c > index 51293b6f331f..1b9a55e2f4a7 100644 > --- a/fs/xfs/xfs_aops.c > +++ b/fs/xfs/xfs_aops.c > @@ -758,7 +758,8 @@ xfs_vm_bmap( > static void > xfs_bio_submit_read( > const struct iomap_iter *iter, > - struct iomap_read_folio_ctx *ctx) > + struct iomap_read_folio_ctx *ctx, > + bool force) > { > struct bio *bio = ctx->read_ctx; > > diff --git a/include/linux/iomap.h b/include/linux/iomap.h > index 56b43d594e6e..4d8893b02aaf 100644 > --- a/include/linux/iomap.h > +++ b/include/linux/iomap.h > @@ -528,7 +528,7 @@ struct iomap_read_ops { > * This is optional. > */ > void (*submit_read)(const struct iomap_iter *iter, > - struct iomap_read_folio_ctx *ctx); > + struct iomap_read_folio_ctx *ctx, bool force); > > /* > * Optional, allows filesystem to specify own bio_set, so new bio's > -- > 2.53.0 > > ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] iomap: submit read bio after each extent 2026-06-25 17:47 ` Darrick J. Wong @ 2026-06-25 18:32 ` Joanne Koong 2026-06-26 4:33 ` Christoph Hellwig 2026-06-26 4:31 ` Christoph Hellwig 1 sibling, 1 reply; 15+ messages in thread From: Joanne Koong @ 2026-06-25 18:32 UTC (permalink / raw) To: Darrick J. Wong Cc: Christoph Hellwig, Christian Brauner, Kelu Ye, Yifan Zhao, Ritesh Harjani, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel On Thu, Jun 25, 2026 at 10:47 AM Darrick J. Wong <djwong@kernel.org> wrote: > > On Thu, Jun 25, 2026 at 02:07:57PM +0200, Christoph Hellwig wrote: > > > So instead of adding more checks move over to a model where a bio only > > spans a single iomap. Change ->submit_read to be called after each > > iteration, and pass a force argument to indicate that the bio must > > be submitted set on the last iteration. Switch the bio based users > > to always submit, while keeping the single submit for fuse. > > Is fuse the sole reason for the "force" parameter to exist? I wonder if > fuse could drop its submit_read function and call fuse_send_readpages > after the iomap_read{ahead,folio} function returns? > Yes, that works. I think that's a good idea. fuse only needs submit_read logic for readahead. The change would just be: --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -953,19 +953,8 @@ static int fuse_iomap_read_folio_range_async(const struct iomap_iter *iter, return ret; } -static void fuse_iomap_submit_read(const struct iomap_iter *iter, - struct iomap_read_folio_ctx *ctx) -{ - struct fuse_fill_read_data *data = ctx->read_ctx; - - if (data->ia) - fuse_send_readpages(data->ia, data->file, data->nr_bytes, - data->fc->async_read); -} - static const struct iomap_read_ops fuse_iomap_read_ops = { .read_folio_range = fuse_iomap_read_folio_range_async, - .submit_read = fuse_iomap_submit_read, }; static int fuse_read_folio(struct file *file, struct folio *folio) @@ -1089,6 +1078,9 @@ static void fuse_readahead(struct readahead_control *rac) return; iomap_readahead(&fuse_iomap_ops, &ctx, NULL); + if (data.ia) + fuse_send_readpages(data.ia, data.file, data.nr_bytes, + fc->async_read); } If this fix needs to go into 7.2 though, maybe it makes sense to land the v1 implementation [1] + the xfs integrity fix now and do the fuse change later? Thanks, Joanne [1] https://lore.kernel.org/linux-fsdevel/20260619050105.439956-2-hch@lst.de/ ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] iomap: submit read bio after each extent 2026-06-25 18:32 ` Joanne Koong @ 2026-06-26 4:33 ` Christoph Hellwig 2026-06-26 6:16 ` Christoph Hellwig 0 siblings, 1 reply; 15+ messages in thread From: Christoph Hellwig @ 2026-06-26 4:33 UTC (permalink / raw) To: Joanne Koong Cc: Darrick J. Wong, Christoph Hellwig, Christian Brauner, Kelu Ye, Yifan Zhao, Ritesh Harjani, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel On Thu, Jun 25, 2026 at 11:32:40AM -0700, Joanne Koong wrote: > Yes, that works. I think that's a good idea. fuse only needs > submit_read logic for readahead. The change would just be: A nice, I'll fold that in. > If this fix needs to go into 7.2 though, maybe it makes sense to land > the v1 implementation [1] + the xfs integrity fix now and do the fuse > change later? In a way this is actually simpler as it doesn't require the prototype change. And it'll avoid both a temporary fuse performance regression and a bit of churn. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] iomap: submit read bio after each extent 2026-06-26 4:33 ` Christoph Hellwig @ 2026-06-26 6:16 ` Christoph Hellwig 2026-06-26 6:20 ` Darrick J. Wong 2026-06-26 14:51 ` Joanne Koong 0 siblings, 2 replies; 15+ messages in thread From: Christoph Hellwig @ 2026-06-26 6:16 UTC (permalink / raw) To: Joanne Koong Cc: Darrick J. Wong, Christoph Hellwig, Christian Brauner, Kelu Ye, Yifan Zhao, Ritesh Harjani, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel On Fri, Jun 26, 2026 at 06:33:19AM +0200, Christoph Hellwig wrote: > On Thu, Jun 25, 2026 at 11:32:40AM -0700, Joanne Koong wrote: > > Yes, that works. I think that's a good idea. fuse only needs > > submit_read logic for readahead. The change would just be: > > A nice, I'll fold that in. Btw, can I get a signoff from you for this? It looks like splitting this into a separate patch actually works better. If you have a preferred commit log I'd take that as well instead of mine. This is what I'm currently testing: https://git.infradead.org/?p=users/hch/misc.git;a=shortlog;h=refs/heads/iomap-read-submit-bio ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] iomap: submit read bio after each extent 2026-06-26 6:16 ` Christoph Hellwig @ 2026-06-26 6:20 ` Darrick J. Wong 2026-06-26 14:51 ` Joanne Koong 1 sibling, 0 replies; 15+ messages in thread From: Darrick J. Wong @ 2026-06-26 6:20 UTC (permalink / raw) To: Christoph Hellwig Cc: Joanne Koong, Christian Brauner, Kelu Ye, Yifan Zhao, Ritesh Harjani, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel On Fri, Jun 26, 2026 at 08:16:37AM +0200, Christoph Hellwig wrote: > On Fri, Jun 26, 2026 at 06:33:19AM +0200, Christoph Hellwig wrote: > > On Thu, Jun 25, 2026 at 11:32:40AM -0700, Joanne Koong wrote: > > > Yes, that works. I think that's a good idea. fuse only needs > > > submit_read logic for readahead. The change would just be: > > > > A nice, I'll fold that in. > > Btw, can I get a signoff from you for this? It looks like splitting > this into a separate patch actually works better. If you have a > preferred commit log I'd take that as well instead of mine. > > This is what I'm currently testing: > > https://git.infradead.org/?p=users/hch/misc.git;a=shortlog;h=refs/heads/iomap-read-submit-bio For both of the patches at the end of the branch, Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] iomap: submit read bio after each extent 2026-06-26 6:16 ` Christoph Hellwig 2026-06-26 6:20 ` Darrick J. Wong @ 2026-06-26 14:51 ` Joanne Koong 1 sibling, 0 replies; 15+ messages in thread From: Joanne Koong @ 2026-06-26 14:51 UTC (permalink / raw) To: Christoph Hellwig Cc: Darrick J. Wong, Christian Brauner, Kelu Ye, Yifan Zhao, Ritesh Harjani, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel On Thu, Jun 25, 2026 at 11:16 PM Christoph Hellwig <hch@lst.de> wrote: > > On Fri, Jun 26, 2026 at 06:33:19AM +0200, Christoph Hellwig wrote: > > On Thu, Jun 25, 2026 at 11:32:40AM -0700, Joanne Koong wrote: > > > Yes, that works. I think that's a good idea. fuse only needs > > > submit_read logic for readahead. The change would just be: > > > > A nice, I'll fold that in. > > Btw, can I get a signoff from you for this? It looks like splitting > this into a separate patch actually works better. If you have a > preferred commit log I'd take that as well instead of mine. > > This is what I'm currently testing: > > https://git.infradead.org/?p=users/hch/misc.git;a=shortlog;h=refs/heads/iomap-read-submit-bio The submit_read logic is only needed for readahead. We can remove the + if (data.ia) + fuse_send_readpages(data.ia, data.file, data.nr_bytes, + data.fc->async_read); change to fuse_read_folio(). Signed-off-by: Joanne Koong <joannelkoong@gmail.com> Thanks, Joanne ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] iomap: submit read bio after each extent 2026-06-25 17:47 ` Darrick J. Wong 2026-06-25 18:32 ` Joanne Koong @ 2026-06-26 4:31 ` Christoph Hellwig 1 sibling, 0 replies; 15+ messages in thread From: Christoph Hellwig @ 2026-06-26 4:31 UTC (permalink / raw) To: Darrick J. Wong Cc: Christoph Hellwig, Christian Brauner, Kelu Ye, Yifan Zhao, Ritesh Harjani, Joanne Koong, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel On Thu, Jun 25, 2026 at 10:47:58AM -0700, Darrick J. Wong wrote: > On Thu, Jun 25, 2026 at 02:07:57PM +0200, Christoph Hellwig wrote: > > Currently the iomap buffered read path tries to build up read context > > (i.e. bios for the typical block based case) over multiple iomaps as > > long as the sector matches. This does not take into account files > > that can map to multiple different devices. While this could be fixed > > by a bdev check in iomap_bio_read_folio_range, the building up of I/O > > over iomaps actually was a problem for the not yet merged ext2 iomap > > port, as that does want to send out I/O at the end of an indirect > > block mapped range. > > This really puts the onus on block-mapped filesystems (e.g. ext2) to > merge adjacent maps into extents. Granted they *probably* already have > been doing that. Yes. In fact the ext2 conversion was the first ask for this change, because they do not want unlimited merging but kick off I/O at the indirect block boundary. > > So instead of adding more checks move over to a model where a bio only > > spans a single iomap. Change ->submit_read to be called after each > > iteration, and pass a force argument to indicate that the bio must > > be submitted set on the last iteration. Switch the bio based users > > to always submit, while keeping the single submit for fuse. > > Is fuse the sole reason for the "force" parameter to exist? I wonder if > fuse could drop its submit_read function and call fuse_send_readpages > after the iomap_read{ahead,folio} function returns? Probably.. ^ permalink raw reply [flat|nested] 15+ messages in thread
* don't build bios/contexts over multiple iomaps v2 @ 2026-06-23 13:51 Christoph Hellwig 2026-06-23 13:51 ` [PATCH 1/2] iomap: consolidate bio submission Christoph Hellwig 0 siblings, 1 reply; 15+ messages in thread From: Christoph Hellwig @ 2026-06-23 13:51 UTC (permalink / raw) To: Christian Brauner, Darrick J. Wong Cc: Kelu Ye, Yifan Zhao, Ritesh Harjani, Joanne Koong, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel Hi all, this patch changes how iomap submits bios for reads. The old behavior to build up bios across iomap was already considered problematic for a while, but we now ran into a erofs bug because of it, so it's time to finally fix it. It would be great to get the fix into 7.2 as the fixed bug can be triggered by users. Changes since v1: - don't submit fuse context after each iteration - consolidate some code to support the above - fix a bug in the fs PI support found while doing the above ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/2] iomap: consolidate bio submission 2026-06-23 13:51 don't build bios/contexts over multiple iomaps v2 Christoph Hellwig @ 2026-06-23 13:51 ` Christoph Hellwig 2026-06-23 17:04 ` Joanne Koong 2026-06-23 23:57 ` Namjae Jeon 0 siblings, 2 replies; 15+ messages in thread From: Christoph Hellwig @ 2026-06-23 13:51 UTC (permalink / raw) To: Christian Brauner, Darrick J. Wong Cc: Kelu Ye, Yifan Zhao, Ritesh Harjani, Joanne Koong, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel Add a iomap_bio_submit_read_endio helper factored out of iomap_bio_submit_read to that all ->submit_read implementations for iomap_read_ops that use iomap_bio_read_folio_range can shared the logic. Right now that logic is mostly trivial, but already has a bug for XFS because the XFS version is too trivial: file system integrity validation needs a workqueue context and thus can't happen from the default iomap bi_end_io I/O handler. Unfortunately the iomap refactoring just before fs integrity landed moved code around here and the call go misplaced, meaning it never got called. The PI information still is verified by the block layer, but the offloading is less efficient (and the future userspace interface can't get at it). Fixes: 0b10a370529c ("iomap: support T10 protection information") Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/exfat/iomap.c | 5 +---- fs/iomap/bio.c | 13 ++++++++++--- fs/ntfs/aops.c | 6 ++---- fs/ntfs3/inode.c | 5 +---- fs/xfs/xfs_aops.c | 3 +-- include/linux/iomap.h | 2 ++ 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/fs/exfat/iomap.c b/fs/exfat/iomap.c index 1aac38e63fe6..190fc6471f84 100644 --- a/fs/exfat/iomap.c +++ b/fs/exfat/iomap.c @@ -253,10 +253,7 @@ static void exfat_iomap_read_end_io(struct bio *bio) static void exfat_iomap_bio_submit_read(const struct iomap_iter *iter, struct iomap_read_folio_ctx *ctx) { - struct bio *bio = ctx->read_ctx; - - bio->bi_end_io = exfat_iomap_read_end_io; - submit_bio(bio); + iomap_bio_submit_read_endio(iter, ctx, exfat_iomap_read_end_io); } const struct iomap_read_ops exfat_iomap_bio_read_ops = { diff --git a/fs/iomap/bio.c b/fs/iomap/bio.c index 4504f4633f17..0f31e35567b4 100644 --- a/fs/iomap/bio.c +++ b/fs/iomap/bio.c @@ -78,15 +78,23 @@ u32 iomap_finish_ioend_buffered_read(struct iomap_ioend *ioend) return __iomap_read_end_io(&ioend->io_bio, ioend->io_error); } -static void iomap_bio_submit_read(const struct iomap_iter *iter, - struct iomap_read_folio_ctx *ctx) +void iomap_bio_submit_read_endio(const struct iomap_iter *iter, + struct iomap_read_folio_ctx *ctx, bio_end_io_t end_io) { struct bio *bio = ctx->read_ctx; + bio->bi_end_io = end_io; if (iter->iomap.flags & IOMAP_F_INTEGRITY) fs_bio_integrity_alloc(bio); submit_bio(bio); } +EXPORT_SYMBOL_GPL(iomap_bio_submit_read_endio); + +static void iomap_bio_submit_read(const struct iomap_iter *iter, + struct iomap_read_folio_ctx *ctx) +{ + return iomap_bio_submit_read_endio(iter, ctx, iomap_read_end_io); +} static struct bio_set *iomap_read_bio_set(struct iomap_read_folio_ctx *ctx) { @@ -127,7 +135,6 @@ static void iomap_read_alloc_bio(const struct iomap_iter *iter, if (ctx->rac) bio->bi_opf |= REQ_RAHEAD; bio->bi_iter.bi_sector = iomap_sector(iomap, iter->pos); - bio->bi_end_io = iomap_read_end_io; bio_add_folio_nofail(bio, folio, plen, offset_in_folio(folio, iter->pos)); ctx->read_ctx = bio; diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 1fbf832ad165..f2bb56506046 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -38,11 +38,9 @@ static void ntfs_iomap_read_end_io(struct bio *bio) } static void ntfs_iomap_bio_submit_read(const struct iomap_iter *iter, - struct iomap_read_folio_ctx *ctx) + struct iomap_read_folio_ctx *ctx) { - struct bio *bio = ctx->read_ctx; - bio->bi_end_io = ntfs_iomap_read_end_io; - submit_bio(bio); + iomap_bio_submit_read_endio(iter, ctx, ntfs_iomap_read_end_io); } static const struct iomap_read_ops ntfs_iomap_bio_read_ops = { diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 42af1abe17f8..f9600aba1548 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -609,10 +609,7 @@ static void ntfs_iomap_read_end_io(struct bio *bio) static void ntfs_iomap_bio_submit_read(const struct iomap_iter *iter, struct iomap_read_folio_ctx *ctx) { - struct bio *bio = ctx->read_ctx; - - bio->bi_end_io = ntfs_iomap_read_end_io; - submit_bio(bio); + iomap_bio_submit_read_endio(iter, ctx, ntfs_iomap_read_end_io); } static const struct iomap_read_ops ntfs_iomap_bio_read_ops = { diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 2a0c54256e93..51293b6f331f 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -764,8 +764,7 @@ xfs_bio_submit_read( /* defer read completions to the ioend workqueue */ iomap_init_ioend(iter->inode, bio, ctx->read_ctx_file_offset, 0); - bio->bi_end_io = xfs_end_bio; - submit_bio(bio); + iomap_bio_submit_read_endio(iter, ctx, xfs_end_bio); } static const struct iomap_read_ops xfs_iomap_read_ops = { diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 3582ed1fe236..56b43d594e6e 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -622,6 +622,8 @@ extern struct bio_set iomap_ioend_bioset; #ifdef CONFIG_BLOCK int iomap_bio_read_folio_range(const struct iomap_iter *iter, struct iomap_read_folio_ctx *ctx, size_t plen); +void iomap_bio_submit_read_endio(const struct iomap_iter *iter, + struct iomap_read_folio_ctx *ctx, bio_end_io_t end_io); extern const struct iomap_read_ops iomap_bio_read_ops; -- 2.53.0 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 1/2] iomap: consolidate bio submission 2026-06-23 13:51 ` [PATCH 1/2] iomap: consolidate bio submission Christoph Hellwig @ 2026-06-23 17:04 ` Joanne Koong 2026-06-23 23:57 ` Namjae Jeon 1 sibling, 0 replies; 15+ messages in thread From: Joanne Koong @ 2026-06-23 17:04 UTC (permalink / raw) To: Christoph Hellwig Cc: Christian Brauner, Darrick J. Wong, Kelu Ye, Yifan Zhao, Ritesh Harjani, Namjae Jeon, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel On Tue, Jun 23, 2026 at 6:52 AM Christoph Hellwig <hch@lst.de> wrote: > > Add a iomap_bio_submit_read_endio helper factored out of > iomap_bio_submit_read to that all ->submit_read implementations for > iomap_read_ops that use iomap_bio_read_folio_range can shared the > logic. > > Right now that logic is mostly trivial, but already has a bug for XFS > because the XFS version is too trivial: file system integrity validation > needs a workqueue context and thus can't happen from the default iomap > bi_end_io I/O handler. Unfortunately the iomap refactoring just before > fs integrity landed moved code around here and the call go misplaced, > meaning it never got called. The PI information still is verified by > the block layer, but the offloading is less efficient (and the future > userspace interface can't get at it). > > Fixes: 0b10a370529c ("iomap: support T10 protection information") > Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Joanne Koong <joannelkoong@gmail.com> ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/2] iomap: consolidate bio submission 2026-06-23 13:51 ` [PATCH 1/2] iomap: consolidate bio submission Christoph Hellwig 2026-06-23 17:04 ` Joanne Koong @ 2026-06-23 23:57 ` Namjae Jeon 1 sibling, 0 replies; 15+ messages in thread From: Namjae Jeon @ 2026-06-23 23:57 UTC (permalink / raw) To: Christoph Hellwig Cc: Christian Brauner, Darrick J. Wong, Kelu Ye, Yifan Zhao, Ritesh Harjani, Joanne Koong, Sungjong Seo, Hyunchul Lee, Konstantin Komarov, Miklos Szeredi, fuse-devel, ntfs3, linux-erofs, linux-xfs, linux-fsdevel On Tue, Jun 23, 2026 at 10:52 PM Christoph Hellwig <hch@lst.de> wrote: > > Add a iomap_bio_submit_read_endio helper factored out of > iomap_bio_submit_read to that all ->submit_read implementations for > iomap_read_ops that use iomap_bio_read_folio_range can shared the > logic. > > Right now that logic is mostly trivial, but already has a bug for XFS > because the XFS version is too trivial: file system integrity validation > needs a workqueue context and thus can't happen from the default iomap > bi_end_io I/O handler. Unfortunately the iomap refactoring just before > fs integrity landed moved code around here and the call go misplaced, > meaning it never got called. The PI information still is verified by > the block layer, but the offloading is less efficient (and the future > userspace interface can't get at it). > > Fixes: 0b10a370529c ("iomap: support T10 protection information") > Signed-off-by: Christoph Hellwig <hch@lst.de> for ntfs, exfat part. Acked-by: Namjae Jeon <linkinjeon@kernel.org> Thanks! ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-06-26 14:51 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-06-25 12:07 don't build bios/contexts over multiple iomaps v3 Christoph Hellwig 2026-06-25 12:07 ` [PATCH 1/2] iomap: consolidate bio submission Christoph Hellwig 2026-06-25 17:27 ` Darrick J. Wong 2026-06-26 4:30 ` Christoph Hellwig 2026-06-25 12:07 ` [PATCH 2/2] iomap: submit read bio after each extent Christoph Hellwig 2026-06-25 17:47 ` Darrick J. Wong 2026-06-25 18:32 ` Joanne Koong 2026-06-26 4:33 ` Christoph Hellwig 2026-06-26 6:16 ` Christoph Hellwig 2026-06-26 6:20 ` Darrick J. Wong 2026-06-26 14:51 ` Joanne Koong 2026-06-26 4:31 ` Christoph Hellwig -- strict thread matches above, loose matches on Subject: below -- 2026-06-23 13:51 don't build bios/contexts over multiple iomaps v2 Christoph Hellwig 2026-06-23 13:51 ` [PATCH 1/2] iomap: consolidate bio submission Christoph Hellwig 2026-06-23 17:04 ` Joanne Koong 2026-06-23 23:57 ` Namjae Jeon
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.