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 / proto / pvfs2-req-proto.h < prev   
C/C++ Source or Header  |  2011-02-25  |  78KB  |  2,031 lines

  1. /*
  2.  * (C) 2001 Clemson University and The University of Chicago
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6. /* NOTE: if you make any changes to the code contained in this file, please
  7.  * update the PVFS2_PROTO_VERSION accordingly
  8.  */
  9.  
  10. #ifndef __PVFS2_REQ_PROTO_H
  11. #define __PVFS2_REQ_PROTO_H
  12.  
  13. #include "pvfs2-config.h"
  14. #include "pvfs2-types.h"
  15. #include "pvfs2-attr.h"
  16. #include "pint-distribution.h"
  17. #include "pvfs2-request.h"
  18. #include "pint-request.h"
  19. #include "pvfs2-mgmt.h"
  20. #include "pint-hint.h"
  21.  
  22. /* update PVFS2_PROTO_MAJOR on wire protocol changes that break backwards
  23.  * compatibility (such as changing the semantics or protocol fields for an
  24.  * existing request type)
  25.  */
  26. #define PVFS2_PROTO_MAJOR 6
  27. /* update PVFS2_PROTO_MINOR on wire protocol changes that preserve backwards
  28.  * compatibility (such as adding a new request type)
  29.  */
  30. #define PVFS2_PROTO_MINOR 0
  31. #define PVFS2_PROTO_VERSION ((PVFS2_PROTO_MAJOR*1000)+(PVFS2_PROTO_MINOR))
  32.  
  33. /* we set the maximum possible size of a small I/O packed message as 64K.  This
  34.  * is an upper limit that is used to allocate the request and response encoded
  35.  * buffers, and is independent of the max unexpected message size of the specific
  36.  * BMI module.  All max unexpected message sizes for BMI modules have to be less
  37.  * than this value
  38.  */
  39. #define PINT_SMALL_IO_MAXSIZE (16*1024)
  40.  
  41. enum PVFS_server_op
  42. {
  43.     PVFS_SERV_INVALID = 0,
  44.     PVFS_SERV_CREATE = 1,
  45.     PVFS_SERV_REMOVE = 2,
  46.     PVFS_SERV_IO = 3,
  47.     PVFS_SERV_GETATTR = 4,
  48.     PVFS_SERV_SETATTR = 5,
  49.     PVFS_SERV_LOOKUP_PATH = 6,
  50.     PVFS_SERV_CRDIRENT = 7,
  51.     PVFS_SERV_RMDIRENT = 8,
  52.     PVFS_SERV_CHDIRENT = 9,
  53.     PVFS_SERV_TRUNCATE = 10,
  54.     PVFS_SERV_MKDIR = 11,
  55.     PVFS_SERV_READDIR = 12,
  56.     PVFS_SERV_GETCONFIG = 13,
  57.     PVFS_SERV_WRITE_COMPLETION = 14,
  58.     PVFS_SERV_FLUSH = 15,
  59.     PVFS_SERV_MGMT_SETPARAM = 16,
  60.     PVFS_SERV_MGMT_NOOP = 17,
  61.     PVFS_SERV_STATFS = 18,
  62.     PVFS_SERV_PERF_UPDATE = 19,  /* not a real protocol request */
  63.     PVFS_SERV_MGMT_PERF_MON = 20,
  64.     PVFS_SERV_MGMT_ITERATE_HANDLES = 21,
  65.     PVFS_SERV_MGMT_DSPACE_INFO_LIST = 22,
  66.     PVFS_SERV_MGMT_EVENT_MON = 23,
  67.     PVFS_SERV_MGMT_REMOVE_OBJECT = 24,
  68.     PVFS_SERV_MGMT_REMOVE_DIRENT = 25,
  69.     PVFS_SERV_MGMT_GET_DIRDATA_HANDLE = 26,
  70.     PVFS_SERV_JOB_TIMER = 27,    /* not a real protocol request */
  71.     PVFS_SERV_PROTO_ERROR = 28,
  72.     PVFS_SERV_GETEATTR = 29,
  73.     PVFS_SERV_SETEATTR = 30,
  74.     PVFS_SERV_DELEATTR = 31,
  75.     PVFS_SERV_LISTEATTR = 32,
  76.     PVFS_SERV_SMALL_IO = 33,
  77.     PVFS_SERV_LISTATTR = 34,
  78.     PVFS_SERV_BATCH_CREATE = 35,
  79.     PVFS_SERV_BATCH_REMOVE = 36,
  80.     PVFS_SERV_PRECREATE_POOL_REFILLER = 37, /* not a real protocol request */
  81.     PVFS_SERV_UNSTUFF = 38,
  82.     PVFS_SERV_MIRROR = 39,
  83.     PVFS_SERV_IMM_COPIES = 40,
  84.     PVFS_SERV_TREE_REMOVE = 41,
  85.     PVFS_SERV_TREE_GET_FILE_SIZE = 42,
  86.     /* leave this entry last */
  87.     PVFS_SERV_NUM_OPS
  88. };
  89.  
  90. /*
  91.  * These ops must always work, even if the server is in admin mode.
  92.  */
  93. #define PVFS_SERV_IS_MGMT_OP(x) \
  94.     ((x) == PVFS_SERV_MGMT_SETPARAM \
  95.   || (x) == PVFS_SERV_MGMT_REMOVE_OBJECT \
  96.   || (x) == PVFS_SERV_MGMT_REMOVE_DIRENT)
  97.  
  98. /******************************************************************/
  99. /* these values define limits on the maximum size of variable length
  100.  * parameters used within the request protocol
  101.  */
  102.  
  103. /* max size of layout information (may include explicit server list */
  104. #define PVFS_REQ_LIMIT_LAYOUT             4096
  105. /* max size of opaque distribution parameters */
  106. #define PVFS_REQ_LIMIT_DIST_BYTES         1024
  107. /* max size of each configuration file transmitted to clients.
  108.  * Note: If you change this value, you should change the $req_limit
  109.  * in pvfs2-genconfig as well. */
  110. #define PVFS_REQ_LIMIT_CONFIG_FILE_BYTES  65536
  111. /* max size of all path strings */
  112. #define PVFS_REQ_LIMIT_PATH_NAME_BYTES    PVFS_NAME_MAX
  113. /* max size of strings representing a single path element */
  114. #define PVFS_REQ_LIMIT_SEGMENT_BYTES      PVFS_SEGMENT_MAX
  115. /* max total size of I/O request descriptions */
  116. #define PVFS_REQ_LIMIT_IOREQ_BYTES        8192
  117. /* maximum size of distribution name used for the hints */
  118. #define PVFS_REQ_LIMIT_DIST_NAME          128
  119. /* max count of segments allowed per path lookup (note that this governs 
  120.  * the number of handles and attributes returned in lookup_path responses)
  121.  */
  122. #define PVFS_REQ_LIMIT_PATH_SEGMENT_COUNT   40
  123. /* max count of datafiles associated with a logical file */
  124. #define PVFS_REQ_LIMIT_DFILE_COUNT        1024
  125. #define PVFS_REQ_LIMIT_DFILE_COUNT_IS_VALID(dfile_count) \
  126. ((dfile_count > 0) && (dfile_count < PVFS_REQ_LIMIT_DFILE_COUNT))
  127. #define PVFS_REQ_LIMIT_MIRROR_DFILE_COUNT 1024
  128. /* max count of directory entries per readdir request */
  129. #define PVFS_REQ_LIMIT_DIRENT_COUNT        512
  130. /* max number of perf metrics returned by mgmt perf mon op */
  131. #define PVFS_REQ_LIMIT_MGMT_PERF_MON_COUNT 16
  132. /* max number of events returned by mgmt event mon op */
  133. #define PVFS_REQ_LIMIT_MGMT_EVENT_MON_COUNT 2048
  134. /* max number of handles returned by any operation using an array of handles */
  135. #define PVFS_REQ_LIMIT_HANDLES_COUNT 1024
  136. /* max number of handles that can be created at once using batch create */
  137. #define PVFS_REQ_LIMIT_BATCH_CREATE 8192
  138. /* max number of handles returned by mgmt iterate handles op */
  139. #define PVFS_REQ_LIMIT_MGMT_ITERATE_HANDLES_COUNT \
  140.   PVFS_REQ_LIMIT_HANDLES_COUNT
  141. /* max number of info list items returned by mgmt dspace info list op */
  142. /* max number of dspace info structs returned by mgmt dpsace info op */
  143. #define PVFS_REQ_LIMIT_MGMT_DSPACE_INFO_LIST_COUNT 1024
  144. /* max number of path elements in a lookup_attr response */
  145. #define PVFS_REQ_LIMIT_MAX_PATH_ELEMENTS  40
  146. /* max number of symlinks to resolve before erroring out */
  147. #define PVFS_REQ_LIMIT_MAX_SYMLINK_RESOLUTION_COUNT 8
  148. /* max number of bytes in the key of a key/value pair including null term */
  149. #define PVFS_REQ_LIMIT_KEY_LEN 128
  150. /* max number of bytes in a value of a key/value/pair */
  151. #define PVFS_REQ_LIMIT_VAL_LEN 4096
  152. /* max number of key/value pairs to set or get in a list operation */
  153. #define PVFS_REQ_LIMIT_KEYVAL_LIST 32
  154. /* max number of handles for which we return attributes */
  155. #define PVFS_REQ_LIMIT_LISTATTR 60
  156. /* max number of bytes in an extended attribute key including null term */
  157. #define PVFS_REQ_LIMIT_EATTR_KEY_LEN    PVFS_MAX_XATTR_NAMELEN
  158. /* max number of bytes in an extended attribute value including null term */
  159. #define PVFS_REQ_LIMIT_EATTR_VAL_LEN    PVFS_MAX_XATTR_VALUELEN
  160. /* max number of keys or key/value pairs to set or get in an operation */
  161. #define PVFS_REQ_LIMIT_EATTR_LIST       PVFS_MAX_XATTR_LISTLEN 
  162.  
  163.  
  164. /* create *********************************************************/
  165. /* - used to create an object.  This creates a metadata handle,
  166.  * a datafile handle, and links the datafile handle to the metadata handle.
  167.  * It also sets the attributes on the metadata. */
  168.  
  169. struct PVFS_servreq_create
  170. {
  171.     PVFS_fs_id fs_id;
  172.     PVFS_object_attr attr;
  173.  
  174.     int32_t num_dfiles_req;
  175.     /* NOTE: leave layout as final field so that we can deal with encoding
  176.      * errors */
  177.     PVFS_sys_layout layout;
  178. };
  179. endecode_fields_5_struct(
  180.     PVFS_servreq_create,
  181.     PVFS_fs_id, fs_id,
  182.     skip4,,
  183.     PVFS_object_attr, attr,
  184.     int32_t, num_dfiles_req,
  185.     PVFS_sys_layout, layout);
  186.  
  187. #define extra_size_PVFS_servreq_create \
  188.     (extra_size_PVFS_object_attr + extra_size_PVFS_sys_layout)
  189.  
  190. #define PINT_SERVREQ_CREATE_FILL(__req,                                    \
  191.                                  __creds,                                  \
  192.                                  __fsid,                                   \
  193.                                  __attr,                                   \
  194.                                  __num_dfiles_req,                         \
  195.                                  __layout,                                 \
  196.                                  __hints)                                  \
  197. do {                                                                       \
  198.     int mask;                                                              \
  199.     memset(&(__req), 0, sizeof(__req));                                    \
  200.     (__req).op = PVFS_SERV_CREATE;                                         \
  201.     (__req).credentials = (__creds);                                       \
  202.     (__req).hints = (__hints);                                             \
  203.     (__req).u.create.fs_id = (__fsid);                                     \
  204.     (__req).u.create.num_dfiles_req = (__num_dfiles_req);                  \
  205.     (__attr).objtype = PVFS_TYPE_METAFILE;                                 \
  206.     mask = (__attr).mask;                                                  \
  207.     (__attr).mask = PVFS_ATTR_COMMON_ALL;                                  \
  208.     (__attr).mask |= PVFS_ATTR_SYS_TYPE;                                   \
  209.     PINT_copy_object_attr(&(__req).u.create.attr, &(__attr));              \
  210.     (__req).u.create.attr.mask |= mask;                                    \
  211.     (__req).u.create.layout = __layout;                                    \
  212. } while (0)
  213.  
  214. struct PVFS_servresp_create
  215. {
  216.     PVFS_handle metafile_handle;
  217.     int32_t stuffed;
  218.     int32_t datafile_count;
  219.     PVFS_handle *datafile_handles;
  220. };
  221. endecode_fields_2a_struct(
  222.     PVFS_servresp_create,
  223.     PVFS_handle, metafile_handle,
  224.     int32_t, stuffed,
  225.     int32_t, datafile_count,
  226.     PVFS_handle, datafile_handles);
  227. #define extra_size_PVFS_servresp_create \
  228.     (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle))
  229.  
  230. /* batch_create *********************************************************/
  231. /* - used to create new multiple metafile and datafile objects */
  232.  
  233. struct PVFS_servreq_batch_create
  234. {
  235.     PVFS_fs_id fs_id;
  236.     PVFS_ds_type object_type;
  237.     uint32_t object_count;
  238.  
  239.     /*
  240.       an array of handle extents that we use to suggest to
  241.       the server from which handle range to allocate for the
  242.       newly created handle(s).  To request a single handle,
  243.       a single extent with first = last should be used.
  244.     */
  245.     PVFS_handle_extent_array handle_extent_array;
  246. };
  247. endecode_fields_5_struct(
  248.     PVFS_servreq_batch_create,
  249.     PVFS_fs_id, fs_id,
  250.     PVFS_ds_type, object_type,
  251.     uint32_t, object_count,
  252.     skip4,,
  253.     PVFS_handle_extent_array, handle_extent_array);
  254.  
  255. #define extra_size_PVFS_servreq_batch_create \
  256.     (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle_extent))
  257.  
  258. #define PINT_SERVREQ_BATCH_CREATE_FILL(__req,          \
  259.                                  __creds,              \
  260.                                  __fsid,               \
  261.                                  __objtype,            \
  262.                                  __objcount,           \
  263.                                  __ext_array,          \
  264.                                  __hints)              \
  265. do {                                                   \
  266.     memset(&(__req), 0, sizeof(__req));                \
  267.     (__req).op = PVFS_SERV_BATCH_CREATE;               \
  268.     (__req).credentials = (__creds);                   \
  269.     (__req).hints = (__hints);                         \
  270.     (__req).u.batch_create.fs_id = (__fsid);           \
  271.     (__req).u.batch_create.object_type = (__objtype);        \
  272.     (__req).u.batch_create.object_count = (__objcount);      \
  273.     (__req).u.batch_create.handle_extent_array.extent_count =\
  274.         (__ext_array).extent_count;                    \
  275.     (__req).u.batch_create.handle_extent_array.extent_array =\
  276.         (__ext_array).extent_array;                    \
  277. } while (0)
  278.  
  279. struct PVFS_servresp_batch_create
  280. {
  281.     PVFS_handle *handle_array;
  282.     uint32_t handle_count; 
  283. };
  284. endecode_fields_1a_struct(
  285.     PVFS_servresp_batch_create,
  286.     skip4,,
  287.     uint32_t, handle_count,
  288.     PVFS_handle, handle_array);
  289. #define extra_size_PVFS_servresp_batch_create \
  290.   (PVFS_REQ_LIMIT_BATCH_CREATE * sizeof(PVFS_handle))
  291.  
  292. /* remove *****************************************************/
  293. /* - used to remove an existing metafile or datafile object */
  294.  
  295. struct PVFS_servreq_remove
  296. {
  297.     PVFS_handle handle;
  298.     PVFS_fs_id  fs_id;
  299. };
  300. endecode_fields_2_struct(
  301.     PVFS_servreq_remove,
  302.     PVFS_handle, handle,
  303.     PVFS_fs_id, fs_id);
  304.  
  305. #define PINT_SERVREQ_REMOVE_FILL(__req,   \
  306.                                  __creds, \
  307.                                  __fsid,  \
  308.                                  __handle,\
  309.                                  __hints) \
  310. do {                                      \
  311.     memset(&(__req), 0, sizeof(__req));   \
  312.     (__req).op = PVFS_SERV_REMOVE;        \
  313.     (__req).hints = (__hints);            \
  314.     (__req).credentials = (__creds);      \
  315.     (__req).u.remove.fs_id = (__fsid);    \
  316.     (__req).u.remove.handle = (__handle); \
  317. } while (0)
  318.  
  319. struct PVFS_servreq_batch_remove
  320. {
  321.     PVFS_fs_id  fs_id;
  322.     int32_t handle_count;
  323.     PVFS_handle *handles;
  324. };
  325. endecode_fields_1a_struct(
  326.     PVFS_servreq_batch_remove,
  327.     PVFS_fs_id, fs_id,
  328.     int32_t, handle_count,
  329.     PVFS_handle, handles);
  330. #define extra_size_PVFS_servreq_batch_remove \
  331.   (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle))
  332.  
  333. #define PINT_SERVREQ_BATCH_REMOVE_FILL(__req,        \
  334.                                        __creds,      \
  335.                                        __fsid,       \
  336.                                        __count,      \
  337.                                        __handles)    \
  338. do {                                                 \
  339.     memset(&(__req), 0, sizeof(__req));              \
  340.     (__req).op = PVFS_SERV_BATCH_REMOVE;             \
  341.     (__req).credentials = (__creds);                 \
  342.     (__req).u.batch_remove.fs_id = (__fsid);         \
  343.     (__req).u.batch_remove.handle_count = (__count); \
  344.     (__req).u.batch_remove.handles = (__handles);    \
  345. } while (0)
  346.  
  347. /* mgmt_remove_object */
  348. /* - used to remove an existing object reference */
  349.  
  350. struct PVFS_servreq_mgmt_remove_object
  351. {
  352.     PVFS_handle handle;
  353.     PVFS_fs_id fs_id;
  354. };
  355. endecode_fields_2_struct(
  356.     PVFS_servreq_mgmt_remove_object,
  357.     PVFS_handle, handle,
  358.     PVFS_fs_id, fs_id);
  359.  
  360. #define PINT_SERVREQ_MGMT_REMOVE_OBJECT_FILL(__req,   \
  361.                                              __creds, \
  362.                                              __fsid,  \
  363.                                              __handle,\
  364.                                              __hints) \
  365. do {                                                  \
  366.     memset(&(__req), 0, sizeof(__req));               \
  367.     (__req).op = PVFS_SERV_MGMT_REMOVE_OBJECT;        \
  368.     (__req).hints = (__hints);                        \
  369.     (__req).credentials = (__creds);                  \
  370.     (__req).u.mgmt_remove_object.fs_id = (__fsid);    \
  371.     (__req).u.mgmt_remove_object.handle = (__handle); \
  372. } while (0)
  373.  
  374. /* mgmt_remove_dirent */
  375. /* - used to remove an existing dirent under the specified parent ref */
  376.  
  377. struct PVFS_servreq_mgmt_remove_dirent
  378. {
  379.     PVFS_handle handle;
  380.     PVFS_fs_id fs_id;
  381.     char *entry;
  382. };
  383. endecode_fields_4_struct(
  384.     PVFS_servreq_mgmt_remove_dirent,
  385.     PVFS_handle, handle,
  386.     PVFS_fs_id, fs_id,
  387.     skip4,,
  388.     string, entry);
  389. #define extra_size_PVFS_servreq_mgmt_remove_dirent \
  390.   roundup8(PVFS_REQ_LIMIT_SEGMENT_BYTES+1)
  391.  
  392. #define PINT_SERVREQ_MGMT_REMOVE_DIRENT_FILL(__req,   \
  393.                                              __creds, \
  394.                                              __fsid,  \
  395.                                              __handle,\
  396.                                              __entry, \
  397.                                              __hints) \
  398. do {                                                  \
  399.     memset(&(__req), 0, sizeof(__req));               \
  400.     (__req).op = PVFS_SERV_MGMT_REMOVE_DIRENT;        \
  401.     (__req).hints = (__hints);                        \
  402.     (__req).credentials = (__creds);                  \
  403.     (__req).u.mgmt_remove_dirent.fs_id = (__fsid);    \
  404.     (__req).u.mgmt_remove_dirent.handle = (__handle); \
  405.     (__req).u.mgmt_remove_dirent.entry = (__entry);   \
  406. } while (0)
  407.  
  408. struct PVFS_servreq_tree_remove
  409. {
  410.     PVFS_fs_id  fs_id;
  411.     uint32_t num_data_files;
  412.     PVFS_handle *handle_array;
  413. };
  414. endecode_fields_1a_struct(
  415.     PVFS_servreq_tree_remove,
  416.     PVFS_fs_id, fs_id,
  417.     uint32_t, num_data_files,
  418.     PVFS_handle, handle_array);
  419. #define extra_size_PVFS_servreq_tree_remove \
  420.   (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle))
  421.  
  422. #define PINT_SERVREQ_TREE_REMOVE_FILL(__req,                                  \
  423.                                  __creds,                                \
  424.                                  __fsid,                                 \
  425.                                  __num_data_files,                       \
  426.                                  __handle_array,                         \
  427.                                  __hints)                                \
  428. do {                                                                     \
  429.     memset(&(__req), 0, sizeof(__req));                                  \
  430.     (__req).op = PVFS_SERV_TREE_REMOVE;                                  \
  431.     (__req).hints = (__hints);                                           \
  432.     (__req).credentials = (__creds);                                     \
  433.     (__req).u.tree_remove.fs_id = (__fsid);                              \
  434.     (__req).u.tree_remove.num_data_files = (__num_data_files);           \
  435.     (__req).u.tree_remove.handle_array = (__handle_array);               \
  436. } while (0)
  437.  
  438. struct PVFS_servreq_tree_get_file_size
  439. {
  440.     PVFS_fs_id  fs_id;
  441.     uint32_t caller_handle_index;
  442.     uint32_t retry_msgpair_at_leaf;
  443.     uint32_t num_data_files;
  444.     PVFS_handle *handle_array;
  445. };
  446. endecode_fields_3a_struct(
  447.     PVFS_servreq_tree_get_file_size,
  448.     PVFS_fs_id, fs_id,
  449.     uint32_t, caller_handle_index,
  450.     uint32_t, retry_msgpair_at_leaf,
  451.     uint32_t, num_data_files,
  452.     PVFS_handle, handle_array);
  453. #define extra_size_PVFS_servreq_tree_get_file_size \
  454.   (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle))
  455.  
  456. #define PINT_SERVREQ_TREE_GET_FILE_SIZE_FILL(__req,                                \
  457.                                  __creds,                                          \
  458.                                  __fsid,                                           \
  459.                                  __caller_handle_index,                            \
  460.                                  __num_data_files,                                 \
  461.                                  __handle_array,                                   \
  462.                                  __retry_msgpair_at_leaf,                          \
  463.                                  __hints)                                          \
  464. do {                                                                               \
  465.     memset(&(__req), 0, sizeof(__req));                                            \
  466.     (__req).op = PVFS_SERV_TREE_GET_FILE_SIZE;                                     \
  467.     (__req).hints = (__hints);                                                     \
  468.     (__req).credentials = (__creds);                                               \
  469.     (__req).u.tree_get_file_size.fs_id = (__fsid);                                 \
  470.     (__req).u.tree_get_file_size.caller_handle_index = (__caller_handle_index);    \
  471.     (__req).u.tree_get_file_size.num_data_files = (__num_data_files);              \
  472.     (__req).u.tree_get_file_size.handle_array = (__handle_array);                  \
  473.     (__req).u.tree_get_file_size.retry_msgpair_at_leaf = (__retry_msgpair_at_leaf);\
  474. } while (0)
  475.  
  476. struct PVFS_servresp_tree_get_file_size
  477. {
  478.     uint32_t caller_handle_index;
  479.     uint32_t handle_count;
  480.     PVFS_size  *size;
  481.     PVFS_error *error;
  482. };
  483. endecode_fields_1aa_struct(
  484.     PVFS_servresp_tree_get_file_size,
  485.     uint32_t, caller_handle_index,
  486.     uint32_t, handle_count,
  487.     PVFS_size, size,
  488.     PVFS_error, error);
  489. #define extra_size_PVFS_servresp_tree_get_file_size \
  490.   ( (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_error)) + \
  491.     (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_size)) )
  492.  
  493. /* mgmt_get_dirdata_handle */
  494. /* - used to retrieve the dirdata handle of the specified parent ref */
  495. struct PVFS_servreq_mgmt_get_dirdata_handle
  496. {
  497.     PVFS_handle handle;
  498.     PVFS_fs_id fs_id;
  499. };
  500. endecode_fields_2_struct(
  501.     PVFS_servreq_mgmt_get_dirdata_handle,
  502.     PVFS_handle, handle,
  503.     PVFS_fs_id, fs_id);
  504.  
  505. #define PINT_SERVREQ_MGMT_GET_DIRDATA_HANDLE_FILL(__req,   \
  506.                                                   __creds, \
  507.                                                   __fsid,  \
  508.                                                   __handle,\
  509.                                                   __hints) \
  510. do {                                                       \
  511.     memset(&(__req), 0, sizeof(__req));                    \
  512.     (__req).op = PVFS_SERV_MGMT_GET_DIRDATA_HANDLE;        \
  513.     (__req).credentials = (__creds);                       \
  514.     (__req).hints = (__hints);                             \
  515.     (__req).u.mgmt_get_dirdata_handle.fs_id = (__fsid);    \
  516.     (__req).u.mgmt_get_dirdata_handle.handle = (__handle); \
  517. } while (0)
  518.  
  519. struct PVFS_servresp_mgmt_get_dirdata_handle
  520. {
  521.     PVFS_handle handle;
  522. };
  523. endecode_fields_1_struct(
  524.     PVFS_servresp_mgmt_get_dirdata_handle,
  525.     PVFS_handle, handle);
  526.  
  527. /* flush
  528.  * - used to flush an object to disk */
  529. struct PVFS_servreq_flush
  530. {
  531.     PVFS_handle handle;
  532.     PVFS_fs_id fs_id;
  533.     int32_t flags;
  534. };
  535. endecode_fields_3_struct(
  536.     PVFS_servreq_flush,
  537.     PVFS_handle, handle,
  538.     PVFS_fs_id, fs_id,
  539.     int32_t, flags);
  540.  
  541. #define PINT_SERVREQ_FLUSH_FILL(__req,   \
  542.                                 __creds, \
  543.                                 __fsid,  \
  544.                                 __handle,\
  545.                                 __hints )\
  546. do {                                     \
  547.     memset(&(__req), 0, sizeof(__req));  \
  548.     (__req).op = PVFS_SERV_FLUSH;        \
  549.     (__req).credentials = (__creds);     \
  550.     (__req).hints = (__hints);           \
  551.     (__req).u.flush.fs_id = (__fsid);    \
  552.     (__req).u.flush.handle = (__handle); \
  553. } while (0)
  554.  
  555. /* getattr ****************************************************/
  556. /* - retreives attributes based on mask of PVFS_ATTR_XXX values */
  557.  
  558. struct PVFS_servreq_getattr
  559. {
  560.     PVFS_handle handle; /* handle of target object */
  561.     PVFS_fs_id fs_id;   /* file system */
  562.     uint32_t attrmask;  /* mask of desired attributes */
  563. };
  564. endecode_fields_3_struct(
  565.     PVFS_servreq_getattr,
  566.     PVFS_handle, handle,
  567.     PVFS_fs_id, fs_id,
  568.     uint32_t, attrmask);
  569.  
  570. #define PINT_SERVREQ_GETATTR_FILL(__req,   \
  571.                                   __creds, \
  572.                                   __fsid,  \
  573.                                   __handle,\
  574.                                   __amask, \
  575.                                   __hints) \
  576. do {                                       \
  577.     memset(&(__req), 0, sizeof(__req));    \
  578.     (__req).op = PVFS_SERV_GETATTR;        \
  579.     (__req).credentials = (__creds);       \
  580.     (__req).hints = (__hints);             \
  581.     (__req).u.getattr.fs_id = (__fsid);    \
  582.     (__req).u.getattr.handle = (__handle); \
  583.     (__req).u.getattr.attrmask = (__amask);\
  584. } while (0)
  585.  
  586. struct PVFS_servresp_getattr
  587. {
  588.     PVFS_object_attr attr;
  589. };
  590. endecode_fields_1_struct(
  591.     PVFS_servresp_getattr,
  592.     PVFS_object_attr, attr);
  593. #define extra_size_PVFS_servresp_getattr \
  594.     extra_size_PVFS_object_attr
  595.  
  596. /* unstuff ****************************************************/
  597. /* - creates the datafile handles for the file.  This allows a stuffed
  598.  * file to migrate to a large one. */
  599.  
  600. struct PVFS_servreq_unstuff
  601. {
  602.     PVFS_handle handle; /* handle of target object */
  603.     PVFS_fs_id fs_id;   /* file system */
  604.     uint32_t attrmask;  /* mask of desired attributes */
  605. };
  606. endecode_fields_3_struct(
  607.     PVFS_servreq_unstuff,
  608.     PVFS_handle, handle,
  609.     PVFS_fs_id, fs_id,
  610.     uint32_t, attrmask);
  611.  
  612. #define PINT_SERVREQ_UNSTUFF_FILL(__req,           \
  613.                                   __creds,         \
  614.                                   __fsid,          \
  615.                                   __handle,        \
  616.                                   __amask)         \
  617. do {                                               \
  618.     memset(&(__req), 0, sizeof(__req));            \
  619.     (__req).op = PVFS_SERV_UNSTUFF;                \
  620.     (__req).credentials = (__creds);               \
  621.     (__req).u.unstuff.fs_id = (__fsid);            \
  622.     (__req).u.unstuff.handle = (__handle);         \
  623.     (__req).u.unstuff.attrmask = (__amask);        \
  624. } while (0)
  625.  
  626. struct PVFS_servresp_unstuff
  627. {
  628.     /* return the entire object's attributes, which includes the
  629.      * new datafile handles for the migrated file.
  630.      */
  631.     PVFS_object_attr attr;
  632. };
  633. endecode_fields_1_struct(
  634.     PVFS_servresp_unstuff,
  635.     PVFS_object_attr, attr);
  636. #define extra_size_PVFS_servresp_unstuff \
  637.     extra_size_PVFS_object_attr
  638.  
  639. /* setattr ****************************************************/
  640. /* - sets attributes specified by mask of PVFS_ATTR_XXX values */
  641.  
  642. struct PVFS_servreq_setattr
  643. {
  644.     PVFS_handle handle;    /* handle of target object */
  645.     PVFS_fs_id fs_id;      /* file system */
  646.     PVFS_object_attr attr; /* new attributes */
  647. };
  648. endecode_fields_4_struct(
  649.     PVFS_servreq_setattr,
  650.     PVFS_handle, handle,
  651.     PVFS_fs_id, fs_id,
  652.     skip4,,
  653.     PVFS_object_attr, attr);
  654. #define extra_size_PVFS_servreq_setattr \
  655.     extra_size_PVFS_object_attr
  656.  
  657. #define PINT_SERVREQ_SETATTR_FILL(__req,         \
  658.                                   __creds,       \
  659.                                   __fsid,        \
  660.                                   __handle,      \
  661.                                   __objtype,     \
  662.                                   __attr,        \
  663.                                   __extra_amask, \
  664.                                   __hints)       \
  665. do {                                             \
  666.     memset(&(__req), 0, sizeof(__req));          \
  667.     (__req).op = PVFS_SERV_SETATTR;              \
  668.     (__req).credentials = (__creds);             \
  669.     (__req).hints = (__hints);                   \
  670.     (__req).u.setattr.fs_id = (__fsid);          \
  671.     (__req).u.setattr.handle = (__handle);       \
  672.     (__attr).objtype = (__objtype);              \
  673.     (__attr).mask |= PVFS_ATTR_SYS_TYPE;         \
  674.     PINT_CONVERT_ATTR(&(__req).u.setattr.attr, &(__attr), __extra_amask);\
  675. } while (0)
  676.  
  677. /* lookup path ************************************************/
  678. /* - looks up as many elements of the specified path as possible */
  679.  
  680. struct PVFS_servreq_lookup_path
  681. {
  682.     char *path;                  /* path name */
  683.     PVFS_fs_id fs_id;            /* file system */
  684.     PVFS_handle handle; /* handle of path parent */
  685.     /* mask of attribs to return with lookup results */
  686.     uint32_t attrmask;
  687. };
  688. endecode_fields_5_struct(
  689.     PVFS_servreq_lookup_path,
  690.     string, path,
  691.     PVFS_fs_id, fs_id,
  692.     skip4,,
  693.     PVFS_handle, handle,
  694.     uint32_t, attrmask);
  695. #define extra_size_PVFS_servreq_lookup_path \
  696.   roundup8(PVFS_REQ_LIMIT_PATH_NAME_BYTES + 1)
  697.  
  698. #define PINT_SERVREQ_LOOKUP_PATH_FILL(__req,           \
  699.                                       __creds,         \
  700.                                       __path,          \
  701.                                       __fsid,          \
  702.                                       __handle,        \
  703.                                       __amask,         \
  704.                                       __hints)         \
  705. do {                                                   \
  706.     memset(&(__req), 0, sizeof(__req));                \
  707.     (__req).op = PVFS_SERV_LOOKUP_PATH;                \
  708.     (__req).credentials = (__creds);                   \
  709.     (__req).hints = (__hints);                         \
  710.     (__req).u.lookup_path.path = (__path);             \
  711.     (__req).u.lookup_path.fs_id = (__fsid);            \
  712.     (__req).u.lookup_path.handle = (__handle);\
  713.     (__req).u.lookup_path.attrmask = (__amask);        \
  714. } while (0)
  715.  
  716. struct PVFS_servresp_lookup_path
  717. {
  718.     /* array of handles for each successfully resolved path segment */
  719.     PVFS_handle *handle_array;            
  720.     /* array of attributes for each path segment (when available) */
  721.     PVFS_object_attr *attr_array;
  722.     uint32_t handle_count; /* # of handles returned */
  723.     uint32_t attr_count;   /* # of attributes returned */
  724. };
  725. endecode_fields_1a_1a_struct(
  726.     PVFS_servresp_lookup_path,
  727.     skip4,,
  728.     uint32_t, handle_count,
  729.     PVFS_handle, handle_array,
  730.     skip4,,
  731.     uint32_t, attr_count,
  732.     PVFS_object_attr, attr_array);
  733. /* this is a big thing that could be either a full path,
  734. * or lots of handles, just use the max io req limit */
  735. #define extra_size_PVFS_servresp_lookup_path \
  736.   (PVFS_REQ_LIMIT_IOREQ_BYTES)
  737.  
  738. /* mkdir *******************************************************/
  739. /* - makes a new directory object */
  740.  
  741. struct PVFS_servreq_mkdir
  742. {
  743.     PVFS_fs_id fs_id;      /* file system */
  744.     PVFS_object_attr attr; /* initial attributes */
  745.  
  746.     /*
  747.       an array of handle extents that we use to suggest to
  748.       the server from which handle range to allocate for the
  749.       newly created handle(s).  To request a single handle,
  750.       a single extent with first = last should be used.
  751.     */
  752.     PVFS_handle_extent_array handle_extent_array;
  753. };
  754. endecode_fields_4_struct(
  755.     PVFS_servreq_mkdir,
  756.     PVFS_fs_id, fs_id,
  757.     skip4,,
  758.     PVFS_object_attr, attr,
  759.     PVFS_handle_extent_array, handle_extent_array);
  760. #define extra_size_PVFS_servreq_mkdir \
  761.     (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle_extent))
  762.  
  763. #define PINT_SERVREQ_MKDIR_FILL(__req,                 \
  764.                                 __creds,               \
  765.                                 __fs_id,               \
  766.                                 __ext_array,           \
  767.                                 __attr,                \
  768.                                 __hints)               \
  769. do {                                                   \
  770.     memset(&(__req), 0, sizeof(__req));                \
  771.     (__req).op = PVFS_SERV_MKDIR;                      \
  772.     (__req).credentials = (__creds);                   \
  773.     (__req).hints = (__hints);                         \
  774.     (__req).u.mkdir.fs_id = __fs_id;                   \
  775.     (__req).u.mkdir.handle_extent_array.extent_count = \
  776.         (__ext_array).extent_count;                    \
  777.     (__req).u.mkdir.handle_extent_array.extent_array = \
  778.         (__ext_array).extent_array;                    \
  779.     (__attr).objtype = PVFS_TYPE_DIRECTORY;            \
  780.     (__attr).mask   |= PVFS_ATTR_SYS_TYPE;             \
  781.     PINT_CONVERT_ATTR(&(__req).u.mkdir.attr, &(__attr), 0);\
  782. } while (0)
  783.  
  784. struct PVFS_servresp_mkdir
  785. {
  786.     PVFS_handle handle; /* handle of new directory */
  787. };
  788. endecode_fields_1_struct(
  789.     PVFS_servresp_mkdir,
  790.     PVFS_handle, handle);
  791.  
  792. /* create dirent ***********************************************/
  793. /* - creates a new entry within an existing directory */
  794.  
  795. struct PVFS_servreq_crdirent
  796. {
  797.     char *name;                /* name of new entry */
  798.     PVFS_handle new_handle;    /* handle of new entry */
  799.     PVFS_handle handle; /* handle of directory */
  800.     PVFS_fs_id fs_id;          /* file system */
  801. };
  802. endecode_fields_4_struct(
  803.     PVFS_servreq_crdirent,
  804.     string, name,
  805.     PVFS_handle, new_handle,
  806.     PVFS_handle, handle,
  807.     PVFS_fs_id, fs_id);
  808. #define extra_size_PVFS_servreq_crdirent \
  809.   roundup8(PVFS_REQ_LIMIT_SEGMENT_BYTES+1)
  810.  
  811. #define PINT_SERVREQ_CRDIRENT_FILL(__req,           \
  812.                                    __creds,         \
  813.                                    __name,          \
  814.                                    __new_handle,    \
  815.                                    __handle,        \
  816.                                    __fs_id,         \
  817.                                    __hints)         \
  818. do {                                                \
  819.     memset(&(__req), 0, sizeof(__req));             \
  820.     (__req).op = PVFS_SERV_CRDIRENT;                \
  821.     (__req).credentials = (__creds);                \
  822.     (__req).hints = (__hints);                      \
  823.     (__req).u.crdirent.name = (__name);             \
  824.     (__req).u.crdirent.new_handle = (__new_handle); \
  825.     (__req).u.crdirent.handle =                     \
  826.        (__handle);                                  \
  827.     (__req).u.crdirent.fs_id = (__fs_id);           \
  828. } while (0)
  829.  
  830. /* rmdirent ****************************************************/
  831. /* - removes an existing directory entry */
  832.  
  833. struct PVFS_servreq_rmdirent
  834. {
  835.     char *entry;               /* name of entry to remove */
  836.     PVFS_handle handle; /* handle of directory */
  837.     PVFS_fs_id fs_id;          /* file system */
  838. };
  839. endecode_fields_3_struct(
  840.     PVFS_servreq_rmdirent,
  841.     string, entry,
  842.     PVFS_handle, handle,
  843.     PVFS_fs_id, fs_id);
  844. #define extra_size_PVFS_servreq_rmdirent \
  845.   roundup8(PVFS_REQ_LIMIT_SEGMENT_BYTES+1)
  846.  
  847. #define PINT_SERVREQ_RMDIRENT_FILL(__req,         \
  848.                                    __creds,       \
  849.                                    __fsid,        \
  850.                                    __handle,      \
  851.                                    __entry,       \
  852.                                    __hints)       \
  853. do {                                              \
  854.     memset(&(__req), 0, sizeof(__req));           \
  855.     (__req).op = PVFS_SERV_RMDIRENT;              \
  856.     (__req).credentials = (__creds);              \
  857.     (__req).hints = (__hints);                    \
  858.     (__req).u.rmdirent.fs_id = (__fsid);          \
  859.     (__req).u.rmdirent.handle = (__handle);       \
  860.     (__req).u.rmdirent.entry = (__entry);         \
  861. } while (0);
  862.  
  863. struct PVFS_servresp_rmdirent
  864. {
  865.     PVFS_handle entry_handle;   /* handle of removed entry */
  866. };
  867. endecode_fields_1_struct(
  868.     PVFS_servresp_rmdirent,
  869.     PVFS_handle, entry_handle);
  870.  
  871. /* chdirent ****************************************************/
  872. /* - modifies an existing directory entry on a particular file system */
  873.  
  874. struct PVFS_servreq_chdirent
  875. {
  876.     char *entry;                   /* name of entry to remove */
  877.     PVFS_handle new_dirent_handle; /* handle of directory */
  878.     PVFS_handle handle;     /* handle of directory */
  879.     PVFS_fs_id fs_id;              /* file system */
  880. };
  881. endecode_fields_4_struct(
  882.     PVFS_servreq_chdirent,
  883.     string, entry,
  884.     PVFS_handle, new_dirent_handle,
  885.     PVFS_handle, handle,
  886.     PVFS_fs_id, fs_id);
  887. #define extra_size_PVFS_servreq_chdirent \
  888.   roundup8(PVFS_REQ_LIMIT_SEGMENT_BYTES+1)
  889.  
  890. #define PINT_SERVREQ_CHDIRENT_FILL(__req,          \
  891.                                    __creds,        \
  892.                                    __fsid,         \
  893.                                    __handle,       \
  894.                                    __new_dirent,   \
  895.                                    __entry,        \
  896.                                    __hints)        \
  897. do {                                               \
  898.     memset(&(__req), 0, sizeof(__req));            \
  899.     (__req).op = PVFS_SERV_CHDIRENT;               \
  900.     (__req).credentials = (__creds);               \
  901.     (__req).hints = (__hints);                     \
  902.     (__req).u.chdirent.fs_id = (__fsid);           \
  903.     (__req).u.chdirent.handle =                    \
  904.         (__handle);                                \
  905.     (__req).u.chdirent.new_dirent_handle =         \
  906.         (__new_dirent);                            \
  907.     (__req).u.chdirent.entry = (__entry);          \
  908. } while (0);
  909.  
  910. struct PVFS_servresp_chdirent
  911. {
  912.     PVFS_handle old_dirent_handle;
  913. };
  914. endecode_fields_1_struct(
  915.     PVFS_servresp_chdirent,
  916.     PVFS_handle, old_dirent_handle);
  917.  
  918. /* readdir *****************************************************/
  919. /* - reads entries from a directory */
  920.  
  921. struct PVFS_servreq_readdir
  922. {
  923.     PVFS_handle handle;     /* handle of dir object */
  924.     PVFS_fs_id fs_id;       /* file system */
  925.     PVFS_ds_position token; /* dir offset */
  926.     uint32_t dirent_count;  /* desired # of entries */
  927. };
  928. endecode_fields_4_struct(
  929.     PVFS_servreq_readdir,
  930.     PVFS_handle, handle,
  931.     PVFS_fs_id, fs_id,
  932.     uint32_t, dirent_count,
  933.     PVFS_ds_position, token);
  934.  
  935. #define PINT_SERVREQ_READDIR_FILL(__req,              \
  936.                                   __creds,            \
  937.                                   __fsid,             \
  938.                                   __handle,           \
  939.                                   __token,            \
  940.                                   __dirent_count,     \
  941.                                   __hints)            \
  942. do {                                                  \
  943.     memset(&(__req), 0, sizeof(__req));               \
  944.     (__req).op = PVFS_SERV_READDIR;                   \
  945.     (__req).credentials = (__creds);                  \
  946.     (__req).hints = (__hints);                        \
  947.     (__req).u.readdir.fs_id = (__fsid);               \
  948.     (__req).u.readdir.handle = (__handle);            \
  949.     (__req).u.readdir.token = (__token);              \
  950.     (__req).u.readdir.dirent_count = (__dirent_count);\
  951. } while (0);
  952.  
  953. struct PVFS_servresp_readdir
  954. {
  955.     PVFS_ds_position token;  /* new dir offset */
  956.     /* array of directory entries */
  957.     PVFS_dirent *dirent_array;
  958.     uint32_t dirent_count;   /* # of entries retrieved */
  959.     uint64_t directory_version;
  960. };
  961. endecode_fields_3a_struct(
  962.     PVFS_servresp_readdir,
  963.     PVFS_ds_position, token,
  964.     uint64_t, directory_version,
  965.     skip4,,
  966.     uint32_t, dirent_count,
  967.     PVFS_dirent, dirent_array);
  968. #define extra_size_PVFS_servresp_readdir \
  969.   roundup8(PVFS_REQ_LIMIT_DIRENT_COUNT * (PVFS_NAME_MAX + 1 + 8))
  970.  
  971. /* getconfig ***************************************************/
  972. /* - retrieves initial configuration information from server */
  973.  
  974. #define PINT_SERVREQ_GETCONFIG_FILL(__req, __creds, __hints)\
  975. do {                                               \
  976.     memset(&(__req), 0, sizeof(__req));            \
  977.     (__req).op = PVFS_SERV_GETCONFIG;              \
  978.     (__req).hints = (__hints);                     \
  979.     (__req).credentials = (__creds);               \
  980. } while (0);
  981.  
  982. struct PVFS_servresp_getconfig
  983. {
  984.     char *fs_config_buf;
  985.     uint32_t fs_config_buf_size;
  986. };
  987. endecode_fields_3_struct(
  988.     PVFS_servresp_getconfig,
  989.     uint32_t, fs_config_buf_size,
  990.     skip4,,
  991.     string, fs_config_buf);
  992. #define extra_size_PVFS_servresp_getconfig \
  993.     (PVFS_REQ_LIMIT_CONFIG_FILE_BYTES)
  994.  
  995. /* mirror ******************************************************/
  996. /* - copies a datahandle owned by the local server to a data-  */
  997. /*   handle on a remote server. There could be multiple desti- */
  998. /*   nation data handles. dst_count tells us how many there    */
  999. /*   are.                                                      */
  1000. struct PVFS_servreq_mirror
  1001. {
  1002.     PVFS_handle src_handle;
  1003.     PVFS_handle *dst_handle;
  1004.     PVFS_fs_id  fs_id;
  1005.     PINT_dist   *dist;
  1006.     uint32_t    bsize;
  1007.     uint32_t    src_server_nr;
  1008.     uint32_t    *wcIndex;
  1009.     uint32_t     dst_count;
  1010.     enum PVFS_flowproto_type flow_type;
  1011.     enum PVFS_encoding_type encoding;
  1012. };
  1013.  
  1014. #ifdef __PINT_REQPROTO_ENCODE_FUNCS_C
  1015. #define encode_PVFS_servreq_mirror(pptr,x) do {      \
  1016.    encode_PVFS_handle(pptr,&(x)->src_handle);        \
  1017.    encode_PVFS_fs_id(pptr,&(x)->fs_id);              \
  1018.    encode_PINT_dist(pptr,&(x)->dist);                \
  1019.    encode_uint32_t(pptr,&(x)->bsize);                \
  1020.    encode_uint32_t(pptr,&(x)->src_server_nr);        \
  1021.    encode_uint32_t(pptr,&(x)->dst_count);            \
  1022.    encode_enum(pptr,&(x)->flow_type);                \
  1023.    encode_enum(pptr,&(x)->encoding);                 \
  1024.    int i;                                            \
  1025.    for (i=0; i<(x)->dst_count; i++)                  \
  1026.    {                                                 \
  1027.        encode_PVFS_handle(pptr,&(x)->dst_handle[i]); \
  1028.        encode_uint32_t(pptr,&(x)->wcIndex[i]);       \
  1029.    }                                                 \
  1030. } while (0)
  1031.  
  1032. #define decode_PVFS_servreq_mirror(pptr,x) do {          \
  1033.    decode_PVFS_handle(pptr,&(x)->src_handle);            \
  1034.    decode_PVFS_fs_id(pptr,&(x)->fs_id);                  \
  1035.    decode_PINT_dist(pptr,&(x)->dist);                    \
  1036.    decode_uint32_t(pptr,&(x)->bsize);                    \
  1037.    decode_uint32_t(pptr,&(x)->src_server_nr);            \
  1038.    decode_uint32_t(pptr,&(x)->dst_count);                \
  1039.    decode_enum(pptr,&(x)->flow_type);                    \
  1040.    decode_enum(pptr,&(x)->encoding);                     \
  1041.    (x)->dst_handle = decode_malloc((x)->dst_count *      \
  1042.                                    sizeof(PVFS_handle)); \
  1043.    (x)->wcIndex = decode_malloc((x)->dst_count *         \
  1044.                                sizeof(uint32_t));        \
  1045.    int i;                                                \
  1046.    for (i=0; i<(x)->dst_count; i++)                      \
  1047.    {                                                     \
  1048.        decode_PVFS_handle(pptr,&(x)->dst_handle[i]);     \
  1049.        decode_uint32_t(pptr,&(x)->wcIndex[i]);           \
  1050.    }                                                     \
  1051. } while (0)
  1052. #endif
  1053.  
  1054. #define extra_size_PVFS_servreq_mirror \
  1055.    ( (sizeof(PVFS_handle) * PVFS_REQ_LIMIT_HANDLES_COUNT) + \
  1056.      (sizeof(uint32_t) * PVFS_REQ_LIMIT_HANDLES_COUNT) )
  1057.  
  1058. /*Response to mirror request.  Identifies the number of bytes written and the */
  1059. /*status of that write for each source-destination handle pair. (Source is    */
  1060. /*always the same for each pair.)                                             */
  1061. struct PVFS_servresp_mirror
  1062. {
  1063.     PVFS_handle src_handle;
  1064.     uint32_t src_server_nr;
  1065.     uint32_t *bytes_written;
  1066.     uint32_t *write_status_code;
  1067.     uint32_t dst_count;
  1068. };
  1069.  
  1070. #ifdef __PINT_REQPROTO_ENCODE_FUNCS_C
  1071. #define encode_PVFS_servresp_mirror(pptr,x) do {         \
  1072.    encode_PVFS_handle(pptr,&(x)->src_handle);            \
  1073.    encode_uint32_t(pptr,&(x)->src_server_nr);            \
  1074.    encode_uint32_t(pptr,&(x)->dst_count);                \
  1075.    int i;                                                \
  1076.    for (i=0; i<(x)->dst_count; i++)                      \
  1077.    {                                                     \
  1078.        encode_uint32_t(pptr,&(x)->bytes_written[i]);     \
  1079.        encode_uint32_t(pptr,&(x)->write_status_code[i]); \
  1080.    }                                                     \
  1081. } while (0)
  1082.  
  1083. #define decode_PVFS_servresp_mirror(pptr,x) do {            \
  1084.   decode_PVFS_handle(pptr,&(x)->src_handle);                \
  1085.   decode_uint32_t(pptr,&(x)->src_server_nr);                \
  1086.   decode_uint32_t(pptr,&(x)->dst_count);                    \
  1087.   (x)->bytes_written     = decode_malloc((x)->dst_count *   \
  1088.                                          sizeof(uint32_t)); \
  1089.   (x)->write_status_code = decode_malloc((x)->dst_count *   \
  1090.                                          sizeof(uint32_t)); \
  1091.   int i;                                                    \
  1092.   for (i=0; i<(x)->dst_count; i++ )                         \
  1093.   {                                                         \
  1094.       decode_uint32_t(pptr,&(x)->bytes_written[i]);         \
  1095.       decode_uint32_t(pptr,&(x)->write_status_code[i]);     \
  1096.   }                                                         \
  1097. } while (0)
  1098. #endif
  1099.  
  1100. #define extra_size_PVFS_servresp_mirror \
  1101.   ( (sizeof(uint32_t) * PVFS_REQ_LIMIT_HANDLES_COUNT) + \
  1102.     (sizeof(uint32_t) * PVFS_REQ_LIMIT_HANDLES_COUNT) )
  1103.  
  1104.  
  1105. /* truncate ****************************************************/
  1106. /* - resizes an existing datafile */
  1107.  
  1108. struct PVFS_servreq_truncate
  1109. {
  1110.     PVFS_handle handle; /* handle of obj to resize */
  1111.     PVFS_fs_id fs_id;   /* file system */
  1112.     PVFS_size size;     /* new size */
  1113.     int32_t flags;      /* future use */
  1114.  
  1115. };
  1116. endecode_fields_5_struct(
  1117.     PVFS_servreq_truncate,
  1118.     PVFS_handle, handle,
  1119.     PVFS_fs_id, fs_id,
  1120.     skip4,,
  1121.     PVFS_size, size,
  1122.     int32_t, flags);
  1123. #define PINT_SERVREQ_TRUNCATE_FILL(__req,  \
  1124.                                 __creds,   \
  1125.                                 __fsid,    \
  1126.                                 __size,    \
  1127.                                 __handle,  \
  1128.                                 __hints)   \
  1129. do {                                       \
  1130.     memset(&(__req), 0, sizeof(__req));    \
  1131.     (__req).op = PVFS_SERV_TRUNCATE;       \
  1132.     (__req).credentials = (__creds);       \
  1133.     (__req).hints = (__hints);             \
  1134.     (__req).u.truncate.fs_id = (__fsid);   \
  1135.     (__req).u.truncate.size = (__size);    \
  1136.     (__req).u.truncate.handle = (__handle);\
  1137. } while (0)
  1138.  
  1139. /* statfs ****************************************************/
  1140. /* - retrieves statistics for a particular file system */
  1141.  
  1142. struct PVFS_servreq_statfs
  1143. {
  1144.     PVFS_fs_id fs_id;  /* file system */
  1145. };
  1146. endecode_fields_1_struct(
  1147.     PVFS_servreq_statfs,
  1148.     PVFS_fs_id, fs_id);
  1149.  
  1150. #define PINT_SERVREQ_STATFS_FILL(__req, __creds, __fsid,__hints)\
  1151. do {                                                    \
  1152.     memset(&(__req), 0, sizeof(__req));                 \
  1153.     (__req).op = PVFS_SERV_STATFS;                      \
  1154.     (__req).credentials = (__creds);                    \
  1155.     (__req).hints = (__hints);                          \
  1156.     (__req).u.statfs.fs_id = (__fsid);                  \
  1157. } while (0)
  1158.  
  1159. struct PVFS_servresp_statfs
  1160. {
  1161.     PVFS_statfs stat;
  1162. };
  1163. endecode_fields_1_struct(
  1164.     PVFS_servresp_statfs,
  1165.     PVFS_statfs, stat);
  1166.  
  1167. /* io **********************************************************/
  1168. /* - performs a read or write operation */
  1169.  
  1170. struct PVFS_servreq_io
  1171. {
  1172.     PVFS_handle handle;        /* target datafile */
  1173.     PVFS_fs_id fs_id;          /* file system */
  1174.     /* type of I/O operation to perform */
  1175.     enum PVFS_io_type io_type; /* enum defined in pvfs2-types.h */
  1176.  
  1177.     /* type of flow protocol to use for I/O transfer */
  1178.     enum PVFS_flowproto_type flow_type;
  1179.  
  1180.     /* relative number of this I/O server in distribution */
  1181.     uint32_t server_nr;
  1182.     /* total number of I/O servers involved in distribution */
  1183.     uint32_t server_ct;
  1184.  
  1185.     /* distribution */
  1186.     PINT_dist *io_dist;
  1187.     /* file datatype */
  1188.     struct PINT_Request * file_req;
  1189.     /* offset into file datatype */
  1190.     PVFS_offset file_req_offset;
  1191.     /* aggregate size of data to transfer */
  1192.     PVFS_size aggregate_size;
  1193. };
  1194. #ifdef __PINT_REQPROTO_ENCODE_FUNCS_C
  1195. #define encode_PVFS_servreq_io(pptr,x) do { \
  1196.     encode_PVFS_handle(pptr, &(x)->handle); \
  1197.     encode_PVFS_fs_id(pptr, &(x)->fs_id); \
  1198.     encode_skip4(pptr,); \
  1199.     encode_enum(pptr, &(x)->io_type); \
  1200.     encode_enum(pptr, &(x)->flow_type); \
  1201.     encode_uint32_t(pptr, &(x)->server_nr); \
  1202.     encode_uint32_t(pptr, &(x)->server_ct); \
  1203.     encode_PINT_dist(pptr, &(x)->io_dist); \
  1204.     encode_PINT_Request(pptr, &(x)->file_req); \
  1205.     encode_PVFS_offset(pptr, &(x)->file_req_offset); \
  1206.     encode_PVFS_size(pptr, &(x)->aggregate_size); \
  1207. } while (0)
  1208. #define decode_PVFS_servreq_io(pptr,x) do { \
  1209.     decode_PVFS_handle(pptr, &(x)->handle); \
  1210.     decode_PVFS_fs_id(pptr, &(x)->fs_id); \
  1211.     decode_skip4(pptr,); \
  1212.     decode_enum(pptr, &(x)->io_type); \
  1213.     decode_enum(pptr, &(x)->flow_type); \
  1214.     decode_uint32_t(pptr, &(x)->server_nr); \
  1215.     decode_uint32_t(pptr, &(x)->server_ct); \
  1216.     decode_PINT_dist(pptr, &(x)->io_dist); \
  1217.     decode_PINT_Request(pptr, &(x)->file_req); \
  1218.     PINT_request_decode((x)->file_req); /* unpacks the pointers */ \
  1219.     decode_PVFS_offset(pptr, &(x)->file_req_offset); \
  1220.     decode_PVFS_size(pptr, &(x)->aggregate_size); \
  1221. } while (0)
  1222. /* could be huge, limit to max ioreq size beyond struct itself */
  1223. #define extra_size_PVFS_servreq_io roundup8(PVFS_REQ_LIMIT_PATH_NAME_BYTES) \
  1224.   + roundup8(PVFS_REQ_LIMIT_PINT_REQUEST_NUM * sizeof(PINT_Request))
  1225. #endif
  1226.  
  1227. #define PINT_SERVREQ_IO_FILL(__req,                   \
  1228.                              __creds,                 \
  1229.                              __fsid,                  \
  1230.                              __handle,                \
  1231.                              __io_type,               \
  1232.                              __flow_type,             \
  1233.                              __datafile_nr,           \
  1234.                              __datafile_ct,           \
  1235.                              __io_dist,               \
  1236.                              __file_req,              \
  1237.                              __file_req_off,          \
  1238.                              __aggregate_size,        \
  1239.                              __hints)                 \
  1240. do {                                                  \
  1241.     memset(&(__req), 0, sizeof(__req));               \
  1242.     (__req).op                 = PVFS_SERV_IO;        \
  1243.     (__req).credentials        = (__creds);           \
  1244.     (__req).hints              = (__hints);           \
  1245.     (__req).u.io.fs_id         = (__fsid);            \
  1246.     (__req).u.io.handle        = (__handle);          \
  1247.     (__req).u.io.io_type       = (__io_type);         \
  1248.     (__req).u.io.flow_type     = (__flow_type);       \
  1249.     (__req).u.io.server_nr       = (__datafile_nr);   \
  1250.     (__req).u.io.server_ct     = (__datafile_ct);     \
  1251.     (__req).u.io.io_dist       = (__io_dist);         \
  1252.     (__req).u.io.file_req        = (__file_req);      \
  1253.     (__req).u.io.file_req_offset = (__file_req_off);  \
  1254.     (__req).u.io.aggregate_size  = (__aggregate_size);\
  1255. } while (0)
  1256.  
  1257. struct PVFS_servresp_io
  1258. {
  1259.     PVFS_size bstream_size;  /* size of datafile */
  1260. };
  1261. endecode_fields_1_struct(
  1262.     PVFS_servresp_io,
  1263.     PVFS_size, bstream_size);
  1264.  
  1265. /* write operations require a second response to announce completion */
  1266. struct PVFS_servresp_write_completion
  1267. {
  1268.     PVFS_size total_completed; /* amount of data transferred */
  1269. };
  1270. endecode_fields_1_struct(
  1271.     PVFS_servresp_write_completion,
  1272.     PVFS_size, total_completed);
  1273.  
  1274. #define SMALL_IO_MAX_SEGMENTS 64
  1275.  
  1276. struct PVFS_servreq_small_io
  1277. {
  1278.     PVFS_handle handle;
  1279.     PVFS_fs_id fs_id;
  1280.     enum PVFS_io_type io_type;
  1281.  
  1282.     uint32_t server_nr;
  1283.     uint32_t server_ct;
  1284.  
  1285.     PINT_dist * dist;
  1286.     struct PINT_Request * file_req;
  1287.     PVFS_offset file_req_offset;
  1288.     PVFS_size aggregate_size;
  1289.  
  1290.     /* these are used for writes to map the regions of the memory buffer
  1291.      * to the contiguous encoded message.  They don't get encoded.
  1292.      */
  1293.     int segments;
  1294.     PVFS_offset offsets[SMALL_IO_MAX_SEGMENTS];
  1295.     PVFS_size sizes[SMALL_IO_MAX_SEGMENTS];
  1296.  
  1297.     PVFS_size total_bytes; /* changed from int32_t */
  1298.     char * buffer;
  1299. };
  1300.  
  1301. #ifdef __PINT_REQPROTO_ENCODE_FUNCS_C
  1302. #define encode_PVFS_servreq_small_io(pptr,x) do { \
  1303.     encode_PVFS_handle(pptr, &(x)->handle); \
  1304.     encode_PVFS_fs_id(pptr, &(x)->fs_id); \
  1305.     encode_enum(pptr, &(x)->io_type); \
  1306.     encode_uint32_t(pptr, &(x)->server_nr); \
  1307.     encode_uint32_t(pptr, &(x)->server_ct); \
  1308.     encode_PINT_dist(pptr, &(x)->dist); \
  1309.     encode_PINT_Request(pptr, &(x)->file_req); \
  1310.     encode_PVFS_offset(pptr, &(x)->file_req_offset); \
  1311.     encode_PVFS_size(pptr, &(x)->aggregate_size); \
  1312.     encode_PVFS_size(pptr, &(x)->total_bytes); \
  1313.     encode_skip4(pptr,); \
  1314.     if ((x)->io_type == PVFS_IO_WRITE) \
  1315.     { \
  1316.         int i = 0; \
  1317.         for(; i < (x)->segments; ++i) \
  1318.         { \
  1319.             memcpy((*pptr), \
  1320.                    (char *)(x)->buffer + ((x)->offsets[i]), \
  1321.                    (x)->sizes[i]); \
  1322.             (*pptr) += (x)->sizes[i]; \
  1323.         } \
  1324.     } \
  1325. } while (0)
  1326.  
  1327. #define decode_PVFS_servreq_small_io(pptr,x) do { \
  1328.     decode_PVFS_handle(pptr, &(x)->handle); \
  1329.     decode_PVFS_fs_id(pptr, &(x)->fs_id); \
  1330.     decode_enum(pptr, &(x)->io_type); \
  1331.     decode_uint32_t(pptr, &(x)->server_nr); \
  1332.     decode_uint32_t(pptr, &(x)->server_ct); \
  1333.     decode_PINT_dist(pptr, &(x)->dist); \
  1334.     decode_PINT_Request(pptr, &(x)->file_req); \
  1335.     PINT_request_decode((x)->file_req); /* unpacks the pointers */ \
  1336.     decode_PVFS_offset(pptr, &(x)->file_req_offset); \
  1337.     decode_PVFS_size(pptr, &(x)->aggregate_size); \
  1338.     decode_PVFS_size(pptr, &(x)->total_bytes); \
  1339.     decode_skip4(pptr,); \
  1340.     if ((x)->io_type == PVFS_IO_WRITE) \
  1341.     { \
  1342.         /* instead of copying the message we just set the pointer, since \
  1343.          * we know it will not be freed unil the small io state machine \
  1344.          * has completed. \
  1345.          */ \
  1346.         (x)->buffer = (*pptr); \
  1347.         (*pptr) += (x)->total_bytes; \
  1348.     } \
  1349. } while (0)
  1350. #endif
  1351.  
  1352. #define extra_size_PVFS_servreq_small_io PINT_SMALL_IO_MAXSIZE
  1353.  
  1354. /* could be huge, limit to max ioreq size beyond struct itself */
  1355. #define PINT_SERVREQ_SMALL_IO_FILL(__req,                                \
  1356.                                    __creds,                              \
  1357.                                    __fsid,                               \
  1358.                                    __handle,                             \
  1359.                                    __io_type,                            \
  1360.                                    __dfile_nr,                           \
  1361.                                    __dfile_ct,                           \
  1362.                                    __dist,                               \
  1363.                                    __filereq,                            \
  1364.                                    __filereq_offset,                     \
  1365.                                    __segments,                           \
  1366.                                    __memreq_size,                        \
  1367.                                    __hints )                             \
  1368. do {                                                                     \
  1369.     int _sio_i;                                                          \
  1370.     (__req).op                                = PVFS_SERV_SMALL_IO;      \
  1371.     (__req).credentials                       = (__creds);               \
  1372.     (__req).hints                             = (__hints);               \
  1373.     (__req).u.small_io.fs_id                  = (__fsid);                \
  1374.     (__req).u.small_io.handle                 = (__handle);              \
  1375.     (__req).u.small_io.io_type                = (__io_type);             \
  1376.     (__req).u.small_io.server_nr              = (__dfile_nr);            \
  1377.     (__req).u.small_io.server_ct              = (__dfile_ct);            \
  1378.     (__req).u.small_io.dist                   = (__dist);                \
  1379.     (__req).u.small_io.file_req               = (__filereq);             \
  1380.     (__req).u.small_io.file_req_offset        = (__filereq_offset);      \
  1381.     (__req).u.small_io.aggregate_size         = (__memreq_size);         \
  1382.     (__req).u.small_io.segments               = (__segments);            \
  1383.     (__req).u.small_io.total_bytes            = 0;                       \
  1384.     for(_sio_i = 0; _sio_i < (__segments); ++_sio_i)                     \
  1385.     {                                                                    \
  1386.         (__req).u.small_io.total_bytes +=                                \
  1387.             (__req).u.small_io.sizes[_sio_i];                            \
  1388.     }                                                                    \
  1389. } while(0)
  1390.  
  1391. struct PVFS_servresp_small_io
  1392. {
  1393.     enum PVFS_io_type io_type;
  1394.  
  1395.     /* the io state machine needs the total bstream size to calculate
  1396.      * the correct return size
  1397.      */
  1398.     PVFS_size bstream_size;
  1399.  
  1400.     /* for writes, this is the amount written.  
  1401.      * for reads, this is the number of bytes read */
  1402.     PVFS_size result_size; 
  1403.     char * buffer;
  1404. };
  1405.  
  1406. #ifdef __PINT_REQPROTO_ENCODE_FUNCS_C
  1407. #define encode_PVFS_servresp_small_io(pptr,x) \
  1408.     do { \
  1409.         encode_enum(pptr, &(x)->io_type); \
  1410.         encode_skip4(pptr,); \
  1411.         encode_PVFS_size(pptr, &(x)->bstream_size); \
  1412.         encode_PVFS_size(pptr, &(x)->result_size); \
  1413.         if((x)->io_type == PVFS_IO_READ && (x)->buffer) \
  1414.         { \
  1415.             memcpy((*pptr), (x)->buffer, (x)->result_size); \
  1416.             (*pptr) += (x)->result_size; \
  1417.         } \
  1418.     } while(0)
  1419.  
  1420. #define decode_PVFS_servresp_small_io(pptr,x) \
  1421.     do { \
  1422.         decode_enum(pptr, &(x)->io_type); \
  1423.         decode_skip4(pptr,); \
  1424.         decode_PVFS_size(pptr, &(x)->bstream_size); \
  1425.         decode_PVFS_size(pptr, &(x)->result_size); \
  1426.         if((x)->io_type == PVFS_IO_READ) \
  1427.         { \
  1428.             (x)->buffer = (*pptr); \
  1429.             (*pptr) += (x)->result_size; \
  1430.         } \
  1431.     } while(0)
  1432. #endif
  1433.  
  1434. #define extra_size_PVFS_servresp_small_io PINT_SMALL_IO_MAXSIZE
  1435.  
  1436. /* listattr ****************************************************/
  1437. /* - retrieves attributes for a list of handles based on mask of PVFS_ATTR_XXX values */
  1438.  
  1439. struct PVFS_servreq_listattr
  1440. {
  1441.     PVFS_fs_id  fs_id;   /* file system */
  1442.     uint32_t    attrmask;  /* mask of desired attributes */
  1443.     uint32_t    nhandles; /* number of handles */
  1444.     PVFS_handle *handles; /* handle of target object */
  1445. };
  1446. endecode_fields_3a_struct(
  1447.     PVFS_servreq_listattr,
  1448.     PVFS_fs_id, fs_id,
  1449.     uint32_t, attrmask, 
  1450.     skip4,,
  1451.     uint32_t, nhandles,
  1452.     PVFS_handle, handles);
  1453. #define extra_size_PVFS_servreq_listattr \
  1454.     (PVFS_REQ_LIMIT_LISTATTR * sizeof(PVFS_handle))
  1455.  
  1456. #define PINT_SERVREQ_LISTATTR_FILL(__req,   \
  1457.                                   __creds, \
  1458.                                   __fsid,  \
  1459.                                   __amask, \
  1460.                                   __nhandles, \
  1461.                                   __handle_array, \
  1462.                                   __hints) \
  1463. do {                                       \
  1464.     memset(&(__req), 0, sizeof(__req));    \
  1465.     (__req).op = PVFS_SERV_LISTATTR;        \
  1466.     (__req).credentials = (__creds);       \
  1467.     (__req).hints = (__hints);             \
  1468.     (__req).u.listattr.fs_id = (__fsid);    \
  1469.     (__req).u.listattr.attrmask = (__amask);\
  1470.     (__req).u.listattr.nhandles = (__nhandles);    \
  1471.     (__req).u.listattr.handles = (__handle_array); \
  1472. } while (0)
  1473.  
  1474. struct PVFS_servresp_listattr
  1475. {
  1476.     uint32_t nhandles;
  1477.     PVFS_error       *error;
  1478.     PVFS_object_attr *attr;
  1479. };
  1480. endecode_fields_1aa_struct(
  1481.     PVFS_servresp_listattr,
  1482.     skip4,,
  1483.     uint32_t, nhandles,
  1484.     PVFS_error, error,
  1485.     PVFS_object_attr, attr);
  1486. #define extra_size_PVFS_servresp_listattr \
  1487.     ((PVFS_REQ_LIMIT_LISTATTR * sizeof(PVFS_error)) + (PVFS_REQ_LIMIT_LISTATTR * extra_size_PVFS_object_attr))
  1488.  
  1489.  
  1490. /* mgmt_setparam ****************************************************/
  1491. /* - management operation for setting runtime parameters */
  1492.  
  1493. struct PVFS_servreq_mgmt_setparam
  1494. {
  1495.     PVFS_fs_id fs_id;             /* file system */
  1496.     enum PVFS_server_param param; /* parameter to set */
  1497.     struct PVFS_mgmt_setparam_value value;
  1498. };
  1499. endecode_fields_3_struct(
  1500.     PVFS_servreq_mgmt_setparam,
  1501.     PVFS_fs_id, fs_id,
  1502.     enum, param,
  1503.     PVFS_mgmt_setparam_value, value);
  1504.  
  1505. #define PINT_SERVREQ_MGMT_SETPARAM_FILL(__req,                   \
  1506.                                         __creds,                 \
  1507.                                         __fsid,                  \
  1508.                                         __param,                 \
  1509.                                         __value,                 \
  1510.                                         __hints)                 \
  1511. do {                                                             \
  1512.     memset(&(__req), 0, sizeof(__req));                          \
  1513.     (__req).op = PVFS_SERV_MGMT_SETPARAM;                        \
  1514.     (__req).credentials = (__creds);                             \
  1515.     (__req).hints = (__hints);                                   \
  1516.     (__req).u.mgmt_setparam.fs_id = (__fsid);                    \
  1517.     (__req).u.mgmt_setparam.param = (__param);                   \
  1518.     if(__value){                                                 \
  1519.         (__req).u.mgmt_setparam.value.type = (__value)->type;    \
  1520.         (__req).u.mgmt_setparam.value.u.value = (__value)->u.value; \
  1521.     } \
  1522. } while (0)
  1523.  
  1524. /* mgmt_noop ********************************************************/
  1525. /* - does nothing except contact a server to see if it is responding
  1526.  * to requests
  1527.  */
  1528.  
  1529. #define PINT_SERVREQ_MGMT_NOOP_FILL(__req, __creds, __hints)\
  1530. do {                                               \
  1531.     memset(&(__req), 0, sizeof(__req));            \
  1532.     (__req).op = PVFS_SERV_MGMT_NOOP;              \
  1533.     (__req).credentials = (__creds);               \
  1534.     (__req).hints = (__hints);                     \
  1535. } while (0)
  1536.  
  1537.  
  1538. /* mgmt_perf_mon ****************************************************/
  1539. /* retrieves performance statistics from server */
  1540.  
  1541. struct PVFS_servreq_mgmt_perf_mon
  1542. {
  1543.     uint32_t next_id;  /* next time stamp id we want to retrieve */
  1544.     uint32_t count;    /* how many measurements we want */
  1545. };
  1546. endecode_fields_2_struct(
  1547.     PVFS_servreq_mgmt_perf_mon,
  1548.     uint32_t, next_id,
  1549.     uint32_t, count);
  1550.  
  1551. #define PINT_SERVREQ_MGMT_PERF_MON_FILL(__req,    \
  1552.                                         __creds,  \
  1553.                                         __next_id,\
  1554.                                         __count,  \
  1555.                                         __hints)  \
  1556. do {                                              \
  1557.     memset(&(__req), 0, sizeof(__req));           \
  1558.     (__req).op = PVFS_SERV_MGMT_PERF_MON;         \
  1559.     (__req).credentials = (__creds);              \
  1560.     (__req).hints = (__hints);                    \
  1561.     (__req).u.mgmt_perf_mon.next_id = (__next_id);\
  1562.     (__req).u.mgmt_perf_mon.count = (__count);    \
  1563. } while (0)
  1564.  
  1565. struct PVFS_servresp_mgmt_perf_mon
  1566. {
  1567.     struct PVFS_mgmt_perf_stat* perf_array; /* array of statistics */
  1568.     uint32_t perf_array_count;              /* size of above array */
  1569.     /* next id to pick up from this point */
  1570.     uint32_t suggested_next_id;
  1571.     uint64_t end_time_ms;  /* end time for final array entry */
  1572.     uint64_t cur_time_ms;  /* current time according to svr */
  1573. };
  1574. endecode_fields_5a_struct(
  1575.     PVFS_servresp_mgmt_perf_mon,
  1576.     uint32_t, suggested_next_id,
  1577.     skip4,,
  1578.     uint64_t, end_time_ms,
  1579.     uint64_t, cur_time_ms,
  1580.     skip4,,
  1581.     uint32_t, perf_array_count,
  1582.     PVFS_mgmt_perf_stat, perf_array);
  1583. #define extra_size_PVFS_servresp_mgmt_perf_mon \
  1584.     (PVFS_REQ_LIMIT_IOREQ_BYTES)
  1585.  
  1586. /* mgmt_iterate_handles ***************************************/
  1587. /* iterates through handles stored on server */
  1588.  
  1589. struct PVFS_servreq_mgmt_iterate_handles
  1590. {
  1591.     PVFS_fs_id fs_id;
  1592.     int32_t handle_count;
  1593.     int32_t flags;
  1594.     PVFS_ds_position position;
  1595. };
  1596. endecode_fields_4_struct(
  1597.     PVFS_servreq_mgmt_iterate_handles,
  1598.     PVFS_fs_id, fs_id,
  1599.     int32_t, handle_count,
  1600.     int32_t, flags,
  1601.     PVFS_ds_position, position);
  1602.  
  1603. #define PINT_SERVREQ_MGMT_ITERATE_HANDLES_FILL(__req,              \
  1604.                                         __creds,                   \
  1605.                                         __fs_id,                   \
  1606.                                         __handle_count,            \
  1607.                                         __position,                \
  1608.                                         __flags,                   \
  1609.                                         __hints)                   \
  1610. do {                                                               \
  1611.     memset(&(__req), 0, sizeof(__req));                            \
  1612.     (__req).op = PVFS_SERV_MGMT_ITERATE_HANDLES;                   \
  1613.     (__req).credentials = (__creds);                               \
  1614.     (__req).hints = (__hints);                                     \
  1615.     (__req).u.mgmt_iterate_handles.fs_id = (__fs_id);              \
  1616.     (__req).u.mgmt_iterate_handles.handle_count = (__handle_count);\
  1617.     (__req).u.mgmt_iterate_handles.position = (__position),        \
  1618.     (__req).u.mgmt_iterate_handles.flags = (__flags);              \
  1619. } while (0)
  1620.  
  1621. struct PVFS_servresp_mgmt_iterate_handles
  1622. {
  1623.     PVFS_ds_position position;
  1624.     PVFS_handle *handle_array;
  1625.     int handle_count;
  1626. };
  1627. endecode_fields_2a_struct(
  1628.     PVFS_servresp_mgmt_iterate_handles,
  1629.     PVFS_ds_position, position,
  1630.     skip4,,
  1631.     int32_t, handle_count,
  1632.     PVFS_handle, handle_array);
  1633. #define extra_size_PVFS_servresp_mgmt_iterate_handles \
  1634.   (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle))
  1635.  
  1636. /* mgmt_dspace_info_list **************************************/
  1637. /* - returns low level dspace information for a list of handles */
  1638.  
  1639. struct PVFS_servreq_mgmt_dspace_info_list
  1640. {
  1641.     PVFS_fs_id fs_id;
  1642.     PVFS_handle* handle_array;
  1643.     int32_t handle_count;
  1644. };
  1645. endecode_fields_1a_struct(
  1646.     PVFS_servreq_mgmt_dspace_info_list,
  1647.     PVFS_fs_id, fs_id,
  1648.     int32_t, handle_count,
  1649.     PVFS_handle, handle_array);
  1650. #define extra_size_PVFS_servreq_mgmt_dspace_info_list \
  1651.   (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle))
  1652.  
  1653. #define PINT_SERVREQ_MGMT_DSPACE_INFO_LIST(__req,                   \
  1654.                                         __creds,                    \
  1655.                                         __fs_id,                    \
  1656.                                         __handle_array,             \
  1657.                                         __handle_count,             \
  1658.                                         __hints)                    \
  1659. do {                                                                \
  1660.     memset(&(__req), 0, sizeof(__req));                             \
  1661.     (__req).op = PVFS_SERV_MGMT_DSPACE_INFO_LIST;                   \
  1662.     (__req).credentials = (__creds);                                \
  1663.     (__req).hints = (__hints);                                      \
  1664.     (__req).u.mgmt_dspace_info_list.fs_id = (__fs_id);              \
  1665.     (__req).u.mgmt_dspace_info_list.handle_array = (__handle_array);\
  1666.     (__req).u.mgmt_dspace_info_list.handle_count = (__handle_count);\
  1667. } while (0)
  1668.  
  1669. struct PVFS_servresp_mgmt_dspace_info_list
  1670. {
  1671.     struct PVFS_mgmt_dspace_info *dspace_info_array;
  1672.     int32_t dspace_info_count;
  1673. };
  1674. endecode_fields_1a_struct(
  1675.     PVFS_servresp_mgmt_dspace_info_list,
  1676.     skip4,,
  1677.     int32_t, dspace_info_count,
  1678.     PVFS_mgmt_dspace_info, dspace_info_array);
  1679. #define extra_size_PVFS_servresp_mgmt_dspace_info_list \
  1680.    (PVFS_REQ_LIMIT_MGMT_DSPACE_INFO_LIST_COUNT * \
  1681.     sizeof(struct PVFS_mgmt_dspace_info))
  1682.  
  1683. /* mgmt_event_mon **************************************/
  1684. /* - returns event logging data */
  1685.  
  1686. struct PVFS_servreq_mgmt_event_mon
  1687. {
  1688.     uint32_t event_count;
  1689. };
  1690. endecode_fields_1_struct(
  1691.     PVFS_servreq_mgmt_event_mon,
  1692.     uint32_t, event_count);
  1693.  
  1694. #define PINT_SERVREQ_MGMT_EVENT_MON_FILL(__req, __creds, __event_count, __hints)\
  1695. do {                                                                   \
  1696.     memset(&(__req), 0, sizeof(__req));                                \
  1697.     (__req).op = PVFS_SERV_MGMT_EVENT_MON;                             \
  1698.     (__req).credentials = (__creds);                                   \
  1699.     (__req).hints = (__hints);                                         \
  1700.     (__req).u.mgmt_event_mon.event_count = (__event_count);            \
  1701. } while (0)
  1702.  
  1703. struct PVFS_servresp_mgmt_event_mon
  1704. {
  1705.     struct PVFS_mgmt_event* event_array;
  1706.     uint32_t event_count;
  1707. };
  1708. endecode_fields_1a_struct(
  1709.     PVFS_servresp_mgmt_event_mon,
  1710.     skip4,,
  1711.     uint32_t, event_count,
  1712.     PVFS_mgmt_event, event_array);
  1713. #define extra_size_PVFS_servresp_mgmt_event_mon \
  1714.   (PVFS_REQ_LIMIT_MGMT_EVENT_MON_COUNT * \
  1715.    roundup8(sizeof(struct PVFS_mgmt_event)))
  1716.  
  1717. /* geteattr ****************************************************/
  1718. /* - retrieves list of extended attributes */
  1719.  
  1720. struct PVFS_servreq_geteattr
  1721. {
  1722.     PVFS_handle handle;  /* handle of target object */
  1723.     PVFS_fs_id fs_id;    /* file system */
  1724.     int32_t nkey;        /* number of keys to read */
  1725.     PVFS_ds_keyval *key; /* array of keys to read */
  1726.     PVFS_size *valsz;    /* array of value buffer sizes */
  1727. };
  1728. endecode_fields_2aa_struct(
  1729.     PVFS_servreq_geteattr,
  1730.     PVFS_handle, handle,
  1731.     PVFS_fs_id, fs_id,
  1732.     int32_t, nkey,
  1733.     PVFS_ds_keyval, key,
  1734.     PVFS_size, valsz);
  1735. #define extra_size_PVFS_servreq_geteattr \
  1736.     ((PVFS_REQ_LIMIT_EATTR_KEY_LEN + sizeof(PVFS_size) \
  1737.      * PVFS_REQ_LIMIT_EATTR_LIST))
  1738.  
  1739. #define PINT_SERVREQ_GETEATTR_FILL(__req,   \
  1740.                                   __creds, \
  1741.                                   __fsid,  \
  1742.                                   __handle,\
  1743.                                   __nkey,\
  1744.                                   __key_array, \
  1745.                                   __size_array,\
  1746.                                   __hints) \
  1747. do {                                       \
  1748.     memset(&(__req), 0, sizeof(__req));    \
  1749.     (__req).op = PVFS_SERV_GETEATTR;       \
  1750.     (__req).credentials = (__creds);       \
  1751.     (__req).hints = (__hints);             \
  1752.     (__req).u.geteattr.fs_id = (__fsid);   \
  1753.     (__req).u.geteattr.handle = (__handle);\
  1754.     (__req).u.geteattr.nkey = (__nkey);    \
  1755.     (__req).u.geteattr.key = (__key_array);\
  1756.     (__req).u.geteattr.valsz = (__size_array);\
  1757. } while (0)
  1758.  
  1759. struct PVFS_servresp_geteattr
  1760. {
  1761.     int32_t nkey;           /* number of values returned */
  1762.     PVFS_ds_keyval *val;    /* array of values returned */
  1763.     PVFS_error *err;        /* array of error codes */
  1764. };
  1765. endecode_fields_1aa_struct(
  1766.     PVFS_servresp_geteattr,
  1767.     skip4,,
  1768.     int32_t, nkey,
  1769.     PVFS_ds_keyval, val,
  1770.     PVFS_error, err);
  1771. #define extra_size_PVFS_servresp_geteattr \
  1772.     ((PVFS_REQ_LIMIT_EATTR_VAL_LEN + sizeof(PVFS_error)) \
  1773.      * PVFS_REQ_LIMIT_EATTR_LIST)
  1774.  
  1775. /* seteattr ****************************************************/
  1776. /* - sets list of extended attributes */
  1777.  
  1778. struct PVFS_servreq_seteattr
  1779. {
  1780.     PVFS_handle handle;    /* handle of target object */
  1781.     PVFS_fs_id fs_id;      /* file system */
  1782.     int32_t    flags;      /* flags */
  1783.     int32_t    nkey;       /* number of keys and vals */
  1784.     PVFS_ds_keyval *key;    /* attribute key */
  1785.     PVFS_ds_keyval *val;    /* attribute value */
  1786. };
  1787. endecode_fields_4aa_struct(
  1788.     PVFS_servreq_seteattr,
  1789.     PVFS_handle, handle,
  1790.     PVFS_fs_id, fs_id,
  1791.     int32_t, flags,
  1792.     skip4,,
  1793.     int32_t, nkey,
  1794.     PVFS_ds_keyval, key,
  1795.     PVFS_ds_keyval, val);
  1796. #define extra_size_PVFS_servreq_seteattr \
  1797.     ((PVFS_REQ_LIMIT_EATTR_KEY_LEN  + PVFS_REQ_LIMIT_EATTR_VAL_LEN) \
  1798.         * PVFS_REQ_LIMIT_EATTR_LIST)
  1799.  
  1800. #define PINT_SERVREQ_SETEATTR_FILL(__req,   \
  1801.                                   __creds,       \
  1802.                                   __fsid,        \
  1803.                                   __handle,      \
  1804.                                   __flags,       \
  1805.                                   __nkey,        \
  1806.                                   __key_array,   \
  1807.                                   __val_array,   \
  1808.                                   __hints)       \
  1809. do {                                             \
  1810.     memset(&(__req), 0, sizeof(__req));          \
  1811.     (__req).op = PVFS_SERV_SETEATTR;        \
  1812.     (__req).credentials = (__creds);        \
  1813.     (__req).hints = (__hints);              \
  1814.     (__req).u.seteattr.fs_id = (__fsid);    \
  1815.     (__req).u.seteattr.handle = (__handle); \
  1816.     (__req).u.seteattr.flags = (__flags);   \
  1817.     (__req).u.seteattr.nkey = (__nkey);     \
  1818.     (__req).u.seteattr.key = (__key_array); \
  1819.     (__req).u.seteattr.val = (__val_array); \
  1820. } while (0)
  1821.  
  1822. /* deleattr ****************************************************/
  1823. /* - deletes extended attributes */
  1824.  
  1825. struct PVFS_servreq_deleattr
  1826. {
  1827.     PVFS_handle handle; /* handle of target object */
  1828.     PVFS_fs_id fs_id;   /* file system */
  1829.     PVFS_ds_keyval key; /* key to read */
  1830. };
  1831. endecode_fields_3_struct(
  1832.     PVFS_servreq_deleattr,
  1833.     PVFS_handle, handle,
  1834.     PVFS_fs_id, fs_id,
  1835.     PVFS_ds_keyval, key);
  1836. #define extra_size_PVFS_servreq_deleattr \
  1837.     PVFS_REQ_LIMIT_EATTR_KEY_LEN 
  1838.  
  1839. #define PINT_SERVREQ_DELEATTR_FILL(__req,   \
  1840.                                   __creds, \
  1841.                                   __fsid,  \
  1842.                                   __handle,\
  1843.                                   __key,   \
  1844.                                   __hints) \
  1845. do {                                       \
  1846.     memset(&(__req), 0, sizeof(__req));    \
  1847.     (__req).op = PVFS_SERV_DELEATTR;        \
  1848.     (__req).credentials = (__creds);       \
  1849.     (__req).hints = (__hints);             \
  1850.     (__req).u.deleattr.fs_id = (__fsid);    \
  1851.     (__req).u.deleattr.handle = (__handle); \
  1852.     (__req).u.deleattr.key.buffer_sz = (__key).buffer_sz;\
  1853.     (__req).u.deleattr.key.buffer = (__key).buffer;\
  1854. } while (0)
  1855.  
  1856. /* listeattr **************************************************/
  1857. /* - list extended attributes */
  1858.  
  1859. struct PVFS_servreq_listeattr
  1860. {
  1861.     PVFS_handle handle;     /* handle of dir object */
  1862.     PVFS_fs_id  fs_id;      /* file system */
  1863.     PVFS_ds_position token; /* offset */
  1864.     uint32_t     nkey;      /* desired number of keys to read */
  1865.     PVFS_size   *keysz;     /* array of key buffer sizes */
  1866. };
  1867. endecode_fields_4a_struct(
  1868.     PVFS_servreq_listeattr,
  1869.     PVFS_handle, handle,
  1870.     PVFS_fs_id, fs_id,
  1871.     skip4,,
  1872.     PVFS_ds_position, token,
  1873.     uint32_t, nkey,
  1874.     PVFS_size, keysz);
  1875. #define extra_size_PVFS_servreq_listeattr \
  1876.     (PVFS_REQ_LIMIT_EATTR_LIST * sizeof(PVFS_size))
  1877.  
  1878. #define PINT_SERVREQ_LISTEATTR_FILL(__req,            \
  1879.                                   __creds,            \
  1880.                                   __fsid,             \
  1881.                                   __handle,           \
  1882.                                   __token,            \
  1883.                                   __nkey,             \
  1884.                                   __size_array,       \
  1885.                                   __hints)            \
  1886. do {                                                  \
  1887.     memset(&(__req), 0, sizeof(__req));               \
  1888.     (__req).op = PVFS_SERV_LISTEATTR;                 \
  1889.     (__req).credentials = (__creds);                  \
  1890.     (__req).hints = (__hints);                        \
  1891.     (__req).u.listeattr.fs_id = (__fsid);             \
  1892.     (__req).u.listeattr.handle = (__handle);          \
  1893.     (__req).u.listeattr.token = (__token);            \
  1894.     (__req).u.listeattr.nkey = (__nkey);              \
  1895.     (__req).u.listeattr.keysz = (__size_array);       \
  1896. } while (0);
  1897.  
  1898. struct PVFS_servresp_listeattr
  1899. {
  1900.     PVFS_ds_position token;  /* new dir offset */
  1901.     uint32_t nkey;   /* # of keys retrieved */
  1902.     PVFS_ds_keyval *key; /* array of keys returned */
  1903. };
  1904. endecode_fields_2a_struct(
  1905.     PVFS_servresp_listeattr,
  1906.     PVFS_ds_position, token,
  1907.     skip4,,
  1908.     uint32_t, nkey,
  1909.     PVFS_ds_keyval, key);
  1910. #define extra_size_PVFS_servresp_listeattr \
  1911.     (PVFS_REQ_LIMIT_EATTR_KEY_LEN * PVFS_REQ_LIMIT_EATTR_LIST)
  1912.  
  1913.  
  1914. /* server request *********************************************/
  1915. /* - generic request with union of all op specific structs */
  1916.  
  1917. struct PVFS_server_req
  1918. {
  1919.     enum PVFS_server_op op;
  1920.     PVFS_credentials credentials;
  1921.     PVFS_hint hints;
  1922.  
  1923.     union
  1924.     {
  1925.         struct PVFS_servreq_mirror mirror;
  1926.         struct PVFS_servreq_create create;
  1927.         struct PVFS_servreq_unstuff unstuff;
  1928.         struct PVFS_servreq_batch_create batch_create;
  1929.         struct PVFS_servreq_remove remove;
  1930.         struct PVFS_servreq_batch_remove batch_remove;
  1931.         struct PVFS_servreq_io io;
  1932.         struct PVFS_servreq_getattr getattr;
  1933.         struct PVFS_servreq_setattr setattr;
  1934.         struct PVFS_servreq_mkdir mkdir;
  1935.         struct PVFS_servreq_readdir readdir;
  1936.         struct PVFS_servreq_lookup_path lookup_path;
  1937.         struct PVFS_servreq_crdirent crdirent;
  1938.         struct PVFS_servreq_rmdirent rmdirent;
  1939.         struct PVFS_servreq_chdirent chdirent;
  1940.         struct PVFS_servreq_truncate truncate;
  1941.         struct PVFS_servreq_flush flush;
  1942.         struct PVFS_servreq_mgmt_setparam mgmt_setparam;
  1943.         struct PVFS_servreq_statfs statfs;
  1944.         struct PVFS_servreq_mgmt_perf_mon mgmt_perf_mon;
  1945.         struct PVFS_servreq_mgmt_iterate_handles mgmt_iterate_handles;
  1946.         struct PVFS_servreq_mgmt_dspace_info_list mgmt_dspace_info_list;
  1947.         struct PVFS_servreq_mgmt_event_mon mgmt_event_mon;
  1948.         struct PVFS_servreq_mgmt_remove_object mgmt_remove_object;
  1949.         struct PVFS_servreq_mgmt_remove_dirent mgmt_remove_dirent;
  1950.         struct PVFS_servreq_mgmt_get_dirdata_handle mgmt_get_dirdata_handle;
  1951.         struct PVFS_servreq_geteattr geteattr;
  1952.         struct PVFS_servreq_seteattr seteattr;
  1953.         struct PVFS_servreq_deleattr deleattr;
  1954.         struct PVFS_servreq_listeattr listeattr;
  1955.         struct PVFS_servreq_small_io small_io;
  1956.         struct PVFS_servreq_listattr listattr;
  1957.         struct PVFS_servreq_tree_remove tree_remove;
  1958.         struct PVFS_servreq_tree_get_file_size tree_get_file_size;
  1959.     } u;
  1960. };
  1961. #ifdef __PINT_REQPROTO_ENCODE_FUNCS_C
  1962. /* insert padding to ensure the union starts on an aligned boundary */
  1963. static inline void
  1964. encode_PVFS_server_req(char **pptr, const struct PVFS_server_req *x) {
  1965.     encode_enum(pptr, &x->op);
  1966. #ifdef HAVE_VALGRIND_H
  1967.     *(int32_t*) *pptr = 0;  /* else possible memcpy in BMI sees uninit */
  1968. #endif
  1969.     *pptr += 4;
  1970.     encode_PVFS_credentials(pptr, &x->credentials);
  1971.     encode_PINT_hint(pptr, x->hints);
  1972. }
  1973. static inline void
  1974. decode_PVFS_server_req(char **pptr, struct PVFS_server_req *x) {
  1975.     decode_enum(pptr, &x->op);
  1976.     *pptr += 4;
  1977.     decode_PVFS_credentials(pptr, &x->credentials);
  1978.     decode_PINT_hint(pptr, &x->hints);
  1979. }
  1980. #endif
  1981.  
  1982. /* server response *********************************************/
  1983. /* - generic response with union of all op specific structs */
  1984. struct PVFS_server_resp
  1985. {
  1986.     enum PVFS_server_op op;
  1987.     PVFS_error status;
  1988.     union
  1989.     {
  1990.         struct PVFS_servresp_mirror mirror;
  1991.         struct PVFS_servresp_create create;
  1992.         struct PVFS_servresp_unstuff unstuff;
  1993.         struct PVFS_servresp_batch_create batch_create;
  1994.         struct PVFS_servresp_getattr getattr;
  1995.         struct PVFS_servresp_mkdir mkdir;
  1996.         struct PVFS_servresp_readdir readdir;
  1997.         struct PVFS_servresp_lookup_path lookup_path;
  1998.         struct PVFS_servresp_rmdirent rmdirent;
  1999.         struct PVFS_servresp_chdirent chdirent;
  2000.         struct PVFS_servresp_getconfig getconfig;
  2001.         struct PVFS_servresp_io io;
  2002.         struct PVFS_servresp_write_completion write_completion;
  2003.         struct PVFS_servresp_statfs statfs;
  2004.         struct PVFS_servresp_mgmt_perf_mon mgmt_perf_mon;
  2005.         struct PVFS_servresp_mgmt_iterate_handles mgmt_iterate_handles;
  2006.         struct PVFS_servresp_mgmt_dspace_info_list mgmt_dspace_info_list;
  2007.         struct PVFS_servresp_mgmt_event_mon mgmt_event_mon;
  2008.         struct PVFS_servresp_mgmt_get_dirdata_handle mgmt_get_dirdata_handle;
  2009.         struct PVFS_servresp_geteattr geteattr;
  2010.         struct PVFS_servresp_listeattr listeattr;
  2011.         struct PVFS_servresp_small_io small_io;
  2012.         struct PVFS_servresp_listattr listattr;
  2013.         struct PVFS_servresp_tree_get_file_size tree_get_file_size;
  2014.     } u;
  2015. };
  2016. endecode_fields_2_struct(
  2017.     PVFS_server_resp,
  2018.     enum, op,
  2019.     PVFS_error, status);
  2020.  
  2021. #endif /* __PVFS2_REQ_PROTO_H */
  2022.  
  2023. /*
  2024.  * Local variables:
  2025.  *  c-indent-level: 4
  2026.  *  c-basic-offset: 4
  2027.  * End:
  2028.  *
  2029.  * vim: ts=8 sts=4 sw=4 expandtab
  2030.  */
  2031.