Commit f96e7cb1 authored by Neil Brown's avatar Neil Brown Committed by David S. Miller

[PATCH] kNFSd 2: Lockd to shutdown without engaging with nfsd

Currently, when lockd wants to invalidate all it's
clients, it asks nfsd to iterate through them.  Now
it iterates itself.
parent 0ec2ca38
......@@ -159,6 +159,30 @@ nlm_lookup_host(struct svc_client *clnt, struct sockaddr_in *sin,
return host;
}
struct nlm_host *
nlm_find_client(void)
{
/* find a nlm_host for a client for which h_killed == 0.
* and return it
*/
int hash;
down(&nlm_host_sema);
for (hash = 0 ; hash < NLM_HOST_NRHASH; hash++) {
struct nlm_host *host, **hp;
for (hp = &nlm_hosts[hash]; (host = *hp) ; hp = &host->h_next) {
if (host->h_exportent != NULL &&
host->h_killed == 0) {
nlm_get_host(host);
up(&nlm_host_sema);
return host;
}
}
}
up(&nlm_host_sema);
return NULL;
}
/*
* Create the NLM RPC client for an NLM peer
*/
......
......@@ -130,7 +130,7 @@ lockd(struct svc_rqst *rqstp)
flush_signals(current);
spin_unlock_irq(&current->sigmask_lock);
if (nlmsvc_ops) {
nlmsvc_ops->detach();
nlmsvc_invalidate_all();
grace_period_expire = set_grace_period();
}
}
......@@ -187,7 +187,7 @@ lockd(struct svc_rqst *rqstp)
*/
if (!nlmsvc_pid || current->pid == nlmsvc_pid) {
if (nlmsvc_ops)
nlmsvc_ops->detach();
nlmsvc_invalidate_all();
nlm_shutdown_hosts();
nlmsvc_pid = 0;
} else
......
......@@ -309,3 +309,18 @@ nlmsvc_invalidate_client(struct svc_client *clnt)
nlm_release_host(host);
}
}
/*
* delete all hosts structs for clients
*/
void
nlmsvc_invalidate_all(void)
{
struct nlm_host *host;
while ((host = nlm_find_client()) != NULL) {
nlmsvc_free_host_resources(host);
host->h_expires = 0;
host->h_killed = 1;
nlm_release_host(host);
}
}
......@@ -877,18 +877,6 @@ exp_unhashclient(svc_client *clp)
kfree (ch[i]);
}
/*
* Lockd is shutting down and tells us to unregister all clients
*/
void
exp_nlmdetach(void)
{
struct svc_client *clp;
for (clp = clients; clp; clp = clp->cl_next)
nfsd_lockd_unexport(clp);
}
/*
* Verify that string is non-empty and does not exceed max length.
*/
......
......@@ -66,7 +66,6 @@ struct nlmsvc_binding nfsd_nlm_ops = {
.exp_getclient = exp_getclient, /* look up NFS client */
.fopen = nlm_fopen, /* open file for locking */
.fclose = nlm_fclose, /* close file */
.detach = exp_nlmdetach, /* lockd shutdown notification */
};
/*
......
......@@ -26,7 +26,6 @@ struct nlmsvc_binding {
struct nfs_fh *,
struct file *);
void (*fclose)(struct file *);
void (*detach)(void);
};
extern struct nlmsvc_binding * nlmsvc_ops;
......
......@@ -150,6 +150,8 @@ void nlm_rebind_host(struct nlm_host *);
struct nlm_host * nlm_get_host(struct nlm_host *);
void nlm_release_host(struct nlm_host *);
void nlm_shutdown_hosts(void);
extern struct nlm_host *nlm_find_client(void);
/*
* Server-side lock handling
......@@ -173,6 +175,7 @@ u32 nlm_lookup_file(struct svc_rqst *, struct nlm_file **,
void nlm_release_file(struct nlm_file *);
void nlmsvc_mark_resources(void);
void nlmsvc_free_host_resources(struct nlm_host *);
void nlmsvc_invalidate_all(void);
static __inline__ struct inode *
nlmsvc_file_inode(struct nlm_file *file)
......
......@@ -102,7 +102,6 @@ struct svc_export * exp_get_by_name(struct svc_client *clp,
int exp_rootfh(struct svc_client *,
char *path, struct knfsd_fh *, int maxsize);
int nfserrno(int errno);
void exp_nlmdetach(void);
#endif /* __KERNEL__ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment