Skip to contentSkip to conversation

NFSD: fix up error returned by write_threads()

PATCH In review Scott Mayhew 3 participants 3 messages Jun 8 – Jun 9

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFSD: fix up error returned by write_threads()

Previously, writing 0 to /proc/fs/nfsd/threads would return 0 if the NFS server wasn't running. After commit 14282cc3cfa2, -EIO is returned. Existing scripts don't expect this behavior.

Add a check to bypass the call to nfsd_svc() when newthreads is 0 and the NFS server is already stopped.

Fixes 14282cc3cfa2 ("NFSD: don't start nfsd if sv_permsocks is empty")
---
 fs/nfsd/nfsctl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/nfsd/nfsctl.c +5 -1
index 04e3954d54bd..ed1a06b4edcd 100644
@@ -419,6 +419,7 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
 	char *mesg = buf;
 	int rv;
 	struct net *net = netns(file);
+	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
 
 	if (size > 0) {
 		int newthreads;
@@ -429,7 +430,10 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
 			return -EINVAL;
 		trace_nfsd_ctl_threads(net, newthreads);
 		mutex_lock(&nfsd_mutex);
-		rv = nfsd_svc(1, &newthreads, net, file->f_cred, NULL);
+		if (newthreads > 0 || nn->nfsd_serv != NULL)
+			rv = nfsd_svc(1, &newthreads, net, file->f_cred, NULL);
+		else
+			rv = 0;
 		mutex_unlock(&nfsd_mutex);
 		if (rv < 0)
 			return rv;
Signature · 1 line
2.54.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · Scott Mayhew

Previously, writing 0 to /proc/fs/nfsd/threads would return 0 if the NFS server wasn't running. After commit 14282cc3cfa2, -EIO is returned. Existing scripts don't expect this behavior.

Add a check to bypass the call to nfsd_svc() when newthreads is 0 and the NFS server is already stopped.

Fixes 14282cc3cfa2 ("NFSD: don't start nfsd if sv_permsocks is empty")
---
 fs/nfsd/nfsctl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/nfsd/nfsctl.c +1 -0
index 04e3954d54bd..ed1a06b4edcd 100644
@@ -419,6 +419,7 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
 	char *mesg = buf;
 	int rv;
 	struct net *net = netns(file);
+	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
 
 	if (size > 0) {
 		int newthreads;
@@ -429,7 +430,10 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
 			return -EINVAL;

fs/nfsd/nfsctl.c static ssize_t write_threads(struct file *file, char *buf, size_t size) · line 439

Quoted 10 lines
fs/nfsd/nfsctl.c +4 -1
 		trace_nfsd_ctl_threads(net, newthreads);
 		mutex_lock(&nfsd_mutex);
-		rv = nfsd_svc(1, &newthreads, net, file->f_cred, NULL);
+		if (newthreads > 0 || nn->nfsd_serv != NULL)
+			rv = nfsd_svc(1, &newthreads, net, file->f_cred, NULL);
+		else
+			rv = 0;
 		mutex_unlock(&nfsd_mutex);
 		if (rv < 0)
 			return rv;
maintainer
#2 lore raw
In reply to Scott Mayhew

From: Chuck Lever <[email protected]>

Quoted 8 lines · Scott Mayhew

Previously, writing 0 to /proc/fs/nfsd/threads would return 0 if the NFS server wasn't running. After commit 14282cc3cfa2, -EIO is returned. Existing scripts don't expect this behavior.

Add a check to bypass the call to nfsd_svc() when newthreads is 0 and the NFS server is already stopped.

[...]

Applied to nfsd-testing, thanks!

[1/1] NFSD: fix up error returned by write_threads()

      commit: 36f28c2e37a6a508f5a7be62ebe9c8887ed9bd20

--
Chuck Lever <[email protected]>