Skip to content

Commit caa4e76

Browse files
Stanislav KinsburskyJ. Bruce Fields
authored andcommitted
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>
1 parent 3cf7fb0 commit caa4e76

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎fs/lockd/host.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ static struct nlm_host *nlm_alloc_host(struct nlm_lookup_host_info *ni,
173173
static void nlm_destroy_host_locked(struct nlm_host *host)
174174
{
175175
struct rpc_clnt *clnt;
176+
struct lockd_net *ln = net_generic(host->net, lockd_net_id);
176177

177178
dprintk("lockd: destroy host %s\n", host->h_name);
178179

@@ -189,6 +190,7 @@ static void nlm_destroy_host_locked(struct nlm_host *host)
189190
rpc_shutdown_client(clnt);
190191
kfree(host);
191192

193+
ln->nrhosts--;
192194
nrhosts--;
193195
}
194196

@@ -229,6 +231,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
229231
struct hlist_node *pos;
230232
struct nlm_host *host;
231233
struct nsm_handle *nsm = NULL;
234+
struct lockd_net *ln = net_generic(net, lockd_net_id);
232235

233236
dprintk("lockd: %s(host='%s', vers=%u, proto=%s)\n", __func__,
234237
(hostname ? hostname : "<none>"), version,
@@ -263,6 +266,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
263266
goto out;
264267

265268
hlist_add_head(&host->h_hash, chain);
269+
ln->nrhosts++;
266270
nrhosts++;
267271

268272
dprintk("lockd: %s created host %s (%s)\n", __func__,
@@ -384,6 +388,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
384388
memcpy(nlm_srcaddr(host), src_sap, src_len);
385389
host->h_srcaddrlen = src_len;
386390
hlist_add_head(&host->h_hash, chain);
391+
ln->nrhosts++;
387392
nrhosts++;
388393

389394
dprintk("lockd: %s created host %s (%s)\n",
@@ -592,6 +597,19 @@ nlm_shutdown_hosts_net(struct net *net)
592597
/* Then, perform a garbage collection pass */
593598
nlm_gc_hosts(net);
594599
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+
}
595613
}
596614

597615
/*

‎fs/lockd/netns.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
struct lockd_net {
77
unsigned int nlmsvc_users;
88
unsigned long next_gc;
9+
unsigned long nrhosts;
910
};
1011

1112
extern int lockd_net_id;

0 commit comments

Comments
 (0)