On Mon, Jul 08, 2019 at 09:19:19AM -0700, Darrick J. Wong wrote: > So I think the solution is that we have to call submit_bio_wait on that > very first bio (bio0) since the bios created in the inner loop will be > chained to it... ? Thoughts/flames/"go finish your morning coffee"? I think we could also just turn the direction of the chaining around, then the newly allocated bio is the "parent" to the previous one and we can simply wait for the last one. Something like the patch below, running it through xfstests now, and then after that I'll add a way to inject chaining even into relatively small I/Os to actually test this code path: diff --git a/fs/xfs/xfs_bio_io.c b/fs/xfs/xfs_bio_io.c index 757c1d9293eb..e2148f2d5d6b 100644 --- a/fs/xfs/xfs_bio_io.c +++ b/fs/xfs/xfs_bio_io.c @@ -43,7 +43,7 @@ xfs_rw_bdev( bio_copy_dev(bio, prev); bio->bi_iter.bi_sector = bio_end_sector(prev); bio->bi_opf = prev->bi_opf; - bio_chain(bio, prev); + bio_chain(prev, bio); submit_bio(prev); }