From patchwork Mon Sep 11 15:17:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 9947531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D232F602C9 for ; Mon, 11 Sep 2017 15:16:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C652028B8A for ; Mon, 11 Sep 2017 15:16:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB57728B8C; Mon, 11 Sep 2017 15:16:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D32028B8A for ; Mon, 11 Sep 2017 15:16:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751771AbdIKPQC (ORCPT ); Mon, 11 Sep 2017 11:16:02 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:38175 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751515AbdIKPQA (ORCPT ); Mon, 11 Sep 2017 11:16:00 -0400 Received: by mail-pf0-f196.google.com with SMTP id q76so5014980pfq.5; Mon, 11 Sep 2017 08:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=AbBdfuow3vADgcXS9k9NKAJyGA5v7I6kwUj4Pnnp6NM=; b=BxIfj+mgEMhr2dxbI5853eyXOy4e5LKr1I7RgFVDaK9BTl8jbzXZScPYMehYDdlqyk INzcPazD0/t3Lltzbx6bFImHP4BaL7bBgjXE/2kYAGGcDiT03sF0Zzxp+Hji6xYwn2Pb ysNnZY5k0RZ/f6AK4vRSNX9zBxgvS1IG4zoDxTHS1QTLW7GXAPTpeQQl9wzDSFdlgTLR 1BFNPKsmZwAAwYXvirppGz9YsnBYNU5wiNbXK1TIf0ZV9auavaIStC4yzzgxysjnAMPu 1RqJQPm9eKNuG68/cciHclpmPVXz8VbleUcir3XOltLZniee1Mg0iPa0wNmxsdMgkSrj V8Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=AbBdfuow3vADgcXS9k9NKAJyGA5v7I6kwUj4Pnnp6NM=; b=p+HPo+e1V1j0XE3+dsTZlXk5Mv0c0iwVliUgIJhyaYJHtXVXo6nBrDitrmx6nLd2YW wKdJ4AjJCNP3qiIlbsJcgx9EpzbCAHCy+U6FDxYDpSyGLAfPA8/ZT30p57OaDUK9pGXt 0XSDSt4mIF+fyHbRo6RHh2g55tI9AgmM8ZbKQfCnHrc7RVBLeKiU6nvn0jz9pNsK0Q/1 Mg6RlYfX1jjIKzTOaAhcrX3qkExuavvlf/E8e87UXd8E3M4AP0mLQ7FcPJXhXNhbS6Mo Ie3g4ASbQ451/turzWzhJydfvC0RowDHgZJZuGoOSwrBCt4X16p5Xx2krBYyj3Toa4e/ NUGw== X-Gm-Message-State: AHPjjUgfDpX+800fJ/cSLsH47l6qRX7xrPZo4gxLF0nuSm6QuGM2kAT1 X77RPYN6n4l4IQ== X-Google-Smtp-Source: ADKCNb4uIxQINMnQZDpWoKCPjBP+EybI+2MHJs/7n6LYeFV5rmBJnZ6NUrram9qZun9fnyKpbz0v+Q== X-Received: by 10.101.68.65 with SMTP id e1mr12516803pgq.134.1505142960181; Mon, 11 Sep 2017 08:16:00 -0700 (PDT) Received: from lebasque.1015granger.net ([8.25.222.2]) by smtp.gmail.com with ESMTPSA id y5sm4107451pfd.89.2017.09.11.08.15.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Sep 2017 08:15:59 -0700 (PDT) Subject: [PATCH v1 2/7] xprtrdma: Change return value of rpcrdma_prepare_send_sges() From: Chuck Lever To: jgunthorpe@obsidianresearch.com, sagi@grimberg.me Cc: linux-rdma@vger.kernel.org, linux-nfs@vger.kernel.org Date: Mon, 11 Sep 2017 11:17:54 -0400 Message-ID: <150514306906.1307.8979554419454501550.stgit@lebasque.1015granger.net> In-Reply-To: <150514269466.1307.1991885208569456320.stgit@lebasque.1015granger.net> References: <150514269466.1307.1991885208569456320.stgit@lebasque.1015granger.net> User-Agent: StGit/0.17.1-24-g0acc MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Clean up: Make rpcrdma_prepare_send_sges() return a negative errno instead of a bool. Soon callers will want distinct treatments of different types of failures. Signed-off-by: Chuck Lever --- net/sunrpc/xprtrdma/backchannel.c | 6 +++- net/sunrpc/xprtrdma/rpc_rdma.c | 52 +++++++++++++++++++++++-------------- net/sunrpc/xprtrdma/xprt_rdma.h | 6 +++- 3 files changed, 40 insertions(+), 24 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/sunrpc/xprtrdma/backchannel.c b/net/sunrpc/xprtrdma/backchannel.c index d31d0ac..90a0438 100644 --- a/net/sunrpc/xprtrdma/backchannel.c +++ b/net/sunrpc/xprtrdma/backchannel.c @@ -206,6 +206,7 @@ int rpcrdma_bc_marshal_reply(struct rpc_rqst *rqst) struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(rqst->rq_xprt); struct rpcrdma_req *req = rpcr_to_rdmar(rqst); __be32 *p; + int rc; rpcrdma_set_xdrlen(&req->rl_hdrbuf, 0); xdr_init_encode(&req->rl_stream, &req->rl_hdrbuf, @@ -222,8 +223,9 @@ int rpcrdma_bc_marshal_reply(struct rpc_rqst *rqst) *p++ = xdr_zero; *p = xdr_zero; - if (!rpcrdma_prepare_send_sges(&r_xprt->rx_ia, req, RPCRDMA_HDRLEN_MIN, - &rqst->rq_snd_buf, rpcrdma_noch)) + rc = rpcrdma_prepare_send_sges(r_xprt, req, RPCRDMA_HDRLEN_MIN, + &rqst->rq_snd_buf, rpcrdma_noch); + if (rc) return -EIO; return 0; } diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c index bc464b1..0db7ba0 100644 --- a/net/sunrpc/xprtrdma/rpc_rdma.c +++ b/net/sunrpc/xprtrdma/rpc_rdma.c @@ -522,7 +522,7 @@ rpcrdma_prepare_hdr_sge(struct rpcrdma_ia *ia, struct rpcrdma_req *req, if (unlikely(!rpcrdma_regbuf_is_mapped(rb))) { if (!__rpcrdma_dma_map_regbuf(ia, rb)) - return false; + goto out_regbuf; sge->addr = rdmab_addr(rb); sge->lkey = rdmab_lkey(rb); } @@ -532,6 +532,10 @@ rpcrdma_prepare_hdr_sge(struct rpcrdma_ia *ia, struct rpcrdma_req *req, sge->length, DMA_TO_DEVICE); req->rl_send_wr.num_sge++; return true; + +out_regbuf: + pr_err("rpcrdma: failed to DMA map a Send buffer\n"); + return false; } /* Prepare the Send SGEs. The head and tail iovec, and each entry @@ -552,7 +556,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req, * DMA-mapped. Sync the content that has changed. */ if (!rpcrdma_dma_map_regbuf(ia, rb)) - return false; + goto out_regbuf; sge_no = 1; sge[sge_no].addr = rdmab_addr(rb); sge[sge_no].length = xdr->head[0].iov_len; @@ -639,6 +643,10 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req, req->rl_mapped_sges = sge_no - 1; return true; +out_regbuf: + pr_err("rpcrdma: failed to DMA map a Send buffer\n"); + return false; + out_mapping_overflow: pr_err("rpcrdma: too many Send SGEs (%u)\n", sge_no); return false; @@ -648,25 +656,31 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req, return false; } -bool -rpcrdma_prepare_send_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req, - u32 hdrlen, struct xdr_buf *xdr, - enum rpcrdma_chunktype rtype) +/** + * rpcrdma_prepare_send_sges - Construct SGEs for a Send WR + * @r_xprt: controlling transport + * @req: context of RPC Call being marshalled + * @hdrlen: size of transport header, in bytes + * @xdr: xdr_buf containing RPC Call + * @rtype: chunk type being encoded + * + * Returns 0 on success; otherwise a negative errno is returned. + */ +int +rpcrdma_prepare_send_sges(struct rpcrdma_xprt *r_xprt, + struct rpcrdma_req *req, u32 hdrlen, + struct xdr_buf *xdr, enum rpcrdma_chunktype rtype) { req->rl_send_wr.num_sge = 0; - if (!rpcrdma_prepare_hdr_sge(ia, req, hdrlen)) - goto out_map; + if (!rpcrdma_prepare_hdr_sge(&r_xprt->rx_ia, req, hdrlen)) + return -EIO; if (rtype != rpcrdma_areadch) - if (!rpcrdma_prepare_msg_sges(ia, req, xdr, rtype)) - goto out_map; - - return true; + if (!rpcrdma_prepare_msg_sges(&r_xprt->rx_ia, req, xdr, rtype)) + return -EIO; -out_map: - pr_err("rpcrdma: failed to DMA map a Send buffer\n"); - return false; + return 0; } void @@ -833,12 +847,10 @@ rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst) transfertypes[rtype], transfertypes[wtype], xdr_stream_pos(xdr)); - if (!rpcrdma_prepare_send_sges(&r_xprt->rx_ia, req, - xdr_stream_pos(xdr), - &rqst->rq_snd_buf, rtype)) { - ret = -EIO; + ret = rpcrdma_prepare_send_sges(r_xprt, req, xdr_stream_pos(xdr), + &rqst->rq_snd_buf, rtype); + if (ret) goto out_err; - } return 0; out_err: diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h index 45dab24..93f3a36 100644 --- a/net/sunrpc/xprtrdma/xprt_rdma.h +++ b/net/sunrpc/xprtrdma/xprt_rdma.h @@ -640,8 +640,10 @@ enum rpcrdma_chunktype { rpcrdma_replych }; -bool rpcrdma_prepare_send_sges(struct rpcrdma_ia *, struct rpcrdma_req *, - u32, struct xdr_buf *, enum rpcrdma_chunktype); +int rpcrdma_prepare_send_sges(struct rpcrdma_xprt *r_xprt, + struct rpcrdma_req *req, u32 hdrlen, + struct xdr_buf *xdr, + enum rpcrdma_chunktype rtype); void rpcrdma_unmap_sges(struct rpcrdma_ia *, struct rpcrdma_req *); int rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst); void rpcrdma_set_max_header_sizes(struct rpcrdma_xprt *);