aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/host.c
diff options
context:
space:
mode:
authorOlaf Kirch <okir@suse.de>2006-10-04 05:15:55 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-04 10:55:17 -0400
commit5c8dd29ca7fc7483690cef4306549742d534f2a2 (patch)
treeedf51e354535448ea6b57a59358d9f28c556684c /fs/lockd/host.c
parentf0737a39a64a9df32bb045c54e1cdf6cecdcbdd7 (diff)
[PATCH] knfsd: lockd: Make nlm_host_rebooted use the nsm_handle
This patch makes the SM_NOTIFY handling understand and use the nsm_handle. To make it a bit clear what is happening: nlmclent_prepare_reclaim and nlmclnt_finish_reclaim get open-coded into 'reclaimer' The result is tidied up. Then some of that functionality is moved out into nlm_host_rebooted (which calls nlmclnt_recovery which starts a thread which runs reclaimer). Also host_rebooted now finds an nsm_handle rather than a host, then then iterates over all hosts and deals with each host that shares that nsm_handle. 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>
Diffstat (limited to 'fs/lockd/host.c')
-rw-r--r--fs/lockd/host.c63
1 files changed, 46 insertions, 17 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 4990223a3e18..3cd96e2e1256 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -290,28 +290,57 @@ void nlm_release_host(struct nlm_host *host)
290 * has rebooted. 290 * has rebooted.
291 * Release all resources held by that peer. 291 * Release all resources held by that peer.
292 */ 292 */
293void nlm_host_rebooted(const struct sockaddr_in *sin, const struct nlm_reboot *argp) 293void nlm_host_rebooted(const struct sockaddr_in *sin,
294 const char *hostname, int hostname_len,
295 u32 new_state)
294{ 296{
295 struct nlm_host *host; 297 struct nsm_handle *nsm;
296 int server; 298 struct nlm_host *host, **hp;
299 int hash;
297 300
298 /* Obtain the host pointer for this NFS server and try to 301 dprintk("lockd: nlm_host_rebooted(%s, %u.%u.%u.%u)\n",
299 * reclaim all locks we hold on this server. 302 hostname, NIPQUAD(sin->sin_addr));
300 */ 303
301 server = (argp->proto & 1)? 1 : 0; 304 /* Find the NSM handle for this peer */
302 host = nlm_lookup_host(server, sin, argp->proto >> 1, argp->vers, 305 if (!(nsm = __nsm_find(sin, hostname, hostname_len, 0)))
303 argp->mon, argp->len);
304 if (host == NULL)
305 return; 306 return;
306 307
307 if (server == 0) { 308 /* When reclaiming locks on this peer, make sure that
308 /* We are client, he's the server: try to reclaim all locks. */ 309 * we set up a new notification */
309 nlmclnt_recovery(host, argp->state); 310 nsm->sm_monitored = 0;
310 } else { 311
311 /* He's the client, we're the server: delete all locks held by the client */ 312 /* Mark all hosts tied to this NSM state as having rebooted.
312 nlmsvc_free_host_resources(host); 313 * We run the loop repeatedly, because we drop the host table
314 * lock for this.
315 * To avoid processing a host several times, we match the nsmstate.
316 */
317again: mutex_lock(&nlm_host_mutex);
318 for (hash = 0; hash < NLM_HOST_NRHASH; hash++) {
319 for (hp = &nlm_hosts[hash]; (host = *hp); hp = &host->h_next) {
320 if (host->h_nsmhandle == nsm
321 && host->h_nsmstate != new_state) {
322 host->h_nsmstate = new_state;
323 host->h_state++;
324
325 nlm_get_host(host);
326 mutex_unlock(&nlm_host_mutex);
327
328 if (host->h_server) {
329 /* We're server for this guy, just ditch
330 * all the locks he held. */
331 nlmsvc_free_host_resources(host);
332 } else {
333 /* He's the server, initiate lock recovery. */
334 nlmclnt_recovery(host);
335 }
336
337 nlm_release_host(host);
338 goto again;
339 }
340 }
313 } 341 }
314 nlm_release_host(host); 342
343 mutex_unlock(&nlm_host_mutex);
315} 344}
316 345
317/* 346/*