]> git.hungrycats.org Git - linux/commitdiff
block: save page offset gaps in cloned bio
authorKeith Busch <kbusch@kernel.org>
Wed, 19 Aug 2026 15:49:37 +0000 (08:49 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Sep 2026 11:36:18 +0000 (13:36 +0200)
[ Upstream commit 96c8ea3c5add7920b3c43840d1ea76b3354c8d2d ]

The cloned bio needs to inherit the accumulated gaps between vectors so
that we can know if this bio can subscribe to the iova coalescing
optimization.

When cloning for a split, the gap only applies to the front bio since
that's as far as has been processed. The remaining bio can reset its
gaps to 0 since it advanced past the checked vectors, and will start its
accounting from there on the next split check.

Fixes: 2f6b2565d43c ("block: accumulate memory segment gaps per bio")
Reported-by: Eric Auger <eauger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20260819154937.3903312-1-kbusch@meta.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/bio.c

index 5d1861dbe4c8bd5b2129b14a75dae595ccfd8030..63994b8cd8e1f6e51f27edd82978107e9f36e72f 100644 (file)
@@ -834,6 +834,7 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)
        bio->bi_ioprio = bio_src->bi_ioprio;
        bio->bi_write_hint = bio_src->bi_write_hint;
        bio->bi_write_stream = bio_src->bi_write_stream;
+       bio->bi_bvec_gap_bit = bio_src->bi_bvec_gap_bit;
        bio->bi_iter = bio_src->bi_iter;
 
        if (bio->bi_bdev) {
@@ -1717,6 +1718,14 @@ struct bio *bio_split(struct bio *bio, int sectors,
 
        bio_advance(bio, split->bi_iter.bi_size);
 
+       /*
+        * The gap bit is set when splitting to limits and only applies to the
+        * front bio that was split off. The remaining bio will calcualte its
+        * gap value when it is subsequently split to limits, so it is safe to
+        * re-initialize the value back to 0.
+        */
+       bio->bi_bvec_gap_bit = 0;
+
        if (bio_flagged(bio, BIO_TRACE_COMPLETION))
                bio_set_flag(split, BIO_TRACE_COMPLETION);