[PATCH] knfsd: hide use of lockd's h_monitored flag
This patch moves all checks of the h_monitored flag into the nsm_monitor/unmonitor functions. A subsequent patch will replace the mechanism by which we mark a host as being monitored. There is still one occurence of h_monitored outside of mon.c and that is in clntlock.c where we respond to a reboot. The subsequent patch will modify this too. 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>
This commit is contained in:
parent
7b2b1fee30
commit
977faf392f
5 changed files with 20 additions and 12 deletions
|
@ -499,7 +499,7 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
|
||||||
unsigned char fl_flags = fl->fl_flags;
|
unsigned char fl_flags = fl->fl_flags;
|
||||||
int status = -ENOLCK;
|
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",
|
printk(KERN_NOTICE "lockd: failed to monitor %s\n",
|
||||||
host->h_name);
|
host->h_name);
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -331,9 +331,12 @@ nlm_gc_hosts(void)
|
||||||
}
|
}
|
||||||
dprintk("lockd: delete host %s\n", host->h_name);
|
dprintk("lockd: delete host %s\n", host->h_name);
|
||||||
*q = host->h_next;
|
*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 ((clnt = host->h_rpcclnt) != NULL) {
|
||||||
if (atomic_read(&clnt->cl_users)) {
|
if (atomic_read(&clnt->cl_users)) {
|
||||||
printk(KERN_WARNING
|
printk(KERN_WARNING
|
||||||
|
|
|
@ -74,6 +74,8 @@ nsm_monitor(struct nlm_host *host)
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
dprintk("lockd: nsm_monitor(%s)\n", host->h_name);
|
dprintk("lockd: nsm_monitor(%s)\n", host->h_name);
|
||||||
|
if (host->h_monitored)
|
||||||
|
return 0;
|
||||||
|
|
||||||
status = nsm_mon_unmon(host, SM_MON, &res);
|
status = nsm_mon_unmon(host, SM_MON, &res);
|
||||||
|
|
||||||
|
@ -91,15 +93,18 @@ int
|
||||||
nsm_unmonitor(struct nlm_host *host)
|
nsm_unmonitor(struct nlm_host *host)
|
||||||
{
|
{
|
||||||
struct nsm_res res;
|
struct nsm_res res;
|
||||||
int status;
|
int status = 0;
|
||||||
|
|
||||||
dprintk("lockd: nsm_unmonitor(%s)\n", host->h_name);
|
dprintk("lockd: nsm_unmonitor(%s)\n", host->h_name);
|
||||||
|
if (!host->h_monitored)
|
||||||
|
return 0;
|
||||||
|
host->h_monitored = 0;
|
||||||
|
|
||||||
status = nsm_mon_unmon(host, SM_UNMON, &res);
|
if (!host->h_killed) {
|
||||||
if (status < 0)
|
status = nsm_mon_unmon(host, SM_UNMON, &res);
|
||||||
printk(KERN_NOTICE "lockd: cannot unmonitor %s\n", host->h_name);
|
if (status < 0)
|
||||||
else
|
printk(KERN_NOTICE "lockd: cannot unmonitor %s\n", host->h_name);
|
||||||
host->h_monitored = 0;
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||||
|
|
||||||
/* Obtain host handle */
|
/* Obtain host handle */
|
||||||
if (!(host = nlmsvc_lookup_host(rqstp))
|
if (!(host = nlmsvc_lookup_host(rqstp))
|
||||||
|| (argp->monitor && !host->h_monitored && nsm_monitor(host) < 0))
|
|| (argp->monitor && nsm_monitor(host) < 0))
|
||||||
goto no_locks;
|
goto no_locks;
|
||||||
*hostp = host;
|
*hostp = host;
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||||
|
|
||||||
/* Obtain host handle */
|
/* Obtain host handle */
|
||||||
if (!(host = nlmsvc_lookup_host(rqstp))
|
if (!(host = nlmsvc_lookup_host(rqstp))
|
||||||
|| (argp->monitor && !host->h_monitored && nsm_monitor(host) < 0))
|
|| (argp->monitor && nsm_monitor(host) < 0))
|
||||||
goto no_locks;
|
goto no_locks;
|
||||||
*hostp = host;
|
*hostp = host;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue