nfsd: don't take nfsd_mutex twice when setting number of threads.
authorNeilBrown <neilb@suse.de>
Tue, 16 Jun 2009 01:03:07 +0000 (11:03 +1000)
committerJ. Bruce Fields <bfields@citi.umich.edu>
Thu, 18 Jun 2009 16:40:31 +0000 (09:40 -0700)
commit82e12fe9244ff653f703722a8937b595e10e71f4
treeaacafeb07d90c9453c31cc6771324e7960c52477
parent5d77ddfbcb062f2617ea79d7a371b4bc78f28417
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>
fs/nfsd/nfsctl.c
fs/nfsd/nfssvc.c