When testing NFS in different network namespace with stable-3.4, the situation start NFSd in one non init_net network namespace, and stop it in another one will trigger kernel panic, because RPCBIND client is stored per net, and will be NULL on NFSd shutdown. Walk through the code, this problem also exists in stable-3.5 to stable-3.7. Stanislav Kinsbursky had committed a fixed patch for 3.8: commit f7fb86c6e639360ad9c253cec534819ef928a674 (nfsd: use "init_net" for portmapper). But it causes another bug, When starting NFSd in a non init_net network namespace will trigger kernel panic. Because RPCBIND client will be NULL when register RPC service with the local portmapper in svc_addsock(). This new bug also exists in 3.8, but disappears after patch commit 11f779421a39b86da8a523d97e5fd3477878d44f ("containerize NFSd filesystem") in 3.9. So backport Stanislav's patches from 3.8 to fix the former bug and cleanup init_net reference, and then using the current->nsproxy->net_ns to repalce the init_net to make NFSd keep using a consistent network namespace all the time to resolve the new bug. After this patchset, testing NFS in different network namespace will not trigger kernel panic any more, and other NFS client can use the NFS server's shared files normally which was started in init_net namespace: # ip netns add test # ip netns list test # ip netns exec test service nfsserver start Starting kernel based NFS server: idmapd mountd statd nfsd sm-notify done # service nfsserver status Checking for kernel based NFS server: idmapd running mountd running statd running nfsd running sles28:~ # # service nfsserver stop Shutting down kernel based NFS server: nfsd statd mountd idmapd done # service nfsserver status Checking for kernel based NFS server: idmapd unused mountd unused statd unused nfsd unused # dmesg [ 74.505511] eth0: no IPv6 routers present [ 99.412867] RPC: Registered named UNIX socket transport module. [ 99.412871] RPC: Registered udp transport module. [ 99.412873] RPC: Registered tcp transport module. [ 99.412875] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 99.637872] Installing knfsd (copyright (C) 1996 okir@xxxxxxxxxxxx). [ 100.055152] NFSD: Using /var/lib/nfs/v4recovery as the NFSv4 state recovery directory [ 100.058699] NFSD: starting 90-second grace period [ 129.449088] nfsd: last server has exited, flushing export cache Stanislav Kinsbursky (8): nfsd: use "init_net" for portmapper nfsd: pass net to nfsd_init_socks() nfsd: pass net to nfsd_startup() and nfsd_shutdown() nfsd: pass net to nfsd_create_serv() nfsd: pass net to nfsd_svc() nfsd: pass net to nfsd_set_nrthreads() nfsd: pass net to __write_ports() and down nfsd: pass proper net to nfsd_destroy() from NFSd kthreads Weng Meiling (1): nfsd: use the current net ns in write_threads() and write_ports() fs/nfsd/nfsctl.c | 34 +++++++++++++++++++--------------- fs/nfsd/nfsd.h | 6 +++--- fs/nfsd/nfssvc.c | 40 +++++++++++++++++++--------------------- 3 files changed, 41 insertions(+), 39 deletions(-) -- 1.8.2.2 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html