All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jinyoung CHOI <j-young.choi@samsung.com>
To: Jinyoung CHOI <j-young.choi@samsung.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>, "hch@lst.de" <hch@lst.de>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH 14/15] block: blk-integrity: change sg-table configuration method for integrity
Date: Wed, 03 May 2023 19:27:19 +0900	[thread overview]
Message-ID: <20230503102719epcms2p457434fefd535ee43d502eff854227919@epcms2p4> (raw)
In-Reply-To: <20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4>

Previously, a bio_vec of bip was made of one page in the block layer, and
sg_list was generated using hw information in lld.

This is done in the block layer and the bio_vec has been changed to
multi-page, so it is changed to configure the sg-table using the existing
api, such as the sg-table setting for the bio. (e.g. multi-page map)

Cc: Christoph Hellwig <hch@lst.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>

Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
---
 block/blk-integrity.c | 52 -------------------------------------------
 block/blk-merge.c     | 52 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 64407b412947..c50954652177 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -55,58 +55,6 @@ int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio)
 }
 EXPORT_SYMBOL(blk_rq_count_integrity_sg);
 
-/**
- * blk_rq_map_integrity_sg - Map integrity metadata into a scatterlist
- * @q:		request queue
- * @bio:	bio with integrity metadata attached
- * @sglist:	target scatterlist
- *
- * Description: Map the integrity vectors in request into a
- * scatterlist.  The scatterlist must be big enough to hold all
- * elements.  I.e. sized using blk_rq_count_integrity_sg().
- */
-int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio,
-			    struct scatterlist *sglist)
-{
-	struct bio_vec iv, ivprv = { NULL };
-	struct scatterlist *sg = NULL;
-	unsigned int segments = 0;
-	struct bvec_iter iter;
-	int prev = 0;
-
-	bio_for_each_integrity_vec(iv, bio, iter) {
-
-		if (prev) {
-			if (!biovec_phys_mergeable(q, &ivprv, &iv))
-				goto new_segment;
-			if (sg->length + iv.bv_len > queue_max_segment_size(q))
-				goto new_segment;
-
-			sg->length += iv.bv_len;
-		} else {
-new_segment:
-			if (!sg)
-				sg = sglist;
-			else {
-				sg_unmark_end(sg);
-				sg = sg_next(sg);
-			}
-
-			sg_set_page(sg, iv.bv_page, iv.bv_len, iv.bv_offset);
-			segments++;
-		}
-
-		prev = 1;
-		ivprv = iv;
-	}
-
-	if (sg)
-		sg_mark_end(sg);
-
-	return segments;
-}
-EXPORT_SYMBOL(blk_rq_map_integrity_sg);
-
 /**
  * blk_integrity_compare - Compare integrity profile of two disks
  * @gd1:	Disk to compare
diff --git a/block/blk-merge.c b/block/blk-merge.c
index c6a0958e8df1..71539d88ffe6 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -524,6 +524,58 @@ __blk_segment_map_sg_merge(struct request_queue *q, struct bio_vec *bvec,
 	return true;
 }
 
+/**
+ * blk_rq_map_integrity_sg - Map integrity metadata into a scatterlist
+ * @q:		request queue
+ * @bio:	bio with integrity metadata attached
+ * @sglist:	target scatterlist
+ *
+ * Description: Map the integrity vectors in request into a scatterlist.
+ * The scatterlist must be big enough to hold all elements.
+ */
+int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio,
+			    struct scatterlist *sglist)
+{
+	struct bio_vec iv, ivprv = { NULL };
+	struct scatterlist *sg = NULL;
+	unsigned int nsegs = 0;
+	struct bvec_iter iter;
+	bool new_bio = false;
+
+	for_each_bio(bio) {
+		struct bio_integrity_payload *bip = bio->bi_integrity;
+
+		bip_for_each_mp_bvec(iv, bip, iter) {
+			/*
+			 * Only try to merge bvecs from two bios given we
+			 * have done bio internal merge when adding pages
+			 * to bio
+			 */
+			if (new_bio &&
+			    __blk_segment_map_sg_merge(q, &iv, &ivprv, &sg))
+				goto next_iv;
+
+			if (iv.bv_offset + iv.bv_len <= PAGE_SIZE)
+				nsegs += __blk_bvec_map_sg(iv, sglist, &sg);
+			else
+				nsegs += blk_bvec_map_sg(q, &iv, sglist, &sg);
+ next_iv:
+			new_bio = false;
+		}
+
+		if (likely(bip->bip_iter.bi_size)) {
+			ivprv = iv;
+			new_bio = true;
+		}
+	}
+
+	if (sg)
+		sg_mark_end(sg);
+
+	return nsegs;
+}
+EXPORT_SYMBOL(blk_rq_map_integrity_sg);
+
 static int __blk_bios_map_sg(struct request_queue *q, struct bio *bio,
 			     struct scatterlist *sglist,
 			     struct scatterlist **sg)
