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

From: Trond Myklebust
Date: Tue Jan 23 2018 - 19:47:40 EST


On Tue, 2018-01-23 at 17:09 -0500, J. Bruce Fields wrote:
>
> The object still has useful information in it so we can't just
> reinitalize it completely. I guess we could make nlm_get_host do
>
> if (refcount_read(&host->h_count))
> refcount_inc(&host->h_count);
> else
> refcount_set(&host->h_count, 1);
>
> Or we could just change the code so the refcount is always 1 higher
> in
> the NFS server case, so "1" instead of "0" is used to mean "nobody's
> using this, you can garbage collect this", and then it won't go to 0
> until the garbage collector actually destroys it.
>
> This isn't an unusual pattern, what have other subsystems been doing?
>

Hi Bruce,

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.

What say we fix the issue with something like the following?

8<------------------------------------------------------------