From patchwork Sat Apr 15 00:17:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13212216 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6D0BC77B72 for ; Sat, 15 Apr 2023 00:18:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4877D900004; Fri, 14 Apr 2023 20:18:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43796900002; Fri, 14 Apr 2023 20:18:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 326F9900004; Fri, 14 Apr 2023 20:18:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 260D2900002 for ; Fri, 14 Apr 2023 20:18:01 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D9AEAABB9B for ; Sat, 15 Apr 2023 00:18:00 +0000 (UTC) X-FDA: 80681712720.19.000FAE0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id 386AE4000D for ; Sat, 15 Apr 2023 00:17:59 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="hXfE/aAz"; spf=pass (imf07.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681517879; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DU+K9sMszFdIIwO7wrAMkgVApC9slAiX2drMJII2Ya8=; b=PQtyTOv+OLn9qKXaTZPhWd2qdjuSzH464izVtDUAaf+U2BRfdB9AXhCu9OT1wVFIiiqGDb yiXALTHHUoOuvtbkhtcnTG4EF/aljiPrwVASX9Z7G2XWC0Xg/6WvVAfkevCg45o1rPP98J pGLzlFnn3/txvPCOYKLLq2/w2DI9mq0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="hXfE/aAz"; spf=pass (imf07.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681517879; a=rsa-sha256; cv=none; b=OpUsalFOb2ZDHbW+4xRYH3FyJqkNBIaZqovuJfiaYL+3LCLhLeJ3m9Rr0eScgLutjI+Hlj nxQ3Dulfsvt81ItLK8MnYZGjlIGNMRNO754OfxOCridN32qJjtiFjjmOawN6aewIEN76Bn KQqESDNbX0wPsDAqzaH+lZinQpfgwWM= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4473E645C6 for ; Sat, 15 Apr 2023 00:17:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A180C433A0; Sat, 15 Apr 2023 00:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681517877; bh=w0AGIKncJ+aMWbYsTzdaumoT4rTj66CdiASkX6lZ4UU=; h=Subject:From:To:Date:In-Reply-To:References:From; b=hXfE/aAz5R89eQvCA4gEJ1LT2dArTmazeb+qhr8Mtd66M5OTM+PGTvU9rdnSeR6Vg 074TTlq2rc4bDFuQK7AqzwnV8Zl5ifmGeJe/TPUUWrotsP4PD2QuLYXTI9saUYiYjt wSjljvZ3yk5NpYqS1z4iRE7Ks4rnxK0Myvax2Zh380qVjPqBqyQTxOKU7xP8Ur2zrs IWBmKDIXIWAZJAqA3pmiSo13JBhPGxHGHZoCnjGeg2uV4skBFbMuw6BLbB13t1iNlV ja9fRCsIDDXwBVt+1usSOEjYbiY9VX328hIVzOHLo7/PIxsJYooPL/nGq1s8tpQkr0 ip9uTDQcWasOA== Subject: [PATCH v1 1/4] SUNRPC: Relocate svc_free_res_pages() From: Chuck Lever To: linux-nfs@vger.kernel.org, linux-mm@kvack.org Date: Fri, 14 Apr 2023 20:17:56 -0400 Message-ID: <168151787655.1588.13024575588334839763.stgit@klimt.1015granger.net> In-Reply-To: <168151777579.1588.7882383278745556830.stgit@klimt.1015granger.net> References: <168151777579.1588.7882383278745556830.stgit@klimt.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 386AE4000D X-Stat-Signature: azu754yez1t8ei91djuteiurr8wrksr1 X-Rspam-User: X-HE-Tag: 1681517879-680692 X-HE-Meta: U2FsdGVkX1/O7+/D7xCdikg4bn0TAyERH4wpcVyo/mJo3JC4RB6SOxHbFfXYjAYbUF137dy/HJcG2AgsQtO+uldYCg5CQHoQAW8FHipG+1pbywU8Xr0W35D5cjd1xfPIhU8nuKIon8ANkUk+WtSyn6wVeadTZPBQzHf3/4uyoG2SKS2l8qfNmHc4k1XwfzqCac4S0Qr6eADCDlXFzmyoj60nDbv03XFDOhrRfVDy24ua/ng8MTuY4AafCF2RdeZ/fODT+bOoCexNYhUAojyWfPSabIU1DvrdimYLHCtXiuR4wckC0owqVomgp/JeOTi7Ll+w2Qz/soLz0et9/KhURAGA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ogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Chuck Lever Clean-up: There doesn't seem to be a reason why this function is stuck in a header. One thing it prevents is the convenient addition of tracing. Moving it to a source file also makes the rq_respages clean-up logic easier to find. Signed-off-by: Chuck Lever --- include/linux/sunrpc/svc.h | 12 +----------- net/sunrpc/svc.c | 19 +++++++++++++++++++ net/sunrpc/svc_xprt.c | 2 +- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 2d31121fc2e6..762d7231e574 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -309,17 +309,6 @@ static inline struct sockaddr *svc_daddr(const struct svc_rqst *rqst) return (struct sockaddr *) &rqst->rq_daddr; } -static inline void svc_free_res_pages(struct svc_rqst *rqstp) -{ - while (rqstp->rq_next_page != rqstp->rq_respages) { - struct page **pp = --rqstp->rq_next_page; - if (*pp) { - put_page(*pp); - *pp = NULL; - } - } -} - struct svc_deferred_req { u32 prot; /* protocol (UDP or TCP) */ struct svc_xprt *xprt; @@ -424,6 +413,7 @@ struct svc_rqst *svc_rqst_alloc(struct svc_serv *serv, struct svc_pool *pool, int node); bool svc_rqst_replace_page(struct svc_rqst *rqstp, struct page *page); +void svc_rqst_release_pages(struct svc_rqst *rqstp); void svc_rqst_free(struct svc_rqst *); void svc_exit_thread(struct svc_rqst *); struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 0aa8892fad63..0fc70cc405b2 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -869,6 +869,25 @@ bool svc_rqst_replace_page(struct svc_rqst *rqstp, struct page *page) } EXPORT_SYMBOL_GPL(svc_rqst_replace_page); +/** + * svc_rqst_release_pages - Release Reply buffer pages + * @rqstp: RPC transaction context + * + * Release response pages that might still be in flight after + * svc_send, and any spliced filesystem-owned pages. + */ +void svc_rqst_release_pages(struct svc_rqst *rqstp) +{ + while (rqstp->rq_next_page != rqstp->rq_respages) { + struct page **pp = --rqstp->rq_next_page; + + if (*pp) { + put_page(*pp); + *pp = NULL; + } + } +} + /* * Called from a server thread as it's exiting. Caller must hold the "service * mutex" for the service. diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 36c79b718323..533e08c4f319 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -542,7 +542,7 @@ static void svc_xprt_release(struct svc_rqst *rqstp) rqstp->rq_deferred = NULL; pagevec_release(&rqstp->rq_pvec); - svc_free_res_pages(rqstp); + svc_rqst_release_pages(rqstp); rqstp->rq_res.page_len = 0; rqstp->rq_res.page_base = 0;