-- 
2.34.1

  parent reply	other threads:[~2023-05-03 10:27 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p4>
2023-05-03  9:49 ` [PATCH 00/15] Change the integrity configuration method in block Jinyoung CHOI
     [not found]   ` <CGME20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p3>
2023-05-03 10:02     ` [PATCH 02/15] block: blk-integiry: add helper functions for bio_integrity_add_page Jinyoung CHOI
2023-05-03 15:55       ` hch
     [not found]       ` <CGME20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p7>
2023-05-04  6:46         ` Jinyoung CHOI
2023-05-03 10:09     ` [PATCH 04/15] block: bio-integiry: cleanup bio_integrity_prep Jinyoung CHOI
2023-05-03 15:55       ` hch
2023-05-03 10:18     ` [PATCH 09/15] scsi: add scsi_alloc_integrity_sgtables() for integrity process Jinyoung CHOI
2023-05-03 10:25     ` [PATCH 13/15] block: add helper function for iteration of bip's bvec Jinyoung CHOI
     [not found]   ` <CGME20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p2>
2023-05-03 10:00     ` [PATCH 01/15] block: bio: rename page_is_mergeable to bio_page_is_mergeable and make non-static Jinyoung CHOI
2023-05-03 15:52       ` hch
2023-05-03 10:12     ` [PATCH 06/15] block: blk-merge: fix to add the number of integrity segments to the request twice Jinyoung CHOI
2023-05-04  6:24     ` RE:(2) [PATCH 01/15] block: bio: rename page_is_mergeable to bio_page_is_mergeable and make non-static Jinyoung CHOI
     [not found]   ` <CGME20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p6>
2023-05-03 10:10     ` [PATCH 05/15] block: fix not to apply bip information in blk_rq_bio_prep() Jinyoung CHOI
2023-05-03 12:56       ` kernel test robot
2023-05-03 15:57       ` hch
2023-05-03 17:23       ` kernel test robot
2023-05-03 19:06       ` kernel test robot
     [not found]       ` <CGME20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p1>
2023-05-04  6:10         ` Jinyoung CHOI
2023-05-03 10:13     ` [PATCH 07/15] block: blk-merge: fix merging two requests in ll_merge_requests_fn Jinyoung CHOI
     [not found]   ` <CGME20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p5>
2023-05-03 10:06     ` [PATCH 03/15] block: bio-integrity: modify bio_integrity_add_page() Jinyoung CHOI
2023-05-03 10:16     ` [PATCH 08/15] block: add helper function to get the number of integrity segments Jinyoung CHOI
2023-05-03 10:20     ` [PATCH 10/15] scsi: change to use blk_rq_nr_integrity_segments() instead of blk_rq_count_integrity_sg() Jinyoung CHOI
2023-05-03 10:21     ` [PATCH 11/15] block: blk-integrity: change how to find the number of integrity of bio Jinyoung CHOI
2023-05-03 10:23     ` [PATCH 12/15] nvme: rdma: change how to find the number of integrity of request Jinyoung CHOI
     [not found]   ` <CGME20230503094912epcms2p4bef206eab1c41a92eba2583a69c74323@epcms2p8>
2023-05-03 10:28     ` [PATCH 15/15] block: blk-integrity: remove blk_rq_count_integrity_sg() Jinyoung CHOI
2023-05-03 10:27 ` Jinyoung CHOI [this message]
2023-05-03 14:29   ` [PATCH 14/15] block: blk-integrity: change sg-table configuration method for integrity kernel test robot
2023-05-03 20:07   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230503102719epcms2p457434fefd535ee43d502eff854227919@epcms2p4 \
    --to=j-young.choi@samsung.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.