[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1380140564-9030-5-git-send-email-kmo@daterainc.com>
Date: Wed, 25 Sep 2013 13:22:42 -0700
From: Kent Overstreet <kmo@...erainc.com>
To: hch@...radead.org, axboe@...nel.dk, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Kent Overstreet <koverstreet@...gle.com>,
Kent Overstreet <kmo@...erainc.com>
Subject: [PATCH 4/6] convert nvme to blk_max_segment()
From: Kent Overstreet <koverstreet@...gle.com>
Signed-off-by: Kent Overstreet <kmo@...erainc.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists