Received: by 10.213.65.68 with SMTP id h4csp1688081imn; Thu, 29 Mar 2018 09:09:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx4//bmwxpn+4QR20Svg4Mu6eeflDS27bXz42tqg0yDwRa7Vc0/cA/fHmNbwxCBloWVTRZSZy X-Received: by 2002:a17:902:a24:: with SMTP id 33-v6mr9049121plo.72.1522339777763; Thu, 29 Mar 2018 09:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522339777; cv=none; d=google.com; s=arc-20160816; b=JAMh2ScNytg43S21FeMgjVqudSP0wtFJ9lEmd+4DknwVcZc+65ozHsXjvpodSWBbPG y618+teCqXi/CjqKnOGGxH3RydaHWN9usmM92Apaa7qGTWEeFhl7ycCYF/xxVusEtqix 1LbWigq+2A25qRt44cSun/78o7ZmnnGHTvx6ygc3R3x+tGsClHvePFKamPcX44DB9SJN KteysnZgl25Exo+CuI8YDtX3242yJpGlrxjRRRaYYwlbWTKUqwcfGShBR6uwr6KXizh0 IUpAAbj5rW6M5WjxUJdEHGpCWyB5wHQxyY9gQglBW7DCAr8aduBZ5+Y1cFko2cELMYGW +4Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=huo9n7tZTPvnTOeOwuE1cGrDf0DpSI89F5oPuy3pmLM=; b=KKMw7Og3qJtSis8/IEXcVzAqK2X9SySzVAJlQhjozypdqtXSV40xQ64ihDBodqasQe S1e0vDT6aACqSexYvYLmYk4d5t8DSDRij5/YCk+egdBHwg7gFhjpDyxYj/CsBw/VBNQx fgS3viqUTd7t7/MSj6hdbOSrFwnBwcLHTmnY0kBFjBrAdSvEbSdf5R98I9UI6KXSnHLu 64WSiMBtrV9Cs+ycsDSPVCij7NGTjjCc4sHNLfikDUrlJ4Rn49dQgAZbt1r8Rwnv2z9V aVYRkm/NvH5sDIOOyqbBpTlhokhyRhEn7vXJjCmhbaRaaidLMH9tNImukiiYrbzTdyYo KcJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4-v6si6214060pln.744.2018.03.29.09.09.23; Thu, 29 Mar 2018 09:09:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752596AbeC2QHh (ORCPT + 99 others); Thu, 29 Mar 2018 12:07:37 -0400 Received: from ale.deltatee.com ([207.54.116.67]:46348 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752543AbeC2QHf (ORCPT ); Thu, 29 Mar 2018 12:07:35 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1f1a5K-0005mg-OA; Thu, 29 Mar 2018 10:07:34 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1f1a5J-0001EV-3J; Thu, 29 Mar 2018 10:07:29 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Christoph Hellwig , Sagi Grimberg , James Smart , Logan Gunthorpe Date: Thu, 29 Mar 2018 10:07:19 -0600 Message-Id: <20180329160721.4691-3-logang@deltatee.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180329160721.4691-1-logang@deltatee.com> References: <20180329160721.4691-1-logang@deltatee.com> X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, hch@lst.de, sagi@grimberg.me, james.smart@broadcom.com, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.5 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_FREE,MYRULES_NO_TEXT,T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 Subject: [PATCH 2/4] nvmet-rdma: Use new SGL alloc/free helper for requests X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the new helpers introduced in the previous patch to allocate the SGLs for the request. Seeing we use req.transfer_len as the length of the SGL it is set earlier and cleared on any error. It also seems to be unnecessary to accumulate the length as the map_sgl functions should only ever be called once. Signed-off-by: Logan Gunthorpe Cc: Christoph Hellwig Cc: Sagi Grimberg --- drivers/nvme/target/rdma.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c index 978e169c11bf..0dd78229b92f 100644 --- a/drivers/nvme/target/rdma.c +++ b/drivers/nvme/target/rdma.c @@ -431,7 +431,7 @@ static void nvmet_rdma_release_rsp(struct nvmet_rdma_rsp *rsp) } if (rsp->req.sg != &rsp->cmd->inline_sg) - sgl_free(rsp->req.sg); + nvmet_req_free_sgl(&rsp->req); if (unlikely(!list_empty_careful(&queue->rsp_wr_wait_list))) nvmet_rdma_process_wr_wait_list(queue); @@ -565,24 +565,24 @@ static u16 nvmet_rdma_map_sgl_keyed(struct nvmet_rdma_rsp *rsp, { struct rdma_cm_id *cm_id = rsp->queue->cm_id; u64 addr = le64_to_cpu(sgl->addr); - u32 len = get_unaligned_le24(sgl->length); u32 key = get_unaligned_le32(sgl->key); int ret; + rsp->req.transfer_len = get_unaligned_le24(sgl->length); + /* no data command? */ - if (!len) + if (!rsp->req.transfer_len) return 0; - rsp->req.sg = sgl_alloc(len, GFP_KERNEL, &rsp->req.sg_cnt); - if (!rsp->req.sg) - return NVME_SC_INTERNAL; + ret = nvmet_req_alloc_sgl(&rsp->req, &rsp->queue->nvme_sq); + if (ret < 0) + goto error_out; ret = rdma_rw_ctx_init(&rsp->rw, cm_id->qp, cm_id->port_num, rsp->req.sg, rsp->req.sg_cnt, 0, addr, key, nvmet_data_dir(&rsp->req)); if (ret < 0) - return NVME_SC_INTERNAL; - rsp->req.transfer_len += len; + goto error_out; rsp->n_rdma += ret; if (invalidate) { @@ -591,6 +591,10 @@ static u16 nvmet_rdma_map_sgl_keyed(struct nvmet_rdma_rsp *rsp, } return 0; + +error_out: + rsp->req.transfer_len = 0; + return NVME_SC_INTERNAL; } static u16 nvmet_rdma_map_sgl(struct nvmet_rdma_rsp *rsp) -- 2.11.0