Skip to contentSkip to conversation

block: save page offset gaps in cloned bio

PATCH Superseded Keith Busch 4 participants 5 messages Aug 17 – Aug 19 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: save page offset gaps in cloned bio

From: Keith Busch <[email protected]>

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. The split remainder meanwhile can reset its gaps to 0 since it advanced beyond it and will start accounting from there.

Fixes 2f6b2565d43c ("block: accumulate memory segment gaps per bio")
---
 block/bio.c | 2 ++
 1 file changed, 2 insertions(+)
block/bio.c +2 -0
index 898b2f5ef8c81..33aa439c1bae2 100644
@@ -859,6 +859,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;
 	bio->bi_io_vec = bio_src->bi_io_vec;
 
@@ -1971,6 +1972,7 @@ struct bio *bio_split(struct bio *bio, int sectors,
 		bio_integrity_trim(split);
 
 	bio_advance(bio, split->bi_iter.bi_size);
+	bio->bi_bvec_gap_bit = 0;
 
 	if (bio_flagged(bio, BIO_TRACE_COMPLETION))
 		bio_set_flag(split, BIO_TRACE_COMPLETION);
Signature · 1 line
2.53.0-Meta
Tested-by on v1 1/1
#1 lore raw

Hi Keith,

Quoted 10 lines · Keith Busch

From: Keith Busch <[email protected]>

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. The split remainder meanwhile can reset its gaps to 0 since it advanced beyond it and will start accounting from there.

Fixes 2f6b2565d43c ("block: accumulate memory segment gaps per bio")

Many Thanks!

Eric

Quoted 24 lines
---
 block/bio.c | 2 ++
 1 file changed, 2 insertions(+)
block/bio.c +2 -0
index 898b2f5ef8c81..33aa439c1bae2 100644
@@ -859,6 +859,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;
 	bio->bi_io_vec = bio_src->bi_io_vec;
 
@@ -1971,6 +1972,7 @@ struct bio *bio_split(struct bio *bio, int sectors,
 		bio_integrity_trim(split);
 
 	bio_advance(bio, split->bi_iter.bi_size);
+	bio->bi_bvec_gap_bit = 0;
 
 	if (bio_flagged(bio, BIO_TRACE_COMPLETION))
 		bio_set_flag(split, BIO_TRACE_COMPLETION);
#2 lore raw
In reply to Keith Busch
Quoted 5 lines · Keith Busch

From: Keith Busch <[email protected]>

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.

Makes sense.

Quoted 2 lines

The split remainder meanwhile can reset its gaps to 0 since it advanced beyond it and will start accounting from there.

I don't really understand this part, though. As in I don't even understand what you mean here..

#3 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · Keith Busch

From: Keith Busch <[email protected]>

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.

Quoted 7 lines

Makes sense.

Quoted 2 lines

The split remainder meanwhile can reset its gaps to 0 since it advanced beyond it and will start accounting from there.

I don't really understand this part, though. As in I don't even understand what you mean here..

The accounting for the vector gaps happens at the same time we consider a bio for splitting. When we do split, the gap value applies only to the front bio because that's as far as been processed. The remaining split bio should reset its gap value to 0, and it will be recalculated when it continues through the split consideration.

#4 lore raw
Quoted 11 lines · Keith Busch
Quoted 5 lines
Quoted 2 lines

The split remainder meanwhile can reset its gaps to 0 since it advanced beyond it and will start accounting from there.

I don't really understand this part, though. As in I don't even understand what you mean here..

The accounting for the vector gaps happens at the same time we consider a bio for splitting. When we do split, the gap value applies only to the front bio because that's as far as been processed. The remaining split bio should reset its gap value to 0, and it will be recalculated when it continues through the split consideration.

Ḣ. but bio_split is used for a lot of different thing. Then again the bi_bvec_gap_bit is only used by the low-level blk-mq code, so it might not matter. But this for sure warrants a big fat comment explaining the rationale for the clearing.