1 6741 th199096 /* 2 6741 th199096 * CDDL HEADER START 3 6741 th199096 * 4 6741 th199096 * The contents of this file are subject to the terms of the 5 6741 th199096 * Common Development and Distribution License (the "License"). 6 6741 th199096 * You may not use this file except in compliance with the License. 7 6741 th199096 * 8 6741 th199096 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 6741 th199096 * or http://www.opensolaris.org/os/licensing. 10 6741 th199096 * See the License for the specific language governing permissions 11 6741 th199096 * and limitations under the License. 12 6741 th199096 * 13 6741 th199096 * When distributing Covered Code, include this CDDL HEADER in each 14 6741 th199096 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 6741 th199096 * If applicable, add the following below this CDDL HEADER, with the 16 6741 th199096 * fields enclosed by brackets "[]" replaced with your own identifying 17 6741 th199096 * information: Portions Copyright [yyyy] [name of copyright owner] 18 6741 th199096 * 19 6741 th199096 * CDDL HEADER END 20 6741 th199096 */ 21 6741 th199096 /* 22 8424 lisa * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 6741 th199096 * Use is subject to license terms. 24 6741 th199096 */ 25 6741 th199096 26 6741 th199096 #ifndef _MDS_STATE_H 27 6741 th199096 #define _MDS_STATE_H 28 7741 Thomas 29 7741 Thomas #ifdef __cplusplus 30 7741 Thomas extern "C" { 31 7741 Thomas #endif 32 6741 th199096 33 6741 th199096 #include <sys/id_space.h> 34 6741 th199096 #include <nfs/nfs4_db_impl.h> 35 6741 th199096 #include <nfs/ds_prot.h> 36 7739 jwahlig #include <nfs/mds_odl.h> 37 8427 James #include <nfs/range.h> 38 7739 jwahlig 39 7739 jwahlig typedef ds_guid_map ds_guid_map_t; 40 7739 jwahlig typedef ds_guid ds_guid_t; 41 6741 th199096 42 6741 th199096 #define MDS_MAX_LAYOUT_DEVS 16 43 6741 th199096 44 6741 th199096 /* 45 7739 jwahlig * A means to plop the internal uint32_t device 46 6741 th199096 * id into an OTW 128 bit device id 47 6741 th199096 */ 48 6741 th199096 typedef union { 49 6741 th199096 struct { 50 6741 th199096 uint32_t pad0; 51 6741 th199096 uint32_t pad1; 52 6741 th199096 uint32_t pad2; 53 6741 th199096 uint32_t did; 54 6741 th199096 } i; 55 6741 th199096 deviceid4 did4; 56 6741 th199096 } ba_devid_t; 57 6741 th199096 58 10016 Thomas extern void mds_set_deviceid(id_t, deviceid4 *); 59 10016 Thomas 60 10016 Thomas /* 61 10016 Thomas * mds_mpd: 62 10016 Thomas * 63 10016 Thomas * The fields mdp_encoded_* are in fact the already 64 10016 Thomas * encoded value for a nfsv4_1_file_layout_ds_addr4 65 10016 Thomas */ 66 10016 Thomas typedef struct mds_mpd { 67 10447 Thomas rfs4_dbe_t *mpd_dbe; 68 10016 Thomas id_t mpd_id; 69 10016 Thomas uint_t mpd_encoded_len; 70 10016 Thomas char *mpd_encoded_val; 71 10016 Thomas list_t mpd_layouts_list; 72 10016 Thomas } mds_mpd_t; 73 10016 Thomas 74 10016 Thomas /* 75 10016 Thomas * Used to build the reply to getdevicelist 76 10016 Thomas */ 77 10016 Thomas typedef struct mds_device_list { 78 10447 Thomas int mdl_count; 79 10447 Thomas deviceid4 *mdl_dl; 80 10016 Thomas } mds_device_list_t; 81 10016 Thomas 82 10016 Thomas typedef struct layout_core { 83 10016 Thomas length4 lc_stripe_unit; 84 10016 Thomas int lc_stripe_count; 85 10016 Thomas mds_sid *lc_mds_sids; 86 10016 Thomas } layout_core_t; 87 6741 th199096 88 6741 th199096 /* 89 7739 jwahlig * mds_layout has the information for the layout that has been 90 7739 jwahlig * allocated by the SPE. It is represented by the structure 91 7739 jwahlig * "struct odl" or on-disk-layout the odl will be plopped 92 7739 jwahlig * onto stable storage, once we know that a data-server 93 7739 jwahlig * has requested verification for an IO operation. 94 7739 jwahlig * -- 95 6741 th199096 * stripe_unit gets plopped into a nfl_util4 in the returned 96 6741 th199096 * layout information; 97 7739 jwahlig * -- 98 6741 th199096 * lo_flags carries if we want dense or sparse data at the 99 6741 th199096 * data-servers and also if we wish the NFS Client to commit 100 6741 th199096 * through the MDS or Data-servers. 101 6741 th199096 */ 102 7739 jwahlig typedef struct mds_layout { 103 10447 Thomas rfs4_dbe_t *mlo_dbe; 104 10016 Thomas int mlo_id; 105 10016 Thomas layouttype4 mlo_type; 106 10016 Thomas layout_core_t mlo_lc; 107 10016 Thomas uint32_t mlo_flags; 108 10016 Thomas rfs4_file_t *mlo_fp; 109 10016 Thomas odl *mlo_odl; 110 10016 Thomas mds_mpd_t *mlo_mpd; 111 10016 Thomas id_t mlo_mpd_id; 112 10016 Thomas list_node_t mpd_layouts_next; 113 6741 th199096 } mds_layout_t; 114 6741 th199096 115 8041 rick #define LO_GRANTED 0x00000001 116 8041 rick #define LO_RECALL_INPROG 0x00000002 117 8041 rick #define LO_RECALLED 0x00000004 118 8041 rick #define LO_RETURNED 0x00000008 119 8041 rick 120 7739 jwahlig typedef struct mds_layout_grant { 121 10447 Thomas rfs4_dbe_t *lo_dbe; 122 7739 jwahlig stateid_t lo_stateid; 123 8041 rick uint32_t lo_status; 124 8041 rick kmutex_t lo_lock; 125 8041 rick struct { 126 8041 rick uint32_t lr_seqid; 127 8041 rick uint32_t lr_reply; 128 8041 rick } lo_rec; 129 10447 Thomas mds_layout_t *lo_lop; 130 10447 Thomas rfs4_client_t *lo_cp; 131 10447 Thomas rfs4_file_t *lo_fp; 132 10447 Thomas rfs41_grant_list_t lo_clientgrantlist; 133 7739 jwahlig rfs41_grant_list_t lo_grant_list; 134 8427 James nfs_range_t *lo_range; 135 6741 th199096 } mds_layout_grant_t; 136 8041 rick 137 8041 rick #define lor_seqid lo_rec.lr_seqid 138 8041 rick #define lor_reply lo_rec.lr_reply 139 7812 James 140 7812 James typedef struct mds_ever_grant { 141 10447 Thomas rfs4_dbe_t *eg_dbe; 142 10447 Thomas rfs4_client_t *eg_cp; 143 7812 James union { 144 7812 James fsid_t fsid; 145 7812 James int64_t key; 146 7812 James } eg_un; 147 7812 James } mds_ever_grant_t; 148 7812 James 149 7812 James #define eg_fsid eg_un.fsid 150 7812 James #define eg_key eg_un.key 151 6741 th199096 152 9404 Thomas /* 153 9404 Thomas * A ds_owner has a list of ds_addrlist entries and 154 9404 Thomas * a list of ds_guid entries. As an entry is added into 155 9404 Thomas * a list, it will bump the refcnts in both the ds_owner 156 9404 Thomas * and itself. It does this to prevent both references 157 9404 Thomas * from becoming invalid. 158 9404 Thomas * 159 9404 Thomas * This sounds nasty and recursive. It is. If an entry 160 9404 Thomas * destroy function is called without going through the 161 9404 Thomas * external linked list release functions, well, this 162 9404 Thomas * is your only warning not to do that. 163 9404 Thomas */ 164 6741 th199096 typedef struct { 165 6741 th199096 rfs4_dbe_t *dbe; 166 7739 jwahlig time_t last_access; 167 7739 jwahlig char *identity; 168 6741 th199096 ds_id ds_id; 169 7739 jwahlig ds_verifier verifier; 170 6741 th199096 uint32_t dsi_flags; 171 7811 Thomas list_t ds_addrlist_list; 172 7739 jwahlig list_t ds_guid_list; 173 7739 jwahlig } ds_owner_t; 174 7739 jwahlig 175 7739 jwahlig /* 176 7739 jwahlig * Mapping of MDS_SID(s) (the MDS storage identifier) to 177 7739 jwahlig * ds_guid; Saved on disk, held in memory for replies to 178 7739 jwahlig * DS_REPORTAVAIL and DS_MAP_MDSSID. 179 7739 jwahlig */ 180 7739 jwahlig typedef struct { 181 7739 jwahlig rfs4_dbe_t *dbe; 182 7739 jwahlig ds_guid_map_t ds_map; 183 7739 jwahlig } mds_mapzap_t; 184 6741 th199096 185 6741 th199096 #define MDS_DSI_REBOOTED 1 186 6741 th199096 187 6741 th199096 /* 188 6741 th199096 * Allow 4 bits for ds_validuse, the rest is 189 6741 th199096 * for our use. 190 6741 th199096 */ 191 6741 th199096 #define MDS_DEV_DS_MASK 0x0000000F 192 6741 th199096 #define MDS_DEV_SKIP_ME 0x00000010 193 6741 th199096 #define MDS_DEV_NEW 0x00000020 194 6741 th199096 195 6741 th199096 #define MDS_SET_DS_FLAGS(dst, flg) \ 196 6741 th199096 dst = (dst & ~MDS_DEV_DS_MASK) | (MDS_DEV_DS_MASK & flg); 197 6741 th199096 198 6741 th199096 /* 199 7811 Thomas * ds_addrlist: 200 6741 th199096 * 201 7739 jwahlig * This list is updated via the control-protocol 202 7739 jwahlig * message DS_REPORTAVAIL. 203 6741 th199096 */ 204 7739 jwahlig typedef struct { 205 7740 Robert rfs4_dbe_t *dbe; 206 7740 Robert netaddr4 dev_addr; 207 7740 Robert struct knetconfig *dev_knc; 208 7740 Robert struct netbuf *dev_nb; 209 7740 Robert uint_t dev_flags; 210 9407 Thomas uint32_t ds_port_key; 211 9407 Thomas uint64_t ds_addr_key; 212 7740 Robert ds_owner_t *ds_owner; 213 7811 Thomas list_node_t ds_addrlist_next; 214 7811 Thomas } ds_addrlist_t; 215 6741 th199096 216 6741 th199096 /* 217 6741 th199096 * Tracks the state 'handed out' to the data-server. 218 6741 th199096 */ 219 6741 th199096 typedef struct { 220 6741 th199096 rfs4_dbe_t *dbe; 221 9404 Thomas ds_owner_t *ds_owner; 222 6741 th199096 } mds_ds_state_t; 223 6741 th199096 224 10016 Thomas struct mds_adddev_args { 225 10016 Thomas int dev_id; 226 10016 Thomas char *dev_netid; 227 10016 Thomas char *dev_addr; 228 10016 Thomas char *ds_addr; 229 10016 Thomas }; 230 10016 Thomas 231 10016 Thomas /* 232 10016 Thomas * Identify the dataset... 233 10016 Thomas */ 234 10016 Thomas 235 10016 Thomas 236 6741 th199096 /* 237 7739 jwahlig * Tracks the mds_sid to data-server guid, and 238 6741 th199096 * associated attributes. 239 6741 th199096 */ 240 6741 th199096 typedef struct { 241 6741 th199096 rfs4_dbe_t *dbe; 242 9404 Thomas ds_owner_t *ds_owner; 243 7739 jwahlig list_node_t ds_guid_next; 244 10016 Thomas ds_guid_t ds_guid; /* This is the mds_dataset_id */ 245 10016 Thomas utf8string ds_dataset_name; /* Name of the dataset */ 246 6741 th199096 uint_t ds_attr_len; 247 10016 Thomas ds_zfsattr *ds_attr_val; /* XXX Should this be more general? */ 248 7739 jwahlig } ds_guid_info_t; 249 6741 th199096 250 6741 th199096 /* 251 7739 jwahlig * A small structure passed in the ds_storinfo create 252 6741 th199096 * entry. 253 6741 th199096 */ 254 6741 th199096 typedef struct { 255 10016 Thomas struct ds_storinfo *si; 256 10016 Thomas ds_owner_t *ds_owner; 257 6741 th199096 } pinfo_create_t; 258 6741 th199096 259 8424 lisa extern int mds_get_odl(vnode_t *, mds_layout_t **); 260 7739 jwahlig extern void mds_xdr_devicelist(rfs4_entry_t, void *); 261 7811 Thomas extern ds_addrlist_t *mds_find_ds_addrlist(nfs_server_instance_t *, uint32_t); 262 10016 Thomas extern ds_addrlist_t *mds_find_ds_addrlist_by_mds_sid(nfs_server_instance_t *, 263 10016 Thomas mds_sid *); 264 7811 Thomas extern ds_addrlist_t *mds_find_ds_addrlist_by_uaddr(nfs_server_instance_t *, 265 10016 Thomas char *); 266 9404 Thomas extern void mds_ds_addrlist_rele(ds_addrlist_t *); 267 10016 Thomas extern ds_guid_info_t *mds_find_ds_guid_info_by_id(ds_guid_t *guid); 268 7740 Robert extern int uaddr2sockaddr(int, char *, void *, in_port_t *); 269 7739 jwahlig extern int mds_put_layout(mds_layout_t *, vnode_t *); 270 7741 Thomas 271 7741 Thomas #ifdef __cplusplus 272 7741 Thomas } 273 7741 Thomas #endif 274 7741 Thomas 275 6741 th199096 #endif /* _MDS_STATE_H */ 276