root/branches/Orange-Branch/src/proto/pvfs2-req-proto.h @ 8891

Revision 8891, 76.6 KB (checked in by walt, 2 years ago)

Modifications to perf counter system
Minor formatting and documentation edits

Line 
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
41enum 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
169struct 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};
179endecode_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)                                  \
197do {                                                                       \
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
214struct PVFS_servresp_create
215{
216    PVFS_handle metafile_handle;
217    int32_t stuffed;
218    int32_t datafile_count;
219    PVFS_handle *datafile_handles;
220};
221endecode_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
233struct 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};
247endecode_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)              \
265do {                                                   \
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
279struct PVFS_servresp_batch_create
280{
281    PVFS_handle *handle_array;
282    uint32_t handle_count;
283};
284endecode_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
295struct PVFS_servreq_remove
296{
297    PVFS_handle handle;
298    PVFS_fs_id  fs_id;
299};
300endecode_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) \
310do {                                      \
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
319struct PVFS_servreq_batch_remove
320{
321    PVFS_fs_id  fs_id;
322    int32_t handle_count;
323    PVFS_handle *handles;
324};
325endecode_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)    \
338do {                                                 \
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
350struct PVFS_servreq_mgmt_remove_object
351{
352    PVFS_handle handle;
353    PVFS_fs_id fs_id;
354};
355endecode_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) \
365do {                                                  \
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
377struct PVFS_servreq_mgmt_remove_dirent
378{
379    PVFS_handle handle;
380    PVFS_fs_id fs_id;
381    char *entry;
382};
383endecode_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) \
398do {                                                  \
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
408struct PVFS_servreq_tree_remove
409{
410    PVFS_fs_id  fs_id;
411    uint32_t num_data_files;
412    PVFS_handle *handle_array;
413};
414endecode_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)                                \
428do {                                                                     \
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
438struct 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};
446endecode_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)                                          \
464do {                                                                               \
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
476struct 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};
483endecode_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 */
495struct PVFS_servreq_mgmt_get_dirdata_handle
496{
497    PVFS_handle handle;
498    PVFS_fs_id fs_id;
499};
500endecode_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) \
510do {                                                       \
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
519struct PVFS_servresp_mgmt_get_dirdata_handle
520{
521    PVFS_handle handle;
522};
523endecode_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 */
529struct PVFS_servreq_flush
530{
531    PVFS_handle handle;
532    PVFS_fs_id fs_id;
533    int32_t flags;
534};
535endecode_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 )\
546do {                                     \
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
558struct 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};
564endecode_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) \
576do {                                       \
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
586struct PVFS_servresp_getattr
587{
588    PVFS_object_attr attr;
589};
590endecode_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
600struct 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};
606endecode_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)         \
617do {                                               \
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
626struct 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};
633endecode_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
642struct 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};
648endecode_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)       \
665do {                                             \
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
680struct 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};
688endecode_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)         \
705do {                                                   \
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
716struct 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};
725endecode_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
741struct 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};
754endecode_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)               \
769do {                                                   \
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
784struct PVFS_servresp_mkdir
785{
786    PVFS_handle handle; /* handle of new directory */
787};
788endecode_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
795struct 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};
802endecode_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)         \
818do {                                                \
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
833struct 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};
839endecode_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)       \
853do {                                              \
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
863struct PVFS_servresp_rmdirent
864{
865    PVFS_handle entry_handle;   /* handle of removed entry */
866};
867endecode_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
874struct 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};
881endecode_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)        \
897do {                                               \
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
910struct PVFS_servresp_chdirent
911{
912    PVFS_handle old_dirent_handle;
913};
914endecode_fields_1_struct(
915    PVFS_servresp_chdirent,
916    PVFS_handle, old_dirent_handle);
917
918/* readdir *****************************************************/
919/* - reads entries from a directory */
920
921struct 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};
928endecode_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)            \
942do {                                                  \
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
953struct 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};
961endecode_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)\
975do {                                               \
976    memset(&(__req), 0, sizeof(__req));            \
977    (__req).op = PVFS_SERV_GETCONFIG;              \
978    (__req).hints = (__hints);                     \
979    (__req).credentials = (__creds);               \
980} while (0);
981
982struct PVFS_servresp_getconfig
983{
984    char *fs_config_buf;
985    uint32_t fs_config_buf_size;
986};
987endecode_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.                                                      */
1000struct 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.)                                             */
1061struct 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
1108struct 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};
1116endecode_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)   \
1129do {                                       \
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
1142struct PVFS_servreq_statfs
1143{
1144    PVFS_fs_id fs_id;  /* file system */
1145};
1146endecode_fields_1_struct(
1147    PVFS_servreq_statfs,
1148    PVFS_fs_id, fs_id);
1149
1150#define PINT_SERVREQ_STATFS_FILL(__req, __creds, __fsid,__hints)\
1151do {                                                    \
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
1159struct PVFS_servresp_statfs
1160{
1161    PVFS_statfs stat;
1162};
1163endecode_fields_1_struct(
1164    PVFS_servresp_statfs,
1165    PVFS_statfs, stat);
1166
1167/* io **********************************************************/
1168/* - performs a read or write operation */
1169
1170struct 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)                 \
1240do {                                                  \
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
1257struct PVFS_servresp_io
1258{
1259    PVFS_size bstream_size;  /* size of datafile */
1260};
1261endecode_fields_1_struct(
1262    PVFS_servresp_io,
1263    PVFS_size, bstream_size);
1264
1265/* write operations require a second response to announce completion */
1266struct PVFS_servresp_write_completion
1267{
1268    PVFS_size total_completed; /* amount of data transferred */
1269};
1270endecode_fields_1_struct(
1271    PVFS_servresp_write_completion,
1272    PVFS_size, total_completed);
1273
1274#define SMALL_IO_MAX_SEGMENTS 64
1275
1276struct 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 )                             \
1368do {                                                                     \
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
1391struct 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
1439struct 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};
1446endecode_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) \
1463do {                                       \
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
1474struct PVFS_servresp_listattr
1475{
1476    uint32_t nhandles;
1477    PVFS_error       *error;
1478    PVFS_object_attr *attr;
1479};
1480endecode_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
1493struct 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};
1499endecode_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)                 \
1511do {                                                             \
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)\
1530do {                                               \
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
1541struct PVFS_servreq_mgmt_perf_mon
1542{
1543    uint32_t next_id;      /* next time stamp id we want to retrieve */
1544    uint32_t key_count;    /* how many counters per measurements we want */
1545    uint32_t count;        /* how many measurements we want */
1546};
1547endecode_fields_3_struct(
1548    PVFS_servreq_mgmt_perf_mon,
1549    uint32_t, next_id,
1550    uint32_t, key_count,
1551    uint32_t, count);
1552
1553#define PINT_SERVREQ_MGMT_PERF_MON_FILL(__req,        \
1554                                        __creds,      \
1555                                        __next_id,    \
1556                                        __key_count,  \
1557                                        __count,      \
1558                                        __hints)      \
1559do {                                                  \
1560    memset(&(__req), 0, sizeof(__req));               \
1561    (__req).op = PVFS_SERV_MGMT_PERF_MON;             \
1562    (__req).credentials = (__creds);                  \
1563    (__req).hints = (__hints);                        \
1564    (__req).u.mgmt_perf_mon.next_id = (__next_id);    \
1565    (__req).u.mgmt_perf_mon.key_count = (__key_count);\
1566    (__req).u.mgmt_perf_mon.count = (__count);        \
1567} while (0)
1568
1569struct PVFS_servresp_mgmt_perf_mon
1570{
1571    int64_t *perf_array;            /* array of statistics */
1572    uint32_t perf_array_count;      /* size of above array */
1573    uint32_t key_count;             /* number of keys in each sample */
1574    uint32_t suggested_next_id;     /* next id to pick up from this point */
1575    uint64_t end_time_ms;           /* end time for final array entry */
1576    uint64_t cur_time_ms;           /* current time according to svr */
1577};
1578endecode_fields_5a_struct(
1579    PVFS_servresp_mgmt_perf_mon,
1580    uint32_t, key_count,
1581    uint32_t, suggested_next_id,
1582    uint64_t, end_time_ms,
1583    uint64_t, cur_time_ms,
1584    skip4,,
1585    uint32_t, perf_array_count,
1586    int64_t,  perf_array);
1587#define extra_size_PVFS_servresp_mgmt_perf_mon \
1588    (PVFS_REQ_LIMIT_IOREQ_BYTES)
1589
1590/* mgmt_iterate_handles ***************************************/
1591/* iterates through handles stored on server */
1592
1593struct PVFS_servreq_mgmt_iterate_handles
1594{
1595    PVFS_fs_id fs_id;
1596    int32_t handle_count;
1597    int32_t flags;
1598    PVFS_ds_position position;
1599};
1600endecode_fields_4_struct(
1601    PVFS_servreq_mgmt_iterate_handles,
1602    PVFS_fs_id, fs_id,
1603    int32_t, handle_count,
1604    int32_t, flags,
1605    PVFS_ds_position, position);
1606
1607#define PINT_SERVREQ_MGMT_ITERATE_HANDLES_FILL(__req,              \
1608                                        __creds,                   \
1609                                        __fs_id,                   \
1610                                        __handle_count,            \
1611                                        __position,                \
1612                                        __flags,                   \
1613                                        __hints)                   \
1614do {                                                               \
1615    memset(&(__req), 0, sizeof(__req));                            \
1616    (__req).op = PVFS_SERV_MGMT_ITERATE_HANDLES;                   \
1617    (__req).credentials = (__creds);                               \
1618    (__req).hints = (__hints);                                     \
1619    (__req).u.mgmt_iterate_handles.fs_id = (__fs_id);              \
1620    (__req).u.mgmt_iterate_handles.handle_count = (__handle_count);\
1621    (__req).u.mgmt_iterate_handles.position = (__position),        \
1622    (__req).u.mgmt_iterate_handles.flags = (__flags);              \
1623} while (0)
1624
1625struct PVFS_servresp_mgmt_iterate_handles
1626{
1627    PVFS_ds_position position;
1628    PVFS_handle *handle_array;
1629    int handle_count;
1630};
1631endecode_fields_2a_struct(
1632    PVFS_servresp_mgmt_iterate_handles,
1633    PVFS_ds_position, position,
1634    skip4,,
1635    int32_t, handle_count,
1636    PVFS_handle, handle_array);
1637#define extra_size_PVFS_servresp_mgmt_iterate_handles \
1638  (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle))
1639
1640/* mgmt_dspace_info_list **************************************/
1641/* - returns low level dspace information for a list of handles */
1642
1643struct PVFS_servreq_mgmt_dspace_info_list
1644{
1645    PVFS_fs_id fs_id;
1646    PVFS_handle* handle_array;
1647    int32_t handle_count;
1648};
1649endecode_fields_1a_struct(
1650    PVFS_servreq_mgmt_dspace_info_list,
1651    PVFS_fs_id, fs_id,
1652    int32_t, handle_count,
1653    PVFS_handle, handle_array);
1654#define extra_size_PVFS_servreq_mgmt_dspace_info_list \
1655  (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle))
1656
1657#define PINT_SERVREQ_MGMT_DSPACE_INFO_LIST(__req,                   \
1658                                        __creds,                    \
1659                                        __fs_id,                    \
1660                                        __handle_array,             \
1661                                        __handle_count,             \
1662                                        __hints)                    \
1663do {                                                                \
1664    memset(&(__req), 0, sizeof(__req));                             \
1665    (__req).op = PVFS_SERV_MGMT_DSPACE_INFO_LIST;                   \
1666    (__req).credentials = (__creds);                                \
1667    (__req).hints = (__hints);                                      \
1668    (__req).u.mgmt_dspace_info_list.fs_id = (__fs_id);              \
1669    (__req).u.mgmt_dspace_info_list.handle_array = (__handle_array);\
1670    (__req).u.mgmt_dspace_info_list.handle_count = (__handle_count);\
1671} while (0)
1672
1673struct PVFS_servresp_mgmt_dspace_info_list
1674{
1675    struct PVFS_mgmt_dspace_info *dspace_info_array;
1676    int32_t dspace_info_count;
1677};
1678endecode_fields_1a_struct(
1679    PVFS_servresp_mgmt_dspace_info_list,
1680    skip4,,
1681    int32_t, dspace_info_count,
1682    PVFS_mgmt_dspace_info, dspace_info_array);
1683#define extra_size_PVFS_servresp_mgmt_dspace_info_list \
1684   (PVFS_REQ_LIMIT_MGMT_DSPACE_INFO_LIST_COUNT * \
1685    sizeof(struct PVFS_mgmt_dspace_info))
1686
1687/* mgmt_event_mon **************************************/
1688/* - returns event logging data */
1689
1690struct PVFS_servreq_mgmt_event_mon
1691{
1692    uint32_t event_count;
1693};
1694endecode_fields_1_struct(
1695    PVFS_servreq_mgmt_event_mon,
1696    uint32_t, event_count);
1697
1698#define PINT_SERVREQ_MGMT_EVENT_MON_FILL(__req, __creds, __event_count, __hints)\
1699do {                                                                   \
1700    memset(&(__req), 0, sizeof(__req));                                \
1701    (__req).op = PVFS_SERV_MGMT_EVENT_MON;                             \
1702    (__req).credentials = (__creds);                                   \
1703    (__req).hints = (__hints);                                         \
1704    (__req).u.mgmt_event_mon.event_count = (__event_count);            \
1705} while (0)
1706
1707struct PVFS_servresp_mgmt_event_mon
1708{
1709    struct PVFS_mgmt_event* event_array;
1710    uint32_t event_count;
1711};
1712endecode_fields_1a_struct(
1713    PVFS_servresp_mgmt_event_mon,
1714    skip4,,
1715    uint32_t, event_count,
1716    PVFS_mgmt_event, event_array);
1717#define extra_size_PVFS_servresp_mgmt_event_mon \
1718  (PVFS_REQ_LIMIT_MGMT_EVENT_MON_COUNT * \
1719   roundup8(sizeof(struct PVFS_mgmt_event)))
1720
1721/* geteattr ****************************************************/
1722/* - retrieves list of extended attributes */
1723
1724struct PVFS_servreq_geteattr
1725{
1726    PVFS_handle handle;  /* handle of target object */
1727    PVFS_fs_id fs_id;    /* file system */
1728    int32_t nkey;        /* number of keys to read */
1729    PVFS_ds_keyval *key; /* array of keys to read */
1730    PVFS_size *valsz;    /* array of value buffer sizes */
1731};
1732endecode_fields_2aa_struct(
1733    PVFS_servreq_geteattr,
1734    PVFS_handle, handle,
1735    PVFS_fs_id, fs_id,
1736    int32_t, nkey,
1737    PVFS_ds_keyval, key,
1738    PVFS_size, valsz);
1739#define extra_size_PVFS_servreq_geteattr \
1740    ((PVFS_REQ_LIMIT_EATTR_KEY_LEN + sizeof(PVFS_size) \
1741     * PVFS_REQ_LIMIT_EATTR_LIST))
1742
1743#define PINT_SERVREQ_GETEATTR_FILL(__req,   \
1744                                  __creds, \
1745                                  __fsid,  \
1746                                  __handle,\
1747                                  __nkey,\
1748                                  __key_array, \
1749                                  __size_array,\
1750                                  __hints) \
1751do {                                       \
1752    memset(&(__req), 0, sizeof(__req));    \
1753    (__req).op = PVFS_SERV_GETEATTR;       \
1754    (__req).credentials = (__creds);       \
1755    (__req).hints = (__hints);             \
1756    (__req).u.geteattr.fs_id = (__fsid);   \
1757    (__req).u.geteattr.handle = (__handle);\
1758    (__req).u.geteattr.nkey = (__nkey);    \
1759    (__req).u.geteattr.key = (__key_array);\
1760    (__req).u.geteattr.valsz = (__size_array);\
1761} while (0)
1762
1763struct PVFS_servresp_geteattr
1764{
1765    int32_t nkey;           /* number of values returned */
1766    PVFS_ds_keyval *val;    /* array of values returned */
1767    PVFS_error *err;        /* array of error codes */
1768};
1769endecode_fields_1aa_struct(
1770    PVFS_servresp_geteattr,
1771    skip4,,
1772    int32_t, nkey,
1773    PVFS_ds_keyval, val,
1774    PVFS_error, err);
1775#define extra_size_PVFS_servresp_geteattr \
1776    ((PVFS_REQ_LIMIT_EATTR_VAL_LEN + sizeof(PVFS_error)) \
1777     * PVFS_REQ_LIMIT_EATTR_LIST)
1778
1779/* seteattr ****************************************************/
1780/* - sets list of extended attributes */
1781
1782struct PVFS_servreq_seteattr
1783{
1784    PVFS_handle handle;    /* handle of target object */
1785    PVFS_fs_id fs_id;      /* file system */
1786    int32_t    flags;      /* flags */
1787    int32_t    nkey;       /* number of keys and vals */
1788    PVFS_ds_keyval *key;    /* attribute key */
1789    PVFS_ds_keyval *val;    /* attribute value */
1790};
1791endecode_fields_4aa_struct(
1792    PVFS_servreq_seteattr,
1793    PVFS_handle, handle,
1794    PVFS_fs_id, fs_id,
1795    int32_t, flags,
1796    skip4,,
1797    int32_t, nkey,
1798    PVFS_ds_keyval, key,
1799    PVFS_ds_keyval, val);
1800#define extra_size_PVFS_servreq_seteattr \
1801    ((PVFS_REQ_LIMIT_EATTR_KEY_LEN  + PVFS_REQ_LIMIT_EATTR_VAL_LEN) \
1802        * PVFS_REQ_LIMIT_EATTR_LIST)
1803
1804#define PINT_SERVREQ_SETEATTR_FILL(__req,   \
1805                                  __creds,       \
1806                                  __fsid,        \
1807                                  __handle,      \
1808                                  __flags,       \
1809                                  __nkey,        \
1810                                  __key_array,   \
1811                                  __val_array,   \
1812                                  __hints)       \
1813do {                                             \
1814    memset(&(__req), 0, sizeof(__req));          \
1815    (__req).op = PVFS_SERV_SETEATTR;        \
1816    (__req).credentials = (__creds);        \
1817    (__req).hints = (__hints);              \
1818    (__req).u.seteattr.fs_id = (__fsid);    \
1819    (__req).u.seteattr.handle = (__handle); \
1820    (__req).u.seteattr.flags = (__flags);   \
1821    (__req).u.seteattr.nkey = (__nkey);     \
1822    (__req).u.seteattr.key = (__key_array); \
1823    (__req).u.seteattr.val = (__val_array); \
1824} while (0)
1825
1826/* deleattr ****************************************************/
1827/* - deletes extended attributes */
1828
1829struct PVFS_servreq_deleattr
1830{
1831    PVFS_handle handle; /* handle of target object */
1832    PVFS_fs_id fs_id;   /* file system */
1833    PVFS_ds_keyval key; /* key to read */
1834};
1835endecode_fields_3_struct(
1836    PVFS_servreq_deleattr,
1837    PVFS_handle, handle,
1838    PVFS_fs_id, fs_id,
1839    PVFS_ds_keyval, key);
1840#define extra_size_PVFS_servreq_deleattr \
1841    PVFS_REQ_LIMIT_EATTR_KEY_LEN
1842
1843#define PINT_SERVREQ_DELEATTR_FILL(__req,   \
1844                                  __creds, \
1845                                  __fsid,  \
1846                                  __handle,\
1847                                  __key,   \
1848                                  __hints) \
1849do {                                       \
1850    memset(&(__req), 0, sizeof(__req));    \
1851    (__req).op = PVFS_SERV_DELEATTR;        \
1852    (__req).credentials = (__creds);       \
1853    (__req).hints = (__hints);             \
1854    (__req).u.deleattr.fs_id = (__fsid);    \
1855    (__req).u.deleattr.handle = (__handle); \
1856    (__req).u.deleattr.key.buffer_sz = (__key).buffer_sz;\
1857    (__req).u.deleattr.key.buffer = (__key).buffer;\
1858} while (0)
1859
1860/* listeattr **************************************************/
1861/* - list extended attributes */
1862
1863struct PVFS_servreq_listeattr
1864{
1865    PVFS_handle handle;     /* handle of dir object */
1866    PVFS_fs_id  fs_id;      /* file system */
1867    PVFS_ds_position token; /* offset */
1868    uint32_t     nkey;      /* desired number of keys to read */
1869    PVFS_size   *keysz;     /* array of key buffer sizes */
1870};
1871endecode_fields_4a_struct(
1872    PVFS_servreq_listeattr,
1873    PVFS_handle, handle,
1874    PVFS_fs_id, fs_id,
1875    skip4,,
1876    PVFS_ds_position, token,
1877    uint32_t, nkey,
1878    PVFS_size, keysz);
1879#define extra_size_PVFS_servreq_listeattr \
1880    (PVFS_REQ_LIMIT_EATTR_LIST * sizeof(PVFS_size))
1881
1882#define PINT_SERVREQ_LISTEATTR_FILL(__req,            \
1883                                  __creds,            \
1884                                  __fsid,             \
1885                                  __handle,           \
1886                                  __token,            \
1887                                  __nkey,             \
1888                                  __size_array,       \
1889                                  __hints)            \
1890do {                                                  \
1891    memset(&(__req), 0, sizeof(__req));               \
1892    (__req).op = PVFS_SERV_LISTEATTR;                 \
1893    (__req).credentials = (__creds);                  \
1894    (__req).hints = (__hints);                        \
1895    (__req).u.listeattr.fs_id = (__fsid);             \
1896    (__req).u.listeattr.handle = (__handle);          \
1897    (__req).u.listeattr.token = (__token);            \
1898    (__req).u.listeattr.nkey = (__nkey);              \
1899    (__req).u.listeattr.keysz = (__size_array);       \
1900} while (0);
1901
1902struct PVFS_servresp_listeattr
1903{
1904    PVFS_ds_position token;  /* new dir offset */
1905    uint32_t nkey;   /* # of keys retrieved */
1906    PVFS_ds_keyval *key; /* array of keys returned */
1907};
1908endecode_fields_2a_struct(
1909    PVFS_servresp_listeattr,
1910    PVFS_ds_position, token,
1911    skip4,,
1912    uint32_t, nkey,
1913    PVFS_ds_keyval, key);
1914#define extra_size_PVFS_servresp_listeattr \
1915    (PVFS_REQ_LIMIT_EATTR_KEY_LEN * PVFS_REQ_LIMIT_EATTR_LIST)
1916
1917
1918/* server request *********************************************/
1919/* - generic request with union of all op specific structs */
1920
1921struct PVFS_server_req
1922{
1923    enum PVFS_server_op op;
1924    PVFS_credentials credentials;
1925    PVFS_hint hints;
1926
1927    union
1928    {
1929        struct PVFS_servreq_mirror mirror;
1930        struct PVFS_servreq_create create;
1931        struct PVFS_servreq_unstuff unstuff;
1932        struct PVFS_servreq_batch_create batch_create;
1933        struct PVFS_servreq_remove remove;
1934        struct PVFS_servreq_batch_remove batch_remove;
1935        struct PVFS_servreq_io io;
1936        struct PVFS_servreq_getattr getattr;
1937        struct PVFS_servreq_setattr setattr;
1938        struct PVFS_servreq_mkdir mkdir;
1939        struct PVFS_servreq_readdir readdir;
1940        struct PVFS_servreq_lookup_path lookup_path;
1941        struct PVFS_servreq_crdirent crdirent;
1942        struct PVFS_servreq_rmdirent rmdirent;
1943        struct PVFS_servreq_chdirent chdirent;
1944        struct PVFS_servreq_truncate truncate;
1945        struct PVFS_servreq_flush flush;
1946        struct PVFS_servreq_mgmt_setparam mgmt_setparam;
1947        struct PVFS_servreq_statfs statfs;
1948        struct PVFS_servreq_mgmt_perf_mon mgmt_perf_mon;
1949        struct PVFS_servreq_mgmt_iterate_handles mgmt_iterate_handles;
1950        struct PVFS_servreq_mgmt_dspace_info_list mgmt_dspace_info_list;
1951        struct PVFS_servreq_mgmt_event_mon mgmt_event_mon;
1952        struct PVFS_servreq_mgmt_remove_object mgmt_remove_object;
1953        struct PVFS_servreq_mgmt_remove_dirent mgmt_remove_dirent;
1954        struct PVFS_servreq_mgmt_get_dirdata_handle mgmt_get_dirdata_handle;
1955        struct PVFS_servreq_geteattr geteattr;
1956        struct PVFS_servreq_seteattr seteattr;
1957        struct PVFS_servreq_deleattr deleattr;
1958        struct PVFS_servreq_listeattr listeattr;
1959        struct PVFS_servreq_small_io small_io;
1960        struct PVFS_servreq_listattr listattr;
1961        struct PVFS_servreq_tree_remove tree_remove;
1962        struct PVFS_servreq_tree_get_file_size tree_get_file_size;
1963    } u;
1964};
1965#ifdef __PINT_REQPROTO_ENCODE_FUNCS_C
1966/* insert padding to ensure the union starts on an aligned boundary */
1967static inline void
1968encode_PVFS_server_req(char **pptr, const struct PVFS_server_req *x) {
1969    encode_enum(pptr, &x->op);
1970#ifdef HAVE_VALGRIND_H
1971    *(int32_t*) *pptr = 0;  /* else possible memcpy in BMI sees uninit */
1972#endif
1973    *pptr += 4;
1974    encode_PVFS_credentials(pptr, &x->credentials);
1975    encode_PINT_hint(pptr, x->hints);
1976}
1977static inline void
1978decode_PVFS_server_req(char **pptr, struct PVFS_server_req *x) {
1979    decode_enum(pptr, &x->op);
1980    *pptr += 4;
1981    decode_PVFS_credentials(pptr, &x->credentials);
1982    decode_PINT_hint(pptr, &x->hints);
1983}
1984#endif
1985
1986/* server response *********************************************/
1987/* - generic response with union of all op specific structs */
1988struct PVFS_server_resp
1989{
1990    enum PVFS_server_op op;
1991    PVFS_error status;
1992    union
1993    {
1994        struct PVFS_servresp_mirror mirror;
1995        struct PVFS_servresp_create create;
1996        struct PVFS_servresp_unstuff unstuff;
1997        struct PVFS_servresp_batch_create batch_create;
1998        struct PVFS_servresp_getattr getattr;
1999        struct PVFS_servresp_mkdir mkdir;
2000        struct PVFS_servresp_readdir readdir;
2001        struct PVFS_servresp_lookup_path lookup_path;
2002        struct PVFS_servresp_rmdirent rmdirent;
2003        struct PVFS_servresp_chdirent chdirent;
2004        struct PVFS_servresp_getconfig getconfig;
2005        struct PVFS_servresp_io io;
2006        struct PVFS_servresp_write_completion write_completion;
2007        struct PVFS_servresp_statfs statfs;
2008        struct PVFS_servresp_mgmt_perf_mon mgmt_perf_mon;
2009        struct PVFS_servresp_mgmt_iterate_handles mgmt_iterate_handles;
2010        struct PVFS_servresp_mgmt_dspace_info_list mgmt_dspace_info_list;
2011        struct PVFS_servresp_mgmt_event_mon mgmt_event_mon;
2012        struct PVFS_servresp_mgmt_get_dirdata_handle mgmt_get_dirdata_handle;
2013        struct PVFS_servresp_geteattr geteattr;
2014        struct PVFS_servresp_listeattr listeattr;
2015        struct PVFS_servresp_small_io small_io;
2016        struct PVFS_servresp_listattr listattr;
2017        struct PVFS_servresp_tree_get_file_size tree_get_file_size;
2018    } u;
2019};
2020endecode_fields_2_struct(
2021    PVFS_server_resp,
2022    enum, op,
2023    PVFS_error, status);
2024
2025#endif /* __PVFS2_REQ_PROTO_H */
2026
2027/*
2028 * Local variables:
2029 *  c-indent-level: 4
2030 *  c-basic-offset: 4
2031 * End:
2032 *
2033 * vim: ts=8 sts=4 sw=4 expandtab
2034 */
Note: See TracBrowser for help on using the browser.