nfsd4: fix v4 state shutdown error paths

If someone tries to shut down the laundry_wq while it isn't up it'll
cause an oops.

This can happen because write_ports can create a nfsd_svc before we
really start the nfs server, and we may fail before the server is ever
started.

Also make sure state is shutdown on error paths in nfsd_svc().

Use a common global nfsd_up flag instead of nfs4_init, and create common
helper functions for nfsd start/shutdown, as there will be other work
that we want done only when we the number of nfsd threads transitions
between zero and nonzero.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
Jeff Layton
2010-07-19 16:50:04 -04:00
committed by J. Bruce Fields
parent 55b13354d7
commit 4ad9a344be
2 changed files with 43 additions and 20 deletions

View File

@ -51,7 +51,6 @@ static time_t boot_time;
static u32 current_ownerid = 1;
static u32 current_fileid = 1;
static u32 current_delegid = 1;
static u32 nfs4_init;
static stateid_t zerostateid; /* bits all 0 */
static stateid_t onestateid; /* bits all 1 */
static u64 current_sessionid = 1;
@ -4071,16 +4070,8 @@ out_free_laundry:
int
nfs4_state_start(void)
{
int ret;
if (nfs4_init)
return 0;
nfsd4_load_reboot_recovery_data();
ret = __nfs4_state_start();
if (ret)
return ret;
nfs4_init = 1;
return 0;
return __nfs4_state_start();
}
static void
@ -4115,7 +4106,6 @@ __nfs4_state_shutdown(void)
}
nfsd4_shutdown_recdir();
nfs4_init = 0;
}
void