aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2012-07-25 08:56:19 -0400
committerJ. Bruce Fields <bfields@redhat.com>2012-07-27 16:48:43 -0400
commitcaa4e76b6f284bab535a98fd37b9c46856158bcb (patch)
tree8f627e46f3dce4257dd3fe261c53e1fd2d915673 /fs/lockd
parent3cf7fb07e077e599d8343113cf4ef81adb2ca627 (diff)
LockD: manage used host count per networks namespace
This patch introduces moves nrhosts in per-net data. It also adds kernel warning to nlm_shutdown_hosts_net() about remaining hosts in specified network namespace context. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/lockd')
-rw-r--r--fs/lockd/host.c18
-rw-r--r--fs/lockd/netns.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 3636734fe2ba..6c56090ca531 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -173,6 +173,7 @@ out:
173static void nlm_destroy_host_locked(struct nlm_host *host) 173static void nlm_destroy_host_locked(struct nlm_host *host)
174{ 174{
175 struct rpc_clnt *clnt; 175 struct rpc_clnt *clnt;
176 struct lockd_net *ln = net_generic(host->net, lockd_net_id);
176 177
177 dprintk("lockd: destroy host %s\n", host->h_name); 178 dprintk("lockd: destroy host %s\n", host->h_name);
178 179
@@ -189,6 +190,7 @@ static void nlm_destroy_host_locked(struct nlm_host *host)
189 rpc_shutdown_client(clnt); 190 rpc_shutdown_client(clnt);
190 kfree(host); 191 kfree(host);
191 192
193 ln->nrhosts--;
192 nrhosts--; 194 nrhosts--;
193} 195}
194 196
@@ -229,6 +231,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
229 struct hlist_node *pos; 231 struct hlist_node *pos;
230 struct nlm_host *host; 232 struct nlm_host *host;
231 struct nsm_handle *nsm = NULL; 233 struct nsm_handle *nsm = NULL;
234 struct lockd_net *ln = net_generic(net, lockd_net_id);
232 235
233 dprintk("lockd: %s(host='%s', vers=%u, proto=%s)\n", __func__, 236 dprintk("lockd: %s(host='%s', vers=%u, proto=%s)\n", __func__,
234 (hostname ? hostname : "<none>"), version, 237 (hostname ? hostname : "<none>"), version,
@@ -263,6 +266,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
263 goto out; 266 goto out;
264 267
265 hlist_add_head(&host->h_hash, chain); 268 hlist_add_head(&host->h_hash, chain);
269 ln->nrhosts++;
266 nrhosts++; 270 nrhosts++;
267 271
268 dprintk("lockd: %s created host %s (%s)\n", __func__, 272 dprintk("lockd: %s created host %s (%s)\n", __func__,
@@ -384,6 +388,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
384 memcpy(nlm_srcaddr(host), src_sap, src_len); 388 memcpy(nlm_srcaddr(host), src_sap, src_len);
385 host->h_srcaddrlen = src_len; 389 host->h_srcaddrlen = src_len;
386 hlist_add_head(&host->h_hash, chain); 390 hlist_add_head(&host->h_hash, chain);
391 ln->nrhosts++;
387 nrhosts++; 392 nrhosts++;
388 393
389 dprintk("lockd: %s created host %s (%s)\n", 394 dprintk("lockd: %s created host %s (%s)\n",
@@ -592,6 +597,19 @@ nlm_shutdown_hosts_net(struct net *net)
592 /* Then, perform a garbage collection pass */ 597 /* Then, perform a garbage collection pass */
593 nlm_gc_hosts(net); 598 nlm_gc_hosts(net);
594 mutex_unlock(&nlm_host_mutex); 599 mutex_unlock(&nlm_host_mutex);
600
601 /* complain if any hosts are left */
602 if (net) {
603 struct lockd_net *ln = net_generic(net, lockd_net_id);
604
605 printk(KERN_WARNING "lockd: couldn't shutdown host module for net %p!\n", net);
606 dprintk("lockd: %lu hosts left in net %p:\n", ln->nrhosts, net);
607 for_each_host(host, pos, chain, nlm_server_hosts) {
608 dprintk(" %s (cnt %d use %d exp %ld net %p)\n",
609 host->h_name, atomic_read(&host->h_count),
610 host->h_inuse, host->h_expires, host->net);
611 }
612 }
595} 613}
596 614
597/* 615/*
diff --git a/fs/lockd/netns.h b/fs/lockd/netns.h
index 97c6c771133f..44c8f0b9230a 100644
--- a/fs/lockd/netns.h
+++ b/fs/lockd/netns.h
@@ -6,6 +6,7 @@
6struct lockd_net { 6struct lockd_net {
7 unsigned int nlmsvc_users; 7 unsigned int nlmsvc_users;
8 unsigned long next_gc; 8 unsigned long next_gc;
9 unsigned long nrhosts;
9}; 10};
10 11
11extern int lockd_net_id; 12extern int lockd_net_id;