nfsd: add nfsd_serv_try_get and nfsd_serv_put
authorMike Snitzer <snitzer@kernel.org>
Thu, 5 Sep 2024 19:09:44 +0000 (15:09 -0400)
committerAnna Schumaker <anna.schumaker@oracle.com>
Mon, 23 Sep 2024 19:03:30 +0000 (15:03 -0400)
commit47e988147f409f70e0f01a5e6dc5940375e02343
treeb164422c4d8f3cfe7aeaadeaefe1880a86a04f71
parentc63f0e48febfaea8a3cd4146abda9cc7a329b0e3
nfsd: add nfsd_serv_try_get and nfsd_serv_put

Introduce nfsd_serv_try_get and nfsd_serv_put and update the nfsd code
to prevent nfsd_destroy_serv from destroying nn->nfsd_serv until any
caller of nfsd_serv_try_get releases their reference using nfsd_serv_put.

A percpu_ref is used to implement the interlock between
nfsd_destroy_serv and any caller of nfsd_serv_try_get.

This interlock is needed to properly wait for the completion of client
initiated localio calls to nfsd (that are _not_ in the context of nfsd).

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: NeilBrown <neilb@suse.de>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
fs/nfsd/netns.h
fs/nfsd/nfssvc.c