[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1492121135-4437-3-git-send-email-logang@deltatee.com>
Date: Thu, 13 Apr 2017 16:05:15 -0600
From: Logan Gunthorpe <logang@...tatee.com>
To: Christoph Hellwig <hch@....de>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
Sagi Grimberg <sagi@...mberg.me>, Jens Axboe <axboe@...nel.dk>,
Tejun Heo <tj@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Dan Williams <dan.j.williams@...el.com>,
Ross Zwisler <ross.zwisler@...ux.intel.com>,
Matthew Wilcox <mawilcox@...rosoft.com>,
Sumit Semwal <sumit.semwal@...aro.org>,
Ming Lin <ming.l@....samsung.com>,
linux-kernel@...r.kernel.org, linux-crypto@...r.kernel.org,
linux-media@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linaro-mm-sig@...ts.linaro.org, intel-gfx@...ts.freedesktop.org,
linux-raid@...r.kernel.org, linux-mmc@...r.kernel.org,
linux-nvme@...ts.infradead.org, linux-nvdimm@...ts.01.org,
linux-scsi@...r.kernel.org, fcoe-devel@...n-fcoe.org,
open-iscsi@...glegroups.com, megaraidlinux.pdl@...adcom.com,
sparmaintainer@...sys.com, devel@...verdev.osuosl.org,
target-devel@...r.kernel.org, netdev@...r.kernel.org,
linux-rdma@...r.kernel.org, rds-devel@....oracle.com
Cc: Steve Wise <swise@...ngridcomputing.com>,
Stephen Bates <sbates@...thlin.com>,
Logan Gunthorpe <logang@...tatee.com>
Subject: [PATCH 02/22] nvmet: Make use of the new sg_map helper function
This is a straight forward conversion in two places. Should kmap fail,
the code will return an INVALD_DATA error in the completion.
Signed-off-by: Logan Gunthorpe <logang@...tatee.com>
---
drivers/nvme/target/fabrics-cmd.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/target/fabrics-cmd.c b/drivers/nvme/target/fabrics-cmd.c
index 8bd022af..f62a634 100644
--- a/drivers/nvme/target/fabrics-cmd.c
+++ b/drivers/nvme/target/fabrics-cmd.c
@@ -122,7 +122,11 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
struct nvmet_ctrl *ctrl = NULL;
u16 status = 0;
- d = kmap(sg_page(req->sg)) + req->sg->offset;
+ d = sg_map(req->sg, SG_KMAP);
+ if (IS_ERR(d)) {
+ status = NVME_SC_SGL_INVALID_DATA;
+ goto out;
+ }
/* zero out initial completion result, assign values as needed */
req->rsp->result.u32 = 0;
@@ -158,7 +162,7 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
req->rsp->result.u16 = cpu_to_le16(ctrl->cntlid);
out:
- kunmap(sg_page(req->sg));
+ sg_unmap(req->sg, d, SG_KMAP);
nvmet_req_complete(req, status);
}
@@ -170,7 +174,11 @@ static void nvmet_execute_io_connect(struct nvmet_req *req)
u16 qid = le16_to_cpu(c->qid);
u16 status = 0;
- d = kmap(sg_page(req->sg)) + req->sg->offset;
+ d = sg_map(req->sg, SG_KMAP);
+ if (IS_ERR(d)) {
+ status = NVME_SC_SGL_INVALID_DATA;
+ goto out;
+ }
/* zero out initial completion result, assign values as needed */
req->rsp->result.u32 = 0;
@@ -205,7 +213,7 @@ static void nvmet_execute_io_connect(struct nvmet_req *req)
pr_info("adding queue %d to ctrl %d.\n", qid, ctrl->cntlid);
out:
- kunmap(sg_page(req->sg));
+ sg_unmap(req->sg, d, SG_KMAP);
nvmet_req_complete(req, status);
return;
--
2.1.4
Powered by blists - more mailing lists