mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-17 10:26:09 +00:00
lockd: Fix server refcounting
The server shouldn't actually delete the struct nlm_host until it hits the garbage collector. In order to make that work correctly with the refcount API, we can bump the refcount by one, and then use refcount_dec_if_one() in the garbage collector. Signed-off-by: Trond Myklebust <trondmy@gmail.com> Acked-by: J. Bruce Fields <bfields@fieldses.org>
This commit is contained in:
parent
8f39fce84a
commit
535cb8f319
@ -388,6 +388,8 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
|
|||||||
ln->nrhosts++;
|
ln->nrhosts++;
|
||||||
nrhosts++;
|
nrhosts++;
|
||||||
|
|
||||||
|
refcount_inc(&host->h_count);
|
||||||
|
|
||||||
dprintk("lockd: %s created host %s (%s)\n",
|
dprintk("lockd: %s created host %s (%s)\n",
|
||||||
__func__, host->h_name, host->h_addrbuf);
|
__func__, host->h_name, host->h_addrbuf);
|
||||||
|
|
||||||
@ -662,8 +664,7 @@ nlm_gc_hosts(struct net *net)
|
|||||||
for_each_host_safe(host, next, chain, nlm_server_hosts) {
|
for_each_host_safe(host, next, chain, nlm_server_hosts) {
|
||||||
if (net && host->net != net)
|
if (net && host->net != net)
|
||||||
continue;
|
continue;
|
||||||
if (refcount_read(&host->h_count) || host->h_inuse
|
if (host->h_inuse || time_before(jiffies, host->h_expires)) {
|
||||||
|| time_before(jiffies, host->h_expires)) {
|
|
||||||
dprintk("nlm_gc_hosts skipping %s "
|
dprintk("nlm_gc_hosts skipping %s "
|
||||||
"(cnt %d use %d exp %ld net %x)\n",
|
"(cnt %d use %d exp %ld net %x)\n",
|
||||||
host->h_name, refcount_read(&host->h_count),
|
host->h_name, refcount_read(&host->h_count),
|
||||||
@ -671,6 +672,7 @@ nlm_gc_hosts(struct net *net)
|
|||||||
host->net->ns.inum);
|
host->net->ns.inum);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (refcount_dec_if_one(&host->h_count))
|
||||||
nlm_destroy_host_locked(host);
|
nlm_destroy_host_locked(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user