From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: NeilBrown <neilb@suse.de>, Chuck Lever <chuck.lever@oracle.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6.y 1/4] SUNRPC: move all of xprt handling into svc_xprt_handle()
Date: Tue, 8 Sep 2026 18:37:07 -0400 [thread overview]
Message-ID: <20260908223710.506600-1-sashal@kernel.org> (raw)
In-Reply-To: <2026090350-breeze-repugnant-70de@gregkh>
From: NeilBrown <neilb@suse.de>
[ Upstream commit e3274026e2ec69eec6ab51bc499e14bb548548d0 ]
svc_xprt_handle() does lots of things itself, but leaves some to the
caller - svc_recv(). This isn't elegant.
Move that code out of svc_recv() into svc_xprt_handle()
Move the calls to svc_xprt_release() from svc_send() and svc_drop()
(the two possible final steps in svc_process()) and from svc_recv() (in
the case where svc_process() wasn't called) into svc_xprt_handle().
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Stable-dep-of: c479bde671cb ("sunrpc: defer rq_argp and rq_resp free until after RCU grace period")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/sunrpc/svc_xprt.c | 53 ++++++++++++++++---------------------------
1 file changed, 20 insertions(+), 33 deletions(-)
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 5cfe5c7408b74..5440d6b50efa5 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -784,7 +784,7 @@ static void svc_add_new_temp_xprt(struct svc_serv *serv, struct svc_xprt *newxpt
svc_xprt_received(newxpt);
}
-static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
+static void svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
{
struct svc_serv *serv = rqstp->rq_server;
int len = 0;
@@ -825,11 +825,26 @@ static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
len = xprt->xpt_ops->xpo_recvfrom(rqstp);
rqstp->rq_reserved = serv->sv_max_mesg;
atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved);
+ if (len <= 0)
+ goto out;
+
+ trace_svc_xdr_recvfrom(&rqstp->rq_arg);
+
+ clear_bit(XPT_OLD, &xprt->xpt_flags);
+
+ rqstp->rq_chandle.defer = svc_defer;
+
+ if (serv->sv_stats)
+ serv->sv_stats->netcnt++;
+ percpu_counter_inc(&rqstp->rq_pool->sp_messages_arrived);
+ rqstp->rq_stime = ktime_get();
+ svc_process(rqstp);
} else
svc_xprt_received(xprt);
out:
- return len;
+ rqstp->rq_res.len = 0;
+ svc_xprt_release(rqstp);
}
/**
@@ -843,11 +858,9 @@ static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt)
void svc_recv(struct svc_rqst *rqstp)
{
struct svc_xprt *xprt = NULL;
- struct svc_serv *serv = rqstp->rq_server;
- int len;
if (!svc_alloc_arg(rqstp))
- goto out;
+ return;
try_to_freeze();
cond_resched();
@@ -855,31 +868,9 @@ void svc_recv(struct svc_rqst *rqstp)
goto out;
xprt = svc_get_next_xprt(rqstp);
- if (!xprt)
- goto out;
-
- len = svc_handle_xprt(rqstp, xprt);
-
- /* No data, incomplete (TCP) read, or accept() */
- if (len <= 0)
- goto out_release;
-
- trace_svc_xdr_recvfrom(&rqstp->rq_arg);
-
- clear_bit(XPT_OLD, &xprt->xpt_flags);
-
- rqstp->rq_chandle.defer = svc_defer;
-
- if (serv->sv_stats)
- serv->sv_stats->netcnt++;
- percpu_counter_inc(&rqstp->rq_pool->sp_messages_arrived);
- rqstp->rq_stime = ktime_get();
- svc_process(rqstp);
+ if (xprt)
+ svc_handle_xprt(rqstp, xprt);
out:
- return;
-out_release:
- rqstp->rq_res.len = 0;
- svc_xprt_release(rqstp);
}
EXPORT_SYMBOL_GPL(svc_recv);
@@ -889,7 +880,6 @@ EXPORT_SYMBOL_GPL(svc_recv);
void svc_drop(struct svc_rqst *rqstp)
{
trace_svc_drop(rqstp);
- svc_xprt_release(rqstp);
}
EXPORT_SYMBOL_GPL(svc_drop);
@@ -905,8 +895,6 @@ void svc_send(struct svc_rqst *rqstp)
int status;
xprt = rqstp->rq_xprt;
- if (!xprt)
- return;
/* calculate over-all length */
xb = &rqstp->rq_res;
@@ -919,7 +907,6 @@ void svc_send(struct svc_rqst *rqstp)
status = xprt->xpt_ops->xpo_sendto(rqstp);
trace_svc_send(rqstp, status);
- svc_xprt_release(rqstp);
}
/*
--
2.53.0
next prev parent reply other threads:[~2026-09-08 22:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 14:06 FAILED: patch "[PATCH] sunrpc: defer rq_argp and rq_resp free until after RCU grace" failed to apply to 6.6-stable tree gregkh
2026-09-08 22:36 ` [PATCH 6.6.y 1/7] SUNRPC: move all of xprt handling into svc_xprt_handle() Sasha Levin
2026-09-08 22:36 ` [PATCH 6.6.y 2/7] SUNRPC: Add a server-side API for retrieving an RPC's pseudoflavor Sasha Levin
2026-09-08 22:36 ` [PATCH 6.6.y 3/7] sunrpc: refactor pool_mode setting code Sasha Levin
2026-09-08 22:36 ` [PATCH 6.6.y 4/7] SUNRPC: make various functions static, or not exported Sasha Levin
2026-09-08 22:36 ` [PATCH 6.6.y 5/7] SUNRPC: Introduce xdr_set_scratch_folio() Sasha Levin
2026-09-08 22:36 ` [PATCH 6.6.y 6/7] SUNRPC: Update svcxdr_init_decode() to call xdr_set_scratch_folio() Sasha Levin
2026-09-08 22:36 ` [PATCH 6.6.y 7/7] sunrpc: defer rq_argp and rq_resp free until after RCU grace period Sasha Levin
2026-09-08 22:37 ` Sasha Levin [this message]
2026-09-08 22:37 ` [PATCH 6.6.y 2/4] SUNRPC: Add a server-side API for retrieving an RPC's pseudoflavor Sasha Levin
2026-09-08 22:37 ` [PATCH 6.6.y 3/4] sunrpc: refactor pool_mode setting code Sasha Levin
2026-09-08 22:37 ` [PATCH 6.6.y 4/4] sunrpc: defer rq_argp and rq_resp free until after RCU grace period Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260908223710.506600-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=neilb@suse.de \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox