All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@fb.com>, Keith Busch <keith.busch@intel.com>,
	Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org
Subject: [PATCH 15/15] nvme-pci: tidy up nvme_map_data
Date: Thu, 21 Mar 2019 16:10:37 -0700	[thread overview]
Message-ID: <20190321231037.25104-16-hch@lst.de> (raw)
In-Reply-To: <20190321231037.25104-1-hch@lst.de>

Remove two pointless local variables, remove ret assignment that is
never used, move the use_sgl initialization closer to where it is used.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/pci.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 38869f59c296..9ec0704d5f78 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -840,10 +840,7 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req,
 		struct nvme_command *cmnd)
 {
 	struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
-	struct request_queue *q = req->q;
-	enum dma_data_direction dma_dir = rq_data_dir(req) ?
-			DMA_TO_DEVICE : DMA_FROM_DEVICE;
-	blk_status_t ret = BLK_STS_IOERR;
+	blk_status_t ret = BLK_STS_RESOURCE;
 	int nr_mapped;
 
 	if (blk_rq_nr_phys_segments(req) == 1) {
@@ -865,25 +862,21 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req,
 	iod->sg = mempool_alloc(dev->iod_mempool, GFP_ATOMIC);
 	if (!iod->sg)
 		return BLK_STS_RESOURCE;
-
-	iod->use_sgl = nvme_pci_use_sgls(dev, req);
-
 	sg_init_table(iod->sg, blk_rq_nr_phys_segments(req));
-	iod->nents = blk_rq_map_sg(q, req, iod->sg);
+	iod->nents = blk_rq_map_sg(req->q, req, iod->sg);
 	if (!iod->nents)
 		goto out;
 
-	ret = BLK_STS_RESOURCE;
-
 	if (is_pci_p2pdma_page(sg_page(iod->sg)))
 		nr_mapped = pci_p2pdma_map_sg(dev->dev, iod->sg, iod->nents,
-					  dma_dir);
+					      rq_dma_dir(req));
 	else
 		nr_mapped = dma_map_sg_attrs(dev->dev, iod->sg, iod->nents,
-					     dma_dir,  DMA_ATTR_NO_WARN);
+					     rq_dma_dir(req), DMA_ATTR_NO_WARN);
 	if (!nr_mapped)
 		goto out;
 
+	iod->use_sgl = nvme_pci_use_sgls(dev, req);
 	if (iod->use_sgl)
 		ret = nvme_pci_setup_sgls(dev, req, &cmnd->rw, nr_mapped);
 	else
-- 
2.20.1


WARNING: multiple messages have this Message-ID (diff)
From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH 15/15] nvme-pci: tidy up nvme_map_data
Date: Thu, 21 Mar 2019 16:10:37 -0700	[thread overview]
Message-ID: <20190321231037.25104-16-hch@lst.de> (raw)
In-Reply-To: <20190321231037.25104-1-hch@lst.de>

Remove two pointless local variables, remove ret assignment that is
never used, move the use_sgl initialization closer to where it is used.

Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/pci.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 38869f59c296..9ec0704d5f78 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -840,10 +840,7 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req,
 		struct nvme_command *cmnd)
 {
 	struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
-	struct request_queue *q = req->q;
-	enum dma_data_direction dma_dir = rq_data_dir(req) ?
-			DMA_TO_DEVICE : DMA_FROM_DEVICE;
-	blk_status_t ret = BLK_STS_IOERR;
+	blk_status_t ret = BLK_STS_RESOURCE;
 	int nr_mapped;
 
 	if (blk_rq_nr_phys_segments(req) == 1) {
@@ -865,25 +862,21 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req,
 	iod->sg = mempool_alloc(dev->iod_mempool, GFP_ATOMIC);
 	if (!iod->sg)
 		return BLK_STS_RESOURCE;
-
-	iod->use_sgl = nvme_pci_use_sgls(dev, req);
-
 	sg_init_table(iod->sg, blk_rq_nr_phys_segments(req));
-	iod->nents = blk_rq_map_sg(q, req, iod->sg);
+	iod->nents = blk_rq_map_sg(req->q, req, iod->sg);
 	if (!iod->nents)
 		goto out;
 
-	ret = BLK_STS_RESOURCE;
-
 	if (is_pci_p2pdma_page(sg_page(iod->sg)))
 		nr_mapped = pci_p2pdma_map_sg(dev->dev, iod->sg, iod->nents,
-					  dma_dir);
+					      rq_dma_dir(req));
 	else
 		nr_mapped = dma_map_sg_attrs(dev->dev, iod->sg, iod->nents,
-					     dma_dir,  DMA_ATTR_NO_WARN);
+					     rq_dma_dir(req), DMA_ATTR_NO_WARN);
 	if (!nr_mapped)
 		goto out;
 
+	iod->use_sgl = nvme_pci_use_sgls(dev, req);
 	if (iod->use_sgl)
 		ret = nvme_pci_setup_sgls(dev, req, &cmnd->rw, nr_mapped);
 	else
