diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c index 0116729cec5f717ed246715e813108e7b12cb6b7..5436be623e3085b039a805f6145cf83d11ca5dd9 100644 --- a/fs/lockd/clntproc.c +++ b/fs/lockd/clntproc.c @@ -499,7 +499,7 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) unsigned char fl_flags = fl->fl_flags; int status = -ENOLCK; - if (!host->h_monitored && nsm_monitor(host) < 0) { + if (nsm_monitor(host) < 0) { printk(KERN_NOTICE "lockd: failed to monitor %s\n", host->h_name); goto out; diff --git a/fs/lockd/host.c b/fs/lockd/host.c index a0d0b58ce7a49968aa8ed942d00fbec3e9fc9539..637ec9567066013ffce7ee554975837a5d6d2234 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -331,9 +331,12 @@ nlm_gc_hosts(void) } dprintk("lockd: delete host %s\n", host->h_name); *q = host->h_next; - /* Don't unmonitor hosts that have been invalidated */ - if (host->h_monitored && !host->h_killed) - nsm_unmonitor(host); + + /* + * Unmonitor unless host was invalidated (i.e. lockd restarted) + */ + nsm_unmonitor(host); + if ((clnt = host->h_rpcclnt) != NULL) { if (atomic_read(&clnt->cl_users)) { printk(KERN_WARNING diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c index a816b920d431fcfd60fc806b10bd4e0cc25c02f7..e02a1a4dfced12a6e2248f9982c2bebee5f2aa12 100644 --- a/fs/lockd/mon.c +++ b/fs/lockd/mon.c @@ -74,6 +74,8 @@ nsm_monitor(struct nlm_host *host) int status; dprintk("lockd: nsm_monitor(%s)\n", host->h_name); + if (host->h_monitored) + return 0; status = nsm_mon_unmon(host, SM_MON, &res); @@ -91,15 +93,18 @@ int nsm_unmonitor(struct nlm_host *host) { struct nsm_res res; - int status; + int status = 0; dprintk("lockd: nsm_unmonitor(%s)\n", host->h_name); - - status = nsm_mon_unmon(host, SM_UNMON, &res); - if (status < 0) - printk(KERN_NOTICE "lockd: cannot unmonitor %s\n", host->h_name); - else - host->h_monitored = 0; + if (!host->h_monitored) + return 0; + host->h_monitored = 0; + + if (!host->h_killed) { + status = nsm_mon_unmon(host, SM_UNMON, &res); + if (status < 0) + printk(KERN_NOTICE "lockd: cannot unmonitor %s\n", host->h_name); + } return status; } diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index a2dd9ccb9b321057b2dd414198e3eba6ce2e3bca..b5aceb83f8cb08e082c75f0298908ca2389136b4 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c @@ -39,7 +39,7 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, /* Obtain host handle */ if (!(host = nlmsvc_lookup_host(rqstp)) - || (argp->monitor && !host->h_monitored && nsm_monitor(host) < 0)) + || (argp->monitor && nsm_monitor(host) < 0)) goto no_locks; *hostp = host; diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index dbb66a3b5cd97ddd49f0b83a71fa177f31b8ec04..dbc4ea2638c9aa7cad313628748b4aeadab0098e 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -67,7 +67,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, /* Obtain host handle */ if (!(host = nlmsvc_lookup_host(rqstp)) - || (argp->monitor && !host->h_monitored && nsm_monitor(host) < 0)) + || (argp->monitor && nsm_monitor(host) < 0)) goto no_locks; *hostp = host;