Skip to content

Commit 7c7cb07

Browse files
J. Bruce Fieldsgregkh
authored andcommitted
nfsd: register pernet ops last, unregister first
[ Upstream commit bd5ae92 ] 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: Zhi Li <yieli@redhat.com> Fixes: 3ba7583 "nfsd4: drc containerization" Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b0363fa commit 7c7cb07

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎fs/nfsd/nfsctl.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,12 +1522,9 @@ static int __init init_nfsd(void)
15221522
int retval;
15231523
printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n");
15241524

1525-
retval = register_pernet_subsys(&nfsd_net_ops);
1526-
if (retval < 0)
1527-
return retval;
15281525
retval = register_cld_notifier();
15291526
if (retval)
1530-
goto out_unregister_pernet;
1527+
return retval;
15311528
retval = nfsd4_init_slabs();
15321529
if (retval)
15331530
goto out_unregister_notifier;
@@ -1544,9 +1541,14 @@ static int __init init_nfsd(void)
15441541
goto out_free_lockd;
15451542
retval = register_filesystem(&nfsd_fs_type);
15461543
if (retval)
1544+
goto out_free_exports;
1545+
retval = register_pernet_subsys(&nfsd_net_ops);
1546+
if (retval < 0)
15471547
goto out_free_all;
15481548
return 0;
15491549
out_free_all:
1550+
unregister_pernet_subsys(&nfsd_net_ops);
1551+
out_free_exports:
15501552
remove_proc_entry("fs/nfs/exports", NULL);
15511553
remove_proc_entry("fs/nfs", NULL);
15521554
out_free_lockd:
@@ -1559,13 +1561,12 @@ static int __init init_nfsd(void)
15591561
nfsd4_free_slabs();
15601562
out_unregister_notifier:
15611563
unregister_cld_notifier();
1562-
out_unregister_pernet:
1563-
unregister_pernet_subsys(&nfsd_net_ops);
15641564
return retval;
15651565
}
15661566

15671567
static void __exit exit_nfsd(void)
15681568
{
1569+
unregister_pernet_subsys(&nfsd_net_ops);
15691570
nfsd_drc_slab_free();
15701571
remove_proc_entry("fs/nfs/exports", NULL);
15711572
remove_proc_entry("fs/nfs", NULL);
@@ -1575,7 +1576,6 @@ static void __exit exit_nfsd(void)
15751576
nfsd4_exit_pnfs();
15761577
unregister_filesystem(&nfsd_fs_type);
15771578
unregister_cld_notifier();
1578-
unregister_pernet_subsys(&nfsd_net_ops);
15791579
}
15801580

15811581
MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>");

0 commit comments

Comments
 (0)