From: mlin@kernel.org (Ming Lin)
Subject: [PATCH v2 1/4] nvme: add helper nvme_map_len()
Date: Tue, 22 Mar 2016 00:24:43 -0700 [thread overview]
Message-ID: <1458631486-14120-2-git-send-email-mlin@kernel.org> (raw)
In-Reply-To: <1458631486-14120-1-git-send-email-mlin@kernel.org>
From: Ming Lin <ming.l@ssi.samsung.com>
The helper returns the number of bytes that need to be mapped
using PRPs/SGL entries.
Signed-off-by: Ming Lin <ming.l at ssi.samsung.com>
---
drivers/nvme/host/nvme.h | 8 ++++++++
drivers/nvme/host/pci.c | 13 +++++--------
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 75982b9..331d437 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -181,6 +181,14 @@ static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector)
return (sector >> (ns->lba_shift - 9));
}
+static inline unsigned nvme_map_len(struct request *rq)
+{
+ if (rq->cmd_flags & REQ_DISCARD)
+ return sizeof(struct nvme_dsm_range);
+ else
+ return blk_rq_bytes(rq);
+}
+
static inline void nvme_setup_flush(struct nvme_ns *ns,
struct nvme_command *cmnd)
{
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 4301584..2db6f89 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -348,16 +348,11 @@ static __le64 **iod_list(struct request *req)
return (__le64 **)(iod->sg + req->nr_phys_segments);
}
-static int nvme_init_iod(struct request *rq, struct nvme_dev *dev)
+static int nvme_init_iod(struct request *rq, unsigned size,
+ struct nvme_dev *dev)
{
struct nvme_iod *iod = blk_mq_rq_to_pdu(rq);
int nseg = rq->nr_phys_segments;
- unsigned size;
-
- if (rq->cmd_flags & REQ_DISCARD)
- size = sizeof(struct nvme_dsm_range);
- else
- size = blk_rq_bytes(rq);
if (nseg > NVME_INT_PAGES || size > NVME_INT_BYTES(dev)) {
iod->sg = kmalloc(nvme_iod_alloc_size(dev, size, nseg), GFP_ATOMIC);
@@ -651,6 +646,7 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
struct nvme_dev *dev = nvmeq->dev;
struct request *req = bd->rq;
struct nvme_command cmnd;
+ unsigned map_len;
int ret = BLK_MQ_RQ_QUEUE_OK;
/*
@@ -666,7 +662,8 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
}
}
- ret = nvme_init_iod(req, dev);
+ map_len = nvme_map_len(req);
+ ret = nvme_init_iod(req, map_len, dev);
if (ret)
return ret;
--
1.9.1
next prev parent reply other threads:[~2016-03-22 7:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-22 7:24 [PATCH v2 0/4] rewrites discard support Ming Lin
2016-03-22 7:24 ` Ming Lin [this message]
2016-03-22 7:31 ` [PATCH v2 1/4] nvme: add helper nvme_map_len() Christoph Hellwig
2016-03-22 7:24 ` [PATCH v2 2/4] block: add offset in blk_add_request_payload() Ming Lin
2016-03-22 7:31 ` Christoph Hellwig
2016-03-22 7:24 ` [PATCH v2 3/4] nvme: rewrite discard support Ming Lin
2016-03-22 7:37 ` Christoph Hellwig
2016-03-22 7:24 ` [PATCH v2 4/4] nvme: add helper nvme_setup_cmd() Ming Lin
2016-03-22 7:38 ` Christoph Hellwig
2016-03-22 20:40 ` [PATCH v2 0/4] rewrites discard support Keith Busch
2016-03-22 20:50 ` Jens Axboe
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=1458631486-14120-2-git-send-email-mlin@kernel.org \
--to=mlin@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