Skip to content

Commit 3644101

Browse files
jtlaytonchucklever
authored andcommitted
nfsd: report the requested maximum number of threads instead of number running
The current netlink and /proc interfaces deviate from their traditional values when dynamic threading is enabled, and there is currently no way to know what the current setting is. This patch brings the reporting back in line with traditional behavior. Make these interfaces report the requested maximum number of threads instead of the number currently running. Also, update documentation and comments to reflect that this value represents a maximum and not the number currently running. Fixes: d8316b8 ("nfsd: add controls to set the minimum number of threads per pool") Signed-off-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 92978c8 commit 3644101

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
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: 9 additions & 9 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
*/
@@ -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
}

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)