diff options
| author | Olaf Kirch <okir@suse.de> | 2006-10-04 05:16:00 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-04 10:55:17 -0400 |
| commit | c53c1bb94f30cecee79ca0a8e9977640338283be (patch) | |
| tree | 88235a72747c8b151be619f3c1a95f9ae1a1dbc0 | |
| parent | f2af793db02d2c2f677bdb5bf8e0efdcbf9c0256 (diff) | |
[PATCH] knfsd: lockd: Add nlm_destroy_host
This patch moves the host destruction code out of nlm_host_gc into a function
of its own.
Signed-off-by: Olaf Kirch <okir@suse.de>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
| -rw-r--r-- | fs/lockd/host.c | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 4449ef0b7837..3b55fe5e94a2 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c | |||
| @@ -164,6 +164,34 @@ out: | |||
| 164 | return host; | 164 | return host; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | /* | ||
| 168 | * Destroy a host | ||
| 169 | */ | ||
| 170 | static void | ||
| 171 | nlm_destroy_host(struct nlm_host *host) | ||
| 172 | { | ||
| 173 | struct rpc_clnt *clnt; | ||
| 174 | |||
| 175 | BUG_ON(!list_empty(&host->h_lockowners)); | ||
| 176 | BUG_ON(atomic_read(&host->h_count)); | ||
| 177 | |||
| 178 | /* | ||
| 179 | * Release NSM handle and unmonitor host. | ||
| 180 | */ | ||
| 181 | nsm_unmonitor(host); | ||
| 182 | |||
| 183 | if ((clnt = host->h_rpcclnt) != NULL) { | ||
| 184 | if (atomic_read(&clnt->cl_users)) { | ||
| 185 | printk(KERN_WARNING | ||
| 186 | "lockd: active RPC handle\n"); | ||
| 187 | clnt->cl_dead = 1; | ||
| 188 | } else { | ||
| 189 | rpc_destroy_client(host->h_rpcclnt); | ||
| 190 | } | ||
| 191 | } | ||
| 192 | kfree(host); | ||
| 193 | } | ||
| 194 | |||
| 167 | struct nlm_host * | 195 | struct nlm_host * |
| 168 | nlm_find_client(void) | 196 | nlm_find_client(void) |
| 169 | { | 197 | { |
| @@ -400,7 +428,6 @@ nlm_gc_hosts(void) | |||
| 400 | struct hlist_head *chain; | 428 | struct hlist_head *chain; |
| 401 | struct hlist_node *pos, *next; | 429 | struct hlist_node *pos, *next; |
| 402 | struct nlm_host *host; | 430 | struct nlm_host *host; |
| 403 | struct rpc_clnt *clnt; | ||
| 404 | 431 | ||
| 405 | dprintk("lockd: host garbage collection\n"); | 432 | dprintk("lockd: host garbage collection\n"); |
| 406 | for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; ++chain) { | 433 | for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; ++chain) { |
| @@ -423,21 +450,7 @@ nlm_gc_hosts(void) | |||
| 423 | dprintk("lockd: delete host %s\n", host->h_name); | 450 | dprintk("lockd: delete host %s\n", host->h_name); |
| 424 | hlist_del_init(&host->h_hash); | 451 | hlist_del_init(&host->h_hash); |
| 425 | 452 | ||
| 426 | /* | 453 | nlm_destroy_host(host); |
| 427 | * Unmonitor unless host was invalidated (i.e. lockd restarted) | ||
| 428 | */ | ||
| 429 | nsm_unmonitor(host); | ||
| 430 | |||
| 431 | if ((clnt = host->h_rpcclnt) != NULL) { | ||
| 432 | if (atomic_read(&clnt->cl_users)) { | ||
| 433 | printk(KERN_WARNING | ||
| 434 | "lockd: active RPC handle\n"); | ||
| 435 | clnt->cl_dead = 1; | ||
| 436 | } else { | ||
| 437 | rpc_destroy_client(host->h_rpcclnt); | ||
| 438 | } | ||
| 439 | } | ||
| 440 | kfree(host); | ||
| 441 | nrhosts--; | 454 | nrhosts--; |
| 442 | } | 455 | } |
| 443 | } | 456 | } |
