Re: [PATCH 7/7] nfsd: filecache: give disposal lock a unique class name.

Chuck Lever
2025-01-27T14:29:53Z

On 1/26/25 8:20 PM, NeilBrown wrote:
> There are at least three locks in the kernel which are initialised as
>
> spin_Lock_init(&l->lock);
>
> This makes them hard to differential in /proc/lock_stat.
>
> For the lock in nfsd/filecache.c introduce a variable with a more
> descriptve name so we can:
>
> spin_lock_init(&nfsd_fcache_disposal->lock);
>
> and easily identify this in /proc/lock_stat.
>
> Signed-off-by: NeilBrown <neilb@suse.de>
> ---
> fs/nfsd/filecache.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
> index eb95a53f806f..af95bc381753 100644
> --- a/fs/nfsd/filecache.c
> +++ b/fs/nfsd/filecache.c
> @@ -867,12 +867,13 @@ __nfsd_file_cache_purge(struct net *net)
> static struct nfsd_fcache_disposal *
> nfsd_alloc_fcache_disposal(void)
> {
> - struct nfsd_fcache_disposal *l;
> + struct nfsd_fcache_disposal *l, *nfsd_fcache_disposal;
>
> l = kmalloc(sizeof(*l), GFP_KERNEL);
> if (!l)
> return NULL;
> - spin_lock_init(&l->lock);
> + nfsd_fcache_disposal = l;
> + spin_lock_init(&nfsd_fcache_disposal->lock);
> timer_setup(&l->timer, nfsd_file_gc_worker, 0);
> INIT_LIST_HEAD(&l->recent);
> INIT_LIST_HEAD(&l->older);

My concern was there would be multiple dynamically allocated locks
in order to make the locking fine-grained, but I guess that was a
mistaken assumption.

No objection to this approach.

--
Chuck Lever