Commit bd5ae928 authored by J. Bruce Fields's avatar J. Bruce Fields Committed by Chuck Lever

nfsd: register pernet ops last, unregister first

These pernet operations may depend on stuff set up or torn down in the
module init/exit functions.  And they may be called at any time in
between.  So it makes more sense for them to be the last to be
registered in the init function, and the first to be unregistered in the
exit function.

In particular, without this, the drc slab is being destroyed before all
the per-net drcs are shut down, resulting in an "Objects remaining in
nfsd_drc on __kmem_cache_shutdown()" warning in exit_nfsd.
Reported-by: default avatarZhi Li <yieli@redhat.com>
Fixes: 3ba75830 "nfsd4: drc containerization"
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent f40ddce8
...@@ -1522,12 +1522,9 @@ static int __init init_nfsd(void) ...@@ -1522,12 +1522,9 @@ static int __init init_nfsd(void)
int retval; int retval;
printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n"); printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n");
retval = register_pernet_subsys(&nfsd_net_ops);
if (retval < 0)
return retval;
retval = register_cld_notifier(); retval = register_cld_notifier();
if (retval) if (retval)
goto out_unregister_pernet; return retval;
retval = nfsd4_init_slabs(); retval = nfsd4_init_slabs();
if (retval) if (retval)
goto out_unregister_notifier; goto out_unregister_notifier;
...@@ -1544,9 +1541,14 @@ static int __init init_nfsd(void) ...@@ -1544,9 +1541,14 @@ static int __init init_nfsd(void)
goto out_free_lockd; goto out_free_lockd;
retval = register_filesystem(&nfsd_fs_type); retval = register_filesystem(&nfsd_fs_type);
if (retval) if (retval)
goto out_free_exports;
retval = register_pernet_subsys(&nfsd_net_ops);
if (retval < 0)
goto out_free_all; goto out_free_all;
return 0; return 0;
out_free_all: out_free_all:
unregister_pernet_subsys(&nfsd_net_ops);
out_free_exports:
remove_proc_entry("fs/nfs/exports", NULL); remove_proc_entry("fs/nfs/exports", NULL);
remove_proc_entry("fs/nfs", NULL); remove_proc_entry("fs/nfs", NULL);
out_free_lockd: out_free_lockd:
...@@ -1559,13 +1561,12 @@ static int __init init_nfsd(void) ...@@ -1559,13 +1561,12 @@ static int __init init_nfsd(void)
nfsd4_free_slabs(); nfsd4_free_slabs();
out_unregister_notifier: out_unregister_notifier:
unregister_cld_notifier(); unregister_cld_notifier();
out_unregister_pernet:
unregister_pernet_subsys(&nfsd_net_ops);
return retval; return retval;
} }
static void __exit exit_nfsd(void) static void __exit exit_nfsd(void)
{ {
unregister_pernet_subsys(&nfsd_net_ops);
nfsd_drc_slab_free(); nfsd_drc_slab_free();
remove_proc_entry("fs/nfs/exports", NULL); remove_proc_entry("fs/nfs/exports", NULL);
remove_proc_entry("fs/nfs", NULL); remove_proc_entry("fs/nfs", NULL);
...@@ -1575,7 +1576,6 @@ static void __exit exit_nfsd(void) ...@@ -1575,7 +1576,6 @@ static void __exit exit_nfsd(void)
nfsd4_exit_pnfs(); nfsd4_exit_pnfs();
unregister_filesystem(&nfsd_fs_type); unregister_filesystem(&nfsd_fs_type);
unregister_cld_notifier(); unregister_cld_notifier();
unregister_pernet_subsys(&nfsd_net_ops);
} }
MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>"); MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment