Skip to content

Commit 1b37ac2

Browse files
committed
Merge tag 'nfsd-7.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
Pull nfsd fixes from Chuck Lever: - Restore previous nfsd thread count reporting behavior - Fix credential reference leaks in the NFSD netlink admin protocol * tag 'nfsd-7.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux: nfsd: report the requested maximum number of threads instead of number running nfsd: Fix cred ref leak in nfsd_nl_listener_set_doit(). nfsd: Fix cred ref leak in nfsd_nl_threads_set_doit().
2 parents 11439c4 + 3644101 commit 1b37ac2

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

Documentation/netlink/specs/nfsd.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ operations:
152152
- compound-ops
153153
-
154154
name: threads-set
155-
doc: set the number of running threads
155+
doc: set the maximum number of running threads
156156
attribute-set: server
157157
flags: [admin-perm]
158158
do:
@@ -165,7 +165,7 @@ operations:
165165
- min-threads
166166
-
167167
name: threads-get
168-
doc: get the number of running threads
168+
doc: get the maximum number of running threads
169169
attribute-set: server
170170
do:
171171
reply:

fs/nfsd/nfsctl.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -377,15 +377,15 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
377377
}
378378

379379
/*
380-
* write_threads - Start NFSD, or report the current number of running threads
380+
* write_threads - Start NFSD, or report the configured number of threads
381381
*
382382
* Input:
383383
* buf: ignored
384384
* size: zero
385385
* Output:
386386
* On success: passed-in buffer filled with '\n'-terminated C
387-
* string numeric value representing the number of
388-
* running NFSD threads;
387+
* string numeric value representing the configured
388+
* number of NFSD threads;
389389
* return code is the size in bytes of the string
390390
* On error: return code is zero
391391
*
@@ -399,8 +399,8 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
399399
* Output:
400400
* On success: NFS service is started;
401401
* passed-in buffer filled with '\n'-terminated C
402-
* string numeric value representing the number of
403-
* running NFSD threads;
402+
* string numeric value representing the configured
403+
* number of NFSD threads;
404404
* return code is the size in bytes of the string
405405
* On error: return code is zero or a negative errno value
406406
*/
@@ -430,7 +430,7 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
430430
}
431431

432432
/*
433-
* write_pool_threads - Set or report the current number of threads per pool
433+
* write_pool_threads - Set or report the configured number of threads per pool
434434
*
435435
* Input:
436436
* buf: ignored
@@ -447,7 +447,7 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
447447
* Output:
448448
* On success: passed-in buffer filled with '\n'-terminated C
449449
* string containing integer values representing the
450-
* number of NFSD threads in each pool;
450+
* configured number of NFSD threads in each pool;
451451
* return code is the size in bytes of the string
452452
* On error: return code is zero or a negative errno value
453453
*/
@@ -1647,7 +1647,7 @@ int nfsd_nl_threads_set_doit(struct sk_buff *skb, struct genl_info *info)
16471647
if (attr)
16481648
nn->min_threads = nla_get_u32(attr);
16491649

1650-
ret = nfsd_svc(nrpools, nthreads, net, get_current_cred(), scope);
1650+
ret = nfsd_svc(nrpools, nthreads, net, current_cred(), scope);
16511651
if (ret > 0)
16521652
ret = 0;
16531653
out_unlock:
@@ -1657,7 +1657,7 @@ int nfsd_nl_threads_set_doit(struct sk_buff *skb, struct genl_info *info)
16571657
}
16581658

16591659
/**
1660-
* nfsd_nl_threads_get_doit - get the number of running threads
1660+
* nfsd_nl_threads_get_doit - get the maximum number of running threads
16611661
* @skb: reply buffer
16621662
* @info: netlink metadata and command arguments
16631663
*
@@ -1700,7 +1700,7 @@ int nfsd_nl_threads_get_doit(struct sk_buff *skb, struct genl_info *info)
17001700
struct svc_pool *sp = &nn->nfsd_serv->sv_pools[i];
17011701

17021702
err = nla_put_u32(skb, NFSD_A_SERVER_THREADS,
1703-
sp->sp_nrthreads);
1703+
sp->sp_nrthrmax);
17041704
if (err)
17051705
goto err_unlock;
17061706
}
@@ -2000,7 +2000,7 @@ int nfsd_nl_listener_set_doit(struct sk_buff *skb, struct genl_info *info)
20002000
}
20012001

20022002
ret = svc_xprt_create_from_sa(serv, xcl_name, net, sa, 0,
2003-
get_current_cred());
2003+
current_cred());
20042004
/* always save the latest error */
20052005
if (ret < 0)
20062006
err = ret;

fs/nfsd/nfssvc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,13 @@ static void nfsd_net_free(struct percpu_ref *ref)
239239

240240
int nfsd_nrthreads(struct net *net)
241241
{
242-
int rv = 0;
242+
int i, rv = 0;
243243
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
244244

245245
mutex_lock(&nfsd_mutex);
246246
if (nn->nfsd_serv)
247-
rv = nn->nfsd_serv->sv_nrthreads;
247+
for (i = 0; i < nn->nfsd_serv->sv_nrpools; ++i)
248+
rv += nn->nfsd_serv->sv_pools[i].sp_nrthrmax;
248249
mutex_unlock(&nfsd_mutex);
249250
return rv;
250251
}
@@ -659,7 +660,7 @@ int nfsd_get_nrthreads(int n, int *nthreads, struct net *net)
659660

660661
if (serv)
661662
for (i = 0; i < serv->sv_nrpools && i < n; i++)
662-
nthreads[i] = serv->sv_pools[i].sp_nrthreads;
663+
nthreads[i] = serv->sv_pools[i].sp_nrthrmax;
663664
return 0;
664665
}
665666

0 commit comments

Comments
 (0)