diff mbox series

[PATCHv4,02/10] blk-mq: set the nr_integrity_segments from bio

Message ID 20240911201240.3982856-3-kbusch@meta.com (mailing list archive)
State Superseded
Headers show
Series block integrity merging and counting | expand

Commit Message

Keith Busch Sept. 11, 2024, 8:12 p.m. UTC
From: Keith Busch <kbusch@kernel.org>

This value is used for merging considerations, so it needs to be
accurate.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
v3->v4:

  Removed the "#if defined" condition.

  Replaced the 'bi_opf & REQ_INTEGRITY' check with bio_integrity(). If
  CONFIG_BLK_DEV_INTEGRITY is not set, the stub function will return
  NULL inline, so the compiler will optimize the setting without
  adding runtime overhead.

 block/blk-mq.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Martin K. Petersen Sept. 13, 2024, 1:47 a.m. UTC | #1
Keith,

> This value is used for merging considerations, so it needs to be
> accurate.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index ef3a2ed499563..82219f0e9a256 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2544,6 +2544,9 @@  static void blk_mq_bio_to_request(struct request *rq, struct bio *bio,
 	rq->__sector = bio->bi_iter.bi_sector;
 	rq->write_hint = bio->bi_write_hint;
 	blk_rq_bio_prep(rq, bio, nr_segs);
+	if (bio_integrity(bio))
+		rq->nr_integrity_segments = blk_rq_count_integrity_sg(rq->q,
+								      bio);
 
 	/* This can't fail, since GFP_NOIO includes __GFP_DIRECT_RECLAIM. */
 	err = blk_crypto_rq_bio_prep(rq, bio, GFP_NOIO);