Message ID | 1492121135-4437-3-git-send-email-logang@deltatee.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Apr 13, 2017 at 04:05:15PM -0600, Logan Gunthorpe wrote: > This is a straight forward conversion in two places. Should kmap fail, > the code will return an INVALD_DATA error in the completion. It really should be using nvmet_copy_from_sgl to make things safer, as we don't want to rely on any particular SG list layout. In fact I'm pretty sure I did the conversion at some point, but it must never have made it upstream.
On 13/04/17 10:59 PM, Christoph Hellwig wrote: > On Thu, Apr 13, 2017 at 04:05:15PM -0600, Logan Gunthorpe wrote: >> This is a straight forward conversion in two places. Should kmap fail, >> the code will return an INVALD_DATA error in the completion. > > It really should be using nvmet_copy_from_sgl to make things safer, > as we don't want to rely on any particular SG list layout. In fact > I'm pretty sure I did the conversion at some point, but it must never > have made it upstream. Ha, I did the conversion too a couple times for my RFC series. I can change this patch to do that. Or maybe I'll just send a patch for that separately seeing it doesn't depend on anything and is pretty simple. I can do that next week. Thanks, Logan
On Thu, Apr 13, 2017 at 11:06:16PM -0600, Logan Gunthorpe wrote: > Or maybe I'll just send a patch for that > separately seeing it doesn't depend on anything and is pretty simple. I > can do that next week. Yes, please just send that patch linux-nvme, we should be able to get it into 4.12.
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;
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@deltatee.com> --- drivers/nvme/target/fabrics-cmd.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)