All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: linux-nfs@vger.kernel.org
Cc: lorenzo.bianconi@redhat.com, chuck.lever@oracle.com,
	neilb@suse.de, netdev@vger.kernel.org, kuba@kernel.org,
	jlayton@kernel.org
Subject: [PATCH v8 1/6] nfsd: move nfsd_mutex handling into nfsd_svc callers
Date: Mon, 15 Apr 2024 21:44:34 +0200	[thread overview]
Message-ID: <2c5ff2829a27f29dd8a912fc9f62fbf214195e73.1713209938.git.lorenzo@kernel.org> (raw)
In-Reply-To: <cover.1713209938.git.lorenzo@kernel.org>

From: Jeff Layton <jlayton@kernel.org>

Currently nfsd_svc holds the nfsd_mutex over the whole function. For
some of the later netlink patches though, we want to do some other
things to the server before starting it. Move the mutex handling into
the callers.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 fs/nfsd/nfsctl.c | 2 ++
 fs/nfsd/nfssvc.c | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 93c87587e646..f2e442d7fe16 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -406,7 +406,9 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
 		if (newthreads < 0)
 			return -EINVAL;
 		trace_nfsd_ctl_threads(net, newthreads);
+		mutex_lock(&nfsd_mutex);
 		rv = nfsd_svc(newthreads, net, file->f_cred);
+		mutex_unlock(&nfsd_mutex);
 		if (rv < 0)
 			return rv;
 	} else
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index c0d17b92b249..ca193f7ff0e1 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -775,7 +775,8 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred)
 	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
 	struct svc_serv *serv;
 
-	mutex_lock(&nfsd_mutex);
+	lockdep_assert_held(&nfsd_mutex);
+
 	dprintk("nfsd: creating service\n");
 
 	nrservs = max(nrservs, 0);
@@ -804,7 +805,6 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred)
 	if (serv->sv_nrthreads == 0)
 		nfsd_destroy_serv(net);
 out:
-	mutex_unlock(&nfsd_mutex);
 	return error;
 }
 
-- 
2.44.0


  reply	other threads:[~2024-04-15 19:45 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 19:44 [PATCH v8 0/6] convert write_threads, write_version and write_ports to netlink commands Lorenzo Bianconi
2024-04-15 19:44 ` Lorenzo Bianconi [this message]
2024-04-15 19:44 ` [PATCH v8 2/6] NFSD: convert write_threads to netlink command Lorenzo Bianconi
2024-04-16 21:55   ` NeilBrown
2024-04-16 22:39     ` Jeff Layton
2024-04-17 13:04       ` Jeff Layton
2024-04-16 22:28   ` NeilBrown
2024-04-16 22:47     ` Jeff Layton
2024-04-15 19:44 ` [PATCH v8 3/6] NFSD: add write_version " Lorenzo Bianconi
2024-04-16  3:16   ` NeilBrown
2024-04-16 10:26     ` Jeff Layton
2024-04-16 21:48       ` NeilBrown
2024-04-16 22:33         ` Jeff Layton
2024-04-16 23:05           ` NeilBrown
2024-04-17  0:10             ` Jeff Layton
2024-04-17  0:43               ` NeilBrown
2024-04-17 11:25                 ` Jeff Layton
2024-04-22  3:36                   ` NeilBrown
2024-04-23 12:42                     ` Jeff Layton
2024-04-15 19:44 ` [PATCH v8 4/6] SUNRPC: introduce svc_xprt_create_from_sa utility routine Lorenzo Bianconi
2024-04-15 19:44 ` [PATCH v8 5/6] SUNRPC: add a new svc_find_listener helper Lorenzo Bianconi
2024-04-15 19:44 ` [PATCH v8 6/6] NFSD: add listener-{set,get} netlink command Lorenzo Bianconi
2024-04-16 19:05 ` [PATCH v8 0/6] convert write_threads, write_version and write_ports to netlink commands Chuck Lever

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=2c5ff2829a27f29dd8a912fc9f62fbf214195e73.1713209938.git.lorenzo@kernel.org \
    --to=lorenzo@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=neilb@suse.de \
    --cc=netdev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.