NFSD: register/unregister of nfsd-client shrinker at nfsd startup/shutdown time
authorDai Ngo <dai.ngo@oracle.com>
Wed, 11 Jan 2023 20:17:09 +0000 (12:17 -0800)
committerChuck Lever <chuck.lever@oracle.com>
Thu, 12 Jan 2023 02:32:05 +0000 (21:32 -0500)
commitf385f7d244134246f984975ed34cd75f77de479f
tree41bf50360fc39545f6b62b58fcadeed4e04a0670
parente6cf91b7b47ff82b624bdfe2fdcde32bb52e71dd
NFSD: register/unregister of nfsd-client shrinker at nfsd startup/shutdown time

Currently the nfsd-client shrinker is registered and unregistered at
the time the nfsd module is loaded and unloaded. The problem with this
is the shrinker is being registered before all of the relevant fields
in nfsd_net are initialized when nfsd is started. This can lead to an
oops when memory is low and the shrinker is called while nfsd is not
running.

This patch moves the  register/unregister of nfsd-client shrinker from
module load/unload time to nfsd startup/shutdown time.

Fixes: 44df6f439a17 ("NFSD: add delegation reaper to react to low memory condition")
Reported-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4state.c
fs/nfsd/nfsctl.c
fs/nfsd/nfsd.h