-- 
2.20.1

  parent reply	other threads:[~2019-03-21 23:12 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 23:10 [RFC] optimize nvme single segment I/O Christoph Hellwig
2019-03-21 23:10 ` Christoph Hellwig
2019-03-21 23:10 ` [PATCH 01/15] block: add a req_bvec helper Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-25  5:07   ` Chaitanya Kulkarni
2019-03-25  5:07     ` Chaitanya Kulkarni
2019-03-27 14:16     ` Christoph Hellwig
2019-03-27 14:16       ` Christoph Hellwig
2019-03-21 23:10 ` [PATCH 02/15] block: add a rq_integrity_vec helper Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-25  5:10   ` Chaitanya Kulkarni
2019-03-25  5:10     ` Chaitanya Kulkarni
2019-03-27 14:19     ` Christoph Hellwig
2019-03-27 14:19       ` Christoph Hellwig
2019-03-21 23:10 ` [PATCH 03/15] block: add a rq_dma_dir helper Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-22 13:06   ` Johannes Thumshirn
2019-03-22 13:06     ` Johannes Thumshirn
2019-03-27 14:20     ` Christoph Hellwig
2019-03-27 14:20       ` Christoph Hellwig
2019-03-28 10:26       ` Johannes Thumshirn
2019-03-28 10:26         ` Johannes Thumshirn
2019-03-25  5:11   ` Chaitanya Kulkarni
2019-03-25  5:11     ` Chaitanya Kulkarni
2019-03-21 23:10 ` [PATCH 04/15] block: add dma_map_bvec helper Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-25  5:13   ` Chaitanya Kulkarni
2019-03-25  5:13     ` Chaitanya Kulkarni
2019-03-21 23:10 ` [PATCH 05/15] nvme-pci: remove the unused iod->length field Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-25  5:14   ` Chaitanya Kulkarni
2019-03-25  5:14     ` Chaitanya Kulkarni
2019-03-21 23:10 ` [PATCH 06/15] nvme-pci: remove nvme_init_iod Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-25  5:19   ` Chaitanya Kulkarni
2019-03-25  5:19     ` Chaitanya Kulkarni
2019-03-27 14:21     ` Christoph Hellwig
2019-03-27 14:21       ` Christoph Hellwig
2019-03-21 23:10 ` [PATCH 07/15] nvme-pci: move the call to nvme_cleanup_cmd out of nvme_unmap_data Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-25  5:21   ` Chaitanya Kulkarni
2019-03-25  5:21     ` Chaitanya Kulkarni
2019-03-21 23:10 ` [PATCH 08/15] nvme-pci: merge nvme_free_iod into nvme_unmap_data Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-25  5:22   ` Chaitanya Kulkarni
2019-03-25  5:22     ` Chaitanya Kulkarni
2019-03-21 23:10 ` [PATCH 09/15] nvme-pci: only call nvme_unmap_data for requests transferring data Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-25  5:23   ` Chaitanya Kulkarni
2019-03-25  5:23     ` Chaitanya Kulkarni
2019-03-21 23:10 ` [PATCH 10/15] nvme-pci: do not build a scatterlist to map metadata Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-25  5:27   ` Chaitanya Kulkarni
2019-03-25  5:27     ` Chaitanya Kulkarni
2019-08-28  9:20   ` Ming Lei
2019-09-12  1:02     ` Ming Lei
2019-09-12  1:02       ` Ming Lei
2019-09-12  8:20       ` Christoph Hellwig
2019-09-12  8:20         ` Christoph Hellwig
2019-03-21 23:10 ` [PATCH 11/15] nvme-pci: split metadata handling from nvme_map_data / nvme_unmap_data Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-25  5:29   ` Chaitanya Kulkarni
2019-03-25  5:29     ` Chaitanya Kulkarni
2019-03-21 23:10 ` [PATCH 12/15] nvme-pci: remove the inline scatterlist optimization Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-25  5:30   ` Chaitanya Kulkarni
2019-03-25  5:30     ` Chaitanya Kulkarni
2019-03-21 23:10 ` [PATCH 13/15] nvme-pci: optimize mapping of small single segment requests Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-25  5:36   ` Chaitanya Kulkarni
2019-03-25  5:36     ` Chaitanya Kulkarni
2019-03-21 23:10 ` [PATCH 14/15] nvme-pci: optimize mapping single segment requests using SGLs Christoph Hellwig
2019-03-21 23:10   ` Christoph Hellwig
2019-03-25  5:39   ` Chaitanya Kulkarni
2019-03-25  5:39     ` Chaitanya Kulkarni
2019-04-30 14:17   ` Klaus Birkelund
2019-04-30 14:17     ` Klaus Birkelund
2019-04-30 14:32     ` Christoph Hellwig
2019-04-30 14:32       ` Christoph Hellwig
2019-03-21 23:10 ` Christoph Hellwig [this message]
2019-03-21 23:10   ` [PATCH 15/15] nvme-pci: tidy up nvme_map_data Christoph Hellwig
2019-03-25  5:40   ` Chaitanya Kulkarni
2019-03-25  5:40     ` Chaitanya Kulkarni
2019-03-22 15:44 ` [RFC] optimize nvme single segment I/O Jens Axboe
2019-03-22 15:44   ` Jens Axboe
2019-03-27 14:24   ` Christoph Hellwig
2019-03-27 14:24     ` Christoph Hellwig
2019-03-22 17:37 ` Keith Busch
2019-03-22 17:37   ` Keith Busch
2019-03-22 18:55 ` Sagi Grimberg
2019-03-22 18:55   ` Sagi Grimberg

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=20190321231037.25104-16-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@fb.com \
    --cc=keith.busch@intel.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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.