diff mbox series

block: make sure ->nr_integrity_segments is cloned in blk_rq_prep_clone

Message ID 20250310091610.2010623-1-ming.lei@redhat.com (mailing list archive)
State New
Headers show
Series block: make sure ->nr_integrity_segments is cloned in blk_rq_prep_clone | expand

Commit Message

Ming Lei March 10, 2025, 9:16 a.m. UTC
Make sure ->nr_integrity_segments is cloned in blk_rq_prep_clone(),
otherwise zero ->nr_integrity_segments will be observed in
sg_alloc_table_chained(), in which BUG() is hit.

Cc: stable@vger.kernel.org
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-mq.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Christoph Hellwig March 10, 2025, 10:42 a.m. UTC | #1
On Mon, Mar 10, 2025 at 05:16:10PM +0800, Ming Lei wrote:
> Make sure ->nr_integrity_segments is cloned in blk_rq_prep_clone(),
> otherwise zero ->nr_integrity_segments will be observed in
> sg_alloc_table_chained(), in which BUG() is hit.

Maybe reword this to:

... otherwise requests cloned by device-mapper multipath will not
have the prope nr_integrity_segments values set?

The fact that sg_alloc_table_chained BUGā½)s is just a symptom of that.

> Cc: stable@vger.kernel.org

... and replace this with a proper Fixes tag?
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 40490ac88045..005c520d3498 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3314,6 +3314,7 @@  int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
 		rq->special_vec = rq_src->special_vec;
 	}
 	rq->nr_phys_segments = rq_src->nr_phys_segments;
+	rq->nr_integrity_segments = rq_src->nr_integrity_segments;
 
 	if (rq->bio && blk_crypto_rq_bio_prep(rq, rq->bio, gfp_mask) < 0)
 		goto free_and_out;