root/trunk/src/proto/pvfs2-req-proto.h @ 4617

Revision 4617, 49.1 KB (checked in by robl, 8 years ago)

[pcarns]: add protocol versioning to PVFS2. Major version changes are
incompatible up or down. New clients can't talk to old servers, but new
servers can talk to old clients.

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 "pvfs2-mgmt.h"
19
20/* update PVFS2_PROTO_MAJOR on wire protocol changes that break backwards
21 * compatibility (such as changing the semantics or protocol fields for an
22 * existing request type)
23 */
24#define PVFS2_PROTO_MAJOR 1
25/* update PVFS2_PROTO_MINOR on wire protocol changes that preserve backwards
26 * compatibility (such as adding a new request type)
27 */
28#define PVFS2_PROTO_MINOR 1
29#define PVFS2_PROTO_VERSION ((PVFS2_PROTO_MAJOR*1000)+(PVFS2_PROTO_MINOR))
30
31enum PVFS_server_op
32{
33    PVFS_SERV_INVALID = 0,
34    PVFS_SERV_CREATE = 1,
35    PVFS_SERV_REMOVE = 2,
36    PVFS_SERV_IO = 3,
37    PVFS_SERV_GETATTR = 4,
38    PVFS_SERV_SETATTR = 5,
39    PVFS_SERV_LOOKUP_PATH = 6,
40    PVFS_SERV_CRDIRENT = 7,
41    PVFS_SERV_RMDIRENT = 8,
42    PVFS_SERV_CHDIRENT = 9,
43    PVFS_SERV_TRUNCATE = 10,
44    PVFS_SERV_MKDIR = 11,
45    PVFS_SERV_READDIR = 12,
46    PVFS_SERV_GETCONFIG = 13,
47    PVFS_SERV_WRITE_COMPLETION = 14,
48    PVFS_SERV_FLUSH = 15,
49    PVFS_SERV_MGMT_SETPARAM = 16,
50    PVFS_SERV_MGMT_NOOP = 17,
51    PVFS_SERV_STATFS = 18,
52    PVFS_SERV_PERF_UPDATE = 19,  /* not a real protocol request */
53    PVFS_SERV_MGMT_PERF_MON = 20,
54    PVFS_SERV_MGMT_ITERATE_HANDLES = 21,
55    PVFS_SERV_MGMT_DSPACE_INFO_LIST = 22,
56    PVFS_SERV_MGMT_EVENT_MON = 23,
57    PVFS_SERV_MGMT_REMOVE_OBJECT = 24,
58    PVFS_SERV_MGMT_REMOVE_DIRENT = 25,
59    PVFS_SERV_MGMT_GET_DIRDATA_HANDLE = 26,
60    PVFS_SERV_JOB_TIMER = 27,    /* not a real protocol request */
61    PVFS_SERV_PROTO_ERROR = 28,
62    PVFS_SERV_GETEATTR = 29,
63    PVFS_SERV_SETEATTR = 30,
64    PVFS_SERV_DELEATTR = 31
65    /* IMPORTANT: please remember to modify PVFS_MAX_SERVER_OP define
66     * (below) if you add a new operation to this list
67     */
68};
69#define PVFS_MAX_SERVER_OP 31
70
71/*
72 * These ops must always work, even if the server is in admin mode.
73 */
74#define PVFS_SERV_IS_MGMT_OP(x) \
75    ((x) == PVFS_SERV_MGMT_REMOVE_OBJECT \
76  || (x) == PVFS_SERV_MGMT_REMOVE_DIRENT)
77
78/* a private internal type */
79typedef struct
80{
81    enum PVFS_server_op type;
82    char *type_str;
83} __req_resp_type_desc_t;
84
85/******************************************************************/
86/* these values define limits on the maximum size of variable length
87 * parameters used within the request protocol
88 */
89
90/* max size of opaque distribution parameters */
91#define PVFS_REQ_LIMIT_DIST_BYTES         1024
92/* max size of each configuration file transmitted to clients */
93#define PVFS_REQ_LIMIT_CONFIG_FILE_BYTES  16384
94/* max size of all path strings */
95#define PVFS_REQ_LIMIT_PATH_NAME_BYTES    PVFS_NAME_MAX
96/* max size of strings representing a single path element */
97#define PVFS_REQ_LIMIT_SEGMENT_BYTES      PVFS_SEGMENT_MAX
98/* max total size of I/O request descriptions */
99#define PVFS_REQ_LIMIT_IOREQ_BYTES        8192
100/* max count of segments allowed per path lookup (note that this governs
101 * the number of handles and attributes returned in lookup_path responses)
102 */
103#define PVFS_REQ_LIMIT_PATH_SEGMENT_COUNT   40
104/* max count of datafiles associated with a logical file */
105#define PVFS_REQ_LIMIT_DFILE_COUNT        1024
106#define PVFS_REQ_LIMIT_DFILE_COUNT_IS_VALID(dfile_count) \
107((dfile_count > 0) && (dfile_count < PVFS_REQ_LIMIT_DFILE_COUNT))
108/* max count of directory entries per readdir request */
109#define PVFS_REQ_LIMIT_DIRENT_COUNT        512
110/* max number of perf metrics returned by mgmt perf mon op */
111#define PVFS_REQ_LIMIT_MGMT_PERF_MON_COUNT 16
112/* max number of events returned by mgmt event mon op */
113#define PVFS_REQ_LIMIT_MGMT_EVENT_MON_COUNT 2048
114/* max number of handles returned by any operation using an array of handles */
115#define PVFS_REQ_LIMIT_HANDLES_COUNT 1024
116/* max number of handles returned by mgmt iterate handles op */
117#define PVFS_REQ_LIMIT_MGMT_ITERATE_HANDLES_COUNT \
118  PVFS_REQ_LIMIT_HANDLES_COUNT
119/* max number of info list items returned by mgmt dspace info list op */
120/* max number of dspace info structs returned by mgmt dpsace info op */
121#define PVFS_REQ_LIMIT_MGMT_DSPACE_INFO_LIST_COUNT 1024
122/* max number of path elements in a lookup_attr response */
123#define PVFS_REQ_LIMIT_MAX_PATH_ELEMENTS  40
124/* max number of symlinks to resolve before erroring out */
125#define PVFS_REQ_LIMIT_MAX_SYMLINK_RESOLUTION_COUNT 8
126/* max depth of a PINT_Request used in anything, just servreq IO now */
127#define PVFS_REQ_LIMIT_PINT_REQUEST_NUM  100
128/* max number of bytes in the key of a key/value pair including null term */
129#define PVFS_REQ_LIMIT_KEY_LEN 128
130/* max number of bytes in a value of a key/value/pair */
131#define PVFS_REQ_LIMIT_VAL_LEN 4096
132/* man number of key/value pairs to set or get in a list operation */
133#define PVFS_REQ_LIMIT_KEYVAL_LIST 32
134
135/* create *********************************************************/
136/* - used to create new metafile and datafile objects */
137
138struct PVFS_servreq_create
139{
140    PVFS_fs_id fs_id;
141    PVFS_ds_type object_type;
142
143    /*
144      an array of handle extents that we use to suggest to
145      the server from which handle range to allocate for the
146      newly created handle(s).  To request a single handle,
147      a single extent with first = last should be used.
148    */
149    PVFS_handle_extent_array handle_extent_array;
150};
151endecode_fields_3_struct(
152    PVFS_servreq_create,
153    PVFS_fs_id, fs_id,
154    PVFS_ds_type, object_type,
155    PVFS_handle_extent_array, handle_extent_array)
156#define extra_size_PVFS_servreq_create \
157    (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle_extent))
158
159#define PINT_SERVREQ_CREATE_FILL(__req,                \
160                                 __creds,              \
161                                 __fsid,               \
162                                 __objtype,            \
163                                 __ext_array)          \
164do {                                                   \
165    memset(&(__req), 0, sizeof(__req));                \
166    (__req).op = PVFS_SERV_CREATE;                     \
167    (__req).credentials = (__creds);                   \
168    (__req).u.create.fs_id = (__fsid);                 \
169    (__req).u.create.object_type = (__objtype);        \
170    (__req).u.create.handle_extent_array.extent_count =\
171        (__ext_array).extent_count;                    \
172    (__req).u.create.handle_extent_array.extent_array =\
173        (__ext_array).extent_array;                    \
174} while (0)
175
176struct PVFS_servresp_create
177{
178    PVFS_handle handle;
179};
180endecode_fields_1_struct(
181    PVFS_servresp_create,
182    PVFS_handle, handle)
183
184/* remove *****************************************************/
185/* - used to remove an existing metafile or datafile object */
186
187struct PVFS_servreq_remove
188{
189    PVFS_handle handle;
190    PVFS_fs_id fs_id;
191};
192endecode_fields_2_struct(
193    PVFS_servreq_remove,
194    PVFS_handle, handle,
195    PVFS_fs_id, fs_id)
196
197#define PINT_SERVREQ_REMOVE_FILL(__req,   \
198                                 __creds, \
199                                 __fsid,  \
200                                 __handle)\
201do {                                      \
202    memset(&(__req), 0, sizeof(__req));   \
203    (__req).op = PVFS_SERV_REMOVE;        \
204    (__req).credentials = (__creds);      \
205    (__req).u.remove.fs_id = (__fsid);    \
206    (__req).u.remove.handle = (__handle); \
207} while (0)
208
209/* mgmt_remove_object */
210/* - used to remove an existing object reference */
211
212struct PVFS_servreq_mgmt_remove_object
213{
214    PVFS_handle handle;
215    PVFS_fs_id fs_id;
216};
217endecode_fields_2_struct(
218    PVFS_servreq_mgmt_remove_object,
219    PVFS_handle, handle,
220    PVFS_fs_id, fs_id)
221
222#define PINT_SERVREQ_MGMT_REMOVE_OBJECT_FILL(__req,   \
223                                             __creds, \
224                                             __fsid,  \
225                                             __handle)\
226do {                                                  \
227    memset(&(__req), 0, sizeof(__req));               \
228    (__req).op = PVFS_SERV_MGMT_REMOVE_OBJECT;        \
229    (__req).credentials = (__creds);                  \
230    (__req).u.mgmt_remove_object.fs_id = (__fsid);    \
231    (__req).u.mgmt_remove_object.handle = (__handle); \
232} while (0)
233
234/* mgmt_remove_dirent */
235/* - used to remove an existing dirent under the specified parent ref */
236
237struct PVFS_servreq_mgmt_remove_dirent
238{
239    PVFS_handle handle;
240    PVFS_fs_id fs_id;
241    char *entry;
242};
243endecode_fields_4_struct(
244    PVFS_servreq_mgmt_remove_dirent,
245    PVFS_handle, handle,
246    PVFS_fs_id, fs_id,
247    skip4,,
248    string, entry)
249#define extra_size_PVFS_servreq_mgmt_remove_dirent \
250  roundup8(PVFS_REQ_LIMIT_SEGMENT_BYTES+1)
251
252#define PINT_SERVREQ_MGMT_REMOVE_DIRENT_FILL(__req,   \
253                                             __creds, \
254                                             __fsid,  \
255                                             __handle,\
256                                             __entry) \
257do {                                                  \
258    memset(&(__req), 0, sizeof(__req));               \
259    (__req).op = PVFS_SERV_MGMT_REMOVE_DIRENT;        \
260    (__req).credentials = (__creds);                  \
261    (__req).u.mgmt_remove_dirent.fs_id = (__fsid);    \
262    (__req).u.mgmt_remove_dirent.handle = (__handle); \
263    (__req).u.mgmt_remove_dirent.entry = (__entry);   \
264} while (0)
265
266/* mgmt_get_dirdata_handle */
267/* - used to retrieve the dirdata handle of the specified parent ref */
268struct PVFS_servreq_mgmt_get_dirdata_handle
269{
270    PVFS_handle handle;
271    PVFS_fs_id fs_id;
272};
273endecode_fields_2_struct(
274    PVFS_servreq_mgmt_get_dirdata_handle,
275    PVFS_handle, handle,
276    PVFS_fs_id, fs_id)
277
278#define PINT_SERVREQ_MGMT_GET_DIRDATA_HANDLE_FILL(__req,   \
279                                                  __creds, \
280                                                  __fsid,  \
281                                                  __handle)\
282do {                                                       \
283    memset(&(__req), 0, sizeof(__req));                    \
284    (__req).op = PVFS_SERV_MGMT_GET_DIRDATA_HANDLE;        \
285    (__req).credentials = (__creds);                       \
286    (__req).u.mgmt_get_dirdata_handle.fs_id = (__fsid);    \
287    (__req).u.mgmt_get_dirdata_handle.handle = (__handle); \
288} while (0)
289
290struct PVFS_servresp_mgmt_get_dirdata_handle
291{
292    PVFS_handle handle;
293};
294endecode_fields_1_struct(
295    PVFS_servresp_mgmt_get_dirdata_handle,
296    PVFS_handle, handle)
297
298/* flush
299 * - used to flush an object to disk */
300struct PVFS_servreq_flush
301{
302    PVFS_handle handle;
303    PVFS_fs_id fs_id;
304    int32_t flags;
305};
306endecode_fields_3_struct(
307    PVFS_servreq_flush,
308    PVFS_handle, handle,
309    PVFS_fs_id, fs_id,
310    int32_t, flags)
311
312#define PINT_SERVREQ_FLUSH_FILL(__req,   \
313                                __creds, \
314                                __fsid,  \
315                                __handle)\
316do {                                     \
317    memset(&(__req), 0, sizeof(__req));  \
318    (__req).op = PVFS_SERV_FLUSH;        \
319    (__req).credentials = (__creds);     \
320    (__req).u.flush.fs_id = (__fsid);    \
321    (__req).u.flush.handle = (__handle); \
322} while (0)
323
324/* getattr ****************************************************/
325/* - retreives attributes based on mask of PVFS_ATTR_XXX values */
326
327struct PVFS_servreq_getattr
328{
329    PVFS_handle handle; /* handle of target object */
330    PVFS_fs_id fs_id;   /* file system */
331    uint32_t attrmask;  /* mask of desired attributes */
332};
333endecode_fields_3_struct(
334    PVFS_servreq_getattr,
335    PVFS_handle, handle,
336    PVFS_fs_id, fs_id,
337    uint32_t, attrmask)
338
339#define PINT_SERVREQ_GETATTR_FILL(__req,   \
340                                  __creds, \
341                                  __fsid,  \
342                                  __handle,\
343                                  __amask) \
344do {                                       \
345    memset(&(__req), 0, sizeof(__req));    \
346    (__req).op = PVFS_SERV_GETATTR;        \
347    (__req).credentials = (__creds);       \
348    (__req).u.getattr.fs_id = (__fsid);    \
349    (__req).u.getattr.handle = (__handle); \
350    (__req).u.getattr.attrmask = (__amask);\
351} while (0)
352
353struct PVFS_servresp_getattr
354{
355    PVFS_object_attr attr;
356};
357endecode_fields_1_struct(
358    PVFS_servresp_getattr,
359    PVFS_object_attr, attr)
360#define extra_size_PVFS_servresp_getattr \
361    extra_size_PVFS_object_attr
362
363/* setattr ****************************************************/
364/* - sets attributes specified by mask of PVFS_ATTR_XXX values */
365
366struct PVFS_servreq_setattr
367{
368    PVFS_handle handle;    /* handle of target object */
369    PVFS_fs_id fs_id;      /* file system */
370    PVFS_object_attr attr; /* new attributes */
371};
372endecode_fields_4_struct(
373    PVFS_servreq_setattr,
374    PVFS_handle, handle,
375    PVFS_fs_id, fs_id,
376    skip4,,
377    PVFS_object_attr, attr)
378#define extra_size_PVFS_servreq_setattr \
379    extra_size_PVFS_object_attr
380
381#define PINT_SERVREQ_SETATTR_FILL(__req,         \
382                                  __creds,       \
383                                  __fsid,        \
384                                  __handle,      \
385                                  __objtype,     \
386                                  __attr,        \
387                                  __amask)       \
388do {                                             \
389    memset(&(__req), 0, sizeof(__req));          \
390    (__req).op = PVFS_SERV_SETATTR;              \
391    (__req).credentials = (__creds);             \
392    (__req).u.setattr.fs_id = (__fsid);          \
393    (__req).u.setattr.handle = (__handle);       \
394    PINT_CONVERT_ATTR(&(__req).u.setattr.attr,   \
395       &(__attr), PVFS_ATTR_COMMON_ALL);         \
396    (__req).u.setattr.attr.objtype = (__objtype);\
397    (__req).u.setattr.attr.mask |= (__amask);    \
398} while (0)
399
400/* lookup path ************************************************/
401/* - looks up as many elements of the specified path as possible */
402
403struct PVFS_servreq_lookup_path
404{
405    char *path;                  /* path name */
406    PVFS_fs_id fs_id;            /* file system */
407    PVFS_handle starting_handle; /* handle of path parent */
408    /* mask of attribs to return with lookup results */
409    uint32_t attrmask;
410};
411endecode_fields_5_struct(
412    PVFS_servreq_lookup_path,
413    string, path,
414    PVFS_fs_id, fs_id,
415    skip4,,
416    PVFS_handle, starting_handle,
417    uint32_t, attrmask)
418#define extra_size_PVFS_servreq_lookup_path \
419  roundup8(PVFS_REQ_LIMIT_PATH_NAME_BYTES + 1)
420
421#define PINT_SERVREQ_LOOKUP_PATH_FILL(__req,           \
422                                      __creds,         \
423                                      __path,          \
424                                      __fsid,          \
425                                      __handle,        \
426                                      __amask)         \
427do {                                                   \
428    memset(&(__req), 0, sizeof(__req));                \
429    (__req).op = PVFS_SERV_LOOKUP_PATH;                \
430    (__req).credentials = (__creds);                   \
431    (__req).u.lookup_path.path = (__path);             \
432    (__req).u.lookup_path.fs_id = (__fsid);            \
433    (__req).u.lookup_path.starting_handle = (__handle);\
434    (__req).u.lookup_path.attrmask = (__amask);        \
435} while (0)
436
437struct PVFS_servresp_lookup_path
438{
439    /* array of handles for each successfully resolved path segment */
440    PVFS_handle *handle_array;           
441    /* array of attributes for each path segment (when available) */
442    PVFS_object_attr *attr_array;
443    uint32_t handle_count; /* # of handles returned */
444    uint32_t attr_count;   /* # of attributes returned */
445};
446endecode_fields_1a_1a_struct(
447    PVFS_servresp_lookup_path,
448    skip4,,
449    uint32_t, handle_count,
450    PVFS_handle, handle_array,
451    skip4,,
452    uint32_t, attr_count,
453    PVFS_object_attr, attr_array)
454/* this is a big thing that could be either a full path,
455* or lots of handles, just use the max io req limit */
456#define extra_size_PVFS_servresp_lookup_path \
457  (PVFS_REQ_LIMIT_IOREQ_BYTES)
458
459/* mkdir *******************************************************/
460/* - makes a new directory object */
461
462struct PVFS_servreq_mkdir
463{
464    PVFS_fs_id fs_id;      /* file system */
465    PVFS_object_attr attr; /* initial attributes */
466
467    /*
468      an array of handle extents that we use to suggest to
469      the server from which handle range to allocate for the
470      newly created handle(s).  To request a single handle,
471      a single extent with first = last should be used.
472    */
473    PVFS_handle_extent_array handle_extent_array;
474};
475endecode_fields_4_struct(
476    PVFS_servreq_mkdir,
477    PVFS_fs_id, fs_id,
478    skip4,,
479    PVFS_object_attr, attr,
480    PVFS_handle_extent_array, handle_extent_array)
481#define extra_size_PVFS_servreq_mkdir \
482    (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle_extent))
483
484#define PINT_SERVREQ_MKDIR_FILL(__req,                 \
485                                __creds,               \
486                                __fs_id,               \
487                                __ext_array,           \
488                                __attr,                \
489                                __amask)               \
490do {                                                   \
491    memset(&(__req), 0, sizeof(__req));                \
492    (__req).op = PVFS_SERV_MKDIR;                      \
493    (__req).credentials = (__creds);                   \
494    (__req).u.mkdir.fs_id = __fs_id;                   \
495    (__req).u.mkdir.handle_extent_array.extent_count = \
496        (__ext_array).extent_count;                    \
497    (__req).u.mkdir.handle_extent_array.extent_array = \
498        (__ext_array).extent_array;                    \
499    PINT_CONVERT_ATTR(&(__req).u.mkdir.attr,           \
500       &(__attr), PVFS_ATTR_COMMON_ALL);               \
501    (__req).u.mkdir.attr.mask &= (__amask);            \
502    (__req).u.mkdir.attr.mask |= PVFS_ATTR_COMMON_TYPE;\
503    (__req).u.mkdir.attr.objtype = PVFS_TYPE_DIRECTORY;\
504} while (0)
505
506struct PVFS_servresp_mkdir
507{
508    PVFS_handle handle; /* handle of new directory */
509};
510endecode_fields_1_struct(
511    PVFS_servresp_mkdir,
512    PVFS_handle, handle)
513
514/* create dirent ***********************************************/
515/* - creates a new entry within an existing directory */
516
517struct PVFS_servreq_crdirent
518{
519    char *name;                /* name of new entry */
520    PVFS_handle new_handle;    /* handle of new entry */
521    PVFS_handle parent_handle; /* handle of directory */
522    PVFS_fs_id fs_id;          /* file system */
523    PVFS_time parent_atime;
524    PVFS_time parent_mtime;
525    PVFS_time parent_ctime;
526};
527endecode_fields_8_struct(
528    PVFS_servreq_crdirent,
529    string, name,
530    PVFS_handle, new_handle,
531    PVFS_handle, parent_handle,
532    PVFS_fs_id, fs_id,
533    skip4,,
534    PVFS_time, parent_atime,
535    PVFS_time, parent_mtime,
536    PVFS_time, parent_ctime)
537#define extra_size_PVFS_servreq_crdirent \
538  roundup8(PVFS_REQ_LIMIT_SEGMENT_BYTES+1)
539
540#define PINT_SERVREQ_CRDIRENT_FILL(__req,           \
541                                   __creds,         \
542                                   __name,          \
543                                   __new_handle,    \
544                                   __parent_handle, \
545                                   __fs_id,         \
546                                   __parent_atime,  \
547                                   __parent_mtime,  \
548                                   __parent_ctime)  \
549do {                                                \
550    memset(&(__req), 0, sizeof(__req));             \
551    (__req).op = PVFS_SERV_CRDIRENT;                \
552    (__req).credentials = (__creds);                \
553    (__req).u.crdirent.name = (__name);             \
554    (__req).u.crdirent.new_handle = (__new_handle); \
555    (__req).u.crdirent.parent_handle =              \
556       (__parent_handle);                           \
557    (__req).u.crdirent.fs_id = (__fs_id);           \
558    (__req).u.crdirent.parent_atime =               \
559       (__parent_atime);                            \
560    (__req).u.crdirent.parent_mtime =               \
561       (__parent_mtime);                            \
562    (__req).u.crdirent.parent_ctime =               \
563       (__parent_ctime);                            \
564} while (0)
565
566/* rmdirent ****************************************************/
567/* - removes an existing directory entry */
568
569struct PVFS_servreq_rmdirent
570{
571    char *entry;               /* name of entry to remove */
572    PVFS_handle parent_handle; /* handle of directory */
573    PVFS_fs_id fs_id;          /* file system */
574    PVFS_time parent_atime;
575    PVFS_time parent_mtime;
576    PVFS_time parent_ctime;
577};
578endecode_fields_7_struct(
579    PVFS_servreq_rmdirent,
580    string, entry,
581    PVFS_handle, parent_handle,
582    PVFS_fs_id, fs_id,
583    skip4,,
584    PVFS_time, parent_atime,
585    PVFS_time, parent_mtime,
586    PVFS_time, parent_ctime)
587#define extra_size_PVFS_servreq_rmdirent \
588  roundup8(PVFS_REQ_LIMIT_SEGMENT_BYTES+1)
589
590#define PINT_SERVREQ_RMDIRENT_FILL(__req,         \
591                                   __creds,       \
592                                   __fsid,        \
593                                   __handle,      \
594                                   __entry,       \
595                                   __parent_atime,\
596                                   __parent_mtime,\
597                                   __parent_ctime)\
598do {                                              \
599    memset(&(__req), 0, sizeof(__req));           \
600    (__req).op = PVFS_SERV_RMDIRENT;              \
601    (__req).credentials = (__creds);              \
602    (__req).u.rmdirent.fs_id = (__fsid);          \
603    (__req).u.rmdirent.parent_handle = (__handle);\
604    (__req).u.rmdirent.entry = (__entry);         \
605    (__req).u.rmdirent.parent_atime =             \
606       (__parent_atime);                          \
607    (__req).u.rmdirent.parent_mtime =             \
608       (__parent_mtime);                          \
609    (__req).u.rmdirent.parent_ctime =             \
610       (__parent_ctime);                          \
611} while (0);
612
613struct PVFS_servresp_rmdirent
614{
615    PVFS_handle entry_handle; /* handle of removed entry */
616};
617endecode_fields_1_struct(
618    PVFS_servresp_rmdirent,
619    PVFS_handle, entry_handle)
620
621/* chdirent ****************************************************/
622/* - modifies an existing directory entry on a particular file system */
623
624struct PVFS_servreq_chdirent
625{
626    char *entry;                   /* name of entry to remove */
627    PVFS_handle new_dirent_handle; /* handle of directory */
628    PVFS_handle parent_handle;     /* handle of directory */
629    PVFS_fs_id fs_id;              /* file system */
630    PVFS_time parent_atime;
631    PVFS_time parent_mtime;
632    PVFS_time parent_ctime;
633};
634endecode_fields_8_struct(
635    PVFS_servreq_chdirent,
636    string, entry,
637    PVFS_handle, new_dirent_handle,
638    PVFS_handle, parent_handle,
639    PVFS_fs_id, fs_id,
640    skip4,,
641    PVFS_time, parent_atime,
642    PVFS_time, parent_mtime,
643    PVFS_time, parent_ctime)
644#define extra_size_PVFS_servreq_chdirent \
645  roundup8(PVFS_REQ_LIMIT_SEGMENT_BYTES+1)
646
647#define PINT_SERVREQ_CHDIRENT_FILL(__req,          \
648                                   __creds,        \
649                                   __fsid,         \
650                                   __parent_handle,\
651                                   __new_dirent,   \
652                                   __entry,        \
653                                   __parent_atime, \
654                                   __parent_mtime, \
655                                   __parent_ctime) \
656do {                                               \
657    memset(&(__req), 0, sizeof(__req));            \
658    (__req).op = PVFS_SERV_CHDIRENT;               \
659    (__req).credentials = (__creds);               \
660    (__req).u.chdirent.fs_id = (__fsid);           \
661    (__req).u.chdirent.parent_handle =             \
662        (__parent_handle);                         \
663    (__req).u.chdirent.new_dirent_handle =         \
664        (__new_dirent);                            \
665    (__req).u.chdirent.entry = (__entry);          \
666    (__req).u.chdirent.parent_atime =              \
667       (__parent_atime);                           \
668    (__req).u.chdirent.parent_mtime =              \
669       (__parent_mtime);                           \
670    (__req).u.chdirent.parent_ctime =              \
671       (__parent_ctime);                           \
672} while (0);
673
674struct PVFS_servresp_chdirent
675{
676    PVFS_handle old_dirent_handle;
677};
678endecode_fields_1_struct(
679    PVFS_servresp_chdirent,
680    PVFS_handle, old_dirent_handle)
681
682/* readdir *****************************************************/
683/* - reads entries from a directory */
684
685struct PVFS_servreq_readdir
686{
687    PVFS_handle handle;     /* handle of dir object */
688    PVFS_fs_id fs_id;       /* file system */
689    PVFS_ds_position token; /* dir offset */
690    uint32_t dirent_count;  /* desired # of entries */
691};
692endecode_fields_4_struct(
693    PVFS_servreq_readdir,
694    PVFS_handle, handle,
695    PVFS_fs_id, fs_id,
696    PVFS_ds_position, token,
697    uint32_t, dirent_count)
698
699#define PINT_SERVREQ_READDIR_FILL(__req,              \
700                                  __creds,            \
701                                  __fsid,             \
702                                  __handle,           \
703                                  __token,            \
704                                  __dirent_count)     \
705do {                                                  \
706    memset(&(__req), 0, sizeof(__req));               \
707    (__req).op = PVFS_SERV_READDIR;                   \
708    (__req).credentials = (__creds);                  \
709    (__req).u.readdir.fs_id = (__fsid);               \
710    (__req).u.readdir.handle = (__handle);            \
711    (__req).u.readdir.token = (__token);              \
712    (__req).u.readdir.dirent_count = (__dirent_count);\
713} while (0);
714
715struct PVFS_servresp_readdir
716{
717    PVFS_ds_position token;  /* new dir offset */
718    /* array of directory entries */
719    PVFS_dirent *dirent_array;
720    uint32_t dirent_count;   /* # of entries retrieved */
721    uint64_t directory_version;
722};
723endecode_fields_4a_struct(
724    PVFS_servresp_readdir,
725    PVFS_ds_position, token,
726    skip4,,
727    uint64_t, directory_version,
728    skip4,,
729    uint32_t, dirent_count,
730    PVFS_dirent, dirent_array)
731#define extra_size_PVFS_servresp_readdir \
732  roundup8(PVFS_REQ_LIMIT_DIRENT_COUNT * (PVFS_NAME_MAX + 1 + 8))
733
734/* getconfig ***************************************************/
735/* - retrieves initial configuration information from server */
736
737#define PINT_SERVREQ_GETCONFIG_FILL(__req, __creds)\
738do {                                               \
739    memset(&(__req), 0, sizeof(__req));            \
740    (__req).op = PVFS_SERV_GETCONFIG;              \
741    (__req).credentials = (__creds);               \
742} while (0);
743
744struct PVFS_servresp_getconfig
745{
746    char *fs_config_buf;
747    uint32_t fs_config_buf_size;
748    char *server_config_buf;
749    uint32_t server_config_buf_size;
750};
751endecode_fields_4_struct(
752    PVFS_servresp_getconfig,
753    uint32_t, fs_config_buf_size,
754    uint32_t, server_config_buf_size,
755    string, fs_config_buf,
756    string, server_config_buf)
757#define extra_size_PVFS_servresp_getconfig \
758    (2 * PVFS_REQ_LIMIT_CONFIG_FILE_BYTES)
759
760/* truncate ****************************************************/
761/* - resizes an existing datafile */
762
763struct PVFS_servreq_truncate
764{
765    PVFS_handle handle; /* handle of obj to resize */
766    PVFS_fs_id fs_id;   /* file system */
767    PVFS_size size;     /* new size */
768    int32_t flags;      /* future use */
769
770};
771endecode_fields_5_struct(
772    PVFS_servreq_truncate,
773    PVFS_handle, handle,
774    PVFS_fs_id, fs_id,
775    skip4,,
776    PVFS_size, size,
777    int32_t, flags)
778#define PINT_SERVREQ_TRUNCATE_FILL(__req,  \
779                                __creds,   \
780                                __fsid,    \
781                                __size,    \
782                                __handle)  \
783do {                                       \
784    memset(&(__req), 0, sizeof(__req));    \
785    (__req).op = PVFS_SERV_TRUNCATE;       \
786    (__req).credentials = (__creds);       \
787    (__req).u.truncate.fs_id = (__fsid);   \
788    (__req).u.truncate.size = (__size);    \
789    (__req).u.truncate.handle = (__handle);\
790} while (0)
791
792/* statfs ****************************************************/
793/* - retrieves statistics for a particular file system */
794
795struct PVFS_servreq_statfs
796{
797    PVFS_fs_id fs_id;  /* file system */
798};
799endecode_fields_1_struct(
800    PVFS_servreq_statfs,
801    PVFS_fs_id, fs_id)
802
803#define PINT_SERVREQ_STATFS_FILL(__req, __creds, __fsid)\
804do {                                                    \
805    memset(&(__req), 0, sizeof(__req));                 \
806    (__req).op = PVFS_SERV_STATFS;                      \
807    (__req).credentials = (__creds);                    \
808    (__req).u.statfs.fs_id = (__fsid);                  \
809} while (0)
810
811struct PVFS_servresp_statfs
812{
813    PVFS_statfs stat;
814};
815endecode_fields_1_struct(
816    PVFS_servresp_statfs,
817    PVFS_statfs, stat)
818
819/* io **********************************************************/
820/* - performs a read or write operation */
821
822struct PVFS_servreq_io
823{
824    PVFS_handle handle;        /* target datafile */
825    PVFS_fs_id fs_id;          /* file system */
826    /* type of I/O operation to perform */
827    enum PVFS_io_type io_type; /* enum defined in pvfs2-types.h */
828
829    /* type of flow protocol to use for I/O transfer */
830    enum PVFS_flowproto_type flow_type;
831
832    /* relative number of this I/O server in distribution */
833    uint32_t server_nr;
834    /* total number of I/O servers involved in distribution */
835    uint32_t server_ct;
836
837    /* distribution */
838    PINT_dist *io_dist;
839    /* file datatype */
840    PVFS_Request file_req;
841    /* offset into file datatype */
842    PVFS_offset file_req_offset;
843    /* aggregate size of data to transfer */
844    PVFS_size aggregate_size;
845};
846#ifdef __PINT_REQPROTO_ENCODE_FUNCS_C
847#define encode_PVFS_servreq_io(pptr,x) do { \
848    encode_PVFS_handle(pptr, &(x)->handle); \
849    encode_PVFS_fs_id(pptr, &(x)->fs_id); \
850    encode_skip4(pptr,); \
851    encode_enum(pptr, &(x)->io_type); \
852    encode_enum(pptr, &(x)->flow_type); \
853    encode_uint32_t(pptr, &(x)->server_nr); \
854    encode_uint32_t(pptr, &(x)->server_ct); \
855    encode_PINT_dist(pptr, &(x)->io_dist); \
856    { \
857    /* XXX: This linearizes into a fresh buffer, encodes, then throws
858     * it away; later fix the structure so that it is easier to
859     * send. */ \
860    struct PINT_Request *lin; \
861    if ((x)->file_req->num_nested_req > PVFS_REQ_LIMIT_PINT_REQUEST_NUM) \
862        gossip_err("%s: encode_PVFS_servreq_io: demands %d elements," \
863          " more than maximum %d\n", __func__, \
864          (x)->file_req->num_nested_req, PVFS_REQ_LIMIT_PINT_REQUEST_NUM); \
865    lin = decode_malloc(((x)->file_req->num_nested_req + 1) * sizeof(*lin)); \
866    (void) PINT_request_commit(lin, (x)->file_req); \
867    PINT_request_encode(lin); /* packs the pointers */ \
868    encode_int32_t(pptr, &(x)->file_req->num_nested_req); \
869    encode_skip4(pptr,); \
870    encode_PVFS_Request(pptr, lin); \
871    decode_free(lin); \
872    } \
873    encode_PVFS_offset(pptr, &(x)->file_req_offset); \
874    encode_PVFS_size(pptr, &(x)->aggregate_size); \
875} while (0)
876#define decode_PVFS_servreq_io(pptr,x) do { int numreq; \
877    decode_PVFS_handle(pptr, &(x)->handle); \
878    decode_PVFS_fs_id(pptr, &(x)->fs_id); \
879    decode_skip4(pptr,); \
880    decode_enum(pptr, &(x)->io_type); \
881    decode_enum(pptr, &(x)->flow_type); \
882    decode_uint32_t(pptr, &(x)->server_nr); \
883    decode_uint32_t(pptr, &(x)->server_ct); \
884    decode_PINT_dist(pptr, &(x)->io_dist); \
885    decode_int32_t(pptr, &numreq); \
886    decode_skip4(pptr,); \
887    (x)->file_req = decode_malloc((numreq + 1) * sizeof(*(x)->file_req)); \
888    (x)->file_req->num_nested_req = numreq; \
889    decode_PVFS_Request(pptr, (x)->file_req); \
890    PINT_request_decode((x)->file_req); /* unpacks the pointers */ \
891    decode_PVFS_offset(pptr, &(x)->file_req_offset); \
892    decode_PVFS_size(pptr, &(x)->aggregate_size); \
893} while (0)
894/* could be huge, limit to max ioreq size beyond struct itself */
895#define extra_size_PVFS_servreq_io roundup8(PVFS_REQ_LIMIT_PATH_NAME_BYTES) \
896  + roundup8(PVFS_REQ_LIMIT_PINT_REQUEST_NUM * sizeof(PINT_Request))
897#endif
898
899#define PINT_SERVREQ_IO_FILL(__req,                   \
900                             __creds,                 \
901                             __fsid,                  \
902                             __handle,                \
903                             __io_type,               \
904                             __flow_type,             \
905                             __datafile_nr,           \
906                             __datafile_ct,           \
907                             __io_dist,               \
908                             __file_req,              \
909                             __file_req_off,          \
910                             __aggregate_size)        \
911do {                                                  \
912    memset(&(__req), 0, sizeof(__req));               \
913    (__req).op                 = PVFS_SERV_IO;        \
914    (__req).credentials        = (__creds);           \
915    (__req).u.io.fs_id         = (__fsid);            \
916    (__req).u.io.handle        = (__handle);          \
917    (__req).u.io.io_type       = (__io_type);         \
918    (__req).u.io.flow_type     = (__flow_type);       \
919    (__req).u.io.server_nr       = (__datafile_nr);   \
920    (__req).u.io.server_ct     = (__datafile_ct);     \
921    (__req).u.io.io_dist       = (__io_dist);         \
922    (__req).u.io.file_req        = (__file_req);      \
923    (__req).u.io.file_req_offset = (__file_req_off);  \
924    (__req).u.io.aggregate_size  = (__aggregate_size);\
925} while (0)                             
926
927struct PVFS_servresp_io
928{
929    PVFS_size bstream_size;  /* size of datafile */
930};
931endecode_fields_1_struct(
932    PVFS_servresp_io,
933    PVFS_size, bstream_size)
934
935/* write operations require a second response to announce completion */
936struct PVFS_servresp_write_completion
937{
938    PVFS_size total_completed; /* amount of data transfered */
939};
940endecode_fields_1_struct(
941    PVFS_servresp_write_completion,
942    PVFS_size, total_completed)
943
944/* mgmt_setparam ****************************************************/
945/* - management operation for setting runtime parameters */
946
947struct PVFS_servreq_mgmt_setparam
948{
949    PVFS_fs_id fs_id;             /* file system */
950    enum PVFS_server_param param; /* parameter to set */
951    uint64_t value;               /* parameter value */
952};
953endecode_fields_3_struct(
954    PVFS_servreq_mgmt_setparam,
955    PVFS_fs_id, fs_id,
956    enum, param,
957    uint64_t, value)
958
959#define PINT_SERVREQ_MGMT_SETPARAM_FILL(__req,  \
960                                        __creds,\
961                                        __fsid, \
962                                        __param,\
963                                        __value)\
964do {                                            \
965    memset(&(__req), 0, sizeof(__req));         \
966    (__req).op = PVFS_SERV_MGMT_SETPARAM;       \
967    (__req).credentials = (__creds);            \
968    (__req).u.mgmt_setparam.fs_id = (__fsid);   \
969    (__req).u.mgmt_setparam.param = (__param);  \
970    (__req).u.mgmt_setparam.value = (__value);  \
971} while (0)
972
973struct PVFS_servresp_mgmt_setparam
974{
975    uint64_t old_value;
976};
977endecode_fields_1_struct(
978    PVFS_servresp_mgmt_setparam,
979    uint64_t, old_value)
980
981/* mgmt_noop ********************************************************/
982/* - does nothing except contact a server to see if it is responding
983 * to requests
984 */
985
986#define PINT_SERVREQ_MGMT_NOOP_FILL(__req, __creds)\
987do {                                               \
988    memset(&(__req), 0, sizeof(__req));            \
989    (__req).op = PVFS_SERV_MGMT_NOOP;              \
990    (__req).credentials = (__creds);               \
991} while (0)
992
993
994/* mgmt_perf_mon ****************************************************/
995/* retrieves performance statistics from server */
996
997struct PVFS_servreq_mgmt_perf_mon
998{
999    uint32_t next_id;  /* next time stamp id we want to retrieve */
1000    uint32_t count;    /* how many measurements we want */
1001};
1002endecode_fields_2_struct(
1003    PVFS_servreq_mgmt_perf_mon,
1004    uint32_t, next_id,
1005    uint32_t, count)
1006
1007#define PINT_SERVREQ_MGMT_PERF_MON_FILL(__req,    \
1008                                        __creds,  \
1009                                        __next_id,\
1010                                        __count)  \
1011do {                                              \
1012    memset(&(__req), 0, sizeof(__req));           \
1013    (__req).op = PVFS_SERV_MGMT_PERF_MON;         \
1014    (__req).credentials = (__creds);              \
1015    (__req).u.mgmt_perf_mon.next_id = (__next_id);\
1016    (__req).u.mgmt_perf_mon.count = (__count);    \
1017} while (0)
1018
1019struct PVFS_servresp_mgmt_perf_mon
1020{
1021    struct PVFS_mgmt_perf_stat* perf_array; /* array of statistics */
1022    uint32_t perf_array_count;              /* size of above array */
1023    /* next id to pick up from this point */
1024    uint32_t suggested_next_id;
1025    uint64_t end_time_ms;  /* end time for final array entry */
1026    uint64_t cur_time_ms;  /* current time according to svr */
1027};
1028endecode_fields_5a_struct(
1029    PVFS_servresp_mgmt_perf_mon,
1030    uint32_t, suggested_next_id,
1031    skip4,,
1032    uint64_t, end_time_ms,
1033    uint64_t, cur_time_ms,
1034    skip4,,
1035    uint32_t, perf_array_count,
1036    PVFS_mgmt_perf_stat, perf_array)
1037#define extra_size_PVFS_servresp_mgmt_perf_mon \
1038    (PVFS_REQ_LIMIT_IOREQ_BYTES)
1039
1040/* mgmt_iterate_handles ***************************************/
1041/* iterates through handles stored on server */
1042
1043struct PVFS_servreq_mgmt_iterate_handles
1044{
1045    PVFS_fs_id fs_id;
1046    int32_t handle_count;
1047    PVFS_ds_position position;
1048};
1049endecode_fields_3_struct(
1050    PVFS_servreq_mgmt_iterate_handles,
1051    PVFS_fs_id, fs_id,
1052    int32_t, handle_count,
1053    PVFS_ds_position, position)
1054
1055#define PINT_SERVREQ_MGMT_ITERATE_HANDLES_FILL(__req,              \
1056                                        __creds,                   \
1057                                        __fs_id,                   \
1058                                        __handle_count,            \
1059                                        __position)                \
1060do {                                                               \
1061    memset(&(__req), 0, sizeof(__req));                            \
1062    (__req).op = PVFS_SERV_MGMT_ITERATE_HANDLES;                   \
1063    (__req).credentials = (__creds);                               \
1064    (__req).u.mgmt_iterate_handles.fs_id = (__fs_id);              \
1065    (__req).u.mgmt_iterate_handles.handle_count = (__handle_count);\
1066    (__req).u.mgmt_iterate_handles.position = (__position);        \
1067} while (0)
1068
1069struct PVFS_servresp_mgmt_iterate_handles
1070{
1071    PVFS_ds_position position;
1072    PVFS_handle *handle_array;
1073    int handle_count;
1074};
1075endecode_fields_1a_struct(
1076    PVFS_servresp_mgmt_iterate_handles,
1077    PVFS_ds_position, position,
1078    int32_t, handle_count,
1079    PVFS_handle, handle_array)
1080#define extra_size_PVFS_servresp_mgmt_iterate_handles \
1081  (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle))
1082
1083/* mgmt_dspace_info_list **************************************/
1084/* - returns low level dspace information for a list of handles */
1085
1086struct PVFS_servreq_mgmt_dspace_info_list
1087{
1088    PVFS_fs_id fs_id;
1089    PVFS_handle* handle_array;
1090    int32_t handle_count;
1091};
1092endecode_fields_1a_struct(
1093    PVFS_servreq_mgmt_dspace_info_list,
1094    PVFS_fs_id, fs_id,
1095    int32_t, handle_count,
1096    PVFS_handle, handle_array)
1097#define extra_size_PVFS_servreq_mgmt_dspace_info_list \
1098  (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle))
1099
1100#define PINT_SERVREQ_MGMT_DSPACE_INFO_LIST(__req,                   \
1101                                        __creds,                    \
1102                                        __fs_id,                    \
1103                                        __handle_array,             \
1104                                        __handle_count)             \
1105do {                                                                \
1106    memset(&(__req), 0, sizeof(__req));                             \
1107    (__req).op = PVFS_SERV_MGMT_DSPACE_INFO_LIST;                   \
1108    (__req).credentials = (__creds);                                \
1109    (__req).u.mgmt_dspace_info_list.fs_id = (__fs_id);              \
1110    (__req).u.mgmt_dspace_info_list.handle_array = (__handle_array);\
1111    (__req).u.mgmt_dspace_info_list.handle_count = (__handle_count);\
1112} while (0)
1113
1114struct PVFS_servresp_mgmt_dspace_info_list
1115{
1116    struct PVFS_mgmt_dspace_info *dspace_info_array;
1117    int32_t dspace_info_count;
1118};
1119endecode_fields_1a_struct(
1120    PVFS_servresp_mgmt_dspace_info_list,
1121    skip4,,
1122    int32_t, dspace_info_count,
1123    PVFS_mgmt_dspace_info, dspace_info_array)
1124#define extra_size_PVFS_servresp_mgmt_dspace_info_list \
1125   (PVFS_REQ_LIMIT_MGMT_DSPACE_INFO_LIST_COUNT * \
1126    sizeof(struct PVFS_mgmt_dspace_info))
1127
1128/* mgmt_event_mon **************************************/
1129/* - returns event logging data */
1130
1131struct PVFS_servreq_mgmt_event_mon
1132{
1133    uint32_t event_count;
1134};
1135endecode_fields_1_struct(
1136    PVFS_servreq_mgmt_event_mon,
1137    uint32_t, event_count)
1138
1139#define PINT_SERVREQ_MGMT_EVENT_MON_FILL(__req, __creds, __event_count)\
1140do {                                                                   \
1141    memset(&(__req), 0, sizeof(__req));                                \
1142    (__req).op = PVFS_SERV_MGMT_EVENT_MON;                             \
1143    (__req).credentials = (__creds);                                   \
1144    (__req).u.mgmt_event_mon.event_count = (__event_count);            \
1145} while (0)
1146
1147struct PVFS_servresp_mgmt_event_mon
1148{
1149    struct PVFS_mgmt_event* event_array;
1150    uint32_t event_count;
1151};
1152endecode_fields_1a_struct(
1153    PVFS_servresp_mgmt_event_mon,
1154    skip4,,
1155    uint32_t, event_count,
1156    PVFS_mgmt_event, event_array)
1157#define extra_size_PVFS_servresp_mgmt_event_mon \
1158  (PVFS_REQ_LIMIT_MGMT_EVENT_MON_COUNT * \
1159   roundup8(sizeof(struct PVFS_mgmt_event)))
1160
1161/* geteattr ****************************************************/
1162/* - retreives list of extended attributes */
1163
1164struct PVFS_servreq_geteattr
1165{
1166    PVFS_handle handle;  /* handle of target object */
1167    PVFS_fs_id fs_id;    /* file system */
1168    int32_t nkey;        /* number of keys to read */
1169    PVFS_ds_keyval *key; /* array of keys to read */
1170    PVFS_size *valsz;    /* array of value buffer sizes */
1171};
1172endecode_fields_3aa_struct(
1173    PVFS_servreq_geteattr,
1174    PVFS_handle, handle,
1175    PVFS_fs_id, fs_id,
1176    skip4,,
1177    int32_t, nkey,
1178    PVFS_ds_keyval, key,
1179    PVFS_size, valsz);
1180#define extra_size_PVFS_servreq_geteattr \
1181    (PVFS_REQ_LIMIT_KEY_LEN * PVFS_REQ_LIMIT_KEYVAL_LIST)
1182
1183#define PINT_SERVREQ_GETEATTR_FILL(__req,   \
1184                                  __creds, \
1185                                  __fsid,  \
1186                                  __handle,\
1187                                  __nkey,\
1188                                  __key_array, \
1189                                  __size_array) \
1190do {                                       \
1191    memset(&(__req), 0, sizeof(__req));    \
1192    (__req).op = PVFS_SERV_GETEATTR;        \
1193    (__req).credentials = (__creds);       \
1194    (__req).u.geteattr.fs_id = (__fsid);    \
1195    (__req).u.geteattr.handle = (__handle); \
1196    (__req).u.geteattr.nkey = (__nkey); \
1197    (__req).u.geteattr.key = (__key_array);\
1198    (__req).u.geteattr.valsz = (__size_array);\
1199} while (0)
1200
1201struct PVFS_servresp_geteattr
1202{
1203    int32_t nkey;           /* number of values returned */
1204    PVFS_ds_keyval *val;    /* array of values returned */
1205};
1206endecode_fields_1a_struct(
1207    PVFS_servresp_geteattr,
1208    skip4,,
1209    int32_t, nkey,
1210    PVFS_ds_keyval, val)
1211#define extra_size_PVFS_servresp_geteattr \
1212    (PVFS_REQ_LIMIT_VAL_LEN * PVFS_REQ_LIMIT_KEYVAL_LIST)
1213
1214/* seteattr ****************************************************/
1215/* - sets list of extended attributes */
1216
1217struct PVFS_servreq_seteattr
1218{
1219    PVFS_handle handle;    /* handle of target object */
1220    PVFS_fs_id fs_id;      /* file system */
1221    int32_t    flags;      /* flags */
1222    int32_t    nkey;       /* number of keys and vals */
1223    PVFS_ds_keyval *key;    /* attribute key */
1224    PVFS_ds_keyval *val;    /* attribute value */
1225};
1226endecode_fields_4aa_struct(
1227    PVFS_servreq_seteattr,
1228    PVFS_handle, handle,
1229    PVFS_fs_id, fs_id,
1230    int32_t, flags,
1231    skip4,,
1232    int32_t, nkey,
1233    PVFS_ds_keyval, key,
1234    PVFS_ds_keyval, val);
1235#define extra_size_PVFS_servreq_seteattr \
1236    ((PVFS_REQ_LIMIT_KEY_LEN + PVFS_REQ_LIMIT_VAL_LEN) \
1237        * PVFS_REQ_LIMIT_KEYVAL_LIST)
1238
1239#define PINT_SERVREQ_SETEATTR_FILL(__req,   \
1240                                  __creds,       \
1241                                  __fsid,        \
1242                                  __handle,      \
1243                                  __flags,       \
1244                                  __nkey,        \
1245                                  __key_array,   \
1246                                  __val_array)   \
1247do {                                             \
1248    memset(&(__req), 0, sizeof(__req));          \
1249    (__req).op = PVFS_SERV_SETEATTR;        \
1250    (__req).credentials = (__creds);             \
1251    (__req).u.seteattr.fs_id = (__fsid);    \
1252    (__req).u.seteattr.handle = (__handle); \
1253    (__req).u.seteattr.flags = (__flags);   \
1254    (__req).u.seteattr.nkey = (__nkey);     \
1255    (__req).u.seteattr.key = (__key_array); \
1256    (__req).u.seteattr.val = (__val_array); \
1257} while (0)
1258
1259/* deleattr ****************************************************/
1260/* - deletes extended attributes */
1261
1262struct PVFS_servreq_deleattr
1263{
1264    PVFS_handle handle; /* handle of target object */
1265    PVFS_fs_id fs_id;   /* file system */
1266    PVFS_ds_keyval key; /* key to read */
1267};
1268endecode_fields_3_struct(
1269    PVFS_servreq_deleattr,
1270    PVFS_handle, handle,
1271    PVFS_fs_id, fs_id,
1272    PVFS_ds_keyval, key);
1273#define extra_size_PVFS_servreq_deleattr \
1274    PVFS_REQ_LIMIT_KEY_LEN
1275
1276#define PINT_SERVREQ_DELEATTR_FILL(__req,   \
1277                                  __creds, \
1278                                  __fsid,  \
1279                                  __handle,\
1280                                  __key) \
1281do {                                       \
1282    memset(&(__req), 0, sizeof(__req));    \
1283    (__req).op = PVFS_SERV_DELEATTR;        \
1284    (__req).credentials = (__creds);       \
1285    (__req).u.deleattr.fs_id = (__fsid);    \
1286    (__req).u.deleattr.handle = (__handle); \
1287    (__req).u.deleattr.key.buffer_sz = (__key).buffer_sz;\
1288    (__req).u.deleattr.key.buffer = (__key).buffer;\
1289} while (0)
1290
1291/* server request *********************************************/
1292/* - generic request with union of all op specific structs */
1293
1294struct PVFS_server_req
1295{
1296    enum PVFS_server_op op;
1297    PVFS_credentials credentials;
1298    union
1299    {
1300        struct PVFS_servreq_create create;
1301        struct PVFS_servreq_remove remove;
1302        struct PVFS_servreq_io io;
1303        struct PVFS_servreq_getattr getattr;
1304        struct PVFS_servreq_setattr setattr;
1305        struct PVFS_servreq_mkdir mkdir;
1306        struct PVFS_servreq_readdir readdir;
1307        struct PVFS_servreq_lookup_path lookup_path;
1308        struct PVFS_servreq_crdirent crdirent;
1309        struct PVFS_servreq_rmdirent rmdirent;
1310        struct PVFS_servreq_chdirent chdirent;
1311        struct PVFS_servreq_truncate truncate;
1312        struct PVFS_servreq_flush flush;
1313        struct PVFS_servreq_mgmt_setparam mgmt_setparam;
1314        struct PVFS_servreq_statfs statfs;
1315        struct PVFS_servreq_mgmt_perf_mon mgmt_perf_mon;
1316        struct PVFS_servreq_mgmt_iterate_handles mgmt_iterate_handles;
1317        struct PVFS_servreq_mgmt_dspace_info_list mgmt_dspace_info_list;
1318        struct PVFS_servreq_mgmt_event_mon mgmt_event_mon;
1319        struct PVFS_servreq_mgmt_remove_object mgmt_remove_object;
1320        struct PVFS_servreq_mgmt_remove_dirent mgmt_remove_dirent;
1321        struct PVFS_servreq_mgmt_get_dirdata_handle mgmt_get_dirdata_handle;
1322        struct PVFS_servreq_geteattr geteattr;
1323        struct PVFS_servreq_seteattr seteattr;
1324        struct PVFS_servreq_deleattr deleattr;
1325    } u;
1326};
1327#ifdef __PINT_REQPROTO_ENCODE_FUNCS_C
1328/* insert padding to ensure the union starts on an aligned boundary */
1329static inline void
1330encode_PVFS_server_req(char **pptr, const struct PVFS_server_req *x) {
1331    encode_enum(pptr, &x->op);
1332    *pptr += 4;
1333    encode_PVFS_credentials(pptr, &x->credentials);
1334}
1335static inline void
1336decode_PVFS_server_req(char **pptr, struct PVFS_server_req *x) {
1337    decode_enum(pptr, &x->op);
1338    *pptr += 4;
1339    decode_PVFS_credentials(pptr, &x->credentials);
1340}
1341#endif
1342
1343/* server response *********************************************/
1344/* - generic response with union of all op specific structs */
1345struct PVFS_server_resp
1346{
1347    enum PVFS_server_op op;
1348    PVFS_error status;
1349    union
1350    {
1351        struct PVFS_servresp_create create;
1352        struct PVFS_servresp_getattr getattr;
1353        struct PVFS_servresp_mkdir mkdir;
1354        struct PVFS_servresp_readdir readdir;
1355        struct PVFS_servresp_lookup_path lookup_path;
1356        struct PVFS_servresp_rmdirent rmdirent;
1357        struct PVFS_servresp_chdirent chdirent;
1358        struct PVFS_servresp_getconfig getconfig;
1359        struct PVFS_servresp_io io;
1360        struct PVFS_servresp_write_completion write_completion;
1361        struct PVFS_servresp_statfs statfs;
1362        struct PVFS_servresp_mgmt_setparam mgmt_setparam;
1363        struct PVFS_servresp_mgmt_perf_mon mgmt_perf_mon;
1364        struct PVFS_servresp_mgmt_iterate_handles mgmt_iterate_handles;
1365        struct PVFS_servresp_mgmt_dspace_info_list mgmt_dspace_info_list;
1366        struct PVFS_servresp_mgmt_event_mon mgmt_event_mon;
1367        struct PVFS_servresp_mgmt_get_dirdata_handle mgmt_get_dirdata_handle;
1368        struct PVFS_servresp_geteattr geteattr;
1369    } u;
1370};
1371endecode_fields_2_struct(
1372    PVFS_server_resp,
1373    enum, op,
1374    PVFS_error, status)
1375
1376#endif /* __PVFS2_REQ_PROTO_H */
1377
1378/*
1379 * Local variables:
1380 *  c-indent-level: 4
1381 *  c-basic-offset: 4
1382 * End:
1383 *
1384 * vim: ts=8 sts=4 sw=4 expandtab
1385 */
Note: See TracBrowser for help on using the browser.