FreeBSD/sys/fs/nfsserver/nfs_nfsdport.c
/*
 * Called once to initialize data structures...
 */
Called once to initialize data structures
Called once to initialize data structures
static int
nfsd_modevent(module_t mod, int type, void *data)
{
	int error = 0, i;
	static int loaded = 0;
	switch (type) {
	case MOD_LOAD:
		if (loaded)
			goto out;
		newnfs_portinit();
		for (i = 0; i < NFSRVCACHE_HASHSIZE; i++) {
			mtx_init(&nfsrchash_table[i].mtx, "nfsrtc", NULL,
			    MTX_DEF);
			mtx_init(&nfsrcahash_table[i].mtx, "nfsrtca", NULL,
			    MTX_DEF);
		}
		mtx_init(&nfsrc_udpmtx, "nfsuc", NULL, MTX_DEF);
		mtx_init(&nfs_v4root_mutex, "nfs4rt", NULL, MTX_DEF);
		mtx_init(&nfsv4root_mnt.mnt_mtx, "nfs4mnt", NULL, MTX_DEF);
		lockinit(&nfsv4root_mnt.mnt_explock, PVFS, "explock", 0, 0);
		nfsrvd_initcache();
		nfsd_init();
		NFSD_LOCK();
		nfsrvd_init(0);
		NFSD_UNLOCK();
		nfsd_mntinit();
#ifdef VV_DISABLEDELEG
		vn_deleg_ops.vndeleg_recall = nfsd_recalldelegation;
		vn_deleg_ops.vndeleg_disable = nfsd_disabledelegation;
#endif
		nfsd_call_servertimer = nfsrv_servertimer;
		nfsd_call_nfsd = nfssvc_nfsd;
		loaded = 1;
		break;
	case MOD_UNLOAD:
		if (newnfs_numnfsd != 0) {
			error = EBUSY;
			break;
		}
#ifdef VV_DISABLEDELEG
		vn_deleg_ops.vndeleg_recall = NULL;
		vn_deleg_ops.vndeleg_disable = NULL;
#endif
		nfsd_call_servertimer = NULL;
		nfsd_call_nfsd = NULL;
		nfsrv_throwawayallstate(curthread);
		nfsrvd_cleancache();
		if (nfsrvd_pool != NULL)
			svcpool_destroy(nfsrvd_pool);
		for (i = 0; i < NFSRVCACHE_HASHSIZE; i++) {
			mtx_destroy(&nfsrchash_table[i].mtx);
			mtx_destroy(&nfsrcahash_table[i].mtx);
		}
		mtx_destroy(&nfsrc_udpmtx);
		mtx_destroy(&nfs_v4root_mutex);
		mtx_destroy(&nfsv4root_mnt.mnt_mtx);
		for (i = 0; i < nfsrv_sessionhashsize; i++)
			mtx_destroy(&nfssessionhash[i].mtx);
		lockdestroy(&nfsv4root_mnt.mnt_explock);
		free(nfsclienthash, M_NFSDCLIENT);
		free(nfslockhash, M_NFSDLOCKFILE);
		free(nfssessionhash, M_NFSDSESSION);
		loaded = 0;
		break;
	default:
		error = EOPNOTSUPP;
		break;
	}
out:
	NFSEXITCODE(error);
	return (error);
}
static int nfsd_modevent ( module_t mod , int type , void * data ) { int error = 0 , i ; static int loaded = 0 ; switch ( type ) { case MOD_LOAD : if ( loaded ) goto out ; newnfs_portinit ( ) ; for ( i = 0 ; i < NFSRVCACHE_HASHSIZE ; i ++ ) { mtx_init ( & nfsrchash_table [ i ] . mtx , " " , NULL , MTX_DEF ) ; mtx_init ( & nfsrcahash_table [ i ] . mtx , " " , NULL , MTX_DEF ) ; } mtx_init ( & nfsrc_udpmtx , " " , NULL , MTX_DEF ) ; mtx_init ( & nfs_v4root_mutex , " " , NULL , MTX_DEF ) ; mtx_init ( & nfsv4root_mnt . mnt_mtx , " " , NULL , MTX_DEF ) ; lockinit ( & nfsv4root_mnt . mnt_explock , PVFS , " " , 0 , 0 ) ; nfsrvd_initcache ( ) ; nfsd_init ( ) ; NFSD_LOCK ( ) ; nfsrvd_init ( 0 ) ; NFSD_UNLOCK ( ) ; nfsd_mntinit ( ) ; #ifdef VV_DISABLEDELEG vn_deleg_ops . vndeleg_recall = nfsd_recalldelegation ; vn_deleg_ops . vndeleg_disable = nfsd_disabledelegation ; #endif nfsd_call_servertimer = nfsrv_servertimer ; nfsd_call_nfsd = nfssvc_nfsd ; loaded = 1 ; break ; case MOD_UNLOAD : if ( newnfs_numnfsd != 0 ) { error = EBUSY ; break ; } #ifdef VV_DISABLEDELEG vn_deleg_ops . vndeleg_recall = NULL ; vn_deleg_ops . vndeleg_disable = NULL ; #endif nfsd_call_servertimer = NULL ; nfsd_call_nfsd = NULL ; nfsrv_throwawayallstate ( curthread ) ; nfsrvd_cleancache ( ) ; if ( nfsrvd_pool != NULL ) svcpool_destroy ( nfsrvd_pool ) ; for ( i = 0 ; i < NFSRVCACHE_HASHSIZE ; i ++ ) { mtx_destroy ( & nfsrchash_table [ i ] . mtx ) ; mtx_destroy ( & nfsrcahash_table [ i ] . mtx ) ; } mtx_destroy ( & nfsrc_udpmtx ) ; mtx_destroy ( & nfs_v4root_mutex ) ; mtx_destroy ( & nfsv4root_mnt . mnt_mtx ) ; for ( i = 0 ; i < nfsrv_sessionhashsize ; i ++ ) mtx_destroy ( & nfssessionhash [ i ] . mtx ) ; lockdestroy ( & nfsv4root_mnt . mnt_explock ) ; free ( nfsclienthash , M_NFSDCLIENT ) ; free ( nfslockhash , M_NFSDLOCKFILE ) ; free ( nfssessionhash , M_NFSDSESSION ) ; loaded = 0 ; break ; default : error = EOPNOTSUPP ; break ; } out : NFSEXITCODE ( error ) ; return ( error ) ; }
Called once to initialize data structures...
Called once to initialize data structures ...
/* Clean out all NFSv4 state. */ /* Clean the NFS server reply cache */ /* Free up the krpc server pool. */ /* and get rid of the locks */