| 1 | /* |
|---|
| 2 | * (C) 2001 Clemson University and The University of Chicago |
|---|
| 3 | * |
|---|
| 4 | * See COPYING in top-level directory. |
|---|
| 5 | */ |
|---|
| 6 | |
|---|
| 7 | /* |
|---|
| 8 | * Declarations for use in the PVFS2 server. |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | #ifndef __PVFS2_SERVER_H |
|---|
| 12 | #define __PVFS2_SERVER_H |
|---|
| 13 | |
|---|
| 14 | /* NOTE: STATE-MACHINE.H IS INCLUDED AT THE BOTTOM! THIS IS SO WE CAN |
|---|
| 15 | * DEFINE ALL THE STRUCTURES WE NEED BEFORE WE INCLUDE IT. |
|---|
| 16 | */ |
|---|
| 17 | |
|---|
| 18 | #include <stdint.h> |
|---|
| 19 | #include <sys/types.h> |
|---|
| 20 | #include <pwd.h> |
|---|
| 21 | #include <grp.h> |
|---|
| 22 | #include <string.h> |
|---|
| 23 | #include "pvfs2-debug.h" |
|---|
| 24 | #include "pvfs2-storage.h" |
|---|
| 25 | #include "pvfs2-internal.h" |
|---|
| 26 | #include "job.h" |
|---|
| 27 | #include "bmi.h" |
|---|
| 28 | #include "trove.h" |
|---|
| 29 | #include "gossip.h" |
|---|
| 30 | #include "PINT-reqproto-encode.h" |
|---|
| 31 | #include "msgpairarray.h" |
|---|
| 32 | #include "pvfs2-req-proto.h" |
|---|
| 33 | #include "pvfs2-mirror.h" |
|---|
| 34 | #include "state-machine.h" |
|---|
| 35 | #include "pint-event.h" |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | extern job_context_id server_job_context; |
|---|
| 39 | |
|---|
| 40 | #define PVFS2_SERVER_DEFAULT_TIMEOUT_MS 100 |
|---|
| 41 | #define BMI_UNEXPECTED_OP 999 |
|---|
| 42 | |
|---|
| 43 | /* BMI operation timeout if not specified in config file */ |
|---|
| 44 | #define PVFS2_SERVER_JOB_BMI_TIMEOUT_DEFAULT 30 |
|---|
| 45 | /* Flow operation timeout if not specified in config file */ |
|---|
| 46 | #define PVFS2_SERVER_JOB_FLOW_TIMEOUT_DEFAULT 30 |
|---|
| 47 | /* BMI client side operation timeout if not specified in config file */ |
|---|
| 48 | /* NOTE: the default for this timeout is set higher to allow the client to |
|---|
| 49 | * overcome syncing and queueing delays on the server |
|---|
| 50 | */ |
|---|
| 51 | #define PVFS2_CLIENT_JOB_BMI_TIMEOUT_DEFAULT 300 |
|---|
| 52 | /* Flow client side operation timeout if not specified in config file */ |
|---|
| 53 | #define PVFS2_CLIENT_JOB_FLOW_TIMEOUT_DEFAULT 300 |
|---|
| 54 | /* maximum number of times for client to retry restartable operations; |
|---|
| 55 | * use INT_MAX to approximate infinity (187 years with 2 sec delay) |
|---|
| 56 | */ |
|---|
| 57 | #define PVFS2_CLIENT_RETRY_LIMIT_DEFAULT (5) |
|---|
| 58 | /* number of milliseconds that clients will delay between retries */ |
|---|
| 59 | #define PVFS2_CLIENT_RETRY_DELAY_MS_DEFAULT 2000 |
|---|
| 60 | |
|---|
| 61 | /* Specifies the number of handles to be preceated at a time from each |
|---|
| 62 | * server using the batch create request. |
|---|
| 63 | */ |
|---|
| 64 | #define PVFS2_PRECREATE_BATCH_SIZE_DEFAULT 512 |
|---|
| 65 | /* precreate pools will be topped off if they fall below this value */ |
|---|
| 66 | #define PVFS2_PRECREATE_LOW_THRESHOLD_DEFAULT 256 |
|---|
| 67 | |
|---|
| 68 | /* types of permission checking that a server may need to perform for |
|---|
| 69 | * incoming requests |
|---|
| 70 | */ |
|---|
| 71 | enum PINT_server_req_permissions |
|---|
| 72 | { |
|---|
| 73 | PINT_SERVER_CHECK_INVALID = 0, /* invalid request */ |
|---|
| 74 | PINT_SERVER_CHECK_WRITE = 1, /* needs write permission */ |
|---|
| 75 | PINT_SERVER_CHECK_READ = 2, /* needs read permission */ |
|---|
| 76 | PINT_SERVER_CHECK_NONE = 3, /* needs no permission */ |
|---|
| 77 | PINT_SERVER_CHECK_ATTR = 4, /* special case for attribute operations; |
|---|
| 78 | needs ownership */ |
|---|
| 79 | PINT_SERVER_CHECK_CRDIRENT = 5 /* special case for crdirent operations; |
|---|
| 80 | needs write and execute */ |
|---|
| 81 | }; |
|---|
| 82 | |
|---|
| 83 | #define PINT_GET_OBJECT_REF_DEFINE(req_name) \ |
|---|
| 84 | static inline int PINT_get_object_ref_##req_name( \ |
|---|
| 85 | struct PVFS_server_req *req, PVFS_fs_id *fs_id, PVFS_handle *handle) \ |
|---|
| 86 | { \ |
|---|
| 87 | *fs_id = req->u.req_name.fs_id; \ |
|---|
| 88 | *handle = req->u.req_name.handle; \ |
|---|
| 89 | return 0; \ |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | enum PINT_server_req_access_type PINT_server_req_readonly( |
|---|
| 93 | struct PVFS_server_req *req); |
|---|
| 94 | enum PINT_server_req_access_type PINT_server_req_modify( |
|---|
| 95 | struct PVFS_server_req *req); |
|---|
| 96 | |
|---|
| 97 | struct PINT_server_req_params |
|---|
| 98 | { |
|---|
| 99 | const char* string_name; |
|---|
| 100 | |
|---|
| 101 | /* For each request that specifies an object ref (fsid,handle) we |
|---|
| 102 | * get the common attributes on that object and check the permissions. |
|---|
| 103 | * For the request to proceed the permissions required by this flag |
|---|
| 104 | * must be met. |
|---|
| 105 | */ |
|---|
| 106 | enum PINT_server_req_permissions perm; |
|---|
| 107 | |
|---|
| 108 | /* Specifies the type of access on the object (readonly, modify). This |
|---|
| 109 | * is used by the request scheduler to determine |
|---|
| 110 | * which requests to queue (block), and which to schedule (proceed). |
|---|
| 111 | * This is a callback implemented by the request. For example, sometimes |
|---|
| 112 | * the io request writes, sometimes it reads. |
|---|
| 113 | * Default functions PINT_server_req_readonly and PINT_server_req_modify |
|---|
| 114 | * are used for requests that always require the same access type. |
|---|
| 115 | */ |
|---|
| 116 | enum PINT_server_req_access_type (*access_type)( |
|---|
| 117 | struct PVFS_server_req *req); |
|---|
| 118 | |
|---|
| 119 | /* Specifies the scheduling policy for the request. In some cases, |
|---|
| 120 | * we can bypass the request scheduler and proceed directly with the |
|---|
| 121 | * request. |
|---|
| 122 | */ |
|---|
| 123 | enum PINT_server_sched_policy sched_policy; |
|---|
| 124 | |
|---|
| 125 | /* A callback implemented by the request to return the object reference |
|---|
| 126 | * from the server request structure. |
|---|
| 127 | */ |
|---|
| 128 | int (*get_object_ref)( |
|---|
| 129 | struct PVFS_server_req *req, PVFS_fs_id *fs_id, PVFS_handle *handle); |
|---|
| 130 | |
|---|
| 131 | /* The state machine that performs the request */ |
|---|
| 132 | struct PINT_state_machine_s *state_machine; |
|---|
| 133 | }; |
|---|
| 134 | |
|---|
| 135 | struct PINT_server_req_entry |
|---|
| 136 | { |
|---|
| 137 | enum PVFS_server_op op_type; |
|---|
| 138 | struct PINT_server_req_params *params; |
|---|
| 139 | }; |
|---|
| 140 | |
|---|
| 141 | extern struct PINT_server_req_entry PINT_server_req_table[]; |
|---|
| 142 | |
|---|
| 143 | int PINT_server_req_get_object_ref( |
|---|
| 144 | struct PVFS_server_req *req, PVFS_fs_id *fs_id, PVFS_handle *handle); |
|---|
| 145 | |
|---|
| 146 | enum PINT_server_req_permissions |
|---|
| 147 | PINT_server_req_get_perms(struct PVFS_server_req *req); |
|---|
| 148 | enum PINT_server_req_access_type |
|---|
| 149 | PINT_server_req_get_access_type(struct PVFS_server_req *req); |
|---|
| 150 | enum PINT_server_sched_policy |
|---|
| 151 | PINT_server_req_get_sched_policy(struct PVFS_server_req *req); |
|---|
| 152 | |
|---|
| 153 | const char* PINT_map_server_op_to_string(enum PVFS_server_op op); |
|---|
| 154 | |
|---|
| 155 | /* used to keep a random, but handy, list of keys around */ |
|---|
| 156 | typedef struct PINT_server_trove_keys |
|---|
| 157 | { |
|---|
| 158 | char *key; |
|---|
| 159 | int size; |
|---|
| 160 | } PINT_server_trove_keys_s; |
|---|
| 161 | |
|---|
| 162 | extern PINT_server_trove_keys_s Trove_Common_Keys[]; |
|---|
| 163 | /* Reserved keys */ |
|---|
| 164 | enum |
|---|
| 165 | { |
|---|
| 166 | ROOT_HANDLE_KEY = 0, |
|---|
| 167 | DIR_ENT_KEY = 1, |
|---|
| 168 | METAFILE_HANDLES_KEY = 2, |
|---|
| 169 | METAFILE_DIST_KEY = 3, |
|---|
| 170 | SYMLINK_TARGET_KEY = 4, |
|---|
| 171 | METAFILE_LAYOUT_KEY = 5, |
|---|
| 172 | NUM_DFILES_REQ_KEY = 6, |
|---|
| 173 | DIST_DIR_ATTR_KEY = 7, |
|---|
| 174 | DIST_DIRDATA_HANDLES_KEY = 8, |
|---|
| 175 | DIST_DIRDATA_BITMAP_KEY = 9 |
|---|
| 176 | }; |
|---|
| 177 | |
|---|
| 178 | /* optional; user-settable keys */ |
|---|
| 179 | enum |
|---|
| 180 | { |
|---|
| 181 | DIST_NAME_KEY = 0, |
|---|
| 182 | DIST_PARAMS_KEY = 1, |
|---|
| 183 | NUM_DFILES_KEY = 2, |
|---|
| 184 | NUM_SPECIAL_KEYS = 3, /* not an index */ |
|---|
| 185 | METAFILE_HINT_KEY = 3, |
|---|
| 186 | MIRROR_COPIES_KEY = 4, |
|---|
| 187 | MIRROR_HANDLES_KEY = 5, |
|---|
| 188 | MIRROR_STATUS_KEY = 6, |
|---|
| 189 | }; |
|---|
| 190 | |
|---|
| 191 | typedef enum |
|---|
| 192 | { |
|---|
| 193 | SERVER_DEFAULT_INIT = 0, |
|---|
| 194 | SERVER_GOSSIP_INIT = (1 << 0), |
|---|
| 195 | SERVER_CONFIG_INIT = (1 << 1), |
|---|
| 196 | SERVER_ENCODER_INIT = (1 << 2), |
|---|
| 197 | SERVER_BMI_INIT = (1 << 3), |
|---|
| 198 | SERVER_TROVE_INIT = (1 << 4), |
|---|
| 199 | SERVER_FLOW_INIT = (1 << 5), |
|---|
| 200 | SERVER_JOB_INIT = (1 << 6), |
|---|
| 201 | SERVER_JOB_CTX_INIT = (1 << 7), |
|---|
| 202 | SERVER_REQ_SCHED_INIT = (1 << 8), |
|---|
| 203 | SERVER_STATE_MACHINE_INIT = (1 << 9), |
|---|
| 204 | SERVER_BMI_UNEXP_POST_INIT = (1 << 10), |
|---|
| 205 | SERVER_SIGNAL_HANDLER_INIT = (1 << 11), |
|---|
| 206 | SERVER_JOB_OBJS_ALLOCATED = (1 << 12), |
|---|
| 207 | SERVER_PERF_COUNTER_INIT = (1 << 13), |
|---|
| 208 | SERVER_EVENT_INIT = (1 << 14), |
|---|
| 209 | SERVER_JOB_TIME_MGR_INIT = (1 << 15), |
|---|
| 210 | SERVER_DIST_INIT = (1 << 16), |
|---|
| 211 | SERVER_CACHED_CONFIG_INIT = (1 << 17), |
|---|
| 212 | SERVER_PRECREATE_INIT = (1 << 18), |
|---|
| 213 | } PINT_server_status_flag; |
|---|
| 214 | |
|---|
| 215 | typedef enum |
|---|
| 216 | { |
|---|
| 217 | PRELUDE_SCHEDULER_DONE = (1 << 0), |
|---|
| 218 | PRELUDE_GETATTR_DONE = (1 << 1), |
|---|
| 219 | PRELUDE_PERM_CHECK_DONE = (1 << 2), |
|---|
| 220 | PRELUDE_LOCAL_CALL = (1 << 3), |
|---|
| 221 | } PINT_prelude_flag; |
|---|
| 222 | |
|---|
| 223 | struct PINT_server_create_op |
|---|
| 224 | { |
|---|
| 225 | const char **io_servers; |
|---|
| 226 | const char **remote_io_servers; |
|---|
| 227 | int num_io_servers; |
|---|
| 228 | PVFS_handle* handle_array_local; |
|---|
| 229 | PVFS_handle* handle_array_remote; |
|---|
| 230 | int handle_array_local_count; |
|---|
| 231 | int handle_array_remote_count; |
|---|
| 232 | PVFS_error saved_error_code; |
|---|
| 233 | int handle_index; |
|---|
| 234 | }; |
|---|
| 235 | |
|---|
| 236 | /*MIRROR structures*/ |
|---|
| 237 | typedef struct |
|---|
| 238 | { |
|---|
| 239 | /* session identifier created in the PVFS_SERV_IO request. also used as */ |
|---|
| 240 | /* the flow identifier. */ |
|---|
| 241 | bmi_msg_tag_t session_tag; |
|---|
| 242 | |
|---|
| 243 | /*destination server address*/ |
|---|
| 244 | PVFS_BMI_addr_t svr_addr; |
|---|
| 245 | |
|---|
| 246 | /*status from PVFS_SERV_IO*/ |
|---|
| 247 | PVFS_error io_status; |
|---|
| 248 | |
|---|
| 249 | /*variables used to setup write completion ack*/ |
|---|
| 250 | void *encoded_resp_p; |
|---|
| 251 | job_status_s recv_status; |
|---|
| 252 | job_id_t recv_id; |
|---|
| 253 | |
|---|
| 254 | /*variables used to setup flow between the src & dest datahandle*/ |
|---|
| 255 | flow_descriptor *flow_desc; |
|---|
| 256 | job_status_s flow_status; |
|---|
| 257 | job_id_t flow_job_id; |
|---|
| 258 | |
|---|
| 259 | } write_job_t; |
|---|
| 260 | |
|---|
| 261 | |
|---|
| 262 | /*This structure is used during the processing of a "mirror" request.*/ |
|---|
| 263 | struct PINT_server_mirror_op |
|---|
| 264 | { |
|---|
| 265 | /*keep up with the number of outstanding jobs*/ |
|---|
| 266 | int job_count; |
|---|
| 267 | |
|---|
| 268 | /*maximum response size for the write request*/ |
|---|
| 269 | int max_resp_sz; |
|---|
| 270 | |
|---|
| 271 | /*info about each job*/ |
|---|
| 272 | write_job_t *jobs; |
|---|
| 273 | }; |
|---|
| 274 | typedef struct PINT_server_mirror_op PINT_server_mirror_op; |
|---|
| 275 | |
|---|
| 276 | /* Source refers to the handle being copied, and destination refers to */ |
|---|
| 277 | /* its copy. */ |
|---|
| 278 | struct PINT_server_create_copies_op |
|---|
| 279 | { |
|---|
| 280 | /*number of I/O servers required to meet the mirroring request. */ |
|---|
| 281 | uint32_t io_servers_required; |
|---|
| 282 | |
|---|
| 283 | /*mirroring mode. attribute key is user.pvfs2.mirror.mode*/ |
|---|
| 284 | MIRROR_MODE mirror_mode; |
|---|
| 285 | |
|---|
| 286 | /*the expected mirroring mode tells us how to edit the retrieved mirroring*/ |
|---|
| 287 | /*mode. Example: if mirroring was called when immutable was set, then */ |
|---|
| 288 | /*the expected mirroring mode would be MIRROR_ON_IMMUTABLE. */ |
|---|
| 289 | MIRROR_MODE expected_mirror_mode; |
|---|
| 290 | |
|---|
| 291 | /*buffer holding list of remote servers for all copies of the file*/ |
|---|
| 292 | char **my_remote_servers; |
|---|
| 293 | |
|---|
| 294 | /*saved error code*/ |
|---|
| 295 | PVFS_error saved_error_code; |
|---|
| 296 | |
|---|
| 297 | /*number of copies desired. value of user.pvfs2.mirror.copies attribute*/ |
|---|
| 298 | uint32_t copies; |
|---|
| 299 | |
|---|
| 300 | /*successful/failed writes array in order of source handles */ |
|---|
| 301 | /*0=>successful !UINT64_HIGH=>failure UINT64_HIGH=>initial state */ |
|---|
| 302 | /*accessed as if a 2-dimensional array [SrcHandleNR][#ofCopies] */ |
|---|
| 303 | PVFS_handle *writes_completed; |
|---|
| 304 | |
|---|
| 305 | /*number of attempts at writing handles*/ |
|---|
| 306 | int retry_count; |
|---|
| 307 | |
|---|
| 308 | /*list of server names that will be used as destination servers*/ |
|---|
| 309 | char **io_servers; |
|---|
| 310 | |
|---|
| 311 | /*source remote server names in distribution*/ |
|---|
| 312 | char **remote_io_servers; |
|---|
| 313 | |
|---|
| 314 | /*source local server names in distribution*/; |
|---|
| 315 | char **local_io_servers; |
|---|
| 316 | |
|---|
| 317 | /*number of source server names in the distribution*/ |
|---|
| 318 | int num_io_servers; |
|---|
| 319 | |
|---|
| 320 | /*number of source remote server names in distribution*/ |
|---|
| 321 | int remote_io_servers_count; |
|---|
| 322 | |
|---|
| 323 | /*number of source local server names in distribution*/ |
|---|
| 324 | int local_io_servers_count; |
|---|
| 325 | |
|---|
| 326 | /*source datahandles in order of distribution*/ |
|---|
| 327 | PVFS_handle *handle_array_base; |
|---|
| 328 | |
|---|
| 329 | /*local source datahandles*/ |
|---|
| 330 | PVFS_handle *handle_array_base_local; |
|---|
| 331 | |
|---|
| 332 | /*destination datahandles in order of distribution*/ |
|---|
| 333 | PVFS_handle *handle_array_copies; |
|---|
| 334 | |
|---|
| 335 | /*local destination datahandles*/ |
|---|
| 336 | PVFS_handle *handle_array_copies_local; |
|---|
| 337 | |
|---|
| 338 | /*remote destination datahandles*/ |
|---|
| 339 | PVFS_handle *handle_array_copies_remote; |
|---|
| 340 | |
|---|
| 341 | /*number of local source datahandles*/ |
|---|
| 342 | int handle_array_base_local_count; |
|---|
| 343 | |
|---|
| 344 | /*number of local destination datahandles*/ |
|---|
| 345 | int handle_array_copies_local_count; |
|---|
| 346 | |
|---|
| 347 | /*number of remote destination datahandles*/ |
|---|
| 348 | int handle_array_copies_remote_count; |
|---|
| 349 | |
|---|
| 350 | /*number of source datahandles*/ |
|---|
| 351 | uint32_t dfile_count; |
|---|
| 352 | |
|---|
| 353 | /*source metadata handle*/ |
|---|
| 354 | PVFS_handle metadata_handle; |
|---|
| 355 | |
|---|
| 356 | /*source file system*/ |
|---|
| 357 | PVFS_fs_id fs_id; |
|---|
| 358 | |
|---|
| 359 | /*number of io servers defined in the current file system*/ |
|---|
| 360 | int io_servers_count; |
|---|
| 361 | |
|---|
| 362 | /*size of the source distribution structure */ |
|---|
| 363 | uint32_t dist_size; |
|---|
| 364 | |
|---|
| 365 | /*distribution structure for basic_dist*/ |
|---|
| 366 | PINT_dist *dist; |
|---|
| 367 | |
|---|
| 368 | /*local source handles' attribute structure*/ |
|---|
| 369 | /*populates bstream_array_base_local with byte stream size*/ |
|---|
| 370 | PVFS_ds_attributes *ds_attr_a; |
|---|
| 371 | |
|---|
| 372 | /*local source handles' byte stream size*/ |
|---|
| 373 | /*index corresponds to handle_array_base*/ |
|---|
| 374 | PVFS_size *bstream_array_base_local; |
|---|
| 375 | }; |
|---|
| 376 | typedef struct PINT_server_create_copies_op PINT_server_create_copies_op; |
|---|
| 377 | |
|---|
| 378 | |
|---|
| 379 | /*This macro is used to initialize a PINT_server_op structure when pjmp'ing */ |
|---|
| 380 | /*to pvfs2_create_immutable_copies_sm. */ |
|---|
| 381 | #define PVFS_SERVOP_IMM_COPIES_FILL(__new_p,__cur_p) \ |
|---|
| 382 | do { \ |
|---|
| 383 | memcpy(__new_p,__cur_p,sizeof(struct PINT_server_op)); \ |
|---|
| 384 | (__new_p)->op = PVFS_SERV_IMM_COPIES; \ |
|---|
| 385 | memset(&((__new_p)->u.create_copies),0,sizeof((__new_p)->u.create_copies)); \ |
|---|
| 386 | }while(0) |
|---|
| 387 | |
|---|
| 388 | |
|---|
| 389 | |
|---|
| 390 | /* struct PINT_server_lookup_op |
|---|
| 391 | * |
|---|
| 392 | * All the data needed during lookup processing: |
|---|
| 393 | * |
|---|
| 394 | */ |
|---|
| 395 | struct PINT_server_lookup_op |
|---|
| 396 | { |
|---|
| 397 | /* current segment (0..N), number of segments in the path */ |
|---|
| 398 | int seg_ct, seg_nr; |
|---|
| 399 | |
|---|
| 400 | /* number of attrs read succesfully */ |
|---|
| 401 | int attr_ct; |
|---|
| 402 | |
|---|
| 403 | /* number of handles read successfully */ |
|---|
| 404 | int handle_ct; |
|---|
| 405 | |
|---|
| 406 | char *segp; |
|---|
| 407 | void *segstate; |
|---|
| 408 | |
|---|
| 409 | PVFS_handle dirent_handle; |
|---|
| 410 | PVFS_ds_attributes *ds_attr_array; |
|---|
| 411 | }; |
|---|
| 412 | |
|---|
| 413 | struct PINT_server_readdir_op |
|---|
| 414 | { |
|---|
| 415 | uint64_t directory_version; |
|---|
| 416 | PVFS_handle dirent_handle; /* holds handle of dirdata dspace from |
|---|
| 417 | which entries are read */ |
|---|
| 418 | PVFS_size dirdata_size; |
|---|
| 419 | }; |
|---|
| 420 | |
|---|
| 421 | struct PINT_server_crdirent_op |
|---|
| 422 | { |
|---|
| 423 | char *name; |
|---|
| 424 | PVFS_handle new_handle; |
|---|
| 425 | PVFS_handle parent_handle; |
|---|
| 426 | PVFS_fs_id fs_id; |
|---|
| 427 | PVFS_handle dirent_handle; /* holds handle of dirdata dspace that |
|---|
| 428 | * we'll write the dirent into */ |
|---|
| 429 | PVFS_size dirent_count; |
|---|
| 430 | int dir_attr_update_required; |
|---|
| 431 | }; |
|---|
| 432 | |
|---|
| 433 | struct PINT_server_rmdirent_op |
|---|
| 434 | { |
|---|
| 435 | PVFS_handle dirdata_handle; |
|---|
| 436 | PVFS_handle entry_handle; /* holds handle of dirdata object, |
|---|
| 437 | * removed entry */ |
|---|
| 438 | PVFS_size dirent_count; |
|---|
| 439 | int dir_attr_update_required; |
|---|
| 440 | }; |
|---|
| 441 | |
|---|
| 442 | struct PINT_server_chdirent_op |
|---|
| 443 | { |
|---|
| 444 | PVFS_handle dirdata_handle; |
|---|
| 445 | PVFS_handle old_dirent_handle; |
|---|
| 446 | PVFS_handle new_dirent_handle; |
|---|
| 447 | int dir_attr_update_required; |
|---|
| 448 | }; |
|---|
| 449 | |
|---|
| 450 | struct PINT_server_remove_op |
|---|
| 451 | { |
|---|
| 452 | PVFS_handle handle; |
|---|
| 453 | PVFS_fs_id fs_id; |
|---|
| 454 | PVFS_handle dirdata_handle; /* holds dirdata dspace handle in |
|---|
| 455 | * the event that we are removing a |
|---|
| 456 | * directory */ |
|---|
| 457 | PVFS_size dirent_count; |
|---|
| 458 | PVFS_ds_keyval key; |
|---|
| 459 | PVFS_ds_position pos; |
|---|
| 460 | int key_count; |
|---|
| 461 | int index; |
|---|
| 462 | int remove_keyvals_state; |
|---|
| 463 | }; |
|---|
| 464 | |
|---|
| 465 | struct PINT_server_mgmt_remove_dirent_op |
|---|
| 466 | { |
|---|
| 467 | PVFS_handle dirdata_handle; |
|---|
| 468 | }; |
|---|
| 469 | |
|---|
| 470 | struct PINT_server_precreate_pool_refiller_op |
|---|
| 471 | { |
|---|
| 472 | PVFS_handle pool_handle; |
|---|
| 473 | PVFS_handle* precreate_handle_array; |
|---|
| 474 | PVFS_fs_id fsid; |
|---|
| 475 | char* host; |
|---|
| 476 | PVFS_BMI_addr_t host_addr; |
|---|
| 477 | PVFS_handle_extent_array data_handle_extent_array; |
|---|
| 478 | PVFS_ds_type type; |
|---|
| 479 | }; |
|---|
| 480 | |
|---|
| 481 | struct PINT_server_batch_create_op |
|---|
| 482 | { |
|---|
| 483 | int saved_error_code; |
|---|
| 484 | int batch_index; |
|---|
| 485 | }; |
|---|
| 486 | |
|---|
| 487 | struct PINT_server_batch_remove_op |
|---|
| 488 | { |
|---|
| 489 | int handle_index; |
|---|
| 490 | int error_code; |
|---|
| 491 | }; |
|---|
| 492 | |
|---|
| 493 | struct PINT_server_mgmt_get_dirdata_op |
|---|
| 494 | { |
|---|
| 495 | PVFS_handle dirdata_handle; |
|---|
| 496 | }; |
|---|
| 497 | |
|---|
| 498 | struct PINT_server_getconfig_op |
|---|
| 499 | { |
|---|
| 500 | int strsize; /* used to hold string lengths during getconfig |
|---|
| 501 | * processing */ |
|---|
| 502 | }; |
|---|
| 503 | |
|---|
| 504 | struct PINT_server_io_op |
|---|
| 505 | { |
|---|
| 506 | flow_descriptor* flow_d; |
|---|
| 507 | }; |
|---|
| 508 | |
|---|
| 509 | struct PINT_server_small_io_op |
|---|
| 510 | { |
|---|
| 511 | PVFS_offset offsets[IO_MAX_REGIONS]; |
|---|
| 512 | PVFS_size sizes[IO_MAX_REGIONS]; |
|---|
| 513 | PVFS_size result_bytes; |
|---|
| 514 | }; |
|---|
| 515 | |
|---|
| 516 | struct PINT_server_flush_op |
|---|
| 517 | { |
|---|
| 518 | PVFS_handle handle; /* handle of data we want to flush to disk */ |
|---|
| 519 | int flags; /* any special flags for flush */ |
|---|
| 520 | }; |
|---|
| 521 | |
|---|
| 522 | struct PINT_server_truncate_op |
|---|
| 523 | { |
|---|
| 524 | PVFS_handle handle; /* handle of datafile we resize */ |
|---|
| 525 | PVFS_offset size; /* new size of datafile */ |
|---|
| 526 | }; |
|---|
| 527 | |
|---|
| 528 | struct PINT_server_mkdir_op |
|---|
| 529 | { |
|---|
| 530 | PVFS_fs_id fs_id; |
|---|
| 531 | PVFS_handle_extent_array handle_extent_array; |
|---|
| 532 | PVFS_size init_dirdata_size; |
|---|
| 533 | |
|---|
| 534 | /* dist-dir-struct |
|---|
| 535 | * not in resp, only return meta handle |
|---|
| 536 | * should be in attr up-level, PINT_server_op*/ |
|---|
| 537 | |
|---|
| 538 | /* inherit from create_op */ |
|---|
| 539 | /* not using these right now |
|---|
| 540 | const char **dirdata_servers; |
|---|
| 541 | const char **remote_dirdata_servers; |
|---|
| 542 | */ |
|---|
| 543 | int num_dirdata_servers; |
|---|
| 544 | PVFS_handle* handle_array_local; |
|---|
| 545 | PVFS_handle* handle_array_remote; |
|---|
| 546 | int handle_array_local_count; |
|---|
| 547 | int handle_array_remote_count; |
|---|
| 548 | PVFS_error saved_error_code; |
|---|
| 549 | int handle_index; |
|---|
| 550 | |
|---|
| 551 | }; |
|---|
| 552 | |
|---|
| 553 | struct PINT_server_getattr_op |
|---|
| 554 | { |
|---|
| 555 | PVFS_handle handle; |
|---|
| 556 | PVFS_fs_id fs_id; |
|---|
| 557 | PVFS_ds_attributes dirdata_ds_attr; |
|---|
| 558 | uint32_t attrmask; |
|---|
| 559 | PVFS_error* err_array; |
|---|
| 560 | PVFS_ds_keyval_handle_info keyval_handle_info; |
|---|
| 561 | /* store them in resp.u.getattr.attr.u.dir |
|---|
| 562 | int32_t num_dirent_handles; |
|---|
| 563 | PVFS_handle *dirent_handle; |
|---|
| 564 | */ |
|---|
| 565 | int num_dfiles_req; |
|---|
| 566 | PVFS_handle *mirror_dfile_status_array; |
|---|
| 567 | }; |
|---|
| 568 | |
|---|
| 569 | struct PINT_server_listattr_op |
|---|
| 570 | { |
|---|
| 571 | PVFS_object_attr *attr_a; |
|---|
| 572 | PVFS_ds_attributes *ds_attr_a; |
|---|
| 573 | PVFS_error *errors; |
|---|
| 574 | int parallel_sms; |
|---|
| 575 | }; |
|---|
| 576 | |
|---|
| 577 | /* this is used in both set_eattr, get_eattr and list_eattr */ |
|---|
| 578 | struct PINT_server_eattr_op |
|---|
| 579 | { |
|---|
| 580 | void *buffer; |
|---|
| 581 | }; |
|---|
| 582 | |
|---|
| 583 | struct PINT_server_unstuff_op |
|---|
| 584 | { |
|---|
| 585 | PVFS_handle* dfile_array; |
|---|
| 586 | int num_dfiles_req; |
|---|
| 587 | PVFS_sys_layout layout; |
|---|
| 588 | void* encoded_layout; |
|---|
| 589 | }; |
|---|
| 590 | |
|---|
| 591 | struct PINT_server_tree_communicate_op |
|---|
| 592 | { |
|---|
| 593 | int num_partitions; |
|---|
| 594 | PVFS_handle* handle_array_local; |
|---|
| 595 | PVFS_handle* handle_array_remote; |
|---|
| 596 | int handle_array_local_count; |
|---|
| 597 | int handle_array_remote_count; |
|---|
| 598 | int handle_index; |
|---|
| 599 | }; |
|---|
| 600 | |
|---|
| 601 | /* This structure is passed into the void *ptr |
|---|
| 602 | * within the job interface. Used to tell us where |
|---|
| 603 | * to go next in our state machine. |
|---|
| 604 | */ |
|---|
| 605 | typedef struct PINT_server_op |
|---|
| 606 | { |
|---|
| 607 | struct qlist_head next; /* used to queue structures used for unexp style messages */ |
|---|
| 608 | int op_cancelled; /* indicates unexp message was cancelled */ |
|---|
| 609 | job_id_t unexp_id; |
|---|
| 610 | |
|---|
| 611 | enum PVFS_server_op op; /* type of operation that we are servicing */ |
|---|
| 612 | |
|---|
| 613 | PINT_event_id event_id; |
|---|
| 614 | |
|---|
| 615 | /* holds id from request scheduler so we can release it later */ |
|---|
| 616 | job_id_t scheduled_id; |
|---|
| 617 | |
|---|
| 618 | /* generic structures used in most server operations */ |
|---|
| 619 | PVFS_ds_keyval key, val; |
|---|
| 620 | PVFS_ds_keyval *key_a; |
|---|
| 621 | PVFS_ds_keyval *val_a; |
|---|
| 622 | int *error_a; |
|---|
| 623 | int keyval_count; |
|---|
| 624 | |
|---|
| 625 | int free_val; |
|---|
| 626 | |
|---|
| 627 | /* attributes structure associated with target of operation; may be |
|---|
| 628 | * partially filled in by prelude nested state machine (for |
|---|
| 629 | * permission checking); may be used/modified by later states as well |
|---|
| 630 | * |
|---|
| 631 | * the ds_attr is used by the prelude sm only (and for pulling the |
|---|
| 632 | * size out in the get-attr server sm); don't use it otherwise -- |
|---|
| 633 | * the object_attr is prepared for other sm's, so use it instead. |
|---|
| 634 | */ |
|---|
| 635 | PVFS_ds_attributes ds_attr; |
|---|
| 636 | PVFS_object_attr attr; |
|---|
| 637 | |
|---|
| 638 | PVFS_BMI_addr_t addr; /* address of client that contacted us */ |
|---|
| 639 | bmi_msg_tag_t tag; /* operation tag */ |
|---|
| 640 | /* information about unexpected message that initiated this operation */ |
|---|
| 641 | struct BMI_unexpected_info unexp_bmi_buff; |
|---|
| 642 | |
|---|
| 643 | /* decoded request and response structures */ |
|---|
| 644 | struct PVFS_server_req *req; |
|---|
| 645 | struct PVFS_server_resp resp; |
|---|
| 646 | /* encoded request and response structures */ |
|---|
| 647 | struct PINT_encoded_msg encoded; |
|---|
| 648 | struct PINT_decoded_msg decoded; |
|---|
| 649 | |
|---|
| 650 | PINT_sm_msgarray_op msgarray_op; |
|---|
| 651 | |
|---|
| 652 | PVFS_handle target_handle; |
|---|
| 653 | PVFS_fs_id target_fs_id; |
|---|
| 654 | PVFS_object_attr *target_object_attr; |
|---|
| 655 | |
|---|
| 656 | PINT_prelude_flag prelude_mask; |
|---|
| 657 | |
|---|
| 658 | enum PINT_server_req_access_type access_type; |
|---|
| 659 | enum PINT_server_sched_policy sched_policy; |
|---|
| 660 | |
|---|
| 661 | int num_pjmp_frames; |
|---|
| 662 | |
|---|
| 663 | union |
|---|
| 664 | { |
|---|
| 665 | /* request-specific scratch spaces for use during processing */ |
|---|
| 666 | struct PINT_server_create_op create; |
|---|
| 667 | struct PINT_server_eattr_op eattr; |
|---|
| 668 | struct PINT_server_getattr_op getattr; |
|---|
| 669 | struct PINT_server_listattr_op listattr; |
|---|
| 670 | struct PINT_server_getconfig_op getconfig; |
|---|
| 671 | struct PINT_server_lookup_op lookup; |
|---|
| 672 | struct PINT_server_crdirent_op crdirent; |
|---|
| 673 | struct PINT_server_readdir_op readdir; |
|---|
| 674 | struct PINT_server_remove_op remove; |
|---|
| 675 | struct PINT_server_chdirent_op chdirent; |
|---|
| 676 | struct PINT_server_rmdirent_op rmdirent; |
|---|
| 677 | struct PINT_server_io_op io; |
|---|
| 678 | struct PINT_server_small_io_op small_io; |
|---|
| 679 | struct PINT_server_flush_op flush; |
|---|
| 680 | struct PINT_server_truncate_op truncate; |
|---|
| 681 | struct PINT_server_mkdir_op mkdir; |
|---|
| 682 | struct PINT_server_mgmt_remove_dirent_op mgmt_remove_dirent; |
|---|
| 683 | struct PINT_server_mgmt_get_dirdata_op mgmt_get_dirdata_handle; |
|---|
| 684 | struct PINT_server_precreate_pool_refiller_op |
|---|
| 685 | precreate_pool_refiller; |
|---|
| 686 | struct PINT_server_batch_create_op batch_create; |
|---|
| 687 | struct PINT_server_batch_remove_op batch_remove; |
|---|
| 688 | struct PINT_server_unstuff_op unstuff; |
|---|
| 689 | struct PINT_server_create_copies_op create_copies; |
|---|
| 690 | struct PINT_server_mirror_op mirror; |
|---|
| 691 | struct PINT_server_tree_communicate_op tree_communicate; |
|---|
| 692 | } u; |
|---|
| 693 | |
|---|
| 694 | } PINT_server_op; |
|---|
| 695 | |
|---|
| 696 | #define CREATE_LOCAL_OP(__s_op) \ |
|---|
| 697 | do { \ |
|---|
| 698 | __s_op = malloc(sizeof(struct PINT_server_op)); \ |
|---|
| 699 | if(!__s_op) { js_p->error_code = -PVFS_ENOMEM; return SM_ACTION_COMPLETE; } \ |
|---|
| 700 | memset(__s_op, 0, sizeof(struct PINT_server_op)); \ |
|---|
| 701 | __s_op->req = &__s_op->decoded.stub_dec.req; \ |
|---|
| 702 | } while (0) |
|---|
| 703 | |
|---|
| 704 | #define PINT_CREATE_SUBORDINATE_SERVER_FRAME(__smcb, __s_op, __handle, __fs_id, __location, __req, __task_id) \ |
|---|
| 705 | do { \ |
|---|
| 706 | char server_name[1024]; \ |
|---|
| 707 | struct server_configuration_s *server_config = get_server_config_struct(); \ |
|---|
| 708 | __s_op = malloc(sizeof(struct PINT_server_op)); \ |
|---|
| 709 | if(!__s_op) { return -PVFS_ENOMEM; } \ |
|---|
| 710 | memset(__s_op, 0, sizeof(struct PINT_server_op)); \ |
|---|
| 711 | __s_op->req = &__s_op->decoded.stub_dec.req; \ |
|---|
| 712 | PINT_sm_push_frame(__smcb, __task_id, __s_op); \ |
|---|
| 713 | if (__location != LOCAL_OPERATION && __location != REMOTE_OPERATION && __handle) { \ |
|---|
| 714 | PINT_cached_config_get_server_name(server_name, 1024, __handle, __fs_id); \ |
|---|
| 715 | } \ |
|---|
| 716 | if (__location != REMOTE_OPERATION && (__location == LOCAL_OPERATION || ( __handle && ! strcmp(server_config->host_id, server_name)))) { \ |
|---|
| 717 | __location = LOCAL_OPERATION; \ |
|---|
| 718 | __req = __s_op->req; \ |
|---|
| 719 | __s_op->prelude_mask = PRELUDE_SCHEDULER_DONE | PRELUDE_PERM_CHECK_DONE | PRELUDE_LOCAL_CALL; \ |
|---|
| 720 | } \ |
|---|
| 721 | else { \ |
|---|
| 722 | memset(&__s_op->msgarray_op, 0, sizeof(PINT_sm_msgarray_op)); \ |
|---|
| 723 | PINT_serv_init_msgarray_params(__s_op, __fs_id); \ |
|---|
| 724 | } \ |
|---|
| 725 | } while (0) |
|---|
| 726 | |
|---|
| 727 | |
|---|
| 728 | /* PINT_ACCESS_DEBUG() |
|---|
| 729 | * |
|---|
| 730 | * macro for consistent printing of access records |
|---|
| 731 | * |
|---|
| 732 | * no return value |
|---|
| 733 | */ |
|---|
| 734 | #ifdef GOSSIP_DISABLE_DEBUG |
|---|
| 735 | #define PINT_ACCESS_DEBUG(__s_op, __mask, format, f...) do {} while (0) |
|---|
| 736 | #else |
|---|
| 737 | #define PINT_ACCESS_DEBUG(__s_op, __mask, format, f...) \ |
|---|
| 738 | PINT_server_access_debug(__s_op, __mask, format, ##f) |
|---|
| 739 | #endif |
|---|
| 740 | |
|---|
| 741 | void PINT_server_access_debug(PINT_server_op * s_op, |
|---|
| 742 | int64_t debug_mask, |
|---|
| 743 | const char * format, |
|---|
| 744 | ...) __attribute__((format(printf, 3, 4))); |
|---|
| 745 | |
|---|
| 746 | /* server side state machines */ |
|---|
| 747 | extern struct PINT_state_machine_s pvfs2_mirror_sm; |
|---|
| 748 | |
|---|
| 749 | |
|---|
| 750 | /* nested state machines */ |
|---|
| 751 | extern struct PINT_state_machine_s pvfs2_get_attr_work_sm; |
|---|
| 752 | extern struct PINT_state_machine_s pvfs2_get_attr_with_prelude_sm; |
|---|
| 753 | extern struct PINT_state_machine_s pvfs2_prelude_sm; |
|---|
| 754 | extern struct PINT_state_machine_s pvfs2_prelude_work_sm; |
|---|
| 755 | extern struct PINT_state_machine_s pvfs2_final_response_sm; |
|---|
| 756 | extern struct PINT_state_machine_s pvfs2_check_entry_not_exist_sm; |
|---|
| 757 | extern struct PINT_state_machine_s pvfs2_remove_work_sm; |
|---|
| 758 | extern struct PINT_state_machine_s pvfs2_remove_with_prelude_sm; |
|---|
| 759 | extern struct PINT_state_machine_s pvfs2_mkdir_work_sm; |
|---|
| 760 | extern struct PINT_state_machine_s pvfs2_unexpected_sm; |
|---|
| 761 | extern struct PINT_state_machine_s pvfs2_create_immutable_copies_sm; |
|---|
| 762 | extern struct PINT_state_machine_s pvfs2_call_msgpairarray_sm; |
|---|
| 763 | extern struct PINT_state_machine_s pvfs2_mirror_work_sm; |
|---|
| 764 | extern struct PINT_state_machine_s pvfs2_tree_remove_work_sm; |
|---|
| 765 | extern struct PINT_state_machine_s pvfs2_tree_get_file_size_work_sm; |
|---|
| 766 | |
|---|
| 767 | /* Exported Prototypes */ |
|---|
| 768 | struct server_configuration_s *get_server_config_struct(void); |
|---|
| 769 | |
|---|
| 770 | /* exported state machine resource reclamation function */ |
|---|
| 771 | int server_post_unexpected_recv(job_status_s *js_p); |
|---|
| 772 | int server_state_machine_start( PINT_smcb *smcb, job_status_s *js_p); |
|---|
| 773 | int server_state_machine_complete(PINT_smcb *smcb); |
|---|
| 774 | int server_state_machine_terminate(PINT_smcb *smcb, job_status_s *js_p); |
|---|
| 775 | |
|---|
| 776 | /* lists of server ops */ |
|---|
| 777 | extern struct qlist_head posted_sop_list; |
|---|
| 778 | extern struct qlist_head inprogress_sop_list; |
|---|
| 779 | |
|---|
| 780 | /* starts state machines not associated with an incoming request */ |
|---|
| 781 | int server_state_machine_alloc_noreq( |
|---|
| 782 | enum PVFS_server_op op, struct PINT_smcb ** new_op); |
|---|
| 783 | int server_state_machine_start_noreq( |
|---|
| 784 | struct PINT_smcb *new_op); |
|---|
| 785 | |
|---|
| 786 | /* INCLUDE STATE-MACHINE.H DOWN HERE */ |
|---|
| 787 | #if 0 |
|---|
| 788 | #define PINT_OP_STATE PINT_server_op |
|---|
| 789 | #define PINT_OP_STATE_GET_MACHINE(_op) \ |
|---|
| 790 | ((_op >= 0 && _op < PVFS_SERV_NUM_OPS) ? \ |
|---|
| 791 | PINT_server_req_table[_op].params->sm : NULL) |
|---|
| 792 | #endif |
|---|
| 793 | |
|---|
| 794 | #include "pvfs2-internal.h" |
|---|
| 795 | |
|---|
| 796 | struct PINT_state_machine_s *server_op_state_get_machine(int); |
|---|
| 797 | |
|---|
| 798 | #endif /* __PVFS_SERVER_H */ |
|---|
| 799 | |
|---|
| 800 | /* |
|---|
| 801 | * Local variables: |
|---|
| 802 | * c-indent-level: 4 |
|---|
| 803 | * c-basic-offset: 4 |
|---|
| 804 | * End: |
|---|
| 805 | * |
|---|
| 806 | * vim: ts=8 sts=4 sw=4 expandtab |
|---|
| 807 | */ |
|---|