Linux block layer
 help / color / mirror / Atom feed
* [PATCHv2] block: save page offset gaps in cloned bio
@ 2026-08-19 15:49 Keith Busch
  2026-08-19 16:20 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Keith Busch @ 2026-08-19 15:49 UTC (permalink / raw)
  To: linux-block; +Cc: axboe, hch, Keith Busch, Eric Auger, Eric Auger

From: Keith Busch <kbusch@kernel.org>

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>
---
v1->v2:
  Added code comment explaining the reinitialization, and a more clear
  change log.

 block/bio.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/block/bio.c b/block/bio.c
index 898b2f5ef8c81..f95b63c0604af 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -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;
 
@@ -1972,6 +1973,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);
 
-- 
2.53.0-Meta


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCHv2] block: save page offset gaps in cloned bio
  2026-08-19 15:49 [PATCHv2] block: save page offset gaps in cloned bio Keith Busch
@ 2026-08-19 16:20 ` Christoph Hellwig
  2026-08-31 12:26 ` Eric Auger
  2026-09-01 14:44 ` Jens Axboe
  2 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2026-08-19 16:20 UTC (permalink / raw)
  To: Keith Busch; +Cc: linux-block, axboe, hch, Keith Busch, Eric Auger

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv2] block: save page offset gaps in cloned bio
  2026-08-19 15:49 [PATCHv2] block: save page offset gaps in cloned bio Keith Busch
  2026-08-19 16:20 ` Christoph Hellwig
@ 2026-08-31 12:26 ` Eric Auger
  2026-08-31 15:17   ` Keith Busch
  2026-09-01 14:44 ` Jens Axboe
  2 siblings, 1 reply; 7+ messages in thread
From: Eric Auger @ 2026-08-31 12:26 UTC (permalink / raw)
  To: Keith Busch, linux-block; +Cc: axboe, hch, Keith Busch, Eric Auger

Hi,

On 8/19/26 5:49 PM, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
> 
> 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>

gentle ping on that fix. Could someone pull it?

Without it we see NVME I/O errors

Thank you in advance

Eric
> ---
> v1->v2:
>   Added code comment explaining the reinitialization, and a more clear
>   change log.
> 
>  block/bio.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/block/bio.c b/block/bio.c
> index 898b2f5ef8c81..f95b63c0604af 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -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;
>  
> @@ -1972,6 +1973,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);
>  


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv2] block: save page offset gaps in cloned bio
  2026-08-31 12:26 ` Eric Auger
@ 2026-08-31 15:17   ` Keith Busch
  2026-09-01 14:43     ` Jens Axboe
  0 siblings, 1 reply; 7+ messages in thread
From: Keith Busch @ 2026-08-31 15:17 UTC (permalink / raw)
  To: Eric Auger; +Cc: Keith Busch, linux-block, axboe, hch, Eric Auger

On Mon, Aug 31, 2026 at 02:26:06PM +0200, Eric Auger wrote:
> gentle ping on that fix. Could someone pull it?

Yes, and these two pending patches as well:

https://lore.kernel.org/linux-block/20260810164218.3721636-1-kbusch@meta.com/
https://lore.kernel.org/linux-block/d919f5285d16afbec6c51ecdf201692a484566e5.1786637565.git.bvanassche@acm.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv2] block: save page offset gaps in cloned bio
  2026-08-31 15:17   ` Keith Busch
@ 2026-09-01 14:43     ` Jens Axboe
  0 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2026-09-01 14:43 UTC (permalink / raw)
  To: Keith Busch, Eric Auger
  Cc: Keith Busch, linux-block, hch, Eric Auger, Bart Van Assche

On 8/31/26 9:17 AM, Keith Busch wrote:
> On Mon, Aug 31, 2026 at 02:26:06PM +0200, Eric Auger wrote:
>> gentle ping on that fix. Could someone pull it?
> 
> Yes, and these two pending patches as well:
> 
> https://lore.kernel.org/linux-block/20260810164218.3721636-1-kbusch@meta.com/

Done, those two.

> https://lore.kernel.org/linux-block/d919f5285d16afbec6c51ecdf201692a484566e5.1786637565.git.bvanassche@acm.org/

No longer applies.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv2] block: save page offset gaps in cloned bio
  2026-08-19 15:49 [PATCHv2] block: save page offset gaps in cloned bio Keith Busch
  2026-08-19 16:20 ` Christoph Hellwig
  2026-08-31 12:26 ` Eric Auger
@ 2026-09-01 14:44 ` Jens Axboe
  2026-09-01 14:53   ` Eric Auger
  2 siblings, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2026-09-01 14:44 UTC (permalink / raw)
  To: linux-block, Keith Busch; +Cc: hch, Keith Busch, Eric Auger, Eric Auger


On Wed, 19 Aug 2026 08:49:37 -0700, Keith Busch wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] block: save page offset gaps in cloned bio
      commit: 96c8ea3c5add7920b3c43840d1ea76b3354c8d2d

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHv2] block: save page offset gaps in cloned bio
  2026-09-01 14:44 ` Jens Axboe
@ 2026-09-01 14:53   ` Eric Auger
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Auger @ 2026-09-01 14:53 UTC (permalink / raw)
  To: Jens Axboe, linux-block, Keith Busch; +Cc: hch, Keith Busch, Eric Auger

Hi,

On 9/1/26 4:44 PM, Jens Axboe wrote:
> 
> On Wed, 19 Aug 2026 08:49:37 -0700, Keith Busch wrote:
>> 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.
>>
>> [...]
> 
> Applied, thanks!
> 
> [1/1] block: save page offset gaps in cloned bio
>       commit: 96c8ea3c5add7920b3c43840d1ea76b3354c8d2d

Thanks!

Eric
> 
> Best regards,


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-09-01 14:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-19 15:49 [PATCHv2] block: save page offset gaps in cloned bio Keith Busch
2026-08-19 16:20 ` Christoph Hellwig
2026-08-31 12:26 ` Eric Auger
2026-08-31 15:17   ` Keith Busch
2026-09-01 14:43     ` Jens Axboe
2026-09-01 14:44 ` Jens Axboe
2026-09-01 14:53   ` Eric Auger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox