Home | History | Annotate | Download | only in nfs
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License (the "License").
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets "[]" replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 /*
     22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     23  * Use is subject to license terms.
     24  */
     25 
     26 #ifndef _NFS_SERV_INST_H
     27 #define	_NFS_SERV_INST_H
     28 
     29 #include <sys/door.h>
     30 
     31 #ifdef	__cplusplus
     32 extern "C" {
     33 #endif
     34 
     35 /*
     36  * rfs4_deleg_policy is used to signify the server's delegation
     37  * policy.  The disable/enable delegation functions are used to
     38  * eliminate a race with exclusive creates.
     39  */
     40 typedef enum {
     41 	SRV_NEVER_DELEGATE = 0,
     42 	SRV_NORMAL_DELEGATE = 1
     43 } srv_deleg_policy_t;
     44 
     45 /*
     46  * list of all occurrences of NFS Server stateStore.
     47  */
     48 extern  list_t    nsi_head;
     49 extern  krwlock_t nsi_lock;
     50 
     51 struct rfs4_state;
     52 struct rfs4_client;
     53 
     54 /*
     55  * max size of the server instance name
     56  */
     57 #define	NFS_INST_NAMESZ 	15
     58 
     59 /*
     60  * The server instance inst_flags flag bits::
     61  */
     62 #define	NFS_INST_STORE_INIT	0x00000001
     63 #define	NFS_INST_SS_ENABLED	0x00000002
     64 #define	NFS_INST_TERMINUS	0x00000004
     65 
     66 /*
     67  * The server instance capabilities
     68  */
     69 #define	NFS_INST_v40		0x00010000
     70 #define	NFS_INST_v41		0x00020000
     71 #define	NFS_INST_DS		0x00040000
     72 
     73 /*
     74  * NFS stateStore instances.
     75  */
     76 typedef struct nfs_server_instance {
     77 	list_node_t	nsi_list;
     78 	struct rfs4_database	*state_store;
     79 	callb_id_t	cpr_id;
     80 
     81 	char		inst_name[NFS_INST_NAMESZ];
     82 
     83 	/* inst_flags is protected via state_lock */
     84 	uint32_t	inst_flags;
     85 
     86 	time_t		start_time;
     87 	int		reap_time;
     88 	sysid_t		lockt_sysid;
     89 	u_longlong_t	caller_id;	/* for caller context */
     90 	uint_t		vkey;		/* for VSD */
     91 
     92 	krwlock_t	reclaimlst_lock;
     93 	time_t		gstart_time;
     94 	time_t		grace_period;
     95 	time_t		lease_period;
     96 
     97 	list_t 		reclaim_head;
     98 	uint_t		reclaim_cnt;
     99 
    100 	door_handle_t	dh;
    101 
    102 	int		seen_first_compound;
    103 
    104 	verifier4	Write4verf;
    105 	verifier4	Readdir4verf;
    106 
    107 	kmutex_t	state_lock;
    108 
    109 	time_t		file_cache_time;
    110 	krwlock_t	findclient_lock;
    111 	rfs4_table_t	*file_tab;
    112 	rfs4_index_t	*file_idx;
    113 
    114 	time_t	client_cache_time;
    115 	rfs4_table_t	*client_tab;
    116 	rfs4_index_t	*clientid_idx;
    117 	rfs4_index_t	*nfsclnt_idx;
    118 
    119 	time_t	openowner_cache_time;
    120 	rfs4_table_t	*openowner_tab;
    121 	rfs4_index_t	*openowner_idx;
    122 
    123 	time_t	state_cache_time;
    124 	rfs4_table_t	*state_tab;
    125 	rfs4_index_t	*state_idx;
    126 	rfs4_index_t	*state_owner_file_idx;
    127 	rfs4_index_t	*state_file_idx;
    128 
    129 	time_t	lo_state_cache_time;
    130 	rfs4_table_t	*lo_state_tab;
    131 	rfs4_index_t	*lo_state_idx;
    132 	rfs4_index_t	*lo_state_owner_idx;
    133 
    134 	time_t	lockowner_cache_time;
    135 	rfs4_table_t	*lockowner_tab;
    136 	rfs4_index_t	*lockowner_idx;
    137 	rfs4_index_t	*lockowner_pid_idx;
    138 
    139 	time_t	deleg_state_cache_time;
    140 	rfs4_table_t	*deleg_state_tab;
    141 	rfs4_index_t	*deleg_idx;
    142 	rfs4_index_t	*deleg_state_idx;
    143 
    144 	/* XXX: rbg, should move the inst_flags  */
    145 	int		deleg_disabled;
    146 	kmutex_t	deleg_lock;
    147 	krwlock_t	deleg_policy_lock;
    148 	srv_deleg_policy_t	deleg_policy;
    149 
    150 	int		deleg_wlp;
    151 
    152 	rfs4_cbstate_t	(*deleg_cbcheck)(struct rfs4_state *);
    153 	void	(*deleg_cbrecall)(struct rfs4_deleg_state *, bool_t);
    154 	void	(*exi_clean_func)(struct nfs_server_instance *,
    155 	    struct exportinfo *);
    156 	void	(*clnt_clear)(struct rfs4_client *);
    157 
    158 	krwlock_t	findsession_lock;
    159 	rfs4_table_t	*mds_session_tab;
    160 	rfs4_index_t	*mds_session_idx;
    161 	rfs4_index_t	*mds_sess_clientid_idx;
    162 
    163 	rfs4_table_t	*mds_pool_info_tab;
    164 	rfs4_index_t	*mds_pool_info_idx;
    165 	krwlock_t	mds_pool_info_lock;
    166 
    167 	krwlock_t	mds_layout_lock;
    168 	rfs4_table_t	*mds_layout_tab;
    169 	rfs4_index_t	*mds_layout_idx;
    170 	rfs4_index_t	*mds_layout_ID_idx;
    171 
    172 	/*
    173 	 * XXX: Need to track the default ID
    174 	 * until the SMF code is added.
    175 	 */
    176 	int		mds_layout_default_idx;
    177 
    178 	krwlock_t	mds_layout_grant_lock;
    179 	rfs4_table_t	*mds_layout_grant_tab;
    180 	rfs4_index_t	*mds_layout_grant_idx;
    181 	rfs4_index_t	*mds_layout_grant_ID_idx;
    182 
    183 	krwlock_t	mds_ever_grant_lock;
    184 	rfs4_table_t	*mds_ever_grant_tab;
    185 	rfs4_index_t	*mds_ever_grant_idx;
    186 	rfs4_index_t	*mds_ever_grant_fsid_idx;
    187 
    188 	krwlock_t	mds_mpd_lock;
    189 	rfs4_table_t	*mds_mpd_tab;
    190 	rfs4_index_t	*mds_mpd_idx;
    191 	id_space_t	*mds_mpd_id_space;
    192 
    193 	krwlock_t    	ds_addrlist_lock;
    194 	rfs4_table_t	*ds_addrlist_tab;
    195 	rfs4_index_t	*ds_addrlist_idx;
    196 	rfs4_index_t	*ds_addrlist_ip_idx;
    197 	rfs4_index_t	*ds_addrlist_addrkey_idx;
    198 
    199 	krwlock_t	ds_guid_info_lock;
    200 
    201 	/*
    202 	 * XXX: Still a hack, but a useful one
    203 	 * to allow people to *not* specify
    204 	 * polices. Will now come out when
    205 	 * we do the SMF work.
    206 	 */
    207 	uint32_t	ds_guid_info_count;
    208 
    209 	rfs4_table_t	*ds_guid_info_tab;
    210 	rfs4_index_t	*ds_guid_info_inst_idx;
    211 	rfs4_index_t	*ds_guid_info_idx;
    212 	rfs4_index_t	*ds_guid_info_dataset_name_idx;
    213 
    214 	krwlock_t	ds_owner_lock;
    215 	rfs4_table_t	*ds_owner_tab;
    216 	rfs4_index_t	*ds_owner_inst_idx;
    217 	rfs4_index_t	*ds_owner_idx;
    218 
    219 	krwlock_t	mds_mapzap_lock;
    220 	rfs4_table_t	*mds_mapzap_tab;
    221 	rfs4_index_t	*mds_mapzap_idx;
    222 
    223 	fem_t	*deleg_rdops;
    224 	fem_t	*deleg_wrops;
    225 
    226 	attrvers_t	attrvers;
    227 } nfs_server_instance_t;
    228 
    229 #define	SSTOR_CT_INIT(p, val, ct)	\
    230 	if (p->val == 0)			\
    231 		p->val = rfs4_lease_time * ct;
    232 
    233 extern int nsi_create(char *, nfs_server_instance_t **);
    234 
    235 /* temp vvvvvvvv */
    236 extern nfs_server_instance_t *mds_server;
    237 extern nfs_server_instance_t *nfs4_server;
    238 /* temp ^^^^^^^^ */
    239 
    240 
    241 #ifdef	__cplusplus
    242 }
    243 #endif
    244 
    245 #endif /* _NFS_SERV_INST_H */
    246