From patchwork Sun Apr 9 17:06:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 9671605 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 15F3060381 for ; Sun, 9 Apr 2017 17:06:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01D7F283E1 for ; Sun, 9 Apr 2017 17:06:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAFA7283F9; Sun, 9 Apr 2017 17:06:20 +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=-4.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID, URIBL_BLACK 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 3CCBB283E1 for ; Sun, 9 Apr 2017 17:06:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752618AbdDIRGM (ORCPT ); Sun, 9 Apr 2017 13:06:12 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:34742 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752606AbdDIRGI (ORCPT ); Sun, 9 Apr 2017 13:06:08 -0400 Received: by mail-io0-f194.google.com with SMTP id n76so11778246ioe.1; Sun, 09 Apr 2017 10:06:02 -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=vDPxEQI7Dl0p44aSXjYP2LLClIuN8SGLloPXriA6bDk=; b=cGg0FI9XGkdprn1qUMeqqCnmQwsj3S+MHk+ZqhD6M5vhyJIEaYf7m6umbtyKtBpQqz 0hqY7BoplwWONtNi96JfS8jdW/vRci6ciOC6tkEVvKaJrdBtZm10ufbABEJ/jhScUkWJ ofT6RrHem7pxW4xnQJ5jwdwrwwBFhtCtQJp6bY9ED3j/YxbvTvdpj7yalO8glisRsn3k dyYo8S3qGyQcoDij6bVFLnC8rzf1WI2Q+Xb3y7wkzAmCy4L/EFn5cYdkBaxma/t8kvkW 4D55+KOg9VHxV/Ea3XuuEGXI6pk5LprIx0jLEgg7R2flqVCeeIPBLWe9yEe22rvnflXz Xscw== 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=vDPxEQI7Dl0p44aSXjYP2LLClIuN8SGLloPXriA6bDk=; b=CSA8iKlTk0tHft7UJKeoANq9S7uA00dFafLM2s0Jt4kbjR0X4/rdVHyvImSawPhvnW xHwqr0Qrrg4xsoqr/ZHrkklTbbEOuIVwZm1NWhPCVDLvSdWXTLkgazcfxd8jvb32bP1C iXfs6WFB9j1veFbUQmHHGFhPgulv+lZxH4ctyjogBuWltzhpwX1x+ucFGn3o0lIAi9eW Miw2lB/i+kicCTVkQVGPbWp5FHI+zYaI97+25YHQEhh1WNMsYuzPeiM58kLAPeiejB0A U006z509d/4CHIryLr/KdcVqx4kVKem45e8AhzzpbC8SnH/fa4YwB6Zdzj/pTwwCI0ap j9Tg== X-Gm-Message-State: AFeK/H0oZ5q7QfEXBA3+WF3/6n3iSRfWJRP40DZcgVY8XqVTf8WYcKLypzXVon2MZqJktA== X-Received: by 10.107.163.83 with SMTP id m80mr50380231ioe.74.1491757561766; Sun, 09 Apr 2017 10:06:01 -0700 (PDT) Received: from klimt.1015granger.net (c-68-46-169-226.hsd1.mi.comcast.net. [68.46.169.226]) by smtp.gmail.com with ESMTPSA id w75sm2442908itc.21.2017.04.09.10.06.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Apr 2017 10:06:01 -0700 (PDT) Subject: [PATCH v3 04/14] svcrdma: Add helper to save pages under I/O From: Chuck Lever To: bfields@fieldses.org Cc: linux-rdma@vger.kernel.org, linux-nfs@vger.kernel.org Date: Sun, 09 Apr 2017 13:06:00 -0400 Message-ID: <20170409170600.15073.62156.stgit@klimt.1015granger.net> In-Reply-To: <20170409163820.15073.43257.stgit@klimt.1015granger.net> References: <20170409163820.15073.43257.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 Reviewed-by: Christoph Hellwig --- 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 a7dc71d..2798f3e 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_post_send_wr - Set up and post one Send Work Request * @rdma: controlling transport @@ -543,8 +560,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 */ @@ -587,17 +602,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);