From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <chuck.lever@oracle.com>, Neil Brown <neilb@suse.de>,
Olga Kornievskaia <kolga@netapp.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Zhi Li <yieli@redhat.com>, Jeff Layton <jlayton@kernel.org>
Subject: [PATCH RFC] nfsd: fix error handling in nfsd_svc
Date: Mon, 30 Oct 2023 13:32:54 -0400 [thread overview]
Message-ID: <20231030-kdevops-v1-1-bae6baf62c69@kernel.org> (raw)
Once we've set the nfsd_serv pointer in nfsd_svc, we still need to call
nfsd_last_thread if the server fails to be started. Remove the special
casing for nfsd_up_before case since shutting down the per-net stuff is
also handled by nfsd_last_thread.
Finally, add a new special case at the start and skip doing anything if
the service already exists, 0 threads were requested and
serv->sv_nrthreads is 0.
Fixes: 9f28a971ee9f ("nfsd: separate nfsd_last_thread() from nfsd_put()")
Reported-by: Zhi Li <yieli@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
Here's what I was thinking for a targeted patch for stable. Testing it
now, but I won't have results until tomorrow.
---
fs/nfsd/nfssvc.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 3deef000afa9..187b68769815 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -787,7 +787,6 @@ int
nfsd_svc(int nrservs, struct net *net, const struct cred *cred)
{
int error;
- bool nfsd_up_before;
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
struct svc_serv *serv;
@@ -797,8 +796,9 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred)
nrservs = max(nrservs, 0);
nrservs = min(nrservs, NFSD_MAXSERVS);
error = 0;
+ serv = nn->nfsd_serv;
- if (nrservs == 0 && nn->nfsd_serv == NULL)
+ if (nrservs == 0 && (serv == NULL || serv->sv_nrthreads == 0))
goto out;
strscpy(nn->nfsd_name, utsname()->nodename,
@@ -808,22 +808,17 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred)
if (error)
goto out;
- nfsd_up_before = nn->nfsd_net_up;
serv = nn->nfsd_serv;
error = nfsd_startup_net(net, cred);
if (error)
goto out_put;
error = svc_set_num_threads(serv, NULL, nrservs);
- if (error)
- goto out_shutdown;
- error = serv->sv_nrthreads;
if (error == 0)
- nfsd_last_thread(net);
-out_shutdown:
- if (error < 0 && !nfsd_up_before)
- nfsd_shutdown_net(net);
+ error = serv->sv_nrthreads;
out_put:
+ if (serv->sv_nrthreads == 0)
+ nfsd_last_thread(net);
/* Threads now hold service active */
if (xchg(&nn->keep_active, 0))
svc_put(serv);
---
base-commit: 31b5a36c4b88b44c91cdd523997b1e86fb47339d
change-id: 20231030-kdevops-5f7366897ef4
Best regards,
--
Jeff Layton <jlayton@kernel.org>
next reply other threads:[~2023-10-30 17:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-30 17:32 Jeff Layton [this message]
2023-10-30 21:33 ` [PATCH RFC] nfsd: fix error handling in nfsd_svc NeilBrown
2023-10-30 21:43 ` Jeff Layton
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=20231030-kdevops-v1-1-bae6baf62c69@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=kolga@netapp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
--cc=tom@talpey.com \
--cc=yieli@redhat.com \
/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