Whamcloud - gitweb
Branch b1_4_mountconf
[fs/lustre-release.git] / lustre / include / linux / lustre_idl.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *   This file is part of Lustre, http://www.lustre.org
5  *
6  * Lustre wire protocol definitions.
7  *
8  * All structs passing over the wire should be declared here (lov_mds_md
9  * being the lone exception).  Structs must be properly aligned to put
10  * 64-bit values on an 8-byte boundary.  Any structs being added here
11  * must also be added to utils/wirecheck.c and "make newwiretest" run
12  * to regenerate the utils/wiretest.c sources.  This allows us to verify
13  * that wire structs have the proper alignment/size on all architectures.
14  *
15  * We assume all nodes are either little-endian or big-endian, and we
16  * always send messages in the sender's native format.  The receiver
17  * detects the message format by checking the 'magic' field of the message
18  * (see lustre_msg_swabbed() below).
19  *
20  * Each wire type has corresponding 'lustre_swab_xxxtypexxx()' routines,
21  * implemented either here, inline (trivial implementations) or in
22  * ptlrpc/pack_generic.c.  These 'swabbers' convert the type from "other"
23  * endian, in-place in the message buffer.
24  *
25  * A swabber takes a single pointer argument.  The caller must already have
26  * verified that the length of the message buffer >= sizeof (type).
27  *
28  * For variable length types, a second 'lustre_swab_v_xxxtypexxx()' routine
29  * may be defined that swabs just the variable part, after the caller has
30  * verified that the message buffer is large enough.
31  */
32
33 #ifndef _LUSTRE_IDL_H_
34 #define _LUSTRE_IDL_H_
35
36 #ifdef HAVE_ASM_TYPES_H
37 #include <asm/types.h>
38 #else
39 #include <lustre/types.h>
40 #endif
41
42 #ifdef __KERNEL__
43 # include <linux/types.h>
44 # include <linux/fs.h>    /* to check for FMODE_EXEC, dev_t, lest we redefine */
45 #else
46 #ifdef __CYGWIN__
47 # include <sys/types.h>
48 #elif defined(_AIX)
49 # include <inttypes.h>
50 #else
51 # include <stdint.h>
52 #endif
53 #endif
54
55 /* Defn's shared with user-space. */
56 #include <lustre/lustre_user.h>
57
58 /*
59  * this file contains all data structures used in Lustre interfaces:
60  * - obdo and obd_request records
61  * - mds_request records
62  * - ldlm data
63  * - ioctl's
64  */
65
66 /*
67  *  GENERAL STUFF
68  */
69 /* FOO_REQUEST_PORTAL is for incoming requests on the FOO
70  * FOO_REPLY_PORTAL   is for incoming replies on the FOO
71  * FOO_BULK_PORTAL    is for incoming bulk on the FOO
72  */
73
74 #define CONNMGR_REQUEST_PORTAL          1
75 #define CONNMGR_REPLY_PORTAL            2
76 #define OSC_REPLY_PORTAL                4
77 #define OST_IO_PORTAL                   6
78 #define OST_CREATE_PORTAL               7
79 #define OST_BULK_PORTAL                 8
80 #define MDC_REPLY_PORTAL               10
81 #define MDS_REQUEST_PORTAL             12
82 #define MDS_BULK_PORTAL                14
83 #define LDLM_CB_REQUEST_PORTAL         15
84 #define LDLM_CB_REPLY_PORTAL           16
85 #define LDLM_CANCEL_REQUEST_PORTAL     17
86 #define LDLM_CANCEL_REPLY_PORTAL       18
87 #define MDS_SETATTR_PORTAL             22
88 #define MDS_READPAGE_PORTAL            23
89 #define MGC_REQUEST_PORTAL             24 
90 #define MGC_REPLY_PORTAL               25
91 #define MGS_REQUEST_PORTAL             26
92 #define MGS_REPLY_PORTAL               27
93 #define OST_REQUEST_PORTAL             28
94
95 #define SVC_KILLED               1
96 #define SVC_EVENT                2
97 #define SVC_SIGNAL               4
98 #define SVC_RUNNING              8
99 #define SVC_STOPPING            16
100 #define SVC_STOPPED             32
101
102 /* packet types */
103 #define PTL_RPC_MSG_REQUEST 4711
104 #define PTL_RPC_MSG_ERR     4712
105 #define PTL_RPC_MSG_REPLY   4713
106
107 #define PTLRPC_MSG_MAGIC    0x0BD00BD0
108
109
110 #define PTLRPC_MSG_VERSION  0x00000003
111 #define LUSTRE_VERSION_MASK 0xffff0000
112 #define LUSTRE_OBD_VERSION  0x00010000
113 #define LUSTRE_MDS_VERSION  0x00020000
114 #define LUSTRE_OST_VERSION  0x00030000
115 #define LUSTRE_DLM_VERSION  0x00040000
116 #define LUSTRE_LOG_VERSION  0x00050000
117 #define LUSTRE_PBD_VERSION  0x00060000
118
119 struct lustre_handle {
120         __u64 cookie;
121 };
122 #define DEAD_HANDLE_MAGIC 0xdeadbeefcafebabeULL
123
124 static inline int lustre_handle_is_used(struct lustre_handle *lh)
125 {
126         return lh->cookie != 0ull;
127 }
128
129 /* we depend on this structure to be 8-byte aligned */
130 /* this type is only endian-adjusted in lustre_unpack_msg() */
131 struct lustre_msg {
132         struct lustre_handle handle;
133         __u32 magic;
134         __u32 type;
135         __u32 version;
136         __u32 opc;
137         __u64 last_xid;
138         __u64 last_committed;
139         __u64 transno;
140         __u32 status;
141         __u32 flags;
142         __u32 conn_cnt;
143         __u32 bufcount;
144         __u32 buflens[0];
145 };
146
147 /* Flags that are operation-specific go in the top 16 bits. */
148 #define MSG_OP_FLAG_MASK   0xffff0000
149 #define MSG_OP_FLAG_SHIFT  16
150
151 /* Flags that apply to all requests are in the bottom 16 bits */
152 #define MSG_GEN_FLAG_MASK      0x0000ffff
153 #define MSG_LAST_REPLAY        1
154 #define MSG_RESENT             2
155 #define MSG_REPLAY             4
156
157 static inline int lustre_msg_get_flags(struct lustre_msg *msg)
158 {
159         return (msg->flags & MSG_GEN_FLAG_MASK);
160 }
161
162 static inline void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
163 {
164         msg->flags |= MSG_GEN_FLAG_MASK & flags;
165 }
166
167 static inline void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
168 {
169         msg->flags &= ~MSG_GEN_FLAG_MASK;
170         lustre_msg_add_flags(msg, flags);
171 }
172
173 static inline void lustre_msg_clear_flags(struct lustre_msg *msg, int flags)
174 {
175         msg->flags &= ~(MSG_GEN_FLAG_MASK & flags);
176 }
177
178 static inline int lustre_msg_get_op_flags(struct lustre_msg *msg)
179 {
180         return (msg->flags >> MSG_OP_FLAG_SHIFT);
181 }
182
183 static inline void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
184 {
185         msg->flags |= ((flags & MSG_GEN_FLAG_MASK) << MSG_OP_FLAG_SHIFT);
186 }
187
188 static inline void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
189 {
190         msg->flags &= ~MSG_OP_FLAG_MASK;
191         lustre_msg_add_op_flags(msg, flags);
192 }
193
194 /*
195  * Flags for all connect opcodes (MDS_CONNECT, OST_CONNECT)
196  */
197
198 #define MSG_CONNECT_RECOVERING  0x1
199 #define MSG_CONNECT_RECONNECT   0x2
200 #define MSG_CONNECT_REPLAYABLE  0x4
201 //#define MSG_CONNECT_PEER        0x8
202 #define MSG_CONNECT_LIBCLIENT   0x10
203 #define MSG_CONNECT_INITIAL     0x20
204 #define MSG_CONNECT_ASYNC       0x40
205
206 /* Connect flags */
207 #define OBD_CONNECT_RDONLY       0x1ULL
208 #define OBD_CONNECT_INDEX        0x2ULL /* connect to specific LOV idx */
209 #define OBD_CONNECT_GRANT        0x8ULL /* OSC acquires grant at connect */
210 #define OBD_CONNECT_SRVLOCK     0x10ULL /* server takes locks for client */
211 #define OBD_CONNECT_VERSION     0x20ULL /* Server supports versions in ocd */
212 #define OBD_CONNECT_REQPORTAL   0x40ULL /* Separate portal for non-IO reqs */
213 #define OBD_CONNECT_ACL         0x80ULL /* client using access control lists */
214 #define OBD_CONNECT_XATTR      0x100ULL /* client using extended attributes*/
215 #define OBD_CONNECT_CROW       0x200ULL /* MDS is expecting create-on-write */
216 /*
217  * set by servers supporting taking extent locks during obd_punch(). Currently
218  * is requested by liblustre clients only. See bug 9528.
219  */
220 #define OBD_CONNECT_TRUNCLOCK   0x400ULL
221
222 #define MDS_CONNECT_SUPPORTED  (OBD_CONNECT_RDONLY|OBD_CONNECT_VERSION)
223 #define OST_CONNECT_SUPPORTED  (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \
224                                 OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \
225                                 OBD_CONNECT_TRUNCLOCK)
226 #define ECHO_CONNECT_SUPPORTED (0)
227 #define MGMT_CONNECT_SUPPORTED  (0)
228
229 #define OBD_OCD_VERSION(major,minor,patch,fix) (((major)<<24) + ((minor)<<16) +\
230                                                 ((patch)<<8) + (fix))
231 #define OBD_OCD_VERSION_MAJOR(version) ((int)((version)>>24)&255)
232 #define OBD_OCD_VERSION_MINOR(version) ((int)((version)>>16)&255)
233 #define OBD_OCD_VERSION_PATCH(version) ((int)((version)>>8)&255)
234 #define OBD_OCD_VERSION_FIX(version)   ((int)(version)&255)
235
236 /* This structure is used for both request and reply.
237  *
238  * If we eventually have separate connect data for different types, which we
239  * almost certainly will, then perhaps we stick a union in here. */
240 struct obd_connect_data {
241         __u64 ocd_connect_flags;
242         __u32 ocd_version;
243         __u32 ocd_grant;
244         __u32 ocd_index;
245         __u32 ocd_unused;
246         __u64 padding1;                  /* also fix lustre_swab_connect */
247         __u64 padding2;                  /* also fix lustre_swab_connect */
248         __u64 padding3;                  /* also fix lustre_swab_connect */
249         __u64 padding4;                  /* also fix lustre_swab_connect */
250         __u64 padding5;                  /* also fix lustre_swab_connect */
251         __u64 padding6;                  /* also fix lustre_swab_connect */
252 };
253
254 extern void lustre_swab_connect(struct obd_connect_data *ocd);
255
256 /*
257  *   OST requests: OBDO & OBD request records
258  */
259
260 /* opcodes */
261 typedef enum {
262         OST_REPLY      =  0,       /* reply ? */
263         OST_GETATTR    =  1,
264         OST_SETATTR    =  2,
265         OST_READ       =  3,
266         OST_WRITE      =  4,
267         OST_CREATE     =  5,
268         OST_DESTROY    =  6,
269         OST_GET_INFO   =  7,
270         OST_CONNECT    =  8,
271         OST_DISCONNECT =  9,
272         OST_PUNCH      = 10,
273         OST_OPEN       = 11,
274         OST_CLOSE      = 12,
275         OST_STATFS     = 13,
276         OST_SAN_READ   = 14,
277         OST_SAN_WRITE  = 15,
278         OST_SYNC       = 16,
279         OST_SET_INFO   = 17,
280         OST_QUOTACHECK = 18,
281         OST_QUOTACTL   = 19,
282         OST_LAST_OPC
283 } ost_cmd_t;
284 #define OST_FIRST_OPC  OST_REPLY
285
286 typedef uint64_t        obd_id;
287 typedef uint64_t        obd_gr;
288 typedef uint64_t        obd_time;
289 typedef uint64_t        obd_size;
290 typedef uint64_t        obd_off;
291 typedef uint64_t        obd_blocks;
292 typedef uint32_t        obd_blksize;
293 typedef uint32_t        obd_mode;
294 typedef uint32_t        obd_uid;
295 typedef uint32_t        obd_gid;
296 typedef uint32_t        obd_flag;
297 typedef uint64_t        obd_valid;
298 typedef uint32_t        obd_count;
299
300 #define OBD_FL_INLINEDATA    (0x00000001)
301 #define OBD_FL_OBDMDEXISTS   (0x00000002)
302 #define OBD_FL_DELORPHAN     (0x00000004) /* if set in o_flags delete orphans */
303 #define OBD_FL_NORPC         (0x00000008) /* set in o_flags do in OSC not OST */
304 #define OBD_FL_IDONLY        (0x00000010) /* set in o_flags only adjust obj id*/
305 #define OBD_FL_RECREATE_OBJS (0x00000020) /* recreate missing obj */
306 #define OBD_FL_DEBUG_CHECK   (0x00000040) /* echo client/server debug check */
307 #define OBD_FL_NO_USRQUOTA   (0x00000100) /* the object's owner is over quota */
308 #define OBD_FL_NO_GRPQUOTA   (0x00000200) /* the object's group is over quota */
309 /*
310  * set this to delegate DLM locking during obd_punch() to the OSTs. Only OSTs
311  * that declared OBD_CONNECT_TRUNCLOCK in their connect flags support this
312  * functionality.
313  */
314 #define OBD_FL_TRUNCLOCK     (0x00000800)
315
316 #define OBD_INLINESZ    80
317
318 /* Note: 64-bit types are 64-bit aligned in structure */
319 struct obdo {
320         obd_valid               o_valid;        /* hot fields in this obdo */
321         obd_id                  o_id;
322         obd_gr                  o_gr;
323         obd_id                  o_fid;
324         obd_size                o_size;         /* o_size-o_blocks == ost_lvb */
325         obd_time                o_mtime;
326         obd_time                o_atime;
327         obd_time                o_ctime;
328         obd_blocks              o_blocks;       /* brw: cli sent cached bytes */
329         obd_size                o_grant;
330         /* 32-bit fields start here: keep an even number of them via padding */
331         obd_blksize             o_blksize;      /* optimal IO blocksize */
332         obd_mode                o_mode;         /* brw: cli sent cache remain */
333         obd_uid                 o_uid;
334         obd_gid                 o_gid;
335         obd_flag                o_flags;
336         obd_count               o_nlink;        /* brw: checksum */
337         obd_count               o_generation;
338         obd_count               o_misc;         /* brw: o_dropped */
339         __u32                   o_easize;       /* epoch in ost writes */
340         __u32                   o_mds;
341         __u32                   o_padding_1;    /* also fix lustre_swab_obdo */
342         __u32                   o_padding_2;    /* also fix lustre_swab_obdo */
343         char                    o_inline[OBD_INLINESZ]; /* fid in ost writes */
344 };
345
346 #define o_dirty   o_blocks
347 #define o_undirty o_mode
348 #define o_dropped o_misc
349 #define o_cksum   o_nlink
350
351 extern void lustre_swab_obdo (struct obdo *o);
352
353 #define LOV_MAGIC_V1      0x0BD10BD0
354 #define LOV_MAGIC         LOV_MAGIC_V1
355
356 #define LOV_PATTERN_RAID0 0x001   /* stripes are used round-robin */
357 #define LOV_PATTERN_RAID1 0x002   /* stripes are mirrors of each other */
358 #define LOV_PATTERN_FIRST 0x100   /* first stripe is not in round-robin */
359 #define LOV_PATTERN_CMOBD 0x200
360
361 #define lov_ost_data lov_ost_data_v1
362 struct lov_ost_data_v1 {          /* per-stripe data structure (little-endian)*/
363         __u64 l_object_id;        /* OST object ID */
364         __u64 l_object_gr;        /* OST object group (creating MDS number) */
365         __u32 l_ost_gen;          /* generation of this l_ost_idx */
366         __u32 l_ost_idx;          /* OST index in LOV (lov_tgt_desc->tgts) */
367 };
368
369 #define lov_mds_md lov_mds_md_v1
370 struct lov_mds_md_v1 {            /* LOV EA mds/wire data (little-endian) */
371         __u32 lmm_magic;          /* magic number = LOV_MAGIC_V1 */
372         __u32 lmm_pattern;        /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
373         __u64 lmm_object_id;      /* LOV object ID */
374         __u64 lmm_object_gr;      /* LOV object group */
375         __u32 lmm_stripe_size;    /* size of stripe in bytes */
376         __u32 lmm_stripe_count;   /* num stripes in use for this object */
377         struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */
378 };
379
380 #define OBD_MD_FLID        (0x00000001ULL) /* object ID */
381 #define OBD_MD_FLATIME     (0x00000002ULL) /* access time */
382 #define OBD_MD_FLMTIME     (0x00000004ULL) /* data modification time */
383 #define OBD_MD_FLCTIME     (0x00000008ULL) /* change time */
384 #define OBD_MD_FLSIZE      (0x00000010ULL) /* size */
385 #define OBD_MD_FLBLOCKS    (0x00000020ULL) /* allocated blocks count */
386 #define OBD_MD_FLBLKSZ     (0x00000040ULL) /* block size */
387 #define OBD_MD_FLMODE      (0x00000080ULL) /* access bits (mode & ~S_IFMT) */
388 #define OBD_MD_FLTYPE      (0x00000100ULL) /* object type (mode & S_IFMT) */
389 #define OBD_MD_FLUID       (0x00000200ULL) /* user ID */
390 #define OBD_MD_FLGID       (0x00000400ULL) /* group ID */
391 #define OBD_MD_FLFLAGS     (0x00000800ULL) /* flags word */
392 #define OBD_MD_FLNLINK     (0x00002000ULL) /* link count */
393 #define OBD_MD_FLGENER     (0x00004000ULL) /* generation number */
394 #define OBD_MD_FLINLINE    (0x00008000ULL) /* inline data */
395 #define OBD_MD_FLRDEV      (0x00010000ULL) /* device number */
396 #define OBD_MD_FLEASIZE    (0x00020000ULL) /* extended attribute data */
397 #define OBD_MD_LINKNAME    (0x00040000ULL) /* symbolic link target */
398 #define OBD_MD_FLHANDLE    (0x00080000ULL) /* file handle */
399 #define OBD_MD_FLCKSUM     (0x00100000ULL) /* bulk data checksum */
400 #define OBD_MD_FLQOS       (0x00200000ULL) /* quality of service stats */
401 #define OBD_MD_FLOSCOPQ    (0x00400000ULL) /* osc opaque data */
402 #define OBD_MD_FLCOOKIE    (0x00800000ULL) /* log cancellation cookie */
403 #define OBD_MD_FLGROUP     (0x01000000ULL) /* group */
404 #define OBD_MD_FLIFID      (0x02000000ULL) /* ->ost write inline fid */
405 #define OBD_MD_FLEPOCH     (0x04000000ULL) /* ->ost write easize is epoch */
406 #define OBD_MD_FLGRANT     (0x08000000ULL) /* ost preallocation space grant */
407 #define OBD_MD_FLDIREA     (0x10000000ULL) /* dir's extended attribute data */
408 #define OBD_MD_FLUSRQUOTA  (0x20000000ULL) /* over quota flags sent from ost */
409 #define OBD_MD_FLGRPQUOTA  (0x40000000ULL) /* over quota flags sent from ost */
410
411 #define OBD_MD_MDS         (0x0000000100000000ULL) /* where an inode lives on */
412 #define OBD_MD_REINT       (0x0000000200000000ULL) /* reintegrate oa */
413
414 #define OBD_MD_FLXATTR     (0x0000001000000000ULL) /* xattr */
415 #define OBD_MD_FLXATTRLS   (0x0000002000000000ULL) /* xattr list */
416 #define OBD_MD_FLXATTRRM   (0x0000004000000000ULL) /* xattr remove */
417
418 #define OBD_MD_FLGETATTR (OBD_MD_FLID    | OBD_MD_FLATIME | OBD_MD_FLMTIME | \
419                           OBD_MD_FLCTIME | OBD_MD_FLSIZE  | OBD_MD_FLBLKSZ | \
420                           OBD_MD_FLMODE  | OBD_MD_FLTYPE  | OBD_MD_FLUID   | \
421                           OBD_MD_FLGID   | OBD_MD_FLFLAGS | OBD_MD_FLNLINK | \
422                           OBD_MD_FLGENER | OBD_MD_FLRDEV  | OBD_MD_FLGROUP)
423
424 static inline struct lustre_handle *obdo_handle(struct obdo *oa)
425 {
426         return (struct lustre_handle *)oa->o_inline;
427 }
428
429 static inline struct llog_cookie *obdo_logcookie(struct obdo *oa)
430 {
431         return (struct llog_cookie *)(oa->o_inline +
432                                       sizeof(struct lustre_handle));
433 }
434 /* don't forget obdo_fid which is way down at the bottom so it can
435  * come after the definition of llog_cookie */
436
437 struct obd_statfs {
438         __u64           os_type;
439         __u64           os_blocks;
440         __u64           os_bfree;
441         __u64           os_bavail;
442         __u64           os_files;
443         __u64           os_ffree;
444         __u8            os_fsid[40];
445         __u32           os_bsize;
446         __u32           os_namelen;
447         __u64           os_maxbytes;
448         __u32           os_spare[10];
449 };
450
451 extern void lustre_swab_obd_statfs (struct obd_statfs *os);
452
453 /* ost_body.data values for OST_BRW */
454
455 #define OBD_BRW_READ            0x01
456 #define OBD_BRW_WRITE           0x02
457 #define OBD_BRW_RWMASK          (OBD_BRW_READ | OBD_BRW_WRITE)
458 #define OBD_BRW_SYNC            0x08
459 #define OBD_BRW_CHECK           0x10
460 #define OBD_BRW_FROM_GRANT      0x20 /* the osc manages this under llite */
461 #define OBD_BRW_GRANTED         0x40 /* the ost manages this */
462 #define OBD_BRW_DROP            0x80 /* drop the page after IO */
463 #define OBD_BRW_NOQUOTA        0x100
464 #define OBD_BRW_SRVLOCK        0x200 /* Client holds no lock over this page */
465
466 #define OBD_OBJECT_EOF 0xffffffffffffffffULL
467
468 #define OST_MIN_PRECREATE 32
469 #define OST_MAX_PRECREATE 20000
470
471 struct obd_ioobj {
472         obd_id               ioo_id;
473         obd_gr               ioo_gr;
474         __u32                ioo_type;
475         __u32                ioo_bufcnt;
476 };
477
478 extern void lustre_swab_obd_ioobj (struct obd_ioobj *ioo);
479
480 /* multiple of 8 bytes => can array */
481 struct niobuf_remote {
482         __u64 offset;
483         __u32 len;
484         __u32 flags;
485 };
486
487 extern void lustre_swab_niobuf_remote (struct niobuf_remote *nbr);
488
489 /* request structure for OST's */
490
491 struct ost_body {
492         struct  obdo oa;
493 };
494
495 extern void lustre_swab_ost_body (struct ost_body *b);
496 extern void lustre_swab_ost_last_id(obd_id *id);
497
498 /* lock value block communicated between the filter and llite */
499
500 struct ost_lvb {
501         __u64 lvb_size;
502         __u64 lvb_mtime;
503         __u64 lvb_atime;
504         __u64 lvb_ctime;
505         __u64 lvb_blocks;
506 };
507
508 extern void lustre_swab_ost_lvb(struct ost_lvb *);
509
510 /*
511  *   MDS REQ RECORDS
512  */
513
514 /* opcodes */
515 typedef enum {
516         MDS_GETATTR      = 33,
517         MDS_GETATTR_NAME = 34,
518         MDS_CLOSE        = 35,
519         MDS_REINT        = 36,
520         MDS_READPAGE     = 37,
521         MDS_CONNECT      = 38,
522         MDS_DISCONNECT   = 39,
523         MDS_GETSTATUS    = 40,
524         MDS_STATFS       = 41,
525         MDS_PIN          = 42,
526         MDS_UNPIN        = 43,
527         MDS_SYNC         = 44,
528         MDS_DONE_WRITING = 45,
529         MDS_SET_INFO     = 46,
530         MDS_QUOTACHECK   = 47,
531         MDS_QUOTACTL     = 48,
532         MDS_GETXATTR     = 49,
533         MDS_SETXATTR     = 50,
534         MDS_LAST_OPC
535 } mds_cmd_t;
536
537 #define MDS_FIRST_OPC    MDS_GETATTR
538
539 /*
540  * Do not exceed 63
541  */
542
543 typedef enum {
544         REINT_SETATTR  = 1,
545         REINT_CREATE   = 2,
546         REINT_LINK     = 3,
547         REINT_UNLINK   = 4,
548         REINT_RENAME   = 5,
549         REINT_OPEN     = 6,
550 //      REINT_CLOSE    = 7,
551 //      REINT_WRITE    = 8,
552         REINT_MAX
553 } mds_reint_t;
554
555 /* the disposition of the intent outlines what was executed */
556 #define DISP_IT_EXECD     0x01
557 #define DISP_LOOKUP_EXECD 0x02
558 #define DISP_LOOKUP_NEG   0x04
559 #define DISP_LOOKUP_POS   0x08
560 #define DISP_OPEN_CREATE  0x10
561 #define DISP_OPEN_OPEN    0x20
562 #define DISP_ENQ_COMPLETE 0x40
563
564 struct ll_fid {
565         __u64 id;
566         __u32 generation;
567         __u32 f_type;
568 };
569
570 extern void lustre_swab_ll_fid (struct ll_fid *fid);
571
572 #define MDS_STATUS_CONN 1
573 #define MDS_STATUS_LOV 2
574
575 struct mds_status_req {
576         __u32  flags;
577         __u32  repbuf;
578 };
579
580 extern void lustre_swab_mds_status_req (struct mds_status_req *r);
581
582 #define MDS_BFLAG_UNCOMMITTED_WRITES   0x1
583
584 struct mds_body {
585         struct ll_fid  fid1;
586         struct ll_fid  fid2;
587         struct lustre_handle handle;
588         __u64          valid;
589         __u64          size;   /* Offset, in the case of MDS_READPAGE */
590         __u64          mtime;
591         __u64          atime;
592         __u64          ctime;
593         __u64          blocks; /* XID, in the case of MDS_READPAGE */
594         __u64          io_epoch;
595         __u64          ino;
596         __u32          fsuid;
597         __u32          fsgid;
598         __u32          capability;
599         __u32          mode;
600         __u32          uid;
601         __u32          gid;
602         __u32          flags; /* from vfs for pin/unpin, MDS_BFLAG for close */
603         __u32          rdev;
604         __u32          nlink; /* #bytes to read in the case of MDS_READPAGE */
605         __u32          generation;
606         __u32          suppgid;
607         __u32          eadatasize;
608         __u32          padding_1; /* also fix lustre_swab_mds_body */
609         __u32          padding_2; /* also fix lustre_swab_mds_body */
610         __u32          padding_3; /* also fix lustre_swab_mds_body */
611         __u32          padding_4; /* also fix lustre_swab_mds_body */
612 };
613
614 extern void lustre_swab_mds_body (struct mds_body *b);
615
616 /* XXX: same as if_dqinfo struct in kernel */
617 struct obd_dqinfo {
618         __u64 dqi_bgrace;
619         __u64 dqi_igrace;
620         __u32 dqi_flags;
621         __u32 dqi_valid;
622 };
623
624 /* XXX: same as if_dqblk struct in kernel, plus one padding */
625 struct obd_dqblk {
626         __u64 dqb_bhardlimit;
627         __u64 dqb_bsoftlimit;
628         __u64 dqb_curspace;
629         __u64 dqb_ihardlimit;
630         __u64 dqb_isoftlimit;
631         __u64 dqb_curinodes;
632         __u64 dqb_btime;
633         __u64 dqb_itime;
634         __u32 dqb_valid;
635         __u32 padding;          /* also fix lustre_swab_obd_quotactl */
636 };
637
638 #define Q_QUOTACHECK    0x800100
639 #define Q_INITQUOTA     0x800101        /* init slave limits */
640 #define Q_GETOINFO      0x800102        /* get obd quota info */
641 #define Q_GETOQUOTA     0x800103        /* get obd quotas */
642
643 #define Q_TYPESET(oqc, type) \
644         ((oqc)->qc_type == type || (oqc)->qc_type == UGQUOTA)
645
646 #define Q_GETOCMD(oqc) \
647         ((oqc)->qc_cmd == Q_GETOINFO || (oqc)->qc_cmd == Q_GETOQUOTA)
648
649 struct obd_quotactl {
650         __u32                   qc_cmd;
651         __u32                   qc_type;
652         __u32                   qc_id;
653         __u32                   qc_stat;
654         struct obd_dqinfo       qc_dqinfo;
655         struct obd_dqblk        qc_dqblk;
656 };
657
658 extern void lustre_swab_obd_quotactl(struct obd_quotactl *q);
659
660 struct mds_rec_setattr {
661         __u32           sa_opcode;
662         __u32           sa_fsuid;
663         __u32           sa_fsgid;
664         __u32           sa_cap;
665         __u32           sa_suppgid;
666         __u32           sa_mode;
667         struct ll_fid   sa_fid;
668         __u64           sa_valid;
669         __u64           sa_size;
670         __u64           sa_mtime;
671         __u64           sa_atime;
672         __u64           sa_ctime;
673         __u32           sa_uid;
674         __u32           sa_gid;
675         __u32           sa_attr_flags;
676         __u32           sa_padding; /* also fix lustre_swab_mds_rec_setattr */
677 };
678
679 /* Remove this once we declare it in include/linux/fs.h (v21 kernel patch?) */
680 #ifndef ATTR_CTIME_SET
681 #define ATTR_CTIME_SET 0x2000
682 #endif
683
684 extern void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa);
685
686 #ifndef FMODE_READ
687 #define FMODE_READ               00000001
688 #define FMODE_WRITE              00000002
689 #endif
690 #ifndef FMODE_EXEC
691 #define FMODE_EXEC               00000004
692 #endif
693 #define MDS_OPEN_CREAT           00000100
694 #define MDS_OPEN_EXCL            00000200
695 #define MDS_OPEN_TRUNC           00001000
696 #define MDS_OPEN_APPEND          00002000
697 #define MDS_OPEN_SYNC            00010000
698 #define MDS_OPEN_DIRECTORY       00200000
699
700 #define MDS_OPEN_DELAY_CREATE  0100000000 /* delay initial object create */
701 #define MDS_OPEN_OWNEROVERRIDE 0200000000 /* NFSD rw-reopen ro file for owner */
702 #define MDS_OPEN_HAS_EA      010000000000 /* specify object create pattern */
703 #define MDS_OPEN_HAS_OBJS    020000000000 /* Just set the EA the obj exist */
704
705 struct mds_rec_create {
706         __u32           cr_opcode;
707         __u32           cr_fsuid;
708         __u32           cr_fsgid;
709         __u32           cr_cap;
710         __u32           cr_flags; /* for use with open */
711         __u32           cr_mode;
712         struct ll_fid   cr_fid;
713         struct ll_fid   cr_replayfid;
714         __u64           cr_time;
715         __u64           cr_rdev;
716         __u32           cr_suppgid;
717         __u32           cr_padding_1; /* also fix lustre_swab_mds_rec_create */
718         __u32           cr_padding_2; /* also fix lustre_swab_mds_rec_create */
719         __u32           cr_padding_3; /* also fix lustre_swab_mds_rec_create */
720         __u32           cr_padding_4; /* also fix lustre_swab_mds_rec_create */
721         __u32           cr_padding_5; /* also fix lustre_swab_mds_rec_create */
722 };
723
724 extern void lustre_swab_mds_rec_create (struct mds_rec_create *cr);
725
726 struct mds_rec_link {
727         __u32           lk_opcode;
728         __u32           lk_fsuid;
729         __u32           lk_fsgid;
730         __u32           lk_cap;
731         __u32           lk_suppgid1;
732         __u32           lk_suppgid2;
733         struct ll_fid   lk_fid1;
734         struct ll_fid   lk_fid2;
735         __u64           lk_time;
736         __u32           lk_padding_1;  /* also fix lustre_swab_mds_rec_link */
737         __u32           lk_padding_2;  /* also fix lustre_swab_mds_rec_link */
738         __u32           lk_padding_3;  /* also fix lustre_swab_mds_rec_link */
739         __u32           lk_padding_4;  /* also fix lustre_swab_mds_rec_link */
740 };
741
742 extern void lustre_swab_mds_rec_link (struct mds_rec_link *lk);
743
744 struct mds_rec_unlink {
745         __u32           ul_opcode;
746         __u32           ul_fsuid;
747         __u32           ul_fsgid;
748         __u32           ul_cap;
749         __u32           ul_suppgid;
750         __u32           ul_mode;
751         struct ll_fid   ul_fid1;
752         struct ll_fid   ul_fid2;
753         __u64           ul_time;
754         __u32           ul_padding_1; /* also fix lustre_swab_mds_rec_unlink */
755         __u32           ul_padding_2; /* also fix lustre_swab_mds_rec_unlink */
756         __u32           ul_padding_3; /* also fix lustre_swab_mds_rec_unlink */
757         __u32           ul_padding_4; /* also fix lustre_swab_mds_rec_unlink */
758 };
759
760 extern void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul);
761
762 struct mds_rec_rename {
763         __u32           rn_opcode;
764         __u32           rn_fsuid;
765         __u32           rn_fsgid;
766         __u32           rn_cap;
767         __u32           rn_suppgid1;
768         __u32           rn_suppgid2;
769         struct ll_fid   rn_fid1;
770         struct ll_fid   rn_fid2;
771         __u64           rn_time;
772         __u32           rn_padding_1; /* also fix lustre_swab_mds_rec_rename */
773         __u32           rn_padding_2; /* also fix lustre_swab_mds_rec_rename */
774         __u32           rn_padding_3; /* also fix lustre_swab_mds_rec_rename */
775         __u32           rn_padding_4; /* also fix lustre_swab_mds_rec_rename */
776 };
777
778 extern void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn);
779
780 /*
781  *  LOV data structures
782  */
783
784 #define LOV_MIN_STRIPE_SIZE 65536   /* maximum PAGE_SIZE (ia64), power of 2 */
785 #define LOV_MAX_STRIPE_COUNT  160   /* until bug 4424 is fixed */
786
787 #define LOV_MAX_UUID_BUFFER_SIZE  8192
788 /* The size of the buffer the lov/mdc reserves for the
789  * array of UUIDs returned by the MDS.  With the current
790  * protocol, this will limit the max number of OSTs per LOV */
791
792 #define LOV_DESC_MAGIC 0xB0CCDE5C
793
794 struct lov_desc {
795         __u32 ld_tgt_count;                /* how many OBD's */
796         __u32 ld_active_tgt_count;         /* how many active */
797         __u32 ld_default_stripe_count;     /* how many objects are used */
798         __u32 ld_pattern;                  /* PATTERN_RAID0, PATTERN_RAID1 */
799         __u64 ld_default_stripe_size;      /* in bytes */
800         __u64 ld_default_stripe_offset;    /* in bytes */
801         __u32 ld_padding_1;                /* also fix lustre_swab_lov_desc */
802         __u32 ld_padding_2;                /* also fix lustre_swab_lov_desc */
803         __u32 ld_padding_3;                /* also fix lustre_swab_lov_desc */
804         __u32 ld_padding_4;                /* also fix lustre_swab_lov_desc */
805         struct obd_uuid ld_uuid;
806 };
807
808 #define ld_magic ld_active_tgt_count       /* for swabbing from llogs */
809
810 extern void lustre_swab_lov_desc (struct lov_desc *ld);
811
812 /*
813  *   LDLM requests:
814  */
815 /* opcodes -- MUST be distinct from OST/MDS opcodes */
816 typedef enum {
817         LDLM_ENQUEUE     = 101,
818         LDLM_CONVERT     = 102,
819         LDLM_CANCEL      = 103,
820         LDLM_BL_CALLBACK = 104,
821         LDLM_CP_CALLBACK = 105,
822         LDLM_GL_CALLBACK = 106,
823         LDLM_LAST_OPC
824 } ldlm_cmd_t;
825 #define LDLM_FIRST_OPC LDLM_ENQUEUE
826
827 #define RES_NAME_SIZE 4
828 struct ldlm_res_id {
829         __u64 name[RES_NAME_SIZE];
830 };
831
832 extern void lustre_swab_ldlm_res_id (struct ldlm_res_id *id);
833
834 /* lock types */
835 typedef enum {
836         LCK_MINMODE = 0,
837         LCK_EX = 1,
838         LCK_PW = 2,
839         LCK_PR = 4,
840         LCK_CW = 8,
841         LCK_CR = 16,
842         LCK_NL = 32,
843         LCK_GROUP = 64,
844         LCK_MAXMODE
845 } ldlm_mode_t;
846
847 typedef enum {
848         LDLM_PLAIN     = 10,
849         LDLM_EXTENT    = 11,
850         LDLM_FLOCK     = 12,
851 //      LDLM_IBITS     = 13,
852         LDLM_LLOG      = 14,
853         LDLM_MAX_TYPE
854 } ldlm_type_t;
855
856 #define LDLM_MIN_TYPE LDLM_PLAIN
857
858 struct ldlm_extent {
859         __u64 start;
860         __u64 end;
861         __u64 gid;
862 };
863
864 struct ldlm_flock {
865         __u64 start;
866         __u64 end;
867         __u64 blocking_export;  /* not actually used over the wire */
868         __u32 blocking_pid;     /* not actually used over the wire */
869         __u32 pid;
870 };
871
872 /* it's important that the fields of the ldlm_extent structure match
873  * the first fields of the ldlm_flock structure because there is only
874  * one ldlm_swab routine to process the ldlm_policy_data_t union. if
875  * this ever changes we will need to swab the union differently based
876  * on the resource type. */
877
878 typedef union {
879         struct ldlm_extent l_extent;
880         struct ldlm_flock  l_flock;
881 } ldlm_policy_data_t;
882
883 extern void lustre_swab_ldlm_policy_data (ldlm_policy_data_t *d);
884
885 struct ldlm_intent {
886         __u64 opc;
887 };
888
889 extern void lustre_swab_ldlm_intent (struct ldlm_intent *i);
890
891 struct ldlm_resource_desc {
892         ldlm_type_t lr_type;
893         __u32 lr_padding;       /* also fix lustre_swab_ldlm_resource_desc */
894         struct ldlm_res_id lr_name;
895 };
896
897 extern void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r);
898
899 struct ldlm_lock_desc {
900         struct ldlm_resource_desc l_resource;
901         ldlm_mode_t l_req_mode;
902         ldlm_mode_t l_granted_mode;
903         ldlm_policy_data_t l_policy_data;
904 };
905
906 extern void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l);
907
908 struct ldlm_request {
909         __u32 lock_flags;
910         __u32 lock_padding;     /* also fix lustre_swab_ldlm_request */
911         struct ldlm_lock_desc lock_desc;
912         struct lustre_handle lock_handle1;
913         struct lustre_handle lock_handle2;
914 };
915
916 extern void lustre_swab_ldlm_request (struct ldlm_request *rq);
917
918 struct ldlm_reply {
919         __u32 lock_flags;
920         __u32 lock_padding;     /* also fix lustre_swab_ldlm_reply */
921         struct ldlm_lock_desc lock_desc;
922         struct lustre_handle lock_handle;
923         __u64  lock_policy_res1;
924         __u64  lock_policy_res2;
925 };
926
927 extern void lustre_swab_ldlm_reply (struct ldlm_reply *r);
928
929
930 /*
931  * Opcodes for mountconf (mgs and mgc)
932  */
933 typedef enum {
934         MGMT_CONNECT = 250,
935         MGMT_DISCONNECT,
936         MGMT_EXCEPTION,         /* node died, etc. */
937         MGMT_TARGET_ADD,
938         MGMT_TARGET_DEL,
939         MGMT_LAST_OPC
940 } mgs_cmd_t;
941
942 #define NAME_MAXLEN 64
943 #define UUID_MAXLEN NAME_MAXLEN + 5
944
945 struct mgmt_target_info {
946         char             mti_fsname[NAME_MAXLEN];
947         char             mti_targetname[NAME_MAXLEN];
948         char             mti_nodename[NAME_MAXLEN];
949         char             mti_uuid[UUID_MAXLEN];
950         __u64            mti_nid;            /* lnet_nid_t */ //nid list?
951         __u32            mti_config_ver;
952         __u32            mti_flags;
953         __u32            mti_stripe_index;
954         __u32            mti_stripe_pattern;      /* PATTERN_RAID0, PATTERN_RAID1 */
955         __u64            mti_stripe_size;      /* in bytes */
956         __u64            mti_stripe_offset;    /* in bytes */
957 };
958
959 extern void lustre_swab_mgmt_target_info(struct mgmt_target_info *oinfo);
960
961
962 /*
963  * Opcodes for multiple servers.
964  */
965
966 typedef enum {
967         OBD_PING = 400,
968         OBD_LOG_CANCEL,
969         OBD_QC_CALLBACK,
970         OBD_LAST_OPC
971 } obd_cmd_t;
972 #define OBD_FIRST_OPC OBD_PING
973
974 /* catalog of log objects */
975
976 /* Identifier for a single log object */
977 struct llog_logid {
978         __u64                   lgl_oid;
979         __u64                   lgl_ogr;
980         __u32                   lgl_ogen;
981 } __attribute__((packed));
982
983 /* Records written to the CATALOGS list */
984 #define CATLIST "CATALOGS"
985 struct llog_catid {
986         struct llog_logid       lci_logid;
987         __u32                   lci_padding1;
988         __u32                   lci_padding2;
989         __u32                   lci_padding3;
990 } __attribute__((packed));
991
992 /* Log data record types - there is no specific reason that these need to
993  * be related to the RPC opcodes, but no reason not to (may be handy later?)
994  */
995 #define LLOG_OP_MAGIC 0x10600000
996 #define LLOG_OP_MASK  0xfff00000
997
998 typedef enum {
999         LLOG_PAD_MAGIC   = LLOG_OP_MAGIC | 0,
1000         OST_SZ_REC       = LLOG_OP_MAGIC | (OST_SAN_WRITE << 8),
1001         OST_RAID1_REC    = LLOG_OP_MAGIC | ((OST_SAN_WRITE + 1) << 8),
1002         MDS_UNLINK_REC   = LLOG_OP_MAGIC | 0x10000 | (MDS_REINT << 8) | REINT_UNLINK,
1003         MDS_SETATTR_REC  = LLOG_OP_MAGIC | 0x10000 | (MDS_REINT << 8) | REINT_SETATTR,
1004         OBD_CFG_REC      = LLOG_OP_MAGIC | 0x20000,
1005         PTL_CFG_REC      = LLOG_OP_MAGIC | 0x30000, /* obsolete */
1006         LLOG_GEN_REC     = LLOG_OP_MAGIC | 0x40000,
1007         LLOG_HDR_MAGIC   = LLOG_OP_MAGIC | 0x45539,
1008         LLOG_LOGID_MAGIC = LLOG_OP_MAGIC | 0x4553b,
1009 } llog_op_type;
1010
1011 /*
1012  * for now, continue to support old pad records which have 0 for their
1013  * type but still need to be swabbed for their length
1014  */
1015 #define LLOG_REC_HDR_NEEDS_SWABBING(r)                                  \
1016         (((r)->lrh_type & __swab32(LLOG_OP_MASK)) ==                    \
1017          __swab32(LLOG_OP_MAGIC) ||                                     \
1018          (((r)->lrh_type == 0) && ((r)->lrh_len > LLOG_CHUNK_SIZE)))
1019
1020 /* Log record header - stored in little endian order.
1021  * Each record must start with this struct, end with a llog_rec_tail,
1022  * and be a multiple of 256 bits in size.
1023  */
1024 struct llog_rec_hdr {
1025         __u32                   lrh_len;
1026         __u32                   lrh_index;
1027         __u32                   lrh_type;
1028         __u32                   padding;
1029 };
1030
1031 struct llog_rec_tail {
1032         __u32 lrt_len;
1033         __u32 lrt_index;
1034 };
1035
1036 struct llog_logid_rec {
1037         struct llog_rec_hdr     lid_hdr;
1038         struct llog_logid       lid_id;
1039         __u32                   padding1;
1040         __u32                   padding2;
1041         __u32                   padding3;
1042         __u32                   padding4;
1043         __u32                   padding5;
1044         struct llog_rec_tail    lid_tail;
1045 } __attribute__((packed));
1046
1047 struct llog_create_rec {
1048         struct llog_rec_hdr     lcr_hdr;
1049         struct ll_fid           lcr_fid;
1050         obd_id                  lcr_oid;
1051         obd_count               lcr_ogen;
1052         __u32                   padding;
1053         struct llog_rec_tail    lcr_tail;
1054 } __attribute__((packed));
1055
1056 struct llog_orphan_rec {
1057         struct llog_rec_hdr     lor_hdr;
1058         obd_id                  lor_oid;
1059         obd_count               lor_ogen;
1060         __u32                   padding;
1061         struct llog_rec_tail    lor_tail;
1062 } __attribute__((packed));
1063
1064 struct llog_unlink_rec {
1065         struct llog_rec_hdr     lur_hdr;
1066         obd_id                  lur_oid;
1067         obd_count               lur_ogen;
1068         __u32                   padding;
1069         struct llog_rec_tail    lur_tail;
1070 } __attribute__((packed));
1071
1072 struct llog_setattr_rec {
1073         struct llog_rec_hdr     lsr_hdr;
1074         obd_id                  lsr_oid;
1075         obd_count               lsr_ogen;
1076         __u32                   lsr_uid;
1077         __u32                   lsr_gid;
1078         __u32                   padding;
1079         struct llog_rec_tail    lsr_tail;
1080 } __attribute__((packed));
1081
1082 struct llog_size_change_rec {
1083         struct llog_rec_hdr     lsc_hdr;
1084         struct ll_fid           lsc_fid;
1085         __u32                   lsc_io_epoch;
1086         __u32                   padding;
1087         struct llog_rec_tail    lsc_tail;
1088 } __attribute__((packed));
1089
1090 struct llog_gen {
1091         __u64 mnt_cnt;
1092         __u64 conn_cnt;
1093 } __attribute__((packed));
1094
1095 struct llog_gen_rec {
1096         struct llog_rec_hdr     lgr_hdr;
1097         struct llog_gen         lgr_gen;
1098         struct llog_rec_tail    lgr_tail;
1099 };
1100 /* On-disk header structure of each log object, stored in little endian order */
1101 #define LLOG_CHUNK_SIZE         8192
1102 #define LLOG_HEADER_SIZE        (96)
1103 #define LLOG_BITMAP_BYTES       (LLOG_CHUNK_SIZE - LLOG_HEADER_SIZE)
1104
1105 #define LLOG_MIN_REC_SIZE       (24) /* round(llog_rec_hdr + llog_rec_tail) */
1106
1107 /* flags for the logs */
1108 #define LLOG_F_ZAP_WHEN_EMPTY   0x1
1109 #define LLOG_F_IS_CAT           0x2
1110 #define LLOG_F_IS_PLAIN         0x4
1111
1112 struct llog_log_hdr {
1113         struct llog_rec_hdr     llh_hdr;
1114         __u64                   llh_timestamp;
1115         __u32                   llh_count;
1116         __u32                   llh_bitmap_offset;
1117         __u32                   llh_size;
1118         __u32                   llh_flags;
1119         __u32                   llh_cat_idx;
1120         /* for a catalog the first plain slot is next to it */
1121         struct obd_uuid         llh_tgtuuid;
1122         __u32                   llh_reserved[LLOG_HEADER_SIZE/sizeof(__u32) - 23];
1123         __u32                   llh_bitmap[LLOG_BITMAP_BYTES/sizeof(__u32)];
1124         struct llog_rec_tail    llh_tail;
1125 } __attribute__((packed));
1126
1127 #define LLOG_BITMAP_SIZE(llh)  ((llh->llh_hdr.lrh_len -         \
1128                                  llh->llh_bitmap_offset -       \
1129                                  sizeof(llh->llh_tail)) * 8)
1130
1131 /* log cookies are used to reference a specific log file and a record therein */
1132 struct llog_cookie {
1133         struct llog_logid       lgc_lgl;
1134         __u32                   lgc_subsys;
1135         __u32                   lgc_index;
1136         __u32                   lgc_padding;
1137 } __attribute__((packed));
1138
1139 /* llog protocol */
1140 enum llogd_rpc_ops {
1141         LLOG_ORIGIN_HANDLE_CREATE       = 501,
1142         LLOG_ORIGIN_HANDLE_NEXT_BLOCK   = 502,
1143         LLOG_ORIGIN_HANDLE_READ_HEADER  = 503,
1144         LLOG_ORIGIN_HANDLE_WRITE_REC    = 504,
1145         LLOG_ORIGIN_HANDLE_CLOSE        = 505,
1146         LLOG_ORIGIN_CONNECT             = 506,
1147         LLOG_CATINFO                    = 507,  /* for lfs catinfo */
1148 };
1149
1150 struct llogd_body {
1151         struct llog_logid  lgd_logid;
1152         __u32 lgd_ctxt_idx;
1153         __u32 lgd_llh_flags;
1154         __u32 lgd_index;
1155         __u32 lgd_saved_index;
1156         __u32 lgd_len;
1157         __u64 lgd_cur_offset;
1158 } __attribute__((packed));
1159
1160 struct llogd_conn_body {
1161         struct llog_gen         lgdc_gen;
1162         struct llog_logid       lgdc_logid;
1163         __u32                   lgdc_ctxt_idx;
1164 } __attribute__((packed));
1165
1166 extern void lustre_swab_lov_user_md(struct lov_user_md *lum);
1167 extern void lustre_swab_lov_user_md_objects(struct lov_user_md *lum);
1168
1169 /* llog_swab.c */
1170 extern void lustre_swab_llogd_body (struct llogd_body *d);
1171 extern void lustre_swab_llog_hdr (struct llog_log_hdr *h);
1172 extern void lustre_swab_llogd_conn_body (struct llogd_conn_body *d);
1173 extern void lustre_swab_llog_rec(struct llog_rec_hdr  *rec,
1174                                  struct llog_rec_tail *tail);
1175
1176 struct lustre_cfg;
1177 extern void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg);
1178
1179 static inline struct ll_fid *obdo_fid(struct obdo *oa)
1180 {
1181         return (struct ll_fid *)(oa->o_inline + sizeof(struct lustre_handle) +
1182                                  sizeof(struct llog_cookie));
1183 }
1184
1185 /* qutoa */
1186 struct qunit_data {
1187         __u32 qd_id;
1188         __u32 qd_type;
1189         __u32 qd_count;
1190         __u32 qd_isblk; /* indicating if it's block quota */
1191 };
1192 extern void lustre_swab_qdata(struct qunit_data *d);
1193
1194 typedef enum {
1195         QUOTA_DQACQ     = 601,
1196         QUOTA_DQREL     = 602,
1197 } quota_cmd_t;
1198
1199 #endif