From patchwork Thu Mar 16 15:52:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 9628759 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 390A26048C for ; Thu, 16 Mar 2017 15:53:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AAE02029B for ; Thu, 16 Mar 2017 15:53:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FC3F28654; Thu, 16 Mar 2017 15:53:04 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham 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 BF61E2029B for ; Thu, 16 Mar 2017 15:53:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754793AbdCPPxC (ORCPT ); Thu, 16 Mar 2017 11:53:02 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:34281 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752840AbdCPPxB (ORCPT ); Thu, 16 Mar 2017 11:53:01 -0400 Received: by mail-it0-f67.google.com with SMTP id r141so7641812ita.1; Thu, 16 Mar 2017 08:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=ctTx9t/zdbfkb4Vt7kdV4h754mZHjjGDIJaQLhXrefo=; b=IZs1T/9dSXrfhewRHGIWdrFXXheDnvPFu2TBMt/TtOryIr7JDHwZtexcDSoMfa+CGK ZVTZg0ndK+YNrclEs5Mjy439bHBOeNjdZoTaBxHKNoGMiPSXS+0fq7eFvtsfBe5s+OVr Enifk4aBVuUagMWHYBJvyF2zOcMY9aUGpqDMvYD+7zzhUB8QF9u30jC6fOjLzqjNTvGm wQnRjsJdCUaQK5j70z6Kl9ErUd1z17pfxktdGcC1KmClObTyyNQj7jAP294G6f9EfIaz sNc+DuSsH3/zrzd7AGah6mWCDV9EAC4ypdmAibJXz+n5AP+1KwuAgogjunRZgvM3hBn8 1F5w== 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:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=ctTx9t/zdbfkb4Vt7kdV4h754mZHjjGDIJaQLhXrefo=; b=AbJxH8UUQWUPIyz0OlTZXZzBwJAze8LUuVf5cssne0eW0EOi7syxgwRBHyUonynF4E 0B4+JG/Yro6j+beOuO/8bsZbXU/zkDCkScUWapjvLyAtvhdy7vVi/IG7i1zEBbktSJgV RJc84SVoCsrwYB8/IK5xHMWrV/8dqWS6IkvwoDooZl0Jxrp5TWarKaEgNeJL6cMgkEjm fBk/H4ox3S+tMOJrdwzFNdIfOLP1VX5Cbtz77AKz7Nbs4Osl7RT6/78K1bhWh5zQkXXn kTd/KyfRBJhAJkzOZwHRA5T+m5QaqTy/OxTvFcsNA5PL+ZgO1BrMsDjmC65Mcu30n7DZ X+/Q== X-Gm-Message-State: AFeK/H1hdMuZA/i8+myEnvN4faGEpBhdbUibSAqVtJDVu0xt6zN/qDd00yGYbGgs/kNHNQ== X-Received: by 10.36.88.202 with SMTP id f193mr24411161itb.14.1489679579412; Thu, 16 Mar 2017 08:52:59 -0700 (PDT) Received: from klimt.1015granger.net ([2604:8800:100:81fc:ec4:7aff:fe6c:6aa0]) by smtp.gmail.com with ESMTPSA id 7sm1795030itv.16.2017.03.16.08.52.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Mar 2017 08:52:59 -0700 (PDT) Subject: [PATCH v1 04/14] svcrdma: Add helper to save pages under I/O From: Chuck Lever To: linux-rdma@vger.kernel.org, linux-nfs@vger.kernel.org Date: Thu, 16 Mar 2017 11:52:58 -0400 Message-ID: <20170316155258.4482.69182.stgit@klimt.1015granger.net> In-Reply-To: <20170316154132.4482.56769.stgit@klimt.1015granger.net> References: <20170316154132.4482.56769.stgit@klimt.1015granger.net> User-Agent: StGit/0.17.1-dirty 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: extract the logic to save pages under I/O into a helper to add a big documenting comment without adding clutter in the send path. This is a refactoring change only. Signed-off-by: Chuck Lever Reviewed-by: Sagi Grimberg --- net/sunrpc/xprtrdma/svc_rdma_sendto.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 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/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c index 0e55b34..b4028bc3 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c @@ -478,6 +478,23 @@ static int send_reply_chunks(struct svcxprt_rdma *xprt, return -EIO; } +/* The svc_rqst and all resources it owns are released as soon as + * svc_rdma_sendto returns. Transfer pages under I/O to the ctxt + * so they are released by the Send completion handler. + */ +static void svc_rdma_save_io_pages(struct svc_rqst *rqstp, + struct svc_rdma_op_ctxt *ctxt) +{ + int i, pages = rqstp->rq_next_page - rqstp->rq_respages; + + ctxt->count += pages; + for (i = 0; i < pages; i++) { + ctxt->pages[i + 1] = rqstp->rq_respages[i]; + rqstp->rq_respages[i] = NULL; + } + rqstp->rq_next_page = rqstp->rq_respages + 1; +} + /** * svc_rdma_build_send_wr - Set up a Send Work Request * @ctxt: op_ctxt for transmitting the Send WR @@ -529,8 +546,6 @@ static int send_reply(struct svcxprt_rdma *rdma, u32 xdr_off; int sge_no; int sge_bytes; - int page_no; - int pages; int ret = -EIO; /* Prepare the context */ @@ -573,17 +588,7 @@ static int send_reply(struct svcxprt_rdma *rdma, goto err; } - /* Save all respages in the ctxt and remove them from the - * respages array. They are our pages until the I/O - * completes. - */ - pages = rqstp->rq_next_page - rqstp->rq_respages; - for (page_no = 0; page_no < pages; page_no++) { - ctxt->pages[page_no+1] = rqstp->rq_respages[page_no]; - ctxt->count++; - rqstp->rq_respages[page_no] = NULL; - } - rqstp->rq_next_page = rqstp->rq_respages + 1; + svc_rdma_save_io_pages(rqstp, ctxt); if (sge_no > rdma->sc_max_sge) { pr_err("svcrdma: Too many sges (%d)\n", sge_no);