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 / server / pvfs2-server.h < prev    next >
C/C++ Source or Header  |  2011-03-22  |  25KB  |  789 lines

  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. };
  174.  
  175. /* optional; user-settable keys */
  176. enum 
  177. {
  178.     DIST_NAME_KEY        = 0,
  179.     DIST_PARAMS_KEY      = 1,
  180.     NUM_DFILES_KEY       = 2,
  181.     NUM_SPECIAL_KEYS     = 3, /* not an index */
  182.     METAFILE_HINT_KEY    = 3,
  183.     MIRROR_COPIES_KEY    = 4,
  184.     MIRROR_HANDLES_KEY   = 5,
  185.     MIRROR_STATUS_KEY    = 6,
  186. };
  187.  
  188. typedef enum
  189. {
  190.     SERVER_DEFAULT_INIT        = 0,
  191.     SERVER_GOSSIP_INIT         = (1 << 0),
  192.     SERVER_CONFIG_INIT         = (1 << 1),
  193.     SERVER_ENCODER_INIT        = (1 << 2),
  194.     SERVER_BMI_INIT            = (1 << 3),
  195.     SERVER_TROVE_INIT          = (1 << 4),
  196.     SERVER_FLOW_INIT           = (1 << 5),
  197.     SERVER_JOB_INIT            = (1 << 6),
  198.     SERVER_JOB_CTX_INIT        = (1 << 7),
  199.     SERVER_REQ_SCHED_INIT      = (1 << 8),
  200.     SERVER_STATE_MACHINE_INIT  = (1 << 9),
  201.     SERVER_BMI_UNEXP_POST_INIT = (1 << 10),
  202.     SERVER_SIGNAL_HANDLER_INIT = (1 << 11),
  203.     SERVER_JOB_OBJS_ALLOCATED  = (1 << 12),
  204.     SERVER_PERF_COUNTER_INIT   = (1 << 13),
  205.     SERVER_EVENT_INIT          = (1 << 14),
  206.     SERVER_JOB_TIME_MGR_INIT   = (1 << 15),
  207.     SERVER_DIST_INIT           = (1 << 16),
  208.     SERVER_CACHED_CONFIG_INIT  = (1 << 17),
  209.     SERVER_PRECREATE_INIT  = (1 << 18),
  210. } PINT_server_status_flag;
  211.  
  212. typedef enum
  213. {   
  214.     PRELUDE_SCHEDULER_DONE     = (1 << 0),
  215.     PRELUDE_GETATTR_DONE       = (1 << 1),
  216.     PRELUDE_PERM_CHECK_DONE    = (1 << 2),
  217.     PRELUDE_LOCAL_CALL         = (1 << 3),
  218. } PINT_prelude_flag;
  219.  
  220. struct PINT_server_create_op
  221. {
  222.     const char **io_servers;
  223.     const char **remote_io_servers;
  224.     int num_io_servers;
  225.     PVFS_handle* handle_array_local; 
  226.     PVFS_handle* handle_array_remote; 
  227.     int handle_array_local_count;
  228.     int handle_array_remote_count;
  229.     PVFS_error saved_error_code;
  230.     int handle_index;
  231. };
  232.  
  233. /*MIRROR structures*/
  234. typedef struct 
  235. {
  236.    /* session identifier created in the PVFS_SERV_IO request.  also used as  */
  237.    /* the flow identifier.                                                   */
  238.    bmi_msg_tag_t session_tag;
  239.  
  240.    /*destination server address*/
  241.    PVFS_BMI_addr_t svr_addr;
  242.  
  243.    /*status from PVFS_SERV_IO*/
  244.    PVFS_error io_status;
  245.  
  246.    /*variables used to setup write completion ack*/
  247.    void        *encoded_resp_p;
  248.    job_status_s recv_status;
  249.    job_id_t     recv_id;
  250.  
  251.    /*variables used to setup flow between the src & dest datahandle*/
  252.    flow_descriptor *flow_desc;
  253.    job_status_s     flow_status;
  254.    job_id_t         flow_job_id;
  255.   
  256. } write_job_t;
  257.  
  258.  
  259. /*This structure is used during the processing of a "mirror" request.*/
  260. struct PINT_server_mirror_op
  261. {
  262.    /*keep up with the number of outstanding jobs*/
  263.    int job_count;
  264.  
  265.    /*maximum response size for the write request*/
  266.    int max_resp_sz;
  267.  
  268.    /*info about each job*/
  269.    write_job_t *jobs;
  270. };
  271. typedef struct PINT_server_mirror_op PINT_server_mirror_op;
  272.  
  273. /* Source refers to the handle being copied, and destination refers to        */
  274. /* its copy.                                                                  */
  275. struct PINT_server_create_copies_op
  276. {
  277.     /*number of I/O servers required to meet the mirroring request.           */
  278.     uint32_t io_servers_required;
  279.  
  280.     /*mirroring mode. attribute key is user.pvfs2.mirror.mode*/
  281.     MIRROR_MODE mirror_mode;
  282.  
  283.     /*the expected mirroring mode tells us how to edit the retrieved mirroring*/
  284.     /*mode.  Example: if mirroring was called when immutable was set, then    */
  285.     /*the expected mirroring mode would be MIRROR_ON_IMMUTABLE.               */
  286.     MIRROR_MODE expected_mirror_mode;
  287.  
  288.     /*buffer holding list of remote servers for all copies of the file*/
  289.     char **my_remote_servers;
  290.  
  291.     /*saved error code*/
  292.     PVFS_error saved_error_code;
  293.  
  294.     /*number of copies desired. value of user.pvfs2.mirror.copies attribute*/
  295.     uint32_t copies;
  296.  
  297.     /*successful/failed writes array in order of source handles         */
  298.     /*0=>successful  !UINT64_HIGH=>failure   UINT64_HIGH=>initial state */
  299.     /*accessed as if a 2-dimensional array [SrcHandleNR][#ofCopies]     */
  300.     PVFS_handle *writes_completed;
  301.  
  302.     /*number of attempts at writing handles*/
  303.     int retry_count;
  304.  
  305.     /*list of server names that will be used as destination servers*/
  306.     char **io_servers;                       
  307.  
  308.     /*source remote server names in distribution*/
  309.     char **remote_io_servers;
  310.  
  311.     /*source local server names in distribution*/;                
  312.     char **local_io_servers;
  313.  
  314.     /*number of source server names in the distribution*/                     
  315.     int num_io_servers;
  316.  
  317.     /*number of source remote server names in distribution*/                  
  318.     int remote_io_servers_count;             
  319.  
  320.     /*number of source local server names in distribution*/
  321.     int local_io_servers_count;              
  322.  
  323.     /*source datahandles in order of distribution*/
  324.     PVFS_handle *handle_array_base;
  325.  
  326.     /*local source datahandles*/
  327.     PVFS_handle *handle_array_base_local;
  328.  
  329.     /*destination datahandles in order of distribution*/          
  330.     PVFS_handle *handle_array_copies;        
  331.  
  332.     /*local destination datahandles*/
  333.     PVFS_handle *handle_array_copies_local;  
  334.  
  335.     /*remote destination datahandles*/
  336.     PVFS_handle *handle_array_copies_remote;
  337.  
  338.     /*number of local source datahandles*/
  339.     int handle_array_base_local_count; 
  340.  
  341.     /*number of local destination datahandles*/
  342.     int handle_array_copies_local_count;      
  343.  
  344.     /*number of remote destination datahandles*/
  345.     int handle_array_copies_remote_count;     
  346.  
  347.     /*number of source datahandles*/
  348.     uint32_t dfile_count;
  349.  
  350.     /*source metadata handle*/                     
  351.     PVFS_handle metadata_handle; 
  352.  
  353.     /*source file system*/
  354.     PVFS_fs_id fs_id; 
  355.  
  356.     /*number of io servers defined in the current file system*/
  357.     int io_servers_count; 
  358.  
  359.     /*size of the source distribution structure */
  360.     uint32_t dist_size;
  361.  
  362.     /*distribution structure for basic_dist*/
  363.     PINT_dist *dist;
  364.  
  365.     /*local source handles' attribute structure*/
  366.     /*populates bstream_array_base_local with byte stream size*/
  367.     PVFS_ds_attributes *ds_attr_a;
  368.  
  369.     /*local source handles' byte stream size*/
  370.     /*index corresponds to handle_array_base*/
  371.     PVFS_size *bstream_array_base_local;
  372. };
  373. typedef struct PINT_server_create_copies_op PINT_server_create_copies_op;
  374.  
  375.  
  376. /*This macro is used to initialize a PINT_server_op structure when pjmp'ing */
  377. /*to pvfs2_create_immutable_copies_sm.                                      */
  378. #define PVFS_SERVOP_IMM_COPIES_FILL(__new_p,__cur_p)                           \
  379. do {                                                                           \
  380.    memcpy(__new_p,__cur_p,sizeof(struct PINT_server_op));                      \
  381.    (__new_p)->op = PVFS_SERV_IMM_COPIES;                                       \
  382.    memset(&((__new_p)->u.create_copies),0,sizeof((__new_p)->u.create_copies)); \
  383. }while(0)
  384.  
  385.  
  386.  
  387. /* struct PINT_server_lookup_op
  388.  *
  389.  * All the data needed during lookup processing:
  390.  *
  391.  */
  392. struct PINT_server_lookup_op
  393. {
  394.     /* current segment (0..N), number of segments in the path */
  395.     int seg_ct, seg_nr; 
  396.  
  397.     /* number of attrs read succesfully */
  398.     int attr_ct;
  399.  
  400.     /* number of handles read successfully */
  401.     int handle_ct;
  402.  
  403.     char *segp;
  404.     void *segstate;
  405.  
  406.     PVFS_handle dirent_handle;
  407.     PVFS_ds_attributes *ds_attr_array;
  408. };
  409.  
  410. struct PINT_server_readdir_op
  411. {
  412.     uint64_t directory_version;
  413.     PVFS_handle dirent_handle;  /* holds handle of dirdata dspace from
  414.                                    which entries are read */
  415.     PVFS_size dirdata_size;
  416. };
  417.  
  418. struct PINT_server_crdirent_op
  419. {
  420.     char *name;
  421.     PVFS_handle new_handle;
  422.     PVFS_handle parent_handle;
  423.     PVFS_fs_id fs_id;
  424.     PVFS_handle dirent_handle;  /* holds handle of dirdata dspace that
  425.                                  * we'll write the dirent into */
  426.     PVFS_size dirent_count;
  427.     int dir_attr_update_required;
  428. };
  429.  
  430. struct PINT_server_rmdirent_op
  431. {
  432.     PVFS_handle dirdata_handle;
  433.     PVFS_handle entry_handle; /* holds handle of dirdata object,
  434.                                * removed entry */
  435.     PVFS_size dirent_count;
  436.     int dir_attr_update_required;
  437. };
  438.  
  439. struct PINT_server_chdirent_op
  440. {
  441.     PVFS_handle dirdata_handle;
  442.     PVFS_handle old_dirent_handle;
  443.     PVFS_handle new_dirent_handle;
  444.     int dir_attr_update_required;
  445. };
  446.  
  447. struct PINT_server_remove_op
  448. {
  449.     PVFS_handle handle;
  450.     PVFS_fs_id fs_id;
  451.     PVFS_handle dirdata_handle;   /* holds dirdata dspace handle in
  452.                                    * the event that we are removing a
  453.                                    * directory */
  454.     PVFS_size dirent_count;
  455.     PVFS_ds_keyval key;
  456.     PVFS_ds_position pos;
  457.     int key_count;
  458.     int index;
  459.     int remove_keyvals_state;
  460.     int saved_error_code; /* holds error_code from previous state. */
  461. };
  462.  
  463. struct PINT_server_mgmt_remove_dirent_op
  464. {
  465.     PVFS_handle dirdata_handle;
  466. };
  467.  
  468. struct PINT_server_precreate_pool_refiller_op
  469. {
  470.     PVFS_handle pool_handle;
  471.     PVFS_handle* precreate_handle_array;
  472.     PVFS_fs_id fsid;
  473.     char* host;
  474.     PVFS_BMI_addr_t host_addr;
  475.     PVFS_handle_extent_array handle_extent_array;
  476.     PVFS_ds_type type;
  477. };
  478.  
  479. struct PINT_server_batch_create_op
  480. {
  481.     int saved_error_code;
  482.     int batch_index;
  483. };
  484.  
  485. struct PINT_server_batch_remove_op
  486. {
  487.     int handle_index;
  488.     int error_code;
  489. };
  490.  
  491. struct PINT_server_mgmt_get_dirdata_op
  492. {
  493.     PVFS_handle dirdata_handle;
  494. };
  495.  
  496. struct PINT_server_getconfig_op
  497. {
  498.     int strsize; /* used to hold string lengths during getconfig
  499.                   * processing */
  500. };
  501.  
  502. struct PINT_server_io_op
  503. {
  504.     flow_descriptor* flow_d;
  505. };
  506.  
  507. struct PINT_server_small_io_op
  508. {
  509.     PVFS_offset offsets[IO_MAX_REGIONS];
  510.     PVFS_size sizes[IO_MAX_REGIONS];
  511.     PVFS_size result_bytes;
  512. };
  513.  
  514. struct PINT_server_flush_op
  515. {
  516.     PVFS_handle handle;        /* handle of data we want to flush to disk */
  517.     int flags;            /* any special flags for flush */
  518. };
  519.  
  520. struct PINT_server_truncate_op
  521. {
  522.     PVFS_handle handle;        /* handle of datafile we resize */
  523.     PVFS_offset size;        /* new size of datafile */
  524. };
  525.  
  526. struct PINT_server_mkdir_op
  527. {
  528.     PVFS_fs_id fs_id;
  529.     PVFS_handle_extent_array handle_extent_array;
  530.     PVFS_handle dirent_handle;
  531.     PVFS_size init_dirdata_size;
  532. };
  533.  
  534. struct PINT_server_getattr_op
  535. {
  536.     PVFS_handle handle;
  537.     PVFS_fs_id fs_id;
  538.     PVFS_ds_attributes dirdata_ds_attr;
  539.     uint32_t attrmask;
  540.     PVFS_error* err_array;
  541.     PVFS_ds_keyval_handle_info keyval_handle_info;
  542.     PVFS_handle dirent_handle;
  543.     int num_dfiles_req;
  544.     PVFS_handle *mirror_dfile_status_array;
  545. };
  546.  
  547. struct PINT_server_listattr_op
  548. {
  549.     PVFS_object_attr *attr_a;
  550.     PVFS_ds_attributes *ds_attr_a;
  551.     PVFS_error *errors;
  552.     int parallel_sms;
  553. };
  554.  
  555. /* this is used in both set_eattr, get_eattr and list_eattr */
  556. struct PINT_server_eattr_op
  557. {
  558.     void *buffer;
  559. };
  560.  
  561. struct PINT_server_unstuff_op
  562. {
  563.     PVFS_handle* dfile_array;
  564.     int num_dfiles_req;
  565.     PVFS_sys_layout layout;
  566.     void* encoded_layout;
  567. };
  568.  
  569. struct PINT_server_tree_communicate_op
  570. {
  571.     int num_partitions;
  572.     PVFS_handle* handle_array_local; 
  573.     PVFS_handle* handle_array_remote; 
  574.     uint32_t *local_join_size;
  575.     uint32_t *remote_join_size;
  576.     int handle_array_local_count;
  577.     int handle_array_remote_count;
  578.     int handle_index;
  579. };
  580.  
  581. /* This structure is passed into the void *ptr 
  582.  * within the job interface.  Used to tell us where
  583.  * to go next in our state machine.
  584.  */
  585. typedef struct PINT_server_op
  586. {
  587.     struct qlist_head   next; /* used to queue structures used for unexp style messages */
  588.     int op_cancelled; /* indicates unexp message was cancelled */
  589.     job_id_t unexp_id;
  590.  
  591.     enum PVFS_server_op op;  /* type of operation that we are servicing */
  592.  
  593.     PINT_event_id event_id;
  594.  
  595.     /* holds id from request scheduler so we can release it later */
  596.     job_id_t scheduled_id; 
  597.  
  598.     /* generic structures used in most server operations */
  599.     PVFS_ds_keyval key, val; 
  600.     PVFS_ds_keyval *key_a;
  601.     PVFS_ds_keyval *val_a;
  602.     int *error_a;
  603.     int keyval_count;
  604.  
  605.     int free_val;
  606.  
  607.     /* generic int for use by state machines that are accessing
  608.      * PINT_server_op structs before pjumping to them. */
  609.     int local_index;
  610.  
  611.     /* attributes structure associated with target of operation; may be 
  612.      * partially filled in by prelude nested state machine (for 
  613.      * permission checking); may be used/modified by later states as well
  614.      *
  615.      * the ds_attr is used by the prelude sm only (and for pulling the
  616.      * size out in the get-attr server sm); don't use it otherwise --
  617.      * the object_attr is prepared for other sm's, so use it instead.
  618.      */
  619.     PVFS_ds_attributes ds_attr;
  620.     PVFS_object_attr attr;
  621.  
  622.     PVFS_BMI_addr_t addr;   /* address of client that contacted us */
  623.     bmi_msg_tag_t tag; /* operation tag */
  624.     /* information about unexpected message that initiated this operation */
  625.     struct BMI_unexpected_info unexp_bmi_buff;
  626.  
  627.     /* decoded request and response structures */
  628.     struct PVFS_server_req *req; 
  629.     struct PVFS_server_resp resp; 
  630.     /* encoded request and response structures */
  631.     struct PINT_encoded_msg encoded;
  632.     struct PINT_decoded_msg decoded;
  633.  
  634.     PINT_sm_msgarray_op msgarray_op;
  635.  
  636.     PVFS_handle target_handle;
  637.     PVFS_fs_id target_fs_id;
  638.     PVFS_object_attr *target_object_attr;
  639.  
  640.     PINT_prelude_flag prelude_mask;
  641.  
  642.     enum PINT_server_req_access_type access_type;
  643.     enum PINT_server_sched_policy sched_policy;
  644.  
  645.     int num_pjmp_frames;
  646.  
  647.     union
  648.     {
  649.     /* request-specific scratch spaces for use during processing */
  650.         struct PINT_server_create_op create;
  651.         struct PINT_server_eattr_op eattr;
  652.         struct PINT_server_getattr_op getattr;
  653.         struct PINT_server_listattr_op listattr;
  654.     struct PINT_server_getconfig_op getconfig;
  655.     struct PINT_server_lookup_op lookup;
  656.     struct PINT_server_crdirent_op crdirent;
  657.     struct PINT_server_readdir_op readdir;
  658.     struct PINT_server_remove_op remove;
  659.     struct PINT_server_chdirent_op chdirent;
  660.     struct PINT_server_rmdirent_op rmdirent;
  661.     struct PINT_server_io_op io;
  662.         struct PINT_server_small_io_op small_io;
  663.     struct PINT_server_flush_op flush;
  664.     struct PINT_server_truncate_op truncate;
  665.     struct PINT_server_mkdir_op mkdir;
  666.         struct PINT_server_mgmt_remove_dirent_op mgmt_remove_dirent;
  667.         struct PINT_server_mgmt_get_dirdata_op mgmt_get_dirdata_handle;
  668.         struct PINT_server_precreate_pool_refiller_op
  669.             precreate_pool_refiller;
  670.         struct PINT_server_batch_create_op batch_create;
  671.         struct PINT_server_batch_remove_op batch_remove;
  672.         struct PINT_server_unstuff_op unstuff;
  673.         struct PINT_server_create_copies_op create_copies;
  674.         struct PINT_server_mirror_op mirror;
  675.         struct PINT_server_tree_communicate_op tree_communicate;
  676.     } u;
  677.  
  678. } PINT_server_op;
  679.  
  680. #define PINT_CREATE_SUBORDINATE_SERVER_FRAME(__smcb, __s_op, __handle, __fs_id, __location, __req, __task_id) \
  681.     do { \
  682.       char server_name[1024]; \
  683.       struct server_configuration_s *server_config = get_server_config_struct(); \
  684.       __s_op = malloc(sizeof(struct PINT_server_op)); \
  685.       if(!__s_op) { return -PVFS_ENOMEM; } \
  686.       memset(__s_op, 0, sizeof(struct PINT_server_op)); \
  687.       __s_op->req = &__s_op->decoded.stub_dec.req; \
  688.       PINT_sm_push_frame(__smcb, __task_id, __s_op); \
  689.       if (__location != LOCAL_OPERATION && __location != REMOTE_OPERATION && __handle) { \
  690.         PINT_cached_config_get_server_name(server_name, 1024, __handle, __fs_id); \
  691.       } \
  692.       if (__location != REMOTE_OPERATION && (__location == LOCAL_OPERATION || ( __handle && ! strcmp(server_config->host_id, server_name)))) { \
  693.         __location = LOCAL_OPERATION; \
  694.         __req = __s_op->req; \
  695.         __s_op->prelude_mask = PRELUDE_SCHEDULER_DONE | PRELUDE_PERM_CHECK_DONE | PRELUDE_LOCAL_CALL; \
  696.       } \
  697.       else { \
  698.         memset(&__s_op->msgarray_op, 0, sizeof(PINT_sm_msgarray_op)); \
  699.         PINT_serv_init_msgarray_params(__s_op, __fs_id); \
  700.       } \
  701.     } while (0)
  702.  
  703.  
  704. /* PINT_ACCESS_DEBUG()
  705.  *
  706.  * macro for consistent printing of access records
  707.  *
  708.  * no return value
  709.  */
  710. #ifdef GOSSIP_DISABLE_DEBUG
  711. #define PINT_ACCESS_DEBUG(__s_op, __mask, format, f...) do {} while (0)
  712. #else
  713. #define PINT_ACCESS_DEBUG(__s_op, __mask, format, f...)                     \
  714.     PINT_server_access_debug(__s_op, __mask, format, ##f)
  715. #endif
  716.  
  717. void PINT_server_access_debug(PINT_server_op * s_op,
  718.                               int64_t debug_mask,
  719.                               const char * format,
  720.                               ...) __attribute__((format(printf, 3, 4)));
  721.  
  722. /* server side state machines */
  723. extern struct PINT_state_machine_s pvfs2_mirror_sm;
  724. extern struct PINT_state_machine_s pvfs2_pjmp_call_msgpairarray_sm;
  725. extern struct PINT_state_machine_s pvfs2_pjmp_get_attr_with_prelude_sm;
  726. extern struct PINT_state_machine_s pvfs2_pjmp_remove_work_sm;
  727. extern struct PINT_state_machine_s pvfs2_pjmp_mirror_work_sm;
  728. extern struct PINT_state_machine_s pvfs2_pjmp_create_immutable_copies_sm;
  729. extern struct PINT_state_machine_s pvfs2_pjmp_get_attr_work_sm;
  730.  
  731. /* nested state machines */
  732. extern struct PINT_state_machine_s pvfs2_get_attr_work_sm;
  733. extern struct PINT_state_machine_s pvfs2_get_attr_with_prelude_sm;
  734. extern struct PINT_state_machine_s pvfs2_prelude_sm;
  735. extern struct PINT_state_machine_s pvfs2_prelude_work_sm;
  736. extern struct PINT_state_machine_s pvfs2_final_response_sm;
  737. extern struct PINT_state_machine_s pvfs2_check_entry_not_exist_sm;
  738. extern struct PINT_state_machine_s pvfs2_remove_work_sm;
  739. extern struct PINT_state_machine_s pvfs2_remove_with_prelude_sm;
  740. extern struct PINT_state_machine_s pvfs2_mkdir_work_sm;
  741. extern struct PINT_state_machine_s pvfs2_unexpected_sm;
  742. extern struct PINT_state_machine_s pvfs2_create_immutable_copies_sm;
  743. extern struct PINT_state_machine_s pvfs2_mirror_work_sm;
  744. extern struct PINT_state_machine_s pvfs2_tree_remove_work_sm;
  745. extern struct PINT_state_machine_s pvfs2_tree_get_file_size_work_sm;
  746. extern struct PINT_state_machine_s pvfs2_call_msgpairarray_sm;
  747.  
  748. /* Exported Prototypes */
  749. struct server_configuration_s *get_server_config_struct(void);
  750.  
  751. /* exported state machine resource reclamation function */
  752. int server_post_unexpected_recv(job_status_s *js_p);
  753. int server_state_machine_start( PINT_smcb *smcb, job_status_s *js_p);
  754. int server_state_machine_complete(PINT_smcb *smcb);
  755. int server_state_machine_terminate(PINT_smcb *smcb, job_status_s *js_p);
  756.  
  757. /* lists of server ops */
  758. extern struct qlist_head posted_sop_list;
  759. extern struct qlist_head inprogress_sop_list;
  760.  
  761. /* starts state machines not associated with an incoming request */
  762. int server_state_machine_alloc_noreq(
  763.     enum PVFS_server_op op, struct PINT_smcb ** new_op);
  764. int server_state_machine_start_noreq(
  765.     struct PINT_smcb *new_op);
  766.  
  767. /* INCLUDE STATE-MACHINE.H DOWN HERE */
  768. #if 0
  769. #define PINT_OP_STATE       PINT_server_op
  770. #define PINT_OP_STATE_GET_MACHINE(_op) \
  771.     ((_op >= 0 && _op < PVFS_SERV_NUM_OPS) ? \
  772.     PINT_server_req_table[_op].params->sm : NULL)
  773. #endif
  774.  
  775. #include "pvfs2-internal.h"
  776.  
  777. struct PINT_state_machine_s *server_op_state_get_machine(int);
  778.  
  779. #endif /* __PVFS_SERVER_H */
  780.  
  781. /*
  782.  * Local variables:
  783.  *  c-indent-level: 4
  784.  *  c-basic-offset: 4
  785.  * End:
  786.  *
  787.  * vim: ts=8 sts=4 sw=4 expandtab
  788.  */
  789.