Re: [PATCH 1/4] lockd: convert nlm_host.h_count from atomic_t to refcount_t

From: J. Bruce Fields
Date: Wed Jan 24 2018 - 16:09:56 EST


On Tue, Jan 23, 2018 at 07:47:31PM -0500, Trond Myklebust wrote:
> Sorry I forgot about the issues with the server garbage collector, and
> I applied these patches to my linux-next a couple of weeks ago.

Whoops, OK, so who's taking those patches anyway?

> What say we fix the issue with something like the following?
...
> @@ -662,8 +664,7 @@ nlm_gc_hosts(struct net *net)
> for_each_host_safe(host, next, chain, nlm_server_hosts) {
> if (net && host->net != net)
> continue;
> - if (refcount_read(&host->h_count) || host->h_inuse
> - || time_before(jiffies, host->h_expires)) {
> + if (host->h_inuse || time_before(jiffies, host->h_expires)) {

Can you really just drop the h_count check?

Oh, I see:

> @@ -671,7 +672,8 @@ nlm_gc_hosts(struct net *net)
> host->net->ns.inum);
> continue;
> }
> - nlm_destroy_host_locked(host);
> + if (refcount_dec_if_one(&host->h_count))
> + nlm_destroy_host_locked(host);

So this is check that replaces it.

Makes sense to me, thanks. ACK to the patch.

--b.

> }
>
> if (net) {
> --
> 2.14.3
>
> --
> Trond Myklebust
> Linux NFS client maintainer, PrimaryData
> trond.myklebust@xxxxxxxxxxxxxxx