diff --git a/sys/nfsserver/nfs.h b/sys/nfsserver/nfs.h index 262e7371a10f..5295b6900fcc 100644 --- a/sys/nfsserver/nfs.h +++ b/sys/nfsserver/nfs.h @@ -134,6 +134,7 @@ extern struct nfsrvstats nfsrvstats; extern int nfsrv_ticks; extern int nfsrvw_procrastinate; extern int nfsrvw_procrastinate_v3; +extern int nfsrv_numnfsd; /* Various values converted to XDR form. */ extern u_int32_t nfsrv_nfs_false, nfsrv_nfs_true, nfsrv_nfs_xdrneg1, diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c index 4146e730f99a..9da4b1a6843c 100644 --- a/sys/nfsserver/nfs_srvsubs.c +++ b/sys/nfsserver/nfs_srvsubs.c @@ -551,6 +551,8 @@ nfsrv_modevent(module_t mod, int type, void *data) break; case MOD_UNLOAD: + if (nfsrv_numnfsd != 0) + return EBUSY; callout_stop(&nfsrv_callout); sysent[SYS_nfssvc].sy_narg = nfs_prev_nfssvc_sy_narg; diff --git a/sys/nfsserver/nfs_syscalls.c b/sys/nfsserver/nfs_syscalls.c index e947ee62fc46..c3b097e3d7ba 100644 --- a/sys/nfsserver/nfs_syscalls.c +++ b/sys/nfsserver/nfs_syscalls.c @@ -86,7 +86,7 @@ MALLOC_DEFINE(M_NFSD, "NFS daemon", "Nfs server daemon structure"); SYSCTL_DECL(_vfs_nfsrv); int nfsd_waiting = 0; -static int nfs_numnfsd = 0; +int nfsrv_numnfsd = 0; static int notstarted = 1; static int nfs_privport = 0; @@ -304,7 +304,7 @@ nfssvc_nfsd(struct thread *td) s = splnet(); nfsd->nfsd_td = td; TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain); - nfs_numnfsd++; + nfsrv_numnfsd++; /* * Loop getting rpc requests until SIGKILL. @@ -533,7 +533,7 @@ nfssvc_nfsd(struct thread *td) TAILQ_REMOVE(&nfsd_head, nfsd, nfsd_chain); splx(s); free((caddr_t)nfsd, M_NFSD); - if (--nfs_numnfsd == 0) + if (--nfsrv_numnfsd == 0) nfsrv_init(TRUE); /* Reinitialize everything */ return (error); }