NFSD: move nfsd_mutex handling into nfsd_svc callers
authorJeff Layton <jlayton@kernel.org>
Tue, 23 Apr 2024 13:25:38 +0000 (15:25 +0200)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 6 May 2024 13:07:20 +0000 (09:07 -0400)
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>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfsctl.c
fs/nfsd/nfssvc.c

index 340c5d6..2fe78b8 100644 (file)
@@ -404,7 +404,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
index c0d17b9..ca193f7 100644 (file)
@@ -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 @@ out_put:
        if (serv->sv_nrthreads == 0)
                nfsd_destroy_serv(net);
 out:
-       mutex_unlock(&nfsd_mutex);
        return error;
 }