home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / src / client / sysint / client-state-machine.h < prev    next >
C/C++ Source or Header  |  2011-03-22  |  26KB  |  839 lines

  1. /*
  2.  * (C) 2003 Clemson University and The University of Chicago
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6.  
  7. /** \file
  8.  *  Declarations for state machine processing on clients.
  9.  */
  10.  
  11. #ifndef __PVFS2_CLIENT_STATE_MACHINE_H
  12. #define __PVFS2_CLIENT_STATE_MACHINE_H
  13.  
  14. /*
  15.   NOTE: state-machine.h is included at the bottom so we can define all
  16.   the client-sm structures before it's included
  17. */
  18. #include "pvfs2-sysint.h"
  19. #include "pvfs2-types.h"
  20. #include "pvfs2-storage.h"
  21. #include "pvfs2-util.h"
  22. #include "PINT-reqproto-encode.h"
  23. #include "job.h"
  24. #include "trove.h"
  25. #include "acache.h"
  26. #include "id-generator.h"
  27. #include "msgpairarray.h"
  28. #include "pint-sysint-utils.h"
  29. #include "pint-perf-counter.h"
  30. #include "state-machine.h"
  31. #include "pvfs2-hint.h"
  32. #include "pint-event.h"
  33.  
  34. #define MAX_LOOKUP_SEGMENTS PVFS_REQ_LIMIT_PATH_SEGMENT_COUNT
  35. #define MAX_LOOKUP_CONTEXTS PVFS_REQ_LIMIT_MAX_SYMLINK_RESOLUTION_COUNT
  36.  
  37. /* Default client timeout in seconds used to set the timeout for jobs that
  38.  * send or receive request messages.
  39.  */
  40. #ifndef PVFS2_CLIENT_JOB_BMI_TIMEOUT_DEFAULT
  41. #define PVFS2_CLIENT_JOB_BMI_TIMEOUT_DEFAULT 30
  42. #endif
  43.  
  44. /* Default number of times to retry restartable client operations. */
  45. #define PVFS2_CLIENT_RETRY_LIMIT_DEFAULT  (5)
  46.  
  47. /* Default number of milliseconds to delay before retries */
  48. #define PVFS2_CLIENT_RETRY_DELAY_MS_DEFAULT  2000
  49.  
  50. int PINT_client_state_machine_initialize(void);
  51. void PINT_client_state_machine_finalize(void);
  52. job_context_id PINT_client_get_sm_context(void);
  53.  
  54. /* PINT_client_sm_recv_state_s
  55.  *
  56.  * This is used for extra receives, such as acknowledgements from
  57.  * servers at the end of write operations.
  58.  */
  59. typedef struct PINT_client_sm_recv_state_s
  60. {
  61.     int max_resp_sz;
  62.     void *encoded_resp_p;
  63.     job_id_t recv_id;
  64.     job_status_s recv_status;
  65.     PVFS_error op_status;
  66. } PINT_client_sm_recv_state;
  67.  
  68. struct PINT_client_remove_sm
  69. {
  70.     char *object_name;   /* input parameter */
  71.     int stored_error_code;
  72.     int    retry_count;
  73. };
  74.  
  75. struct PINT_client_create_sm
  76. {
  77.     char *object_name;                /* input parameter */
  78.     PVFS_object_attr attr;            /* input parameter */
  79.     PVFS_sysresp_create *create_resp; /* in/out parameter */
  80.  
  81.     int retry_count;
  82.     int num_data_files;
  83.     int user_requested_num_data_files;
  84.     int stored_error_code;
  85.  
  86.     PINT_dist *dist;
  87.     PVFS_sys_layout layout;
  88.  
  89.     PVFS_handle metafile_handle;
  90.     int datafile_count;
  91.     PVFS_handle *datafile_handles;
  92.     int stuffed;
  93.     PVFS_object_attr store_attr;
  94.  
  95.     PVFS_handle handles[2];
  96. };
  97.  
  98. struct PINT_client_mkdir_sm
  99. {
  100.     char *object_name;              /* input parameter  */
  101.     PVFS_sysresp_mkdir *mkdir_resp; /* in/out parameter */
  102.     PVFS_sys_attr sys_attr;         /* input parameter  */
  103.     PVFS_ds_keyval *key_array;
  104.     PVFS_ds_keyval *val_array;
  105.  
  106.     int retry_count;
  107.     int stored_error_code;
  108.     PVFS_handle metafile_handle;
  109. };
  110.  
  111. struct PINT_client_symlink_sm
  112. {
  113.     char *link_name;                /* input parameter */
  114.     char *link_target;              /* input parameter */
  115.     PVFS_sysresp_symlink *sym_resp; /* in/out parameter*/
  116.     PVFS_sys_attr sys_attr;         /* input parameter */
  117.  
  118.     int retry_count;
  119.     int stored_error_code;
  120.     PVFS_handle symlink_handle;
  121. };
  122.  
  123. struct PINT_client_getattr_sm
  124. {
  125.     PVFS_sysresp_getattr *getattr_resp_p; /* destination for output */
  126. };
  127.  
  128. struct PINT_client_setattr_sm
  129. {
  130.     PVFS_sys_attr sys_attr; /* input parameter */
  131. };
  132.  
  133. struct PINT_client_mgmt_remove_dirent_sm
  134. {
  135.     char *entry;
  136. };
  137.  
  138. struct PINT_client_mgmt_create_dirent_sm
  139. {
  140.     char *entry;
  141.     PVFS_handle entry_handle;
  142. };
  143.  
  144. struct PINT_client_mgmt_get_dirdata_handle_sm
  145. {
  146.     PVFS_handle *dirdata_handle;
  147. };
  148.  
  149. /* this structure is used to handle mirrored retries in the small-io case*/
  150. typedef struct PINT_client_mirror_ctx
  151. {
  152.   /*which copy of the mirrored handle are we using?*/
  153.   uint32_t     current_copies_count;
  154.  
  155.   /*the primary datahandle*/
  156.   PVFS_handle  original_datahandle;
  157.  
  158.   /*the server_nr for the primary datahandle*/
  159.   uint32_t original_server_nr;
  160.  
  161.   /*do we retry the primary or use a mirrored handle?*/ 
  162.   PVFS_boolean retry_original;
  163.  
  164.   /*did the current message for this handle complete without any errors?*/
  165.   PVFS_boolean msg_completed;
  166.  
  167. } PINT_client_small_io_ctx;
  168.  
  169.  
  170.  
  171. /* this structure is used to handle mirrored retries when 
  172.  * pvfs2_client_datafile_getattr_sizes_sm is called.
  173. */
  174. typedef struct PINT_client_mirror_ctx PINT_client_getattr_mirror_ctx;
  175.  
  176.  
  177.  
  178. typedef struct PINT_client_io_ctx
  179. {
  180.     /* the index of the current context (in the context array) */
  181.     int index;
  182.  
  183.     /* the metafile's dfile server index we're communicating with */
  184.     int server_nr;
  185.  
  186.     /* the data handle we're responsible for doing I/O on */
  187.     PVFS_handle data_handle;
  188.  
  189.     /* first level index into mirror_dfile_array. second level is         */
  190.     /* the server_nr. mirror_dfile_array[current_copies_count][server_nr] */
  191.     uint32_t current_copies_count;
  192.  
  193.     /* increment after one set of mirrors have been tried. */
  194.     uint32_t local_retry_count;
  195.  
  196.     /* should we retry the original or not? */
  197.     uint32_t retry_original;
  198.  
  199.     job_id_t flow_job_id;
  200.     job_status_s flow_status;
  201.     flow_descriptor flow_desc;
  202.     PVFS_msg_tag_t session_tag;
  203.  
  204.     PINT_sm_msgpair_state msg;
  205.     PINT_client_sm_recv_state write_ack;
  206.  
  207.     /*
  208.       all *_has_been_posted fields are used at io_analyze_results time
  209.       to know if we should be checking for errors on particular fields
  210.     */
  211.     int msg_send_has_been_posted;
  212.     int msg_recv_has_been_posted;
  213.     int flow_has_been_posted;
  214.     int write_ack_has_been_posted;
  215.  
  216.     /*
  217.       all *_in_progress fields are used at cancellation time to
  218.       determine what operations are currently in flight
  219.     */
  220.     int msg_send_in_progress;
  221.     int msg_recv_in_progress;
  222.     int flow_in_progress;
  223.     int write_ack_in_progress;
  224.  
  225. } PINT_client_io_ctx;
  226.  
  227. struct PINT_client_io_sm
  228. {
  229.     /* input parameters */
  230.     enum PVFS_io_type io_type;
  231.     PVFS_Request file_req;
  232.     PVFS_offset file_req_offset;
  233.     void *buffer;
  234.     PVFS_Request mem_req;
  235.  
  236.     /* output parameter */
  237.     PVFS_sysresp_io *io_resp_p;
  238.  
  239.     enum PVFS_flowproto_type flowproto_type;
  240.     enum PVFS_encoding_type encoding;
  241.  
  242.     int *datafile_index_array;
  243.     int datafile_count;
  244.  
  245.     int msgpair_completion_count;
  246.     int flow_completion_count;
  247.     int write_ack_completion_count;
  248.  
  249.     PINT_client_io_ctx *contexts;
  250.     int context_count;
  251.  
  252.     PINT_client_small_io_ctx *small_io_ctx;
  253.  
  254.     int total_cancellations_remaining;
  255.  
  256.     int retry_count;
  257.     int stored_error_code;
  258.  
  259.     PVFS_size total_size;
  260.  
  261.     PVFS_size * dfile_size_array;
  262.     int small_io;
  263. };
  264.  
  265. struct PINT_client_flush_sm
  266. {
  267. };
  268.  
  269. struct PINT_client_readdir_sm
  270. {
  271.     PVFS_ds_position pos_token;         /* input parameter */
  272.     int dirent_limit;                   /* input parameter */
  273.     PVFS_sysresp_readdir *readdir_resp; /* in/out parameter*/
  274. };
  275.  
  276. struct handle_to_index {
  277.     PVFS_handle handle;
  278.     int         handle_index;/* This is the index into the dirent array itself */
  279.     int         aux_index; /* this is used to store the ordinality of the dfile handles */
  280. };
  281.  
  282. struct PINT_client_readdirplus_sm
  283. {
  284.     PVFS_ds_position pos_token;         /* input parameter */
  285.     int dirent_limit;                   /* input parameter */
  286.     int attrmask;                       /* input parameter */
  287.     PVFS_sysresp_readdirplus *readdirplus_resp; /* in/out parameter*/
  288.     /* scratch variables */
  289.     int nhandles;  
  290.     int svr_count;
  291.     PVFS_size        **size_array;
  292.     PVFS_object_attr *obj_attr_array;
  293.     struct handle_to_index *input_handle_array;
  294.     PVFS_BMI_addr_t *server_addresses;
  295.     int  *handle_count;
  296.     PVFS_handle     **handles;
  297. };
  298.  
  299. typedef struct
  300. {
  301.     char *seg_name;
  302.     char *seg_remaining;
  303.     PVFS_object_attr seg_attr;
  304.     PVFS_object_ref seg_starting_refn;
  305.     PVFS_object_ref seg_resolved_refn;
  306. } PINT_client_lookup_sm_segment;
  307.  
  308. typedef struct
  309. {
  310.     int total_segments;
  311.     int current_segment;
  312.     PINT_client_lookup_sm_segment segments[MAX_LOOKUP_SEGMENTS];
  313.     PVFS_object_ref ctx_starting_refn;
  314.     PVFS_object_ref ctx_resolved_refn;
  315. } PINT_client_lookup_sm_ctx;
  316.  
  317. struct PINT_client_lookup_sm
  318. {
  319.     char *orig_pathname;              /* input parameter */
  320.     PVFS_object_ref starting_refn;    /* input parameter */
  321.     PVFS_sysresp_lookup *lookup_resp; /* in/out parameter*/
  322.     int follow_link;                  /* input parameter */
  323.     int skipped_final_resolution;
  324.     int current_context;
  325.     int context_count;
  326.     PINT_client_lookup_sm_ctx * contexts;
  327. };
  328.  
  329. struct PINT_client_rename_sm
  330. {
  331.     char *entries[2];                /* old/new input entry names */
  332.     PVFS_object_ref parent_refns[2]; /* old/new input parent refns */
  333.  
  334.     PVFS_object_ref refns[2];        /* old/new object refns */
  335.     PVFS_ds_type types[2];           /* old/new object types */
  336.     int retry_count;
  337.     int stored_error_code;
  338.     int rmdirent_index;
  339.     int target_dirent_exists;
  340.     PVFS_handle old_dirent_handle;
  341. };
  342.  
  343. struct PINT_client_mgmt_setparam_list_sm 
  344. {
  345.     PVFS_fs_id fs_id;
  346.     enum PVFS_server_param param;
  347.     struct PVFS_mgmt_setparam_value *value;
  348.     PVFS_id_gen_t *addr_array;
  349.     int count;
  350.     int *root_check_status_array;
  351.     PVFS_error_details *details;
  352. };
  353.  
  354. struct PINT_client_mgmt_statfs_list_sm
  355. {
  356.     PVFS_fs_id fs_id;
  357.     struct PVFS_mgmt_server_stat *stat_array;
  358.     int count; 
  359.     PVFS_id_gen_t *addr_array;
  360.     PVFS_error_details *details;
  361.     PVFS_sysresp_statfs* resp; /* ignored by mgmt functions */
  362. };
  363.  
  364. struct PINT_client_mgmt_perf_mon_list_sm
  365. {
  366.     PVFS_fs_id fs_id;
  367.     struct PVFS_mgmt_perf_stat **perf_matrix;
  368.     uint64_t *end_time_ms_array;
  369.     int server_count; 
  370.     int history_count; 
  371.     PVFS_id_gen_t *addr_array;
  372.     uint32_t *next_id_array;
  373.     PVFS_error_details *details;
  374. };
  375.  
  376. struct PINT_client_mgmt_event_mon_list_sm
  377. {
  378.     PVFS_fs_id fs_id;
  379.     struct PVFS_mgmt_event **event_matrix;
  380.     int server_count; 
  381.     int event_count; 
  382.     PVFS_id_gen_t *addr_array;
  383.     PVFS_error_details *details;
  384. };
  385.  
  386. struct PINT_client_mgmt_iterate_handles_list_sm
  387. {
  388.     PVFS_fs_id fs_id;
  389.     int server_count; 
  390.     PVFS_id_gen_t *addr_array;
  391.     PVFS_handle **handle_matrix;
  392.     int *handle_count_array;
  393.     PVFS_ds_position *position_array;
  394.     PVFS_error_details *details;
  395.     int flags;
  396. };
  397.  
  398. struct PINT_client_mgmt_get_dfile_array_sm
  399. {
  400.     PVFS_handle *dfile_array;
  401.     int dfile_count;
  402. };
  403.  
  404. struct PINT_client_truncate_sm
  405. {
  406.     PVFS_size size; /* new logical size of object*/
  407. };
  408.  
  409. struct PINT_server_get_config_sm
  410. {
  411.     struct server_configuration_s *config;
  412.     struct PVFS_sys_mntent *mntent;
  413.     char *fs_config_buf;
  414.     uint32_t fs_config_buf_size;
  415.     int persist_config_buffers;
  416.     int free_config_flag;
  417. };
  418.  
  419. struct PINT_server_fetch_config_sm_state
  420. {
  421.     int nservers;
  422.     PVFS_BMI_addr_t *addr_array;
  423.     char **fs_config_bufs;
  424.     int *fs_config_buf_size;
  425.     int result_count; /* number of servers that actually responded */
  426.     int* result_indexes; /* index into fs_config_bufs of valid responses */
  427. };
  428.  
  429.  
  430.  
  431. /* flag to disable cached lookup during getattr nested sm */
  432. #define PINT_SM_GETATTR_BYPASS_CACHE 1
  433.  
  434. typedef struct PINT_sm_getattr_state
  435. {
  436.     PVFS_object_ref object_ref;
  437.  
  438.    /* request sys attrmask.  Some combination of
  439.      * PVFS_ATTR_SYS_*
  440.      */
  441.     uint32_t req_attrmask;
  442.     
  443.     /*
  444.       Either from the acache or full getattr op, this is the resuling
  445.       attribute that can be used by calling state machines
  446.     */
  447.     PVFS_object_attr attr;
  448.  
  449.  
  450.     /* mirror retry information */
  451.     PINT_client_getattr_mirror_ctx *mir_ctx_array;
  452.     uint32_t mir_ctx_count;
  453.     uint32_t retry_count;
  454.     uint32_t *index_to_server;
  455.  
  456.     PVFS_ds_type ref_type;
  457.  
  458.     PVFS_size * size_array;
  459.     PVFS_size size;
  460.  
  461.     int flags;
  462.     
  463. } PINT_sm_getattr_state;
  464.  
  465. #define PINT_SM_GETATTR_STATE_FILL(_state, _objref, _mask, _reftype, _flags) \
  466.     do { \
  467.         memset(&(_state), 0, sizeof(PINT_sm_getattr_state)); \
  468.         (_state).object_ref.fs_id = (_objref).fs_id; \
  469.         (_state).object_ref.handle = (_objref).handle; \
  470.         (_state).req_attrmask = _mask; \
  471.         (_state).ref_type = _reftype; \
  472.         (_state).flags = _flags; \
  473.     } while(0)
  474.  
  475. #define PINT_SM_GETATTR_STATE_CLEAR(_state) \
  476.     do { \
  477.         PINT_free_object_attr(&(_state).attr); \
  478.         memset(&(_state), 0, sizeof(PINT_sm_getattr_state)); \
  479.     } while(0)
  480.  
  481. #define PINT_SM_DATAFILE_SIZE_ARRAY_INIT(_array, _count) \
  482.     do { \
  483.         (*(_array)) = malloc(sizeof(PVFS_size) * (_count)); \
  484.         memset(*(_array), 0, (sizeof(PVFS_size) * (_count))); \
  485.     } while(0)
  486.  
  487. #define PINT_SM_DATAFILE_SIZE_ARRAY_DESTROY(_array) \
  488.     do { \
  489.         free(*(_array)); \
  490.         *(_array) = NULL; \
  491.     } while(0)
  492.  
  493. struct PINT_client_geteattr_sm
  494. {
  495.     int32_t nkey;
  496.     PVFS_ds_keyval *key_array;
  497.     PVFS_size *size_array;
  498.     PVFS_sysresp_geteattr *resp_p;
  499. };
  500.  
  501. struct PINT_client_seteattr_sm
  502. {
  503.     int32_t nkey;
  504.     int32_t flags; /* flags specify if attrs should not exist (XATTR_CREATE) or
  505.                       if they should exist (XATTR_REPLACE) or neither */
  506.     PVFS_ds_keyval *key_array;
  507.     PVFS_ds_keyval *val_array;
  508. };
  509.  
  510. struct PINT_client_deleattr_sm
  511. {
  512.     PVFS_ds_keyval *key_p;
  513. };
  514.  
  515. struct PINT_client_listeattr_sm
  516. {
  517.     PVFS_ds_position pos_token;         /* input parameter */
  518.     int32_t nkey;                       /* input parameter */
  519.     PVFS_size *size_array;              /* Input/Output */
  520.     PVFS_sysresp_listeattr *resp_p;     /* Output */
  521. };
  522.  
  523. struct PINT_client_perf_count_timer_sm
  524. {
  525.     unsigned int *interval_secs;
  526.     struct PINT_perf_counter *pc;
  527. };
  528.  
  529. struct PINT_client_job_timer_sm
  530. {
  531.     job_id_t job_id;
  532. };
  533.  
  534. struct PINT_sysdev_unexp_sm
  535. {
  536.     struct PINT_dev_unexp_info *info;
  537. };
  538.  
  539. typedef struct 
  540. {
  541.     PVFS_dirent **dirent_array;
  542.     uint32_t      *dirent_outcount;
  543.     PVFS_ds_position *token;
  544.     uint64_t         *directory_version;
  545.     PVFS_ds_position pos_token;     /* input parameter */
  546.     int32_t      dirent_limit;      /* input parameter */
  547. } PINT_sm_readdir_state;
  548.  
  549. typedef struct PINT_client_sm
  550. {
  551.     /* this code removed and corresponding fields added to the generic
  552.      * state machine code in the PINT_smcb struct
  553.      */
  554.     /* used internally by client-state-machine.c */
  555.     PVFS_sys_op_id sys_op_id;
  556.     void *user_ptr;
  557.  
  558.     PINT_event_id event_id;
  559.  
  560.     /* stores the final operation error code on operation exit */
  561.     PVFS_error error_code;
  562.  
  563.     int comp_ct; /* used to keep up with completion of multiple
  564.           * jobs for some states; typically set and
  565.           * then decremented to zero as jobs complete */
  566.  
  567.     /* generic getattr used with getattr sub state machines */
  568.     PINT_sm_getattr_state getattr;
  569.     /* generic dirent array used by both readdir and readdirplus state machines */
  570.     PINT_sm_readdir_state readdir;
  571.  
  572.     /* fetch_config state used by the nested fetch config state machines */
  573.     struct PINT_server_fetch_config_sm_state fetch_config;
  574.  
  575.     PVFS_hint hints;
  576.  
  577.     PINT_sm_msgarray_op msgarray_op;
  578.  
  579.     PVFS_object_ref object_ref;
  580.     PVFS_object_ref parent_ref;
  581.  
  582.  
  583.     PVFS_credentials *cred_p;
  584.     union
  585.     {
  586.     struct PINT_client_remove_sm remove;
  587.         struct PINT_client_create_sm create;
  588.     struct PINT_client_mkdir_sm mkdir;
  589.     struct PINT_client_symlink_sm sym;
  590.     struct PINT_client_getattr_sm getattr;
  591.     struct PINT_client_setattr_sm setattr;
  592.     struct PINT_client_io_sm io;
  593.     struct PINT_client_flush_sm flush;
  594.     struct PINT_client_readdir_sm readdir;
  595.         struct PINT_client_readdirplus_sm readdirplus;
  596.     struct PINT_client_lookup_sm lookup;
  597.     struct PINT_client_rename_sm rename;
  598.     struct PINT_client_mgmt_setparam_list_sm setparam_list;
  599.     struct PINT_client_truncate_sm  truncate;
  600.     struct PINT_client_mgmt_statfs_list_sm statfs_list;
  601.     struct PINT_client_mgmt_perf_mon_list_sm perf_mon_list;
  602.     struct PINT_client_mgmt_event_mon_list_sm event_mon_list;
  603.     struct PINT_client_mgmt_iterate_handles_list_sm iterate_handles_list;
  604.     struct PINT_client_mgmt_get_dfile_array_sm get_dfile_array;
  605.         struct PINT_client_mgmt_remove_dirent_sm mgmt_remove_dirent;
  606.         struct PINT_client_mgmt_create_dirent_sm mgmt_create_dirent;
  607.         struct PINT_client_mgmt_get_dirdata_handle_sm mgmt_get_dirdata_handle;
  608.     struct PINT_server_get_config_sm get_config;
  609.     struct PINT_client_geteattr_sm geteattr;
  610.     struct PINT_client_seteattr_sm seteattr;
  611.     struct PINT_client_deleattr_sm deleattr;
  612.     struct PINT_client_listeattr_sm listeattr;
  613.         struct PINT_client_perf_count_timer_sm perf_count_timer;
  614.         struct PINT_sysdev_unexp_sm sysdev_unexp;
  615.         struct PINT_client_job_timer_sm job_timer;
  616.     } u;
  617. } PINT_client_sm;
  618.  
  619. /* sysint post/test functions */
  620. PVFS_error PINT_client_state_machine_post(
  621.     PINT_smcb *smcb,
  622.     PVFS_sys_op_id *op_id,
  623.     void *user_ptr);
  624.  
  625. PVFS_error PINT_client_state_machine_release(
  626.     PINT_smcb * smcb);
  627.  
  628. PVFS_error PINT_sys_dev_unexp(
  629.     struct PINT_dev_unexp_info *info,
  630.     job_status_s *jstat,
  631.     PVFS_sys_op_id *op_id,
  632.     void *user_ptr);
  633.  
  634. PVFS_error PINT_client_state_machine_test(
  635.     PVFS_sys_op_id op_id,
  636.     int *error_code);
  637.  
  638. PVFS_error PINT_client_state_machine_testsome(
  639.     PVFS_sys_op_id *op_id_array,
  640.     int *op_count, /* in/out */
  641.     void **user_ptr_array,
  642.     int *error_code_array,
  643.     int timeout_ms);
  644.  
  645. /* exposed wrappers around the id-generator code */
  646. static inline int PINT_id_gen_safe_register(
  647.     PVFS_sys_op_id *new_id,
  648.     void *item)
  649. {
  650.     return id_gen_safe_register(new_id, item);
  651. }
  652.  
  653. static inline void *PINT_id_gen_safe_lookup(
  654.     PVFS_sys_op_id id)
  655. {
  656.     return id_gen_safe_lookup(id);
  657. }
  658.  
  659. static inline int PINT_id_gen_safe_unregister(
  660.     PVFS_sys_op_id id)
  661. {
  662.     return id_gen_safe_unregister(id);
  663. }
  664.  
  665. /* debugging method for getting a string macthing the op_type */
  666. const char *PINT_client_get_name_str(int op_type);
  667.  
  668. /* used with post call to tell the system what state machine to use
  669.  * when processing a new PINT_client_sm structure.
  670.  */
  671. enum
  672. {
  673.     PVFS_SYS_REMOVE                = 1,
  674.     PVFS_SYS_CREATE                = 2,
  675.     PVFS_SYS_MKDIR                 = 3,
  676.     PVFS_SYS_SYMLINK               = 4,
  677.     PVFS_SYS_GETATTR               = 5,
  678.     PVFS_SYS_IO                    = 6,
  679.     PVFS_SYS_FLUSH                 = 7,
  680.     PVFS_SYS_TRUNCATE              = 8,
  681.     PVFS_SYS_READDIR               = 9,
  682.     PVFS_SYS_SETATTR               = 10,
  683.     PVFS_SYS_LOOKUP                = 11,
  684.     PVFS_SYS_RENAME                = 12,
  685.     PVFS_SYS_GETEATTR              = 13,
  686.     PVFS_SYS_SETEATTR              = 14,
  687.     PVFS_SYS_DELEATTR              = 15,
  688.     PVFS_SYS_LISTEATTR             = 16,
  689.     PVFS_SYS_SMALL_IO              = 17,
  690.     PVFS_SYS_STATFS                = 18,
  691.     PVFS_SYS_FS_ADD                = 19,
  692.     PVFS_SYS_READDIRPLUS           = 20,
  693.     PVFS_MGMT_SETPARAM_LIST        = 70,
  694.     PVFS_MGMT_NOOP                 = 71,
  695.     PVFS_MGMT_STATFS_LIST          = 72,
  696.     PVFS_MGMT_PERF_MON_LIST        = 73,
  697.     PVFS_MGMT_ITERATE_HANDLES_LIST = 74,
  698.     PVFS_MGMT_GET_DFILE_ARRAY      = 75,
  699.     PVFS_MGMT_EVENT_MON_LIST       = 76,
  700.     PVFS_MGMT_REMOVE_OBJECT        = 77,
  701.     PVFS_MGMT_REMOVE_DIRENT        = 78,
  702.     PVFS_MGMT_CREATE_DIRENT        = 79,
  703.     PVFS_MGMT_GET_DIRDATA_HANDLE   = 80,
  704.     PVFS_SERVER_GET_CONFIG         = 200,
  705.     PVFS_CLIENT_JOB_TIMER          = 300,
  706.     PVFS_CLIENT_PERF_COUNT_TIMER   = 301,
  707.     PVFS_DEV_UNEXPECTED            = 400
  708. };
  709.  
  710. #define PVFS_OP_SYS_MAXVALID  21
  711. #define PVFS_OP_SYS_MAXVAL 69
  712. #define PVFS_OP_MGMT_MAXVALID 81
  713. #define PVFS_OP_MGMT_MAXVAL 199
  714.  
  715. int PINT_client_io_cancel(job_id_t id);
  716.  
  717. /* internal non-blocking helper methods */
  718. int PINT_client_wait_internal(
  719.     PVFS_sys_op_id op_id,
  720.     const char *in_op_str,
  721.     int *out_error,
  722.     const char *in_class_str);
  723.  
  724. void PINT_sys_release(PVFS_sys_op_id op_id);
  725.  
  726. void PINT_mgmt_release(PVFS_mgmt_op_id op_id);
  727.  
  728. /* internal helper macros */
  729. #define PINT_init_sysint_credentials(sm_p_cred_p, user_cred_p)\
  730. do {                                                          \
  731.     if (user_cred_p == NULL)                                  \
  732.     {                                                         \
  733.         gossip_lerr("Invalid user credentials! (nil)\n");     \
  734.         free(sm_p);                                           \
  735.         return -PVFS_EINVAL;                                  \
  736.     }                                                         \
  737.     sm_p_cred_p = PVFS_util_dup_credentials(user_cred_p);     \
  738.     if (!sm_p_cred_p)                                         \
  739.     {                                                         \
  740.         gossip_lerr("Failed to copy user credentials\n");     \
  741.         free(sm_p);                                           \
  742.         return -PVFS_ENOMEM;                                  \
  743.     }                                                         \
  744. } while(0)
  745.  
  746. #define PINT_init_msgarray_params(client_sm_p, __fsid)              \
  747. do {                                                                \
  748.     PINT_sm_msgpair_params *mpp = &client_sm_p->msgarray_op.params; \
  749.     struct server_configuration_s *server_config =                  \
  750.         PINT_get_server_config_struct(__fsid);                      \
  751.     mpp->job_context = pint_client_sm_context;                      \
  752.     if (server_config)                                              \
  753.     {                                                               \
  754.         mpp->job_timeout = server_config->client_job_bmi_timeout;   \
  755.         mpp->retry_limit = server_config->client_retry_limit;       \
  756.         mpp->retry_delay = server_config->client_retry_delay_ms;    \
  757.     }                                                               \
  758.     else                                                            \
  759.     {                                                               \
  760.         mpp->job_timeout = PVFS2_CLIENT_JOB_BMI_TIMEOUT_DEFAULT;    \
  761.         mpp->retry_limit = PVFS2_CLIENT_RETRY_LIMIT_DEFAULT;        \
  762.         mpp->retry_delay = PVFS2_CLIENT_RETRY_DELAY_MS_DEFAULT;     \
  763.     }                                                               \
  764.     PINT_put_server_config_struct(server_config);                   \
  765. } while(0)
  766.  
  767. struct PINT_client_op_entry_s
  768. {
  769.     struct PINT_state_machine_s * sm;
  770. };
  771.                                                                     
  772. extern struct PINT_client_op_entry_s PINT_client_sm_sys_table[];
  773. extern struct PINT_client_op_entry_s PINT_client_sm_mgmt_table[];
  774.  
  775. /* system interface function state machines */
  776. extern struct PINT_state_machine_s pvfs2_client_remove_sm;
  777. extern struct PINT_state_machine_s pvfs2_client_create_sm;
  778. extern struct PINT_state_machine_s pvfs2_client_mkdir_sm;
  779. extern struct PINT_state_machine_s pvfs2_client_symlink_sm;
  780. extern struct PINT_state_machine_s pvfs2_client_sysint_getattr_sm;
  781. extern struct PINT_state_machine_s pvfs2_client_getattr_sm;
  782. extern struct PINT_state_machine_s pvfs2_client_datafile_getattr_sizes_sm;
  783. extern struct PINT_state_machine_s pvfs2_client_setattr_sm;
  784. extern struct PINT_state_machine_s pvfs2_client_io_sm;
  785. extern struct PINT_state_machine_s pvfs2_client_small_io_sm;
  786. extern struct PINT_state_machine_s pvfs2_client_flush_sm;
  787. extern struct PINT_state_machine_s pvfs2_client_sysint_readdir_sm;
  788. extern struct PINT_state_machine_s pvfs2_client_readdir_sm;
  789. extern struct PINT_state_machine_s pvfs2_client_readdirplus_sm;
  790. extern struct PINT_state_machine_s pvfs2_client_lookup_sm;
  791. extern struct PINT_state_machine_s pvfs2_client_rename_sm;
  792. extern struct PINT_state_machine_s pvfs2_client_truncate_sm;
  793. extern struct PINT_state_machine_s pvfs2_sysdev_unexp_sm;
  794. extern struct PINT_state_machine_s pvfs2_client_job_timer_sm;
  795. extern struct PINT_state_machine_s pvfs2_client_perf_count_timer_sm;
  796. extern struct PINT_state_machine_s pvfs2_server_get_config_sm;
  797. extern struct PINT_state_machine_s pvfs2_server_fetch_config_sm;
  798. extern struct PINT_state_machine_s pvfs2_client_mgmt_setparam_list_sm;
  799. extern struct PINT_state_machine_s pvfs2_client_mgmt_statfs_list_sm;
  800. extern struct PINT_state_machine_s pvfs2_client_mgmt_perf_mon_list_sm;
  801. extern struct PINT_state_machine_s pvfs2_client_mgmt_event_mon_list_sm;
  802. extern struct PINT_state_machine_s pvfs2_client_mgmt_iterate_handles_list_sm;
  803. extern struct PINT_state_machine_s pvfs2_client_mgmt_get_dfile_array_sm;
  804. extern struct PINT_state_machine_s pvfs2_client_mgmt_noop_sm;
  805. extern struct PINT_state_machine_s pvfs2_client_mgmt_remove_object_sm;
  806. extern struct PINT_state_machine_s pvfs2_client_mgmt_remove_dirent_sm;
  807. extern struct PINT_state_machine_s pvfs2_client_mgmt_create_dirent_sm;
  808. extern struct PINT_state_machine_s pvfs2_client_mgmt_get_dirdata_handle_sm;
  809. extern struct PINT_state_machine_s pvfs2_client_get_eattr_sm;
  810. extern struct PINT_state_machine_s pvfs2_client_set_eattr_sm;
  811. extern struct PINT_state_machine_s pvfs2_client_del_eattr_sm;
  812. extern struct PINT_state_machine_s pvfs2_client_list_eattr_sm;
  813. extern struct PINT_state_machine_s pvfs2_client_statfs_sm;
  814. extern struct PINT_state_machine_s pvfs2_fs_add_sm;
  815.  
  816. /* nested state machines (helpers) */
  817. extern struct PINT_state_machine_s pvfs2_client_lookup_ncache_sm;
  818. extern struct PINT_state_machine_s pvfs2_client_remove_helper_sm;
  819. extern struct PINT_state_machine_s pvfs2_client_mgmt_statfs_list_nested_sm;
  820. extern struct PINT_state_machine_s pvfs2_server_get_config_nested_sm;
  821. extern struct PINT_state_machine_s pvfs2_server_fetch_config_nested_sm;
  822.  
  823. #include "state-machine.h"
  824.  
  825. /* method for lookup up SM from OP */
  826. struct PINT_state_machine_s *client_op_state_get_machine(int);
  827. int client_state_machine_terminate(struct PINT_smcb *, job_status_s *);
  828.  
  829. #endif /* __PVFS2_CLIENT_STATE_MACHINE_H */
  830.  
  831. /*
  832.  * Local variables:
  833.  *  c-indent-level: 4
  834.  *  c-basic-offset: 4
  835.  * End:
  836.  *
  837.  * vim: ts=8 sts=4 sw=4 expandtab
  838.  */
  839.