Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lockd: hold a reference to nlmsvc_serv while stopping the thread.

Both nfsd and nfsv4-callback take a temporary reference to the svc_serv
while calling svc_set_num_threads() to stop the last thread. lockd does
not.

This extra reference prevents the scv_serv from being freed when the
last thread drops its reference count. This is not currently needed
for lockd as the svc_serv is not accessed after the last thread is told
to exit.

However a future patch will require svc_exit_thread() to access the
svc_serv after the svc_put() so it will need the code that calls
svc_set_num_threads() to keep a reference and keep the svc_serv active.

So copy the pattern from nfsd and nfsv4-cb to lockd, and take a
reference around svc_set_num_threads(.., 0)

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Tested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

authored by

NeilBrown and committed by
Chuck Lever
f4578ba1 063ab935

+2
+2
fs/lockd/svc.c
··· 373 373 unregister_inet6addr_notifier(&lockd_inet6addr_notifier); 374 374 #endif 375 375 376 + svc_get(nlmsvc_serv); 376 377 svc_set_num_threads(nlmsvc_serv, NULL, 0); 378 + svc_put(nlmsvc_serv); 377 379 timer_delete_sync(&nlmsvc_retry); 378 380 nlmsvc_serv = NULL; 379 381 dprintk("lockd_down: service destroyed\n");