aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfssvc.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2009-06-15 21:03:07 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2009-06-18 12:40:31 -0400
commit82e12fe9244ff653f703722a8937b595e10e71f4 (patch)
treeaacafeb07d90c9453c31cc6771324e7960c52477 /fs/nfsd/nfssvc.c
parent5d77ddfbcb062f2617ea79d7a371b4bc78f28417 (diff)
nfsd: don't take nfsd_mutex twice when setting number of threads.
Currently when we write a number to 'threads' in nfsdfs, we take the nfsd_mutex, update the number of threads, then take the mutex again to read the number of threads. Mostly this isn't a big deal. However if we are write '0', and portmap happens to be dead, then we can get unpredictable behaviour. If the nfsd threads all got killed quickly and the last thread is waiting for portmap to respond, then the second time we take the mutex we will block waiting for the last thread. However if the nfsd threads didn't die quite that fast, then there will be no contention when we try to take the mutex again. Unpredictability isn't fun, and waiting for the last thread to exit is pointless, so avoid taking the lock twice. To achieve this, get nfsd_svc return a non-negative number of active threads when not returning a negative error. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'fs/nfsd/nfssvc.c')
-rw-r--r--fs/nfsd/nfssvc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index cbba4a935786..209eaa0885d1 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -413,6 +413,12 @@ nfsd_svc(unsigned short port, int nrservs)
413 goto failure; 413 goto failure;
414 414
415 error = svc_set_num_threads(nfsd_serv, NULL, nrservs); 415 error = svc_set_num_threads(nfsd_serv, NULL, nrservs);
416 if (error == 0)
417 /* We are holding a reference to nfsd_serv which
418 * we don't want to count in the return value,
419 * so subtract 1
420 */
421 error = nfsd_serv->sv_nrthreads - 1;
416 failure: 422 failure:
417 svc_destroy(nfsd_serv); /* Release server */ 423 svc_destroy(nfsd_serv); /* Release server */
418 out: 424 out: