linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kent Overstreet <kmo@daterainc.com>
To: hch@infradead.org, axboe@kernel.dk,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Kent Overstreet <koverstreet@google.com>,
	Kent Overstreet <kmo@daterainc.com>
Subject: [PATCH 4/6] convert nvme to blk_max_segment()
Date: Wed, 25 Sep 2013 13:22:42 -0700	[thread overview]
Message-ID: <1380140564-9030-5-git-send-email-kmo@daterainc.com> (raw)
In-Reply-To: <1380140564-9030-1-git-send-email-kmo@daterainc.com>

From: Kent Overstreet <koverstreet@google.com>

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
---
 drivers/block/nvme-core.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index ddcb405..e4a9502 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -465,6 +465,7 @@ static int nvme_split_and_submit(struct bio *bio, struct nvme_queue *nvmeq,
 static int nvme_map_bio(struct nvme_queue *nvmeq, struct nvme_iod *iod,
 		struct bio *bio, enum dma_data_direction dma_dir, int psegs)
 {
+	struct request_queue *q = bdev_get_queue(bio->bi_bdev);
 	struct bio_vec bvec, bvprv;
 	struct bvec_iter iter;
 	struct scatterlist *sg = NULL;
@@ -477,26 +478,26 @@ static int nvme_map_bio(struct nvme_queue *nvmeq, struct nvme_iod *iod,
 			 (nvmeq->dev->stripe_size - 1));
 
 	sg_init_table(iod->sg, psegs);
-	bio_for_each_segment(bvec, bio, iter) {
-		if (!first && BIOVEC_PHYS_MERGEABLE(&bvprv, &bvec)) {
-			sg->length += bvec.bv_len;
-		} else {
-			if (!first && BIOVEC_NOT_VIRT_MERGEABLE(&bvprv, &bvec))
-				return nvme_split_and_submit(bio, nvmeq,
-							     length);
-
-			sg = sg ? sg + 1 : iod->sg;
-			sg_set_page(sg, bvec.bv_page,
-				    bvec.bv_len, bvec.bv_offset);
-			nsegs++;
-		}
 
-		if (split_len - length < bvec.bv_len)
-			return nvme_split_and_submit(bio, nvmeq, split_len);
+	iter = bio->bi_iter;
+	while (iter.bi_size) {
+		bvec = bio_iovec_iter(bio, iter);
+		bvec.bv_len = blk_max_segment(q, &bvec);
+
+		if (!first && BIOVEC_NOT_VIRT_MERGEABLE(&bvprv, &bvec))
+			return nvme_split_and_submit(bio, nvmeq, length);
+
+		sg = sg ? sg + 1 : iod->sg;
+		sg_set_page(sg, bvec.bv_page, bvec.bv_len, bvec.bv_offset);
+		nsegs++;
+
 		length += bvec.bv_len;
 		bvprv = bvec;
 		first = 0;
+
+		bio_advance_iter(bio, &iter, bvec.bv_len);
 	}
+
 	iod->nents = nsegs;
 	sg_mark_end(sg);
 	if (dma_map_sg(nvmeq->q_dmadev, iod->sg, iod->nents, dma_dir) == 0)
-- 
1.8.4.rc3

  parent reply	other threads:[~2013-09-25 20:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-25 20:22 [PATCH WIP] Multipage biovecs Kent Overstreet
2013-09-25 20:22 ` [PATCH 1/6] block: Introduce bio_for_each_page() Kent Overstreet
2013-09-25 21:17   ` Zach Brown
2013-09-25 21:49     ` Kent Overstreet
2013-09-25 22:47       ` Zach Brown
2013-09-25 20:22 ` [PATCH 2/6] block: Convert various code to bio_for_each_page() Kent Overstreet
2013-09-25 20:22 ` [PATCH 3/6] Introduce blk_max_segment() Kent Overstreet
2013-09-25 20:22 ` Kent Overstreet [this message]
2013-09-25 20:22 ` [PATCH 5/6] convert integrity to new merging Kent Overstreet
2013-09-25 20:22 ` [PATCH 6/6] Multipage bvecs Kent Overstreet

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=1380140564-9030-5-git-send-email-kmo@daterainc.com \
    --to=kmo@daterainc.com \
    --cc=axboe@kernel.dk \
    --cc=hch@infradead.org \
    --cc=koverstreet@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).