diff options
author | NeilBrown <neilb@suse.de> | 2006-10-02 02:17:44 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-02 07:57:17 -0700 |
commit | bc591ccff27e6a85d3a0d6fcb16cfadcc45267a8 (patch) | |
tree | 20692a805b32ce5541f7175192f8ab81975434ec /fs | |
parent | 40f10522173c34e56cb9bf2fd37c62f69a427f1b (diff) | |
download | linux-bc591ccff27e6a85d3a0d6fcb16cfadcc45267a8.tar.bz2 |
[PATCH] knfsd: add a callback for when last rpc thread finishes
nfsd has some cleanup that it wants to do when the last thread exits, and
there will shortly be some more. So collect this all into one place and
define a callback for an rpc service to call when the service is about to be
destroyed.
[akpm@osdl.org: cleanups, build fix]
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/lockd/svc.c | 2 | ||||
-rw-r--r-- | fs/nfs/callback.c | 2 | ||||
-rw-r--r-- | fs/nfsd/nfssvc.c | 40 |
3 files changed, 20 insertions, 24 deletions
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 9a991b52c647..13feba45030e 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -236,7 +236,7 @@ lockd_up(void) "lockd_up: no pid, %d users??\n", nlmsvc_users); error = -ENOMEM; - serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE); + serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, NULL); if (!serv) { printk(KERN_WARNING "lockd_up: create service failed\n"); goto out; diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index a3ee11364db0..e244cdc7afab 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -116,7 +116,7 @@ int nfs_callback_up(void) goto out; init_completion(&nfs_callback_info.started); init_completion(&nfs_callback_info.stopped); - serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE); + serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, NULL); ret = -ENOMEM; if (!serv) goto out_err; diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index ec1decf29bab..c52c99964a4c 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -130,11 +130,25 @@ int nfsd_nrthreads(void) return nfsd_serv->sv_nrthreads; } +static int killsig; /* signal that was used to kill last nfsd */ +static void nfsd_last_thread(struct svc_serv *serv) +{ + /* When last nfsd thread exits we need to do some clean-up */ + nfsd_serv = NULL; + nfsd_racache_shutdown(); + nfs4_state_shutdown(); + + printk(KERN_WARNING "nfsd: last server has exited\n"); + if (killsig != SIG_NOCLEAN) { + printk(KERN_WARNING "nfsd: unexporting all filesystems\n"); + nfsd_export_flush(); + } +} int nfsd_svc(unsigned short port, int nrservs) { int error; - int none_left, found_one, i; + int found_one, i; struct list_head *victim; lock_kernel(); @@ -197,7 +211,8 @@ nfsd_svc(unsigned short port, int nrservs) atomic_set(&nfsd_busy, 0); error = -ENOMEM; - nfsd_serv = svc_create(&nfsd_program, NFSD_BUFSIZE); + nfsd_serv = svc_create(&nfsd_program, NFSD_BUFSIZE, + nfsd_last_thread); if (nfsd_serv == NULL) goto out; error = svc_makesock(nfsd_serv, IPPROTO_UDP, port); @@ -231,13 +246,7 @@ nfsd_svc(unsigned short port, int nrservs) nrservs++; } failure: - none_left = (nfsd_serv->sv_nrthreads == 1); svc_destroy(nfsd_serv); /* Release server */ - if (none_left) { - nfsd_serv = NULL; - nfsd_racache_shutdown(); - nfs4_state_shutdown(); - } out: unlock_kernel(); return error; @@ -353,7 +362,7 @@ nfsd(struct svc_rqst *rqstp) if (sigismember(¤t->pending.signal, signo) && !sigismember(¤t->blocked, signo)) break; - err = signo; + killsig = signo; } /* Clear signals before calling lockd_down() and svc_exit_thread() */ flush_signals(current); @@ -362,19 +371,6 @@ nfsd(struct svc_rqst *rqstp) /* Release lockd */ lockd_down(); - - /* Check if this is last thread */ - if (serv->sv_nrthreads==1) { - - printk(KERN_WARNING "nfsd: last server has exited\n"); - if (err != SIG_NOCLEAN) { - printk(KERN_WARNING "nfsd: unexporting all filesystems\n"); - nfsd_export_flush(); - } - nfsd_serv = NULL; - nfsd_racache_shutdown(); /* release read-ahead cache */ - nfs4_state_shutdown(); - } list_del(&me.list); nfsdstats.th_cnt --; |