Skip to content

Commit 3cf7fb0

Browse files
Stanislav KinsburskyJ. Bruce Fields
authored andcommitted
LockD: manage garbage collection timeout per networks namespace
This patch moves next_gc to per-net data. Note: passed network can be NULL (when Lockd kthread is exiting of Lockd module is removing). Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 27adadd commit 3cf7fb0

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎fs/lockd/host.c‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#include <net/ipv6.h>
2323

24+
#include "netns.h"
25+
2426
#define NLMDBG_FACILITY NLMDBG_HOSTCACHE
2527
#define NLM_HOST_NRHASH 32
2628
#define NLM_HOST_REBIND (60 * HZ)
@@ -41,7 +43,6 @@ static struct hlist_head nlm_client_hosts[NLM_HOST_NRHASH];
4143
hlist_for_each_entry_safe((host), (pos), (next), \
4244
(chain), h_hash)
4345

44-
static unsigned long next_gc;
4546
static unsigned long nrhosts;
4647
static DEFINE_MUTEX(nlm_host_mutex);
4748

@@ -337,14 +338,15 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
337338
.hostname_len = hostname_len,
338339
.net = net,
339340
};
341+
struct lockd_net *ln = net_generic(net, lockd_net_id);
340342

341343
dprintk("lockd: %s(host='%*s', vers=%u, proto=%s)\n", __func__,
342344
(int)hostname_len, hostname, rqstp->rq_vers,
343345
(rqstp->rq_prot == IPPROTO_UDP ? "udp" : "tcp"));
344346

345347
mutex_lock(&nlm_host_mutex);
346348

347-
if (time_after_eq(jiffies, next_gc))
349+
if (time_after_eq(jiffies, ln->next_gc))
348350
nlm_gc_hosts(net);
349351

350352
chain = &nlm_server_hosts[nlm_hash_address(ni.sap)];
@@ -653,5 +655,9 @@ nlm_gc_hosts(struct net *net)
653655
nlm_destroy_host_locked(host);
654656
}
655657

656-
next_gc = jiffies + NLM_HOST_COLLECT;
658+
if (net) {
659+
struct lockd_net *ln = net_generic(net, lockd_net_id);
660+
661+
ln->next_gc = jiffies + NLM_HOST_COLLECT;
662+
}
657663
}

‎fs/lockd/netns.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
struct lockd_net {
77
unsigned int nlmsvc_users;
8+
unsigned long next_gc;
89
};
910

1011
extern int lockd_net_id;

0 commit comments

Comments
 (0)