don't build bios/contexts over multiple iomaps v2
Subsystems (7)
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
PATCH 1/2 iomap: consolidate bio submission
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).
--- 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(-)
fs/exfat/iomap.c +1 -4
@@ -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 = {
fs/iomap/bio.c +10 -3
@@ -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;
fs/ntfs/aops.c +2 -4
@@ -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 = {
fs/ntfs3/inode.c +1 -4
@@ -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 = {
fs/xfs/xfs_aops.c +1 -2
@@ -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 = {
include/linux/iomap.h +2 -0
@@ -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;
Signature · 1 line
2.53.0
Re: [PATCH 1/2] iomap: consolidate bio submission
Quoted 15 lines · Christoph Hellwig
Add a
iomap_bio_submit_read_endiohelper factored out ofiomap_bio_submit_readto that all ->submit_read implementations foriomap_read_opsthat useiomap_bio_read_folio_rangecan 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_ioI/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).
Quoted 2 lines
Fixes 0b10a370529c ("iomap: support T10 protection information")Signed-off-by Christoph Hellwig <[email protected]>
Re: [PATCH 1/2] iomap: consolidate bio submission
In reply to Christoph HellwigQuoted 15 lines · Christoph Hellwig
Add a
iomap_bio_submit_read_endiohelper factored out ofiomap_bio_submit_readto that all ->submit_read implementations foriomap_read_opsthat useiomap_bio_read_folio_rangecan 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_ioI/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).
Quoted 2 lines
Fixes 0b10a370529c ("iomap: support T10 protection information")Signed-off-by Christoph Hellwig <[email protected]>
for ntfs, exfat part.
Thanks!
PATCH 2/2 iomap: submit read bio after each extent
In reply to Christoph HellwigCurrently 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.
--- fs/exfat/iomap.c | 4 ++-- fs/fuse/file.c | 6 +++++- fs/iomap/bio.c | 11 +++++++---- fs/iomap/buffered-io.c | 23 +++++++++++++++-------- fs/ntfs/aops.c | 4 ++-- fs/ntfs3/inode.c | 4 ++-- fs/xfs/xfs_aops.c | 5 +++-- include/linux/iomap.h | 5 +++-- 8 files changed, 39 insertions(+), 23 deletions(-)
fs/exfat/iomap.c +2 -2
@@ -251,9 +251,9 @@ 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); +iomap_bio_submit_read_endio (iter, ctx, force, exfat_iomap_read_end_io); }const struct iomap_read_ops exfat_iomap_bio_read_ops = {
fs/fuse/file.c +5 -1
@@ -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 = {
fs/iomap/bio.c +7 -4
@@ -79,7 +79,8 @@ u32 iomap_finish_ioend_buffered_read(struct iomap_ioend *ioend) }void iomap_bio_submit_read_endio (const struct iomap_iter *iter, -struct iomap_read_folio_ctx *ctx,bio_end_io_t end_io) +struct iomap_read_folio_ctx *ctx,bool force, +bio_end_io_t end_io) {struct bio *bio = ctx->read_ctx;
@@ -87,13 +88,15 @@ 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); +return iomap_bio_submit_read_endio (iter, ctx, force, iomap_read_end_io); }static struct bio_set *iomap_read_bio_set (struct iomap_read_folio_ctx *ctx)
@@ -116,7 +119,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)
fs/iomap/buffered-io.c +15 -8
@@ -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,12 @@ 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 ) { +iomap_submit_read (&iter, ctx, false); 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, true);if (ctx->cur_folio)iomap_read_end (ctx->cur_folio, bytes_submitted);
@@ -718,12 +725,12 @@ 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 ) { +iomap_submit_read (&iter, ctx, false); 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, true);if (ctx->cur_folio)iomap_read_end (ctx->cur_folio, cur_bytes_submitted);
fs/ntfs/aops.c +2 -2
@@ -38,9 +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,bool force) { -iomap_bio_submit_read_endio (iter, ctx, ntfs_iomap_read_end_io); +iomap_bio_submit_read_endio (iter, ctx, force, ntfs_iomap_read_end_io); }static const struct iomap_read_ops ntfs_iomap_bio_read_ops = {
fs/ntfs3/inode.c +2 -2
@@ -607,9 +607,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,bool force) { -iomap_bio_submit_read_endio (iter, ctx, ntfs_iomap_read_end_io); +iomap_bio_submit_read_endio (iter, ctx, force, ntfs_iomap_read_end_io); }static const struct iomap_read_ops ntfs_iomap_bio_read_ops = {
fs/xfs/xfs_aops.c +3 -2
@@ -758,13 +758,14 @@ 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;/* defer read completions to the ioend workqueue */ iomap_init_ioend (iter->inode, bio, ctx->read_ctx_file_offset,0 ); -iomap_bio_submit_read_endio (iter, ctx, xfs_end_bio); +iomap_bio_submit_read_endio (iter, ctx, force, xfs_end_bio); }static const struct iomap_read_ops xfs_iomap_read_ops = {
include/linux/iomap.h +3 -2
@@ -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
@@ -623,7 +623,8 @@ extern struct bio_set iomap_ioend_bioset;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); +struct iomap_read_folio_ctx *ctx,bool force, +bio_end_io_t end_io);extern const struct iomap_read_ops iomap_bio_read_ops;
Signature · 1 line
2.53.0
Re: [PATCH 2/2] iomap: submit read bio after each extent
Quoted 36 lines · Christoph Hellwig
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 <[email protected]>Reported-by Yifan Zhao <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>--- fs/exfat/iomap.c | 4 ++-- fs/fuse/file.c | 6 +++++- fs/iomap/bio.c | 11 +++++++---- fs/iomap/buffered-io.c | 23 +++++++++++++++-------- fs/ntfs/aops.c | 4 ++-- fs/ntfs3/inode.c | 4 ++-- fs/xfs/xfs_aops.c | 5 +++-- include/linux/iomap.h | 5 +++-- 8 files changed, 39 insertions(+), 23 deletions(-)fs/iomap/bio.c +0
-0
fs/iomap/bio.c u32 iomap_finish_ioend_buffered_read(struct iomap_ioend *ioend) · line 82
Quoted 5 lines
fs/iomap/bio.c +1
-1@@ -79,7 +79,8 @@ u32 iomap_finish_ioend_buffered_read(struct iomap_ioend *ioend) } void iomap_bio_submit_read_endio(const struct iomap_iter *iter, -struct iomap_read_folio_ctx *ctx,bio_end_io_t end_io) + struct iomap_read_folio_ctx *ctx, bool force,
nit: might simplify things to drop the unused force arg
Quoted 20 lines
fs/iomap/bio.c +3
-0+ bio_end_io_t end_io) {struct bio *bio = ctx->read_ctx;@@ -87,13 +88,15 @@ 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);fs/iomap/buffered-io.c +0
-0
fs/iomap/buffered-io.c void iomap_read_folio(const struct iomap_ops *ops, · line 655
Quoted 8 lines
fs/iomap/buffered-io.c +2
-1@@ -642,12 +649,12 @@ 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 ) { +iomap_submit_read (&iter, ctx, false); iter.status =iomap_read_folio_iter (&iter, ctx, &bytes_submitted);
should the submit_read happen after the iomap_read_folio_iter() / iomap_readahead_iter() instaed of before? From what I see, it looks like iomap_submit_read() would hold the iter state of the next mapping. It seems like in iomap_bio_submit_read_endio(), the iter->iomap.flags would be the next extent's flags instead of the one that needs to be submitted?
Thanks,
Joanne
Re: [PATCH 2/2] iomap: submit read bio after each extent
Quoted 5 lines · Joanne Koong
fs/iomap/bio.c u32 iomap_finish_ioend_buffered_read(struct iomap_ioend *ioend) · line 82
Quoted 3 lines
void iomap_bio_submit_read_endio(const struct
iomap_iter*iter,fs/iomap/bio.c +1
-1- struct iomap_read_folio_ctx *ctx, bio_end_io_t end_io) + struct iomap_read_folio_ctx *ctx, bool force,nit: might simplify things to drop the unused force arg
I guess this is not directly used as a method, so we could.
Quoted 7 lines
fs/iomap/buffered-io.c void iomap_read_folio(const struct iomap_ops *ops, · line 655
Quoted 6 lines
fs/iomap/buffered-io.c +2
-1-while ((ret =iomap_iter (&iter, ops)) >0 ) +while ((ret =iomap_iter (&iter, ops)) >0 ) { +iomap_submit_read (&iter, ctx, false); iter.status =iomap_read_folio_iter (&iter, ctx, &bytes_submitted);
Quoted 6 lines
should the
submit_readhappen after theiomap_read_folio_iter()/iomap_readahead_iter()instaed of before? From what I see, it looks likeiomap_submit_read()would hold the iter state of the next mapping. It seems like iniomap_bio_submit_read_endio(), theiter->iomap.flagswould be the next extent's flags instead of the one that needs to be submitted?
Yeah, the iter state would be wrong here if anyone actually used it. But the only thing we actually ever use from it is the inode in XFS.
So I'm tempted to instead just adopt the signature to not pass the iter, as nothing should rely on it. The only interesting thing I could think of for the future would be to pass on private data, but that's probably better left for when we actually need it.
Re: [PATCH 2/2] iomap: submit read bio after each extent
In reply to Christoph HellwigQuoted 16 lines · Christoph Hellwig
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.
Quoted 4 lines
Fixes dfeab2e95a75 ("erofs: add multiple device support")Reported-by Kelu Ye <[email protected]>Reported-by Yifan Zhao <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>
for ntfs, exfat part.
Thanks!
Re: [PATCH 2/2] iomap: submit read bio after each extent
In reply to Christoph HellwigThe issue where EROFS could merge bios across devices when using iomap API no longer exists.
Quoted 238 lines · Christoph Hellwig
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 <[email protected]>Reported-by Yifan Zhao <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>--- fs/exfat/iomap.c | 4 ++-- fs/fuse/file.c | 6 +++++- fs/iomap/bio.c | 11 +++++++---- fs/iomap/buffered-io.c | 23 +++++++++++++++-------- fs/ntfs/aops.c | 4 ++-- fs/ntfs3/inode.c | 4 ++-- fs/xfs/xfs_aops.c | 5 +++-- include/linux/iomap.h | 5 +++-- 8 files changed, 39 insertions(+), 23 deletions(-)fs/exfat/iomap.c +2
-2@@ -251,9 +251,9 @@ 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); +iomap_bio_submit_read_endio (iter, ctx, force, exfat_iomap_read_end_io); }const struct iomap_read_ops exfat_iomap_bio_read_ops = {fs/fuse/file.c +5
-1@@ -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 = {fs/iomap/bio.c +7
-4@@ -79,7 +79,8 @@ u32 iomap_finish_ioend_buffered_read(struct iomap_ioend *ioend) }void iomap_bio_submit_read_endio (const struct iomap_iter *iter, -struct iomap_read_folio_ctx *ctx,bio_end_io_t end_io) +struct iomap_read_folio_ctx *ctx,bool force, +bio_end_io_t end_io) {struct bio *bio = ctx->read_ctx;@@ -87,13 +88,15 @@ 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); +return iomap_bio_submit_read_endio (iter, ctx, force, iomap_read_end_io); }static struct bio_set *iomap_read_bio_set (struct iomap_read_folio_ctx *ctx)@@ -116,7 +119,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)fs/iomap/buffered-io.c +15
-8@@ -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,12 @@ 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 ) { +iomap_submit_read (&iter, ctx, false); 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, true);if (ctx->cur_folio)iomap_read_end (ctx->cur_folio, bytes_submitted);@@ -718,12 +725,12 @@ 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 ) { +iomap_submit_read (&iter, ctx, false); 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, true);if (ctx->cur_folio)iomap_read_end (ctx->cur_folio, cur_bytes_submitted);fs/ntfs/aops.c +2
-2@@ -38,9 +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,bool force) { -iomap_bio_submit_read_endio (iter, ctx, ntfs_iomap_read_end_io); +iomap_bio_submit_read_endio (iter, ctx, force, ntfs_iomap_read_end_io); }static const struct iomap_read_ops ntfs_iomap_bio_read_ops = {fs/ntfs3/inode.c +2
-2@@ -607,9 +607,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,bool force) { -iomap_bio_submit_read_endio (iter, ctx, ntfs_iomap_read_end_io); +iomap_bio_submit_read_endio (iter, ctx, force, ntfs_iomap_read_end_io); }static const struct iomap_read_ops ntfs_iomap_bio_read_ops = {fs/xfs/xfs_aops.c +3
-2@@ -758,13 +758,14 @@ 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;/* defer read completions to the ioend workqueue */ iomap_init_ioend (iter->inode, bio, ctx->read_ctx_file_offset,0 ); -iomap_bio_submit_read_endio (iter, ctx, xfs_end_bio); +iomap_bio_submit_read_endio (iter, ctx, force, xfs_end_bio); }static const struct iomap_read_ops xfs_iomap_read_ops = {include/linux/iomap.h +3
-2@@ -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 @@ -623,7 +623,8 @@ extern struct bio_set iomap_ioend_bioset;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); +struct iomap_read_folio_ctx *ctx,bool force, +bio_end_io_t end_io);extern const struct iomap_read_ops iomap_bio_read_ops;