Whamcloud - gitweb
Land b1_8_gate onto b1_8 (20081218_1708)
[fs/lustre-release.git] / lustre / include / lustre / lustre_idl.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/include/lustre/lustre_idl.h
37  *
38  * Lustre wire protocol definitions.
39  *
40  * ALL structs passing over the wire should be declared here.  Structs
41  * that are used in interfaces with userspace should go in lustre_user.h.
42  *
43  * All structs being declared here should be built from simple fixed-size
44  * types (__u8, __u16, __u32, __u64) or be built from other types or
45  * structs also declared in this file.  Similarly, all flags and magic
46  * values in those structs should also be declared here.  This ensures
47  * that the Lustre wire protocol is not influenced by external dependencies.
48  *
49  * The only other acceptable items in this file are VERY SIMPLE accessor
50  * functions to avoid callers grubbing inside the structures, and the
51  * prototypes of the swabber functions for each struct.  Nothing that
52  * depends on external functions or definitions should be in here.
53  *
54  * Structs must be properly aligned to put 64-bit values on an 8-byte
55  * boundary.  Any structs being added here must also be added to
56  * utils/wirecheck.c and "make newwiretest" run to regenerate the
57  * utils/wiretest.c sources.  This allows us to verify that wire structs
58  * have the proper alignment/size on all architectures.
59  *
60  * DO NOT CHANGE any of the structs, flags, values declared here and used
61  * in released Lustre versions.  Some structs may have padding fields that
62  * can be used.  Some structs might allow addition at the end (verify this
63  * in the code to ensure that new/old clients that see this larger struct
64  * do not fail, otherwise you need to implement protocol compatibility).
65  *
66  * We assume all nodes are either little-endian or big-endian, and we
67  * always send messages in the sender's native format.  The receiver
68  * detects the message format by checking the 'magic' field of the message.
69  *
70  * Each wire type has corresponding 'lustre_swab_xxxtypexxx()' routines,
71  * implemented either here, inline (trivial implementations) or in
72  * ptlrpc/pack_generic.c.  These 'swabbers' convert the type from "other"
73  * endian, in-place in the message buffer.
74  *
75  * A swabber takes a single pointer argument.  The caller must already have
76  * verified that the length of the message buffer >= sizeof (type).
77  *
78  * For variable length types, a second 'lustre_swab_v_xxxtypexxx()' routine
79  * may be defined that swabs just the variable part, after the caller has
80  * verified that the message buffer is large enough.
81  */
82
83 #ifndef _LUSTRE_IDL_H_
84 #define _LUSTRE_IDL_H_
85
86 #if defined(__linux__)
87 #include <linux/lustre_types.h>
88 #elif defined(__APPLE__)
89 #include <darwin/lustre_types.h>
90 #elif defined(__WINNT__)
91 #include <winnt/lustre_types.h>
92 #else
93 #error Unsupported operating system.
94 #endif
95
96 /* Defn's shared with user-space. */
97 #include <lustre/lustre_user.h>
98 #include <lustre_ver.h>
99 #include <lustre/ll_fiemap.h>
100
101 #include <libcfs/kp30.h>
102
103 /*
104  * this file contains all data structures used in Lustre interfaces:
105  * - obdo and obd_request records
106  * - mds_request records
107  * - ldlm data
108  * - ioctl's
109  */
110
111 /*
112  *  GENERAL STUFF
113  */
114 /* FOO_REQUEST_PORTAL is for incoming requests on the FOO
115  * FOO_REPLY_PORTAL   is for incoming replies on the FOO
116  * FOO_BULK_PORTAL    is for incoming bulk on the FOO
117  */
118
119 #define CONNMGR_REQUEST_PORTAL          1
120 #define CONNMGR_REPLY_PORTAL            2
121 //#define OSC_REQUEST_PORTAL            3
122 #define OSC_REPLY_PORTAL                4
123 //#define OSC_BULK_PORTAL               5
124 #define OST_IO_PORTAL                   6
125 #define OST_CREATE_PORTAL               7
126 #define OST_BULK_PORTAL                 8
127 //#define MDC_REQUEST_PORTAL            9
128 #define MDC_REPLY_PORTAL               10
129 //#define MDC_BULK_PORTAL              11
130 #define MDS_REQUEST_PORTAL             12
131 //#define MDS_REPLY_PORTAL             13
132 #define MDS_BULK_PORTAL                14
133 #define LDLM_CB_REQUEST_PORTAL         15
134 #define LDLM_CB_REPLY_PORTAL           16
135 #define LDLM_CANCEL_REQUEST_PORTAL     17
136 #define LDLM_CANCEL_REPLY_PORTAL       18
137 //#define PTLBD_REQUEST_PORTAL           19
138 //#define PTLBD_REPLY_PORTAL             20
139 //#define PTLBD_BULK_PORTAL              21
140 #define MDS_SETATTR_PORTAL             22
141 #define MDS_READPAGE_PORTAL            23
142
143 #define MGC_REPLY_PORTAL               25
144 #define MGS_REQUEST_PORTAL             26
145 #define MGS_REPLY_PORTAL               27
146 #define OST_REQUEST_PORTAL             28
147 #define FLD_REQUEST_PORTAL             29
148 #define SEQ_METADATA_PORTAL            30
149
150 #define SVC_KILLED               1
151 #define SVC_EVENT                2
152 #define SVC_SIGNAL               4
153 #define SVC_RUNNING              8
154 #define SVC_STOPPING            16
155 #define SVC_STOPPED             32
156
157 /* packet types */
158 #define PTL_RPC_MSG_REQUEST 4711
159 #define PTL_RPC_MSG_ERR     4712
160 #define PTL_RPC_MSG_REPLY   4713
161
162 /* DON'T use swabbed values of MAGIC as magic! */
163 #define LUSTRE_MSG_MAGIC_V1 0x0BD00BD0
164 #define LUSTRE_MSG_MAGIC_V2 0x0BD00BD3
165
166 #define LUSTRE_MSG_MAGIC_V1_SWABBED 0xD00BD00B
167 #define LUSTRE_MSG_MAGIC_V2_SWABBED 0xD30BD00B
168
169 #define LUSTRE_MSG_MAGIC LUSTRE_MSG_MAGIC_V2
170
171 #define PTLRPC_MSG_VERSION  0x00000003
172 #define LUSTRE_VERSION_MASK 0xffff0000
173 #define LUSTRE_OBD_VERSION  0x00010000
174 #define LUSTRE_MDS_VERSION  0x00020000
175 #define LUSTRE_OST_VERSION  0x00030000
176 #define LUSTRE_DLM_VERSION  0x00040000
177 #define LUSTRE_LOG_VERSION  0x00050000
178 #define LUSTRE_MGS_VERSION  0x00060000
179
180 struct lustre_handle {
181         __u64 cookie;
182 };
183 #define DEAD_HANDLE_MAGIC 0xdeadbeefcafebabeULL
184
185 static inline int lustre_handle_is_used(struct lustre_handle *lh)
186 {
187         return lh->cookie != 0ull;
188 }
189
190 static inline int lustre_handle_equal(struct lustre_handle *lh1,
191                                       struct lustre_handle *lh2)
192 {
193         return lh1->cookie == lh2->cookie;
194 }
195
196 static inline void lustre_handle_copy(struct lustre_handle *tgt,
197                                       struct lustre_handle *src)
198 {
199         tgt->cookie = src->cookie;
200 }
201
202 /* we depend on this structure to be 8-byte aligned */
203 /* this type is only endian-adjusted in lustre_unpack_msg() */
204 struct lustre_msg_v1 {
205         struct lustre_handle lm_handle;
206         __u32 lm_magic;
207         __u32 lm_type;
208         __u32 lm_version;
209         __u32 lm_opc;
210         __u64 lm_last_xid;
211         __u64 lm_last_committed;
212         __u64 lm_transno;
213         __u32 lm_status;
214         __u32 lm_flags;
215         __u32 lm_conn_cnt;
216         __u32 lm_bufcount;
217         __u32 lm_buflens[0];
218 };
219
220 /* flags for lm_flags */
221 #define MSGHDR_AT_SUPPORT               0x1
222
223 #define lustre_msg lustre_msg_v2
224 /* we depend on this structure to be 8-byte aligned */
225 /* this type is only endian-adjusted in lustre_unpack_msg() */
226 struct lustre_msg_v2 {
227         __u32 lm_bufcount;
228         __u32 lm_secflvr;
229         __u32 lm_magic;
230         __u32 lm_repsize;
231         __u32 lm_cksum;
232         __u32 lm_flags;
233         __u32 lm_padding_2;
234         __u32 lm_padding_3;
235         __u32 lm_buflens[0];
236 };
237
238 /* without security, ptlrpc_body is put in the first buffer. */
239 #define PTLRPC_NUM_VERSIONS     4
240 struct ptlrpc_body {
241         struct lustre_handle pb_handle;
242         __u32 pb_type;
243         __u32 pb_version;
244         __u32 pb_opc;
245         __u32 pb_status;
246         __u64 pb_last_xid;
247         __u64 pb_last_seen; /* not used */
248         __u64 pb_last_committed;
249         __u64 pb_transno;
250         __u32 pb_flags;
251         __u32 pb_op_flags;
252         __u32 pb_conn_cnt;
253         __u32 pb_timeout;  /* for req, the deadline, for rep, the service est */
254         __u32 pb_service_time; /* for rep, actual service time */
255         __u32 pb_limit;
256         __u64 pb_slv;
257         /* VBR: pre-versions */
258         __u64 pb_pre_versions[PTLRPC_NUM_VERSIONS];
259         /* padding for future needs */
260         __u64 pb_padding[4];
261 };
262
263 extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb, int msgsize);
264
265 /* message body offset for lustre_msg_v2 */
266 /* ptlrpc body offset in all request/reply messages */
267 #define MSG_PTLRPC_BODY_OFF             0
268
269 /* normal request/reply message record offset */
270 #define REQ_REC_OFF                     1
271 #define REPLY_REC_OFF                   1
272
273 /* ldlm request message body offset */
274 #define DLM_LOCKREQ_OFF                 1 /* lockreq offset */
275 #define DLM_REQ_REC_OFF                 2 /* normal dlm request record offset */
276
277 /* ldlm intent lock message body offset */
278 #define DLM_INTENT_IT_OFF               2 /* intent lock it offset */
279 #define DLM_INTENT_REC_OFF              3 /* intent lock record offset */
280
281 /* ldlm reply message body offset */
282 #define DLM_LOCKREPLY_OFF               1 /* lockrep offset */
283 #define DLM_REPLY_REC_OFF               2 /* reply record offset */
284
285 /* only use in req->rq_{req,rep}_swab_mask */
286 #define MSG_PTLRPC_HEADER_OFF           31
287
288 /* Flags that are operation-specific go in the top 16 bits. */
289 #define MSG_OP_FLAG_MASK   0xffff0000
290 #define MSG_OP_FLAG_SHIFT  16
291
292 /* Flags that apply to all requests are in the bottom 16 bits */
293 #define MSG_GEN_FLAG_MASK      0x0000ffff
294 #define MSG_LAST_REPLAY        1
295 #define MSG_RESENT             2
296 #define MSG_REPLAY             4
297 /* #define MSG_AT_SUPPORT         8  avoid until 1.10+ */
298 #define MSG_DELAY_REPLAY       0x10
299 #define MSG_VERSION_REPLAY     0x20
300
301 /*
302  * Flags for all connect opcodes (MDS_CONNECT, OST_CONNECT)
303  */
304
305 #define MSG_CONNECT_RECOVERING  0x00000001
306 #define MSG_CONNECT_RECONNECT   0x00000002
307 #define MSG_CONNECT_REPLAYABLE  0x00000004
308 //#define MSG_CONNECT_PEER        0x8
309 #define MSG_CONNECT_LIBCLIENT   0x00000010
310 #define MSG_CONNECT_INITIAL     0x00000020
311 #define MSG_CONNECT_ASYNC       0x00000040
312 #define MSG_CONNECT_NEXT_VER    0x00000080 /* use next version of lustre_msg */
313 #define MSG_CONNECT_TRANSNO     0x00000100
314 #define MSG_CONNECT_DELAYED     0x00000200
315
316 /* Connect flags */
317 #define OBD_CONNECT_RDONLY            0x1ULL /*client allowed read-only access*/
318 #define OBD_CONNECT_INDEX             0x2ULL /*connect to specific LOV idx */
319 #define OBD_CONNECT_MDS               0x4ULL /*connect from MDT to OST */
320 #define OBD_CONNECT_GRANT             0x8ULL /*OSC acquires grant at connect */
321 #define OBD_CONNECT_SRVLOCK          0x10ULL /*server takes locks for client */
322 #define OBD_CONNECT_VERSION          0x20ULL /*Lustre versions in ocd */
323 #define OBD_CONNECT_REQPORTAL        0x40ULL /*Separate non-IO request portal */
324 #define OBD_CONNECT_ACL              0x80ULL /*access control lists */
325 #define OBD_CONNECT_XATTR           0x100ULL /*client use extended attributes */
326 #define OBD_CONNECT_CROW            0x200ULL /*MDS+OST create objects on write*/
327 #define OBD_CONNECT_TRUNCLOCK       0x400ULL /*locks on server for punch */
328 #define OBD_CONNECT_TRANSNO         0x800ULL /*replay sends initial transno */
329 #define OBD_CONNECT_IBITS          0x1000ULL /*support for inodebits locks */
330 #define OBD_CONNECT_JOIN           0x2000ULL /*files can be concatenated */
331 #define OBD_CONNECT_ATTRFID        0x4000ULL /*Server supports GetAttr By Fid */
332 #define OBD_CONNECT_NODEVOH        0x8000ULL /*No open handle on special nodes*/
333 #define OBD_CONNECT_LCL_CLIENT    0x10000ULL /*local 1.8 client */
334 #define OBD_CONNECT_RMT_CLIENT    0x20000ULL /*Remote 1.8 client */
335 #define OBD_CONNECT_BRW_SIZE      0x40000ULL /*Max bytes per rpc */
336 #define OBD_CONNECT_QUOTA64       0x80000ULL /*64bit qunit_data.qd_count */
337 #define OBD_CONNECT_MDS_CAPA     0x100000ULL /*MDS capability */
338 #define OBD_CONNECT_OSS_CAPA     0x200000ULL /*OSS capability */
339 #define OBD_CONNECT_CANCELSET    0x400000ULL /*Early batched cancels. */
340 #define OBD_CONNECT_SOM        0x00800000ULL /*Size on MDS */
341 #define OBD_CONNECT_AT         0x01000000ULL /*client uses adaptive timeouts */
342 #define OBD_CONNECT_LRU_RESIZE 0x02000000ULL /*Lru resize feature. */
343 #define OBD_CONNECT_MDS_MDS    0x04000000ULL /*MDS-MDS connection */
344 #define OBD_CONNECT_REAL       0x08000000ULL /*real connection */
345 #define OBD_CONNECT_CHANGE_QS  0x10000000ULL /*shrink/enlarge qunit b=10600 */
346 #define OBD_CONNECT_CKSUM      0x20000000ULL /*support several cksum algos */
347 #define OBD_CONNECT_FID        0x40000000ULL /* FID is supported */
348 #define OBD_CONNECT_VBR        0x80000000ULL /* version based recovery */
349 #define OBD_CONNECT_LOV_V3    0x100000000ULL /* client supports lov v3 ea */
350 /* also update obd_connect_names[] for lprocfs_rd_connect_flags()
351  * and lustre/utils/wirecheck.c */
352
353 #ifdef HAVE_LRU_RESIZE_SUPPORT
354 #define LRU_RESIZE_CONNECT_FLAG OBD_CONNECT_LRU_RESIZE
355 #else
356 #define LRU_RESIZE_CONNECT_FLAG 0
357 #endif
358
359 #define MDS_CONNECT_SUPPORTED  (OBD_CONNECT_RDONLY | OBD_CONNECT_VERSION | \
360                                 OBD_CONNECT_ACL | OBD_CONNECT_XATTR | \
361                                 OBD_CONNECT_IBITS | OBD_CONNECT_JOIN | \
362                                 OBD_CONNECT_NODEVOH | OBD_CONNECT_ATTRFID | \
363                                 OBD_CONNECT_CANCELSET | OBD_CONNECT_AT | \
364                                 LRU_RESIZE_CONNECT_FLAG | OBD_CONNECT_VBR |\
365                                 OBD_CONNECT_LOV_V3)
366 #define OST_CONNECT_SUPPORTED  (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \
367                                 OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \
368                                 OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_INDEX | \
369                                 OBD_CONNECT_BRW_SIZE | OBD_CONNECT_QUOTA64 | \
370                                 OBD_CONNECT_CANCELSET | OBD_CONNECT_AT | \
371                                 LRU_RESIZE_CONNECT_FLAG | OBD_CONNECT_CKSUM | \
372                                 OBD_CONNECT_VBR | OBD_CONNECT_CHANGE_QS | \
373                                 OBD_CONNECT_MDS)
374 #define ECHO_CONNECT_SUPPORTED (0)
375 #define MGS_CONNECT_SUPPORTED  (OBD_CONNECT_VERSION | OBD_CONNECT_AT)
376
377 #define OBD_OCD_VERSION(major,minor,patch,fix) (((major)<<24) + ((minor)<<16) +\
378                                                 ((patch)<<8) + (fix))
379 #define OBD_OCD_VERSION_MAJOR(version) ((int)((version)>>24)&255)
380 #define OBD_OCD_VERSION_MINOR(version) ((int)((version)>>16)&255)
381 #define OBD_OCD_VERSION_PATCH(version) ((int)((version)>>8)&255)
382 #define OBD_OCD_VERSION_FIX(version)   ((int)(version)&255)
383
384 /* This structure is used for both request and reply.
385  *
386  * If we eventually have separate connect data for different types, which we
387  * almost certainly will, then perhaps we stick a union in here. */
388 struct obd_connect_data {
389         __u64 ocd_connect_flags;        /* OBD_CONNECT_* per above */
390         __u32 ocd_version;              /* lustre release version number */
391         __u32 ocd_grant;                /* initial cache grant amount (bytes) */
392         __u32 ocd_index;                /* LOV index to connect to */
393         __u32 ocd_brw_size;             /* Maximum BRW size in bytes */
394         __u64 ocd_ibits_known;          /* inode bits this client understands */
395         __u32 ocd_nllu;                 /* non-local-lustre-user */
396         __u32 ocd_nllg;                 /* non-local-lustre-group */
397         __u64 ocd_transno;              /* Used in lustre 1.8 */
398         __u32 ocd_group;                /* Used in lustre 1.8 */
399         __u32 ocd_cksum_types;          /* supported checksum algorithms */
400         __u64 padding1;                 /* also fix lustre_swab_connect */
401         __u64 padding2;                 /* also fix lustre_swab_connect */
402 };
403
404 extern void lustre_swab_connect(struct obd_connect_data *ocd);
405
406 /* b1_6 has smaller body. The defines below is for interoperability */
407 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2,0,0,0)
408 #define PTLRPC_INTEROP_1_6      1
409 #define PTLRPC_BODY_MIN_SIZE    offsetof(struct ptlrpc_body, pb_pre_versions)
410 #else
411 #define PTLRPC_BODY_MIN_SIZE    sizeof(struct ptlrpc_body)
412 #endif
413
414 /*
415  * Supported checksum algorithms. Up to 32 checksum types are supported.
416  * (32-bit mask stored in obd_connect_data::ocd_cksum_types)
417  * Please update DECLARE_CKSUM_NAME/OBD_CKSUM_ALL in obd.h when adding a new
418  * algorithm and also the OBD_FL_CKSUM* flags.
419  */
420 typedef enum {
421         OBD_CKSUM_CRC32 = 0x00000001,
422         OBD_CKSUM_ADLER = 0x00000002,
423 } cksum_type_t;
424
425 /*
426  *   OST requests: OBDO & OBD request records
427  */
428
429 /* opcodes */
430 typedef enum {
431         OST_REPLY      =  0,       /* reply ? */
432         OST_GETATTR    =  1,
433         OST_SETATTR    =  2,
434         OST_READ       =  3,
435         OST_WRITE      =  4,
436         OST_CREATE     =  5,
437         OST_DESTROY    =  6,
438         OST_GET_INFO   =  7,
439         OST_CONNECT    =  8,
440         OST_DISCONNECT =  9,
441         OST_PUNCH      = 10,
442         OST_OPEN       = 11,
443         OST_CLOSE      = 12,
444         OST_STATFS     = 13,
445 /*      OST_SAN_READ   = 14,    deprecated */
446 /*      OST_SAN_WRITE  = 15,    deprecated */
447         OST_SYNC       = 16,
448         OST_SET_INFO   = 17,
449         OST_QUOTACHECK = 18,
450         OST_QUOTACTL   = 19,
451         OST_QUOTA_ADJUST_QUNIT = 20,
452         OST_LAST_OPC
453 } ost_cmd_t;
454 #define OST_FIRST_OPC  OST_REPLY
455
456 typedef __u64 obd_id;
457 typedef __u64 obd_gr;
458 typedef __u64 obd_time;
459 typedef __u64 obd_size;
460 typedef __u64 obd_off;
461 typedef __u64 obd_blocks;
462 typedef __u64 obd_valid;
463 typedef __u32 obd_blksize;
464 typedef __u32 obd_mode;
465 typedef __u32 obd_uid;
466 typedef __u32 obd_gid;
467 typedef __u32 obd_flag;
468 typedef __u32 obd_count;
469
470 #define OBD_FL_INLINEDATA    (0x00000001)
471 #define OBD_FL_OBDMDEXISTS   (0x00000002)
472 #define OBD_FL_DELORPHAN     (0x00000004) /* if set in o_flags delete orphans */
473 #define OBD_FL_NORPC         (0x00000008) /* set in o_flags do in OSC not OST */
474 #define OBD_FL_IDONLY        (0x00000010) /* set in o_flags only adjust obj id*/
475 #define OBD_FL_RECREATE_OBJS (0x00000020) /* recreate missing obj */
476 #define OBD_FL_DEBUG_CHECK   (0x00000040) /* echo client/server debug check */
477 #define OBD_FL_NO_USRQUOTA   (0x00000100) /* the object's owner is over quota */
478 #define OBD_FL_NO_GRPQUOTA   (0x00000200) /* the object's group is over quota */
479 #define OBD_FL_CREATE_CROW   (0x00000400) /* object should be create on write */
480
481 /*
482  * set this to delegate DLM locking during obd_punch() to the OSTs. Only OSTs
483  * that declared OBD_CONNECT_TRUNCLOCK in their connect flags support this
484  * functionality.
485  */
486 #define OBD_FL_TRUNCLOCK     (0x00000800)
487
488 /*
489  * Checksum types
490  */
491 #define OBD_FL_CKSUM_CRC32    (0x00001000)
492 #define OBD_FL_CKSUM_ADLER    (0x00002000)
493 #define OBD_FL_CKSUM_ALL      (OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER)
494
495 #define LOV_MAGIC_V1      0x0BD10BD0
496 #define LOV_MAGIC         LOV_MAGIC_V1
497 #define LOV_MAGIC_JOIN    0x0BD20BD0
498 #define LOV_MAGIC_V3      0x0BD30BD0
499
500 #define LOV_PATTERN_RAID0 0x001   /* stripes are used round-robin */
501 #define LOV_PATTERN_RAID1 0x002   /* stripes are mirrors of each other */
502 #define LOV_PATTERN_FIRST 0x100   /* first stripe is not in round-robin */
503 #define LOV_PATTERN_CMOBD 0x200
504
505 #define LOV_OBJECT_GROUP_DEFAULT ~0ULL
506 #define LOV_OBJECT_GROUP_CLEAR 0ULL
507
508 #define lov_ost_data lov_ost_data_v1
509 struct lov_ost_data_v1 {          /* per-stripe data structure (little-endian)*/
510         __u64 l_object_id;        /* OST object ID */
511         __u64 l_object_gr;        /* OST object group (creating MDS number) */
512         __u32 l_ost_gen;          /* generation of this l_ost_idx */
513         __u32 l_ost_idx;          /* OST index in LOV (lov_tgt_desc->tgts) */
514 };
515
516 #define lov_mds_md lov_mds_md_v1
517 struct lov_mds_md_v1 {            /* LOV EA mds/wire data (little-endian) */
518         __u32 lmm_magic;          /* magic number = LOV_MAGIC_V1 */
519         __u32 lmm_pattern;        /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
520         __u64 lmm_object_id;      /* LOV object ID */
521         __u64 lmm_object_gr;      /* LOV object group */
522         __u32 lmm_stripe_size;    /* size of stripe in bytes */
523         __u32 lmm_stripe_count;   /* num stripes in use for this object */
524         struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */
525 };
526
527 struct lov_mds_md_v3 {            /* LOV EA mds/wire data (little-endian) */
528         __u32 lmm_magic;          /* magic number = LOV_MAGIC_V3 */
529         __u32 lmm_pattern;        /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
530         __u64 lmm_object_id;      /* LOV object ID */
531         __u64 lmm_object_gr;      /* LOV object group */
532         __u32 lmm_stripe_size;    /* size of stripe in bytes */
533         __u32 lmm_stripe_count;   /* num stripes in use for this object */
534         char  lmm_pool_name[LOV_MAXPOOLNAME]; /* must be 32bit aligned */
535         struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */
536 };
537
538
539 #define OBD_MD_FLID        (0x00000001ULL) /* object ID */
540 #define OBD_MD_FLATIME     (0x00000002ULL) /* access time */
541 #define OBD_MD_FLMTIME     (0x00000004ULL) /* data modification time */
542 #define OBD_MD_FLCTIME     (0x00000008ULL) /* change time */
543 #define OBD_MD_FLSIZE      (0x00000010ULL) /* size */
544 #define OBD_MD_FLBLOCKS    (0x00000020ULL) /* allocated blocks count */
545 #define OBD_MD_FLBLKSZ     (0x00000040ULL) /* block size */
546 #define OBD_MD_FLMODE      (0x00000080ULL) /* access bits (mode & ~S_IFMT) */
547 #define OBD_MD_FLTYPE      (0x00000100ULL) /* object type (mode & S_IFMT) */
548 #define OBD_MD_FLUID       (0x00000200ULL) /* user ID */
549 #define OBD_MD_FLGID       (0x00000400ULL) /* group ID */
550 #define OBD_MD_FLFLAGS     (0x00000800ULL) /* flags word */
551 #define OBD_MD_FLNLINK     (0x00002000ULL) /* link count */
552 #define OBD_MD_FLGENER     (0x00004000ULL) /* generation number */
553 /*#define OBD_MD_FLINLINE      (0x00008000ULL) inline data. used until 1.6.5 */
554 #define OBD_MD_FLRDEV      (0x00010000ULL) /* device number */
555 #define OBD_MD_FLEASIZE    (0x00020000ULL) /* extended attribute data */
556 #define OBD_MD_LINKNAME    (0x00040000ULL) /* symbolic link target */
557 #define OBD_MD_FLHANDLE    (0x00080000ULL) /* file/lock handle */
558 #define OBD_MD_FLCKSUM     (0x00100000ULL) /* bulk data checksum */
559 #define OBD_MD_FLQOS       (0x00200000ULL) /* quality of service stats */
560 #define OBD_MD_FLOSCOPQ    (0x00400000ULL) /* osc opaque data */
561 #define OBD_MD_FLCOOKIE    (0x00800000ULL) /* log cancellation cookie */
562 #define OBD_MD_FLGROUP     (0x01000000ULL) /* group */
563 #define OBD_MD_FLFID       (0x02000000ULL) /* ->ost write inline fid */
564 #define OBD_MD_FLEPOCH     (0x04000000ULL) /* ->ost write easize is epoch */
565 #define OBD_MD_FLGRANT     (0x08000000ULL) /* ost preallocation space grant */
566 #define OBD_MD_FLDIREA     (0x10000000ULL) /* dir's extended attribute data */
567 #define OBD_MD_FLUSRQUOTA  (0x20000000ULL) /* over quota flags sent from ost */
568 #define OBD_MD_FLGRPQUOTA  (0x40000000ULL) /* over quota flags sent from ost */
569 #define OBD_MD_FLMODEASIZE (0x80000000ULL) /* EA size will be changed */
570
571 #define OBD_MD_MDS         (0x0000000100000000ULL) /* where an inode lives on */
572 #define OBD_MD_REINT       (0x0000000200000000ULL) /* reintegrate oa */
573 #define OBD_MD_MEA         (0x0000000400000000ULL) /* CMD split EA  */
574
575 #define OBD_MD_FLXATTR     (0x0000001000000000ULL) /* xattr */
576 #define OBD_MD_FLXATTRLS   (0x0000002000000000ULL) /* xattr list */
577 #define OBD_MD_FLXATTRRM   (0x0000004000000000ULL) /* xattr remove */
578 #define OBD_MD_FLACL       (0x0000008000000000ULL) /* ACL */
579 #define OBD_MD_FLRMTPERM   (0x0000010000000000ULL) /* remote permission */
580 #define OBD_MD_FLMDSCAPA   (0x0000020000000000ULL) /* MDS capability */
581 #define OBD_MD_FLOSSCAPA   (0x0000040000000000ULL) /* OSS capability */
582 #define OBD_MD_FLCKSPLIT   (0x0000080000000000ULL) /* Check split on server */
583 #define OBD_MD_FLCROSSREF  (0x0000100000000000ULL) /* Cross-ref case */
584
585
586 #define OBD_MD_FLGETATTR (OBD_MD_FLID    | OBD_MD_FLATIME | OBD_MD_FLMTIME | \
587                           OBD_MD_FLCTIME | OBD_MD_FLSIZE  | OBD_MD_FLBLKSZ | \
588                           OBD_MD_FLMODE  | OBD_MD_FLTYPE  | OBD_MD_FLUID   | \
589                           OBD_MD_FLGID   | OBD_MD_FLFLAGS | OBD_MD_FLNLINK | \
590                           OBD_MD_FLGENER | OBD_MD_FLRDEV  | OBD_MD_FLGROUP)
591
592
593 /* don't forget obdo_fid which is way down at the bottom so it can
594  * come after the definition of llog_cookie */
595
596 struct obd_statfs {
597         __u64           os_type;
598         __u64           os_blocks;
599         __u64           os_bfree;
600         __u64           os_bavail;
601         __u64           os_files;
602         __u64           os_ffree;
603         __u8            os_fsid[40];
604         __u32           os_bsize;
605         __u32           os_namelen;
606         __u64           os_maxbytes;
607         __u32           os_state;       /* positive error code on server */
608         __u32           os_spare1;
609         __u32           os_spare2;
610         __u32           os_spare3;
611         __u32           os_spare4;
612         __u32           os_spare5;
613         __u32           os_spare6;
614         __u32           os_spare7;
615         __u32           os_spare8;
616         __u32           os_spare9;
617 };
618
619 extern void lustre_swab_obd_statfs (struct obd_statfs *os);
620 #define OBD_STATFS_NODELAY      0x0001  /* requests should be send without delay
621                                          * and resends for avoid deadlocks */
622
623 #define OBD_STATFS_FROM_CACHE   0x0002  /* the statfs callback should not update
624                                          * obd_osfs_age */
625
626 /* ost_body.data values for OST_BRW */
627
628 #define OBD_BRW_READ            0x01
629 #define OBD_BRW_WRITE           0x02
630 #define OBD_BRW_RWMASK          (OBD_BRW_READ | OBD_BRW_WRITE)
631 #define OBD_BRW_SYNC            0x08
632 #define OBD_BRW_CHECK           0x10
633 #define OBD_BRW_FROM_GRANT      0x20 /* the osc manages this under llite */
634 #define OBD_BRW_GRANTED         0x40 /* the ost manages this */
635 #define OBD_BRW_DROP            0x80 /* drop the page after IO */
636 #define OBD_BRW_NOQUOTA        0x100
637 #define OBD_BRW_SRVLOCK        0x200 /* Client holds no lock over this page */
638
639 #define OBD_OBJECT_EOF 0xffffffffffffffffULL
640
641 #define OST_MIN_PRECREATE 32
642 #define OST_MAX_PRECREATE 20000
643
644 struct obd_ioobj {
645         obd_id               ioo_id;
646         obd_gr               ioo_gr;
647         __u32                ioo_type;
648         __u32                ioo_bufcnt;
649 };
650
651 extern void lustre_swab_obd_ioobj (struct obd_ioobj *ioo);
652
653 /* multiple of 8 bytes => can array */
654 struct niobuf_remote {
655         __u64 offset;
656         __u32 len;
657         __u32 flags;
658 };
659
660 extern void lustre_swab_niobuf_remote (struct niobuf_remote *nbr);
661
662 /* lock value block communicated between the filter and llite */
663
664 /* OST_LVB_ERR_INIT is needed because the return code in rc is 
665  * negative, i.e. because ((MASK + rc) & MASK) != MASK. */
666 #define OST_LVB_ERR_INIT 0xffbadbad80000000ULL
667 #define OST_LVB_ERR_MASK 0xffbadbad00000000ULL
668 #define OST_LVB_IS_ERR(blocks)                                          \
669         ((blocks & OST_LVB_ERR_MASK) == OST_LVB_ERR_MASK)
670 #define OST_LVB_SET_ERR(blocks, rc)                                     \
671         do { blocks = OST_LVB_ERR_INIT + rc; } while (0)
672 #define OST_LVB_GET_ERR(blocks)    (int)(blocks - OST_LVB_ERR_INIT)
673
674 struct ost_lvb {
675         __u64 lvb_size;
676         __u64 lvb_mtime;
677         __u64 lvb_atime;
678         __u64 lvb_ctime;
679         __u64 lvb_blocks;
680 };
681
682 extern void lustre_swab_ost_lvb(struct ost_lvb *);
683
684 /*
685  *   MDS REQ RECORDS
686  */
687
688 /* opcodes */
689 typedef enum {
690         MDS_GETATTR      = 33,
691         MDS_GETATTR_NAME = 34,
692         MDS_CLOSE        = 35,
693         MDS_REINT        = 36,
694         MDS_READPAGE     = 37,
695         MDS_CONNECT      = 38,
696         MDS_DISCONNECT   = 39,
697         MDS_GETSTATUS    = 40,
698         MDS_STATFS       = 41,
699         MDS_PIN          = 42,
700         MDS_UNPIN        = 43,
701         MDS_SYNC         = 44,
702         MDS_DONE_WRITING = 45,
703         MDS_SET_INFO     = 46,
704         MDS_QUOTACHECK   = 47,
705         MDS_QUOTACTL     = 48,
706         MDS_GETXATTR     = 49,
707         MDS_SETXATTR     = 50,
708         MDS_LAST_OPC
709 } mds_cmd_t;
710
711 #define MDS_FIRST_OPC    MDS_GETATTR
712
713 /*
714  * Do not exceed 63
715  */
716
717 typedef enum {
718         REINT_SETATTR  = 1,
719         REINT_CREATE   = 2,
720         REINT_LINK     = 3,
721         REINT_UNLINK   = 4,
722         REINT_RENAME   = 5,
723         REINT_OPEN     = 6,
724         REINT_SETXATTR = 7,
725 //      REINT_CLOSE    = 8,
726 //      REINT_WRITE    = 9,
727         REINT_MAX
728 } mds_reint_t;
729
730 /* the disposition of the intent outlines what was executed */
731 #define DISP_IT_EXECD        0x00000001
732 #define DISP_LOOKUP_EXECD    0x00000002
733 #define DISP_LOOKUP_NEG      0x00000004
734 #define DISP_LOOKUP_POS      0x00000008
735 #define DISP_OPEN_CREATE     0x00000010
736 #define DISP_OPEN_OPEN       0x00000020
737 #define DISP_ENQ_COMPLETE    0x00400000
738 #define DISP_ENQ_OPEN_REF    0x00800000
739 #define DISP_ENQ_CREATE_REF  0x01000000
740 #define DISP_OPEN_LOCK       0x02000000
741
742 /* INODE LOCK PARTS */
743 #define MDS_INODELOCK_LOOKUP 0x000001       /* dentry, mode, owner, group */
744 #define MDS_INODELOCK_UPDATE 0x000002       /* size, links, timestamps */
745 #define MDS_INODELOCK_OPEN   0x000004       /* For opened files */
746
747 /* Do not forget to increase MDS_INODELOCK_MAXSHIFT when adding new bits */
748 #define MDS_INODELOCK_MAXSHIFT 2
749 /* This FULL lock is useful to take on unlink sort of operations */
750 #define MDS_INODELOCK_FULL ((1<<(MDS_INODELOCK_MAXSHIFT+1))-1)
751
752 extern void lustre_swab_ll_fid (struct ll_fid *fid);
753
754 struct lu_fid {
755         __u64 f_seq;  /* holds fid sequence. Lustre should support 2^64
756                        * objects, thus even if one sequence has one object we
757                        * reach this value. */
758         __u32 f_oid;  /* fid number within its sequence. */
759         __u32 f_ver;  /* holds fid version. */
760 };
761
762 #define DFID "[0x%16.16"LPF64"x/0x%8.8x:0x%8.8x]"
763
764 #define PFID(fid)     \
765         fid_seq(fid), \
766         fid_oid(fid), \
767         fid_ver(fid)
768
769 enum { 
770         /** put FID sequence at this offset in ldlm_res_id. */
771         LUSTRE_RES_ID_SEQ_OFF = 0,
772         /** put FID oid at this offset in ldlm_res_id. */
773         LUSTRE_RES_ID_OID_OFF = 1,
774         /** put FID version at this offset in ldlm_res_id. */
775         LUSTRE_RES_ID_VER_OFF = 2,
776         /** put pdo hash at this offset in ldlm_res_id. */
777         LUSTRE_RES_ID_HSH_OFF = 3
778 };
779
780 typedef __u64 seqno_t;
781
782 /**
783  * Describes a range of sequence, lsr_start is included but lsr_end is
784  * not in the range.
785  */
786 struct lu_seq_range {
787         __u64 lsr_start;
788         __u64 lsr_end;
789         /** this feild is not used in 1.8 client interop */
790         __u32 lsr_mdt;
791         __u32 lsr_padding;
792 };
793
794 /**
795  * returns  width of given range \a r
796  */
797
798 static inline __u64 range_space(const struct lu_seq_range *r)
799 {
800         return r->lsr_end - r->lsr_start;
801 }
802
803 /**
804  * initialize range to zero
805  */
806 static inline void range_init(struct lu_seq_range *r)
807 {
808         r->lsr_start = r->lsr_end = 0;
809 }
810
811 /**
812  * check if given seq id \a s is within given range \a r
813  */
814 static inline int range_within(const struct lu_seq_range *r,
815                                __u64 s)
816 {
817         return s >= r->lsr_start && s < r->lsr_end;
818 }
819
820 /**
821  * sanity check for range \a r
822  */
823 static inline int range_is_sane(const struct lu_seq_range *r)
824 {
825         return (r->lsr_end >= r->lsr_start);
826 }
827
828 static inline int range_is_zero(struct lu_seq_range *r)
829 {
830         return (r->lsr_start == 0 && r->lsr_end == 0);
831 }
832
833 static inline int range_is_exhausted(const struct lu_seq_range *r)
834 {
835         return range_space(r) == 0;
836 }
837
838 #define DRANGE "[%#16.16"LPF64"x-%#16.16"LPF64"x)"
839
840 #define PRANGE(range)      \
841         (range)->lsr_start, \
842         (range)->lsr_end
843
844 enum {
845         /*
846          * This is how may FIDs may be allocated in one sequence.
847          */
848         LUSTRE_SEQ_MAX_WIDTH = 0x0000000000004000ULL,
849 };
850
851 enum lu_cli_type {
852         LUSTRE_SEQ_METADATA,
853         LUSTRE_SEQ_DATA
854 };
855
856 struct lu_client_seq {
857         /* Sequence-controller export. */
858         struct obd_export      *lcs_exp;
859         struct semaphore        lcs_sem;
860
861         /*
862          * Range of allowed for allocation sequences. When using lu_client_seq
863          * on clients, this contains meta-sequence range. And for servers this
864          * contains super-sequence range.
865          */
866         struct lu_seq_range         lcs_space;
867
868         /* This holds last allocated fid in last obtained seq */
869         struct lu_fid           lcs_fid;
870
871         /* LUSTRE_SEQ_METADATA or LUSTRE_SEQ_DATA */
872         enum lu_cli_type        lcs_type;
873         /*
874          * Service uuid, passed from MDT + seq name to form unique seq name to
875          * use it with procfs.
876          */
877         char                    lcs_name[80];
878
879         /*
880          * Sequence width, that is how many objects may be allocated in one
881          * sequence. Default value for it is LUSTRE_SEQ_MAX_WIDTH.
882          */
883         __u64                   lcs_width;
884
885 };
886
887 /*
888  * fid constants
889  */
890 enum {
891         /* initial fid id value */
892         LUSTRE_FID_INIT_OID  = 1UL
893 };
894
895 extern void lustre_swab_lu_fid(struct lu_fid *fid);
896
897 /* get object sequence */
898 static inline __u64 fid_seq(const struct lu_fid *fid)
899 {
900         return fid->f_seq;
901 }
902
903 /* get object id */
904 static inline __u32 fid_oid(const struct lu_fid *fid)
905 {
906         return fid->f_oid;
907 }
908
909 /* get object version */
910 static inline __u32 fid_ver(const struct lu_fid *fid)
911 {
912         return fid->f_ver;
913 }
914
915 static inline void fid_init(struct lu_fid *fid)
916 {
917         memset(fid, 0, sizeof(*fid));
918 }
919
920 /* Normal FID sequence starts from this value, i.e. 1<<33 */
921 #define FID_SEQ_START  0x200000000ULL
922
923 /* IDIF sequence starts from this value, i.e. 1<<32 */
924 #define IDIF_SEQ_START 0x100000000ULL
925
926 /**
927  * Check if a fid is igif or not.
928  * \param fid the fid to be tested.
929  * \return true if the fid is a igif; otherwise false. 
930  */
931 static inline int fid_is_igif(const struct lu_fid *fid)
932 {
933         return fid_seq(fid) > 0 && fid_seq(fid) < IDIF_SEQ_START;
934 }
935
936 /**
937  * Check if a fid is idif or not.
938  * \param fid the fid to be tested.
939  * \return true if the fid is a idif; otherwise false. 
940  */
941 static inline int fid_is_idif(const struct lu_fid *fid)
942 {
943         return fid_seq(fid) >= IDIF_SEQ_START  && fid_seq(fid) < FID_SEQ_START;
944 }
945
946 /**
947  * Check if a fid is zero.
948  * \param fid the fid to be tested.
949  * \return true if the fid is zero; otherwise false. 
950  */
951 static inline int fid_is_zero(const struct lu_fid *fid)
952 {
953         return fid_seq(fid) == 0 && fid_oid(fid) == 0;
954 }
955
956 /**
957  * Get inode number from a igif.
958  * \param fid a igif to get inode number from.
959  * \return inode number for the igif.
960  */
961 static inline ino_t lu_igif_ino(const struct lu_fid *fid)
962 {
963         return fid_seq(fid);
964 }
965
966 /**
967  * Get inode generation from a igif.
968  * \param fid a igif to get inode generation from.
969  * \return inode generation for the igif.
970  */ 
971 static inline __u32 lu_igif_gen(const struct lu_fid *fid)
972 {
973         return fid_oid(fid);
974 }
975
976 /**
977  * Check if two fids are equal or not.
978  * \param f0 the first fid
979  * \param f1 the second fid
980  * \return true if the two fids are equal; otherwise false. 
981  */
982 static inline int lu_fid_eq(const struct lu_fid *f0,
983                             const struct lu_fid *f1)
984 {
985         /* Check that there is no alignment padding. */
986         CLASSERT(sizeof *f0 ==
987                  sizeof f0->f_seq + sizeof f0->f_oid + sizeof f0->f_ver);
988         LASSERTF(fid_is_igif(f0) || fid_ver(f0) == 0, DFID"\n", PFID(f0));
989         LASSERTF(fid_is_igif(f1) || fid_ver(f1) == 0, DFID"\n", PFID(f1));
990         return memcmp(f0, f1, sizeof *f0) == 0;
991 }
992
993 void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src);
994 void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src);
995
996 struct ldlm_res_id *
997 fid_build_reg_res_name(const struct lu_fid *f, struct ldlm_res_id *name);
998 int fid_res_name_eq(const struct lu_fid *f, const struct ldlm_res_id *name);
999
1000 #define MDS_STATUS_CONN 1
1001 #define MDS_STATUS_LOV 2
1002
1003 struct mds_status_req {
1004         __u32  flags;
1005         __u32  repbuf;
1006 };
1007
1008 extern void lustre_swab_mds_status_req (struct mds_status_req *r);
1009
1010 #define MDS_BFLAG_UNCOMMITTED_WRITES   0x1
1011 #define MDS_BFLAG_EXT_FLAGS     0x80000000 /* == EXT3_RESERVED_FL */
1012
1013 /* these should be identical to their EXT3_*_FL counterparts, and are
1014  * redefined here only to avoid dragging in ext3_fs.h */
1015 #define MDS_SYNC_FL             0x00000008 /* Synchronous updates */
1016 #define MDS_IMMUTABLE_FL        0x00000010 /* Immutable file */
1017 #define MDS_APPEND_FL           0x00000020 /* writes to file may only append */
1018 #define MDS_NOATIME_FL          0x00000080 /* do not update atime */
1019 #define MDS_DIRSYNC_FL          0x00010000 /* dirsync behaviour (dir only) */
1020
1021 #ifdef __KERNEL__
1022 /* If MDS_BFLAG_IOC_FLAGS is set it means we requested EXT3_*_FL inode flags
1023  * and we need to decode these into local S_* flags in the inode.  Otherwise
1024  * we pass flags straight through (see bug 9486). */
1025 static inline int ll_ext_to_inode_flags(int flags)
1026 {
1027         return (flags & MDS_BFLAG_EXT_FLAGS) ?
1028                (((flags & MDS_SYNC_FL)      ? S_SYNC      : 0) |
1029                 ((flags & MDS_NOATIME_FL)   ? S_NOATIME   : 0) |
1030                 ((flags & MDS_APPEND_FL)    ? S_APPEND    : 0) |
1031 #if defined(S_DIRSYNC)
1032                 ((flags & MDS_DIRSYNC_FL)   ? S_DIRSYNC   : 0) |
1033 #endif
1034                 ((flags & MDS_IMMUTABLE_FL) ? S_IMMUTABLE : 0)) :
1035                (flags & ~MDS_BFLAG_EXT_FLAGS);
1036 }
1037
1038 /* If keep is set, we do not do anything with iflags, if it is not set, we
1039  * assume that iflags are inode flags and we need to conver those to
1040  * EXT3_*_FL flags (see bug 9486 and 12848) */
1041 static inline int ll_inode_to_ext_flags(int iflags, int keep)
1042 {
1043         return keep ? (iflags & ~MDS_BFLAG_EXT_FLAGS) :
1044                 (((iflags & S_SYNC)     ? MDS_SYNC_FL      : 0) |
1045                 ((iflags & S_NOATIME)   ? MDS_NOATIME_FL   : 0) |
1046                 ((iflags & S_APPEND)    ? MDS_APPEND_FL    : 0) |
1047 #if defined(S_DIRSYNC)
1048                 ((iflags & S_DIRSYNC)   ? MDS_DIRSYNC_FL   : 0) |
1049 #endif
1050                 ((iflags & S_IMMUTABLE) ? MDS_IMMUTABLE_FL : 0));
1051 }
1052 #endif
1053
1054 /*
1055  * while mds_body is to interact with 1.6, mdt_body is to interact with 2.0.
1056  * both of them should have the same fields layout, because at client side
1057  * one could be dynamically cast to the other.
1058  *
1059  * mdt_body has large size than mds_body, with unused padding (48 bytes)
1060  * at the end. client always use size of mdt_body to prepare request/reply
1061  * buffers, and actual data could be interepeted as mdt_body or mds_body
1062  * accordingly.
1063  */
1064 struct mds_body {
1065         struct ll_fid  fid1;
1066         struct ll_fid  fid2;
1067         struct lustre_handle handle;
1068         __u64          valid;
1069         __u64          size;   /* Offset, in the case of MDS_READPAGE */
1070         __u64          mtime;
1071         __u64          atime;
1072         __u64          ctime;
1073         __u64          blocks; /* XID, in the case of MDS_READPAGE */
1074         __u64          io_epoch;
1075         __u64          ino;
1076         __u32          fsuid;
1077         __u32          fsgid;
1078         __u32          capability;
1079         __u32          mode;
1080         __u32          uid;
1081         __u32          gid;
1082         __u32          flags; /* from vfs for pin/unpin, MDS_BFLAG for close */
1083         __u32          rdev;
1084         __u32          nlink; /* #bytes to read in the case of MDS_READPAGE */
1085         __u32          generation;
1086         __u32          suppgid;
1087         __u32          eadatasize;
1088         __u32          aclsize;
1089         __u32          max_mdsize;
1090         __u32          max_cookiesize; /* also fix lustre_swab_mds_body */
1091         __u32          padding_4; /* also fix lustre_swab_mds_body */
1092 };
1093
1094 extern void lustre_swab_mds_body (struct mds_body *b);
1095
1096 struct mdt_body {
1097         struct lu_fid  fid1;
1098         struct lu_fid  fid2;
1099         struct lustre_handle handle;
1100         __u64          valid;
1101         __u64          size;   /* Offset, in the case of MDS_READPAGE */
1102         __u64          mtime;
1103         __u64          atime;
1104         __u64          ctime;
1105         __u64          blocks; /* XID, in the case of MDS_READPAGE */
1106         __u64          ioepoch;
1107         __u64          ino;    /* for 1.6 compatibility */
1108         __u32          fsuid;
1109         __u32          fsgid;
1110         __u32          capability;
1111         __u32          mode;
1112         __u32          uid;
1113         __u32          gid;
1114         __u32          flags; /* from vfs for pin/unpin, MDS_BFLAG for close */
1115         __u32          rdev;
1116         __u32          nlink; /* #bytes to read in the case of MDS_READPAGE */
1117         __u32          generation; /* for 1.6 compatibility */
1118         __u32          suppgid;
1119         __u32          eadatasize;
1120         __u32          aclsize;
1121         __u32          max_mdsize;
1122         __u32          max_cookiesize;
1123         __u32          padding_4; /* also fix lustre_swab_mdt_body */
1124         __u64          padding_5;
1125         __u64          padding_6;
1126         __u64          padding_7;
1127         __u64          padding_8;
1128         __u64          padding_9;
1129         __u64          padding_10;
1130 };
1131
1132 #define Q_QUOTACHECK    0x800100
1133 #define Q_INITQUOTA     0x800101        /* init slave limits */
1134 #define Q_GETOINFO      0x800102        /* get obd quota info */
1135 #define Q_GETOQUOTA     0x800103        /* get obd quotas */
1136 #define Q_FINVALIDATE   0x800104        /* invalidate operational quotas */
1137
1138 #define Q_TYPEMATCH(id, type) \
1139         ((id) == (type) || (id) == UGQUOTA)
1140
1141 #define Q_TYPESET(oqc, type) Q_TYPEMATCH((oqc)->qc_type, type)
1142
1143 #define Q_GETOCMD(oqc) \
1144         ((oqc)->qc_cmd == Q_GETOINFO || (oqc)->qc_cmd == Q_GETOQUOTA)
1145
1146 struct obd_quotactl {
1147         __u32                   qc_cmd;
1148         __u32                   qc_type;
1149         __u32                   qc_id;
1150         __u32                   qc_stat;
1151         struct obd_dqinfo       qc_dqinfo;
1152         struct obd_dqblk        qc_dqblk;
1153 };
1154
1155 extern void lustre_swab_obd_quotactl(struct obd_quotactl *q);
1156
1157 struct quota_adjust_qunit {
1158         __u32 qaq_flags;
1159         __u32 qaq_id;
1160         __u64 qaq_bunit_sz;
1161         __u64 qaq_iunit_sz;
1162         __u64 padding1;
1163 };
1164 extern void lustre_swab_quota_adjust_qunit(struct quota_adjust_qunit *q);
1165
1166 /* flags in qunit_data and quota_adjust_qunit will use macroes below */
1167 #define LQUOTA_FLAGS_GRP       1UL   /* 0 is user, 1 is group */
1168 #define LQUOTA_FLAGS_BLK       2UL   /* 0 is inode, 1 is block */
1169 #define LQUOTA_FLAGS_ADJBLK    4UL   /* adjust the block qunit size */
1170 #define LQUOTA_FLAGS_ADJINO    8UL   /* adjust the inode qunit size */
1171 #define LQUOTA_FLAGS_CHG_QS   16UL   /* indicate whether it has capability of
1172                                       * OBD_CONNECT_CHANGE_QS */
1173
1174 /* the status of lqs_flags in struct lustre_qunit_size  */
1175 #define LQUOTA_QUNIT_FLAGS (LQUOTA_FLAGS_GRP | LQUOTA_FLAGS_BLK)
1176
1177 #define QAQ_IS_GRP(qaq)    ((qaq)->qaq_flags & LQUOTA_FLAGS_GRP)
1178 #define QAQ_IS_ADJBLK(qaq) ((qaq)->qaq_flags & LQUOTA_FLAGS_ADJBLK)
1179 #define QAQ_IS_ADJINO(qaq) ((qaq)->qaq_flags & LQUOTA_FLAGS_ADJINO)
1180
1181 #define QAQ_SET_GRP(qaq)    ((qaq)->qaq_flags |= LQUOTA_FLAGS_GRP)
1182 #define QAQ_SET_ADJBLK(qaq) ((qaq)->qaq_flags |= LQUOTA_FLAGS_ADJBLK)
1183 #define QAQ_SET_ADJINO(qaq) ((qaq)->qaq_flags |= LQUOTA_FLAGS_ADJINO)
1184
1185 struct mds_rec_setattr {
1186         __u32           sa_opcode;
1187         __u32           sa_fsuid;
1188         __u32           sa_fsgid;
1189         __u32           sa_cap;
1190         __u32           sa_suppgid;
1191         __u32           sa_mode;
1192         struct ll_fid   sa_fid;
1193         __u64           sa_valid; /* MDS_ATTR_* attributes */
1194         __u64           sa_size;
1195         __u64           sa_mtime;
1196         __u64           sa_atime;
1197         __u64           sa_ctime;
1198         __u32           sa_uid;
1199         __u32           sa_gid;
1200         __u32           sa_attr_flags;
1201         __u32           sa_padding; /* also fix lustre_swab_mds_rec_setattr */
1202 };
1203
1204 /*
1205  * Attribute flags used in mds_rec_setattr::sa_valid.
1206  * The kernel's #defines for ATTR_* should not be used over the network
1207  * since the client and MDS may run different kernels (see bug 13828)
1208  * Therefore, we should only use MDS_ATTR_* attributes for sa_valid.
1209  */
1210 #define MDS_ATTR_MODE          0x1ULL /* = 1 */
1211 #define MDS_ATTR_UID           0x2ULL /* = 2 */
1212 #define MDS_ATTR_GID           0x4ULL /* = 4 */
1213 #define MDS_ATTR_SIZE          0x8ULL /* = 8 */
1214 #define MDS_ATTR_ATIME        0x10ULL /* = 16 */
1215 #define MDS_ATTR_MTIME        0x20ULL /* = 32 */
1216 #define MDS_ATTR_CTIME        0x40ULL /* = 64 */
1217 #define MDS_ATTR_ATIME_SET    0x80ULL /* = 128 */
1218 #define MDS_ATTR_MTIME_SET   0x100ULL /* = 256 */
1219 #define MDS_ATTR_FORCE       0x200ULL /* = 512, Not a change, but a change it */
1220 #define MDS_ATTR_ATTR_FLAG   0x400ULL /* = 1024 */
1221 #define MDS_ATTR_KILL_SUID   0x800ULL /* = 2048 */
1222 #define MDS_ATTR_KILL_SGID  0x1000ULL /* = 4096 */
1223 #define MDS_ATTR_CTIME_SET  0x2000ULL /* = 8192 */
1224 #define MDS_ATTR_FROM_OPEN  0x4000ULL /* = 16384, called from open path, ie O_TRUNC */
1225 #define MDS_ATTR_BLOCKS     0x8000ULL /* = 32768 */
1226
1227 extern void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa);
1228
1229 #ifndef FMODE_READ
1230 #define FMODE_READ               00000001
1231 #define FMODE_WRITE              00000002
1232 #endif
1233 #define MDS_FMODE_EXEC           00000004
1234 #define MDS_OPEN_CREAT           00000100
1235 #define MDS_OPEN_EXCL            00000200
1236 #define MDS_OPEN_TRUNC           00001000
1237 #define MDS_OPEN_APPEND          00002000
1238 #define MDS_OPEN_SYNC            00010000
1239 #define MDS_OPEN_DIRECTORY       00200000
1240
1241 #define MDS_OPEN_DELAY_CREATE  0100000000 /* delay initial object create */
1242 #define MDS_OPEN_OWNEROVERRIDE 0200000000 /* NFSD rw-reopen ro file for owner */
1243 #define MDS_OPEN_JOIN_FILE     0400000000 /* open for join file*/
1244 #define MDS_OPEN_LOCK         04000000000 /* This open requires open lock */
1245 #define MDS_OPEN_HAS_EA      010000000000 /* specify object create pattern */
1246 #define MDS_OPEN_HAS_OBJS    020000000000 /* Just set the EA the obj exist */
1247
1248 struct mds_rec_create {
1249         __u32           cr_opcode;
1250         __u32           cr_fsuid;
1251         __u32           cr_fsgid;
1252         __u32           cr_cap;
1253         __u32           cr_flags; /* for use with open */
1254         __u32           cr_mode;
1255         struct ll_fid   cr_fid;
1256         struct ll_fid   cr_replayfid;
1257         __u64           cr_time;
1258         __u64           cr_rdev;
1259         __u32           cr_suppgid;
1260         __u32           cr_padding_1; /* also fix lustre_swab_mds_rec_create */
1261         __u32           cr_padding_2; /* also fix lustre_swab_mds_rec_create */
1262         __u32           cr_padding_3; /* also fix lustre_swab_mds_rec_create */
1263         __u32           cr_padding_4; /* also fix lustre_swab_mds_rec_create */
1264         __u32           cr_padding_5; /* also fix lustre_swab_mds_rec_create */
1265 };
1266
1267 extern void lustre_swab_mds_rec_create (struct mds_rec_create *cr);
1268
1269 struct mdt_rec_create {
1270         __u32           cr_opcode;
1271         __u32           cr_cap;
1272         __u32           cr_fsuid;
1273         __u32           cr_fsuid_h;
1274         __u32           cr_fsgid;
1275         __u32           cr_fsgid_h;
1276         __u32           cr_suppgid1;
1277         __u32           cr_suppgid1_h;
1278         __u32           cr_suppgid2;
1279         __u32           cr_suppgid2_h;
1280         struct lu_fid   cr_fid1;
1281         struct lu_fid   cr_fid2;
1282         struct lustre_handle cr_old_handle; /* handle in case of open replay */
1283         __u64           cr_time;
1284         __u64           cr_rdev;
1285         __u64           cr_ioepoch;
1286         __u64           cr_padding_1; /* pad for 64 bits*/
1287         __u32           cr_mode;
1288         __u32           cr_bias;
1289         __u32           cr_flags;     /* for use with open */
1290         __u32           cr_padding_2; /* pad for 64 bits*/
1291         __u32           cr_padding_3; /* pad for 64 bits*/
1292         __u32           cr_padding_4; /* pad for 64 bits*/
1293 };
1294
1295 struct mdt_epoch {
1296         struct lustre_handle handle;
1297         __u64  ioepoch;
1298         __u32  flags;
1299         __u32  padding;
1300 };
1301
1302 struct mds_rec_join {
1303         struct ll_fid  jr_fid;
1304         __u64          jr_headsize;
1305 };
1306
1307 extern void lustre_swab_mds_rec_join (struct mds_rec_join *jr);
1308
1309 struct mdt_rec_join {
1310         struct lu_fid  jr_fid;
1311         __u64          jr_headsize;
1312 };
1313
1314
1315 struct mds_rec_link {
1316         __u32           lk_opcode;
1317         __u32           lk_fsuid;
1318         __u32           lk_fsgid;
1319         __u32           lk_cap;
1320         __u32           lk_suppgid1;
1321         __u32           lk_suppgid2;
1322         struct ll_fid   lk_fid1;
1323         struct ll_fid   lk_fid2;
1324         __u64           lk_time;
1325         __u32           lk_padding_1;  /* also fix lustre_swab_mds_rec_link */
1326         __u32           lk_padding_2;  /* also fix lustre_swab_mds_rec_link */
1327         __u32           lk_padding_3;  /* also fix lustre_swab_mds_rec_link */
1328         __u32           lk_padding_4;  /* also fix lustre_swab_mds_rec_link */
1329 };
1330
1331 extern void lustre_swab_mds_rec_link (struct mds_rec_link *lk);
1332
1333 struct mdt_rec_link {
1334         __u32           lk_opcode;
1335         __u32           lk_cap;
1336         __u32           lk_fsuid;
1337         __u32           lk_fsuid_h;
1338         __u32           lk_fsgid;
1339         __u32           lk_fsgid_h;
1340         __u32           lk_suppgid1;
1341         __u32           lk_suppgid1_h;
1342         __u32           lk_suppgid2;
1343         __u32           lk_suppgid2_h;
1344         struct lu_fid   lk_fid1;
1345         struct lu_fid   lk_fid2;
1346         __u64           lk_time;
1347         __u64           lk_padding_1;
1348         __u64           lk_padding_2;
1349         __u64           lk_padding_3;
1350         __u64           lk_padding_4;
1351         __u32           lk_bias;
1352         __u32           lk_padding_5;
1353         __u32           lk_padding_6;
1354         __u32           lk_padding_7;
1355         __u32           lk_padding_8;
1356         __u32           lk_padding_9;
1357 };
1358
1359 struct mds_rec_unlink {
1360         __u32           ul_opcode;
1361         __u32           ul_fsuid;
1362         __u32           ul_fsgid;
1363         __u32           ul_cap;
1364         __u32           ul_suppgid;
1365         __u32           ul_mode;
1366         struct ll_fid   ul_fid1;
1367         struct ll_fid   ul_fid2;
1368         __u64           ul_time;
1369         __u32           ul_padding_1; /* also fix lustre_swab_mds_rec_unlink */
1370         __u32           ul_padding_2; /* also fix lustre_swab_mds_rec_unlink */
1371         __u32           ul_padding_3; /* also fix lustre_swab_mds_rec_unlink */
1372         __u32           ul_padding_4; /* also fix lustre_swab_mds_rec_unlink */
1373 };
1374
1375 extern void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul);
1376
1377 struct mdt_rec_unlink {
1378         __u32           ul_opcode;
1379         __u32           ul_cap;
1380         __u32           ul_fsuid;
1381         __u32           ul_fsuid_h;
1382         __u32           ul_fsgid;
1383         __u32           ul_fsgid_h;
1384         __u32           ul_suppgid1;
1385         __u32           ul_suppgid1_h;
1386         __u32           ul_padding2;
1387         __u32           ul_padding2_h;
1388         struct lu_fid   ul_fid1;
1389         struct lu_fid   ul_fid2;
1390         __u64           ul_time;
1391         __u64           ul_padding_2;
1392         __u64           ul_padding_3;
1393         __u64           ul_padding_4;
1394         __u64           ul_padding_5;
1395         __u32           ul_bias;
1396         __u32           ul_mode;
1397         __u32           ul_padding_6;
1398         __u32           ul_padding_7;
1399         __u32           ul_padding_8;
1400         __u32           ul_padding_9;
1401 };
1402
1403 struct mds_rec_rename {
1404         __u32           rn_opcode;
1405         __u32           rn_fsuid;
1406         __u32           rn_fsgid;
1407         __u32           rn_cap;
1408         __u32           rn_suppgid1;
1409         __u32           rn_suppgid2;
1410         struct ll_fid   rn_fid1;
1411         struct ll_fid   rn_fid2;
1412         __u64           rn_time;
1413         __u32           rn_padding_1; /* also fix lustre_swab_mds_rec_rename */
1414         __u32           rn_padding_2; /* also fix lustre_swab_mds_rec_rename */
1415         __u32           rn_padding_3; /* also fix lustre_swab_mds_rec_rename */
1416         __u32           rn_padding_4; /* also fix lustre_swab_mds_rec_rename */
1417 };
1418
1419 extern void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn);
1420
1421 struct mdt_rec_rename {
1422         __u32           rn_opcode;
1423         __u32           rn_cap;
1424         __u32           rn_fsuid;
1425         __u32           rn_fsuid_h;
1426         __u32           rn_fsgid;
1427         __u32           rn_fsgid_h;
1428         __u32           rn_suppgid1;
1429         __u32           rn_suppgid1_h;
1430         __u32           rn_suppgid2;
1431         __u32           rn_suppgid2_h;
1432         struct lu_fid   rn_fid1;
1433         struct lu_fid   rn_fid2;
1434         __u64           rn_time;
1435         __u64           rn_padding_1;
1436         __u64           rn_padding_2;
1437         __u64           rn_padding_3;
1438         __u64           rn_padding_4;
1439         __u32           rn_bias;      /* some operation flags */
1440         __u32           rn_mode;      /* cross-ref rename has mode */
1441         __u32           rn_padding_5;
1442         __u32           rn_padding_6;
1443         __u32           rn_padding_7;
1444         __u32           rn_padding_8;
1445 };
1446
1447 struct mdt_rec_setattr {
1448         __u32           sa_opcode;
1449         __u32           sa_cap;
1450         __u32           sa_fsuid;
1451         __u32           sa_fsuid_h;
1452         __u32           sa_fsgid;
1453         __u32           sa_fsgid_h;
1454         __u32           sa_suppgid;
1455         __u32           sa_suppgid_h;
1456         __u32           sa_padding_1;
1457         __u32           sa_padding_1_h;
1458         struct lu_fid   sa_fid;
1459         __u64           sa_valid;
1460         __u32           sa_uid;
1461         __u32           sa_gid;
1462         __u64           sa_size;
1463         __u64           sa_blocks;
1464         __u64           sa_mtime;
1465         __u64           sa_atime;
1466         __u64           sa_ctime;
1467         __u32           sa_attr_flags;
1468         __u32           sa_mode;
1469         __u32           sa_padding_2;
1470         __u32           sa_padding_3;
1471         __u32           sa_padding_4;
1472         __u32           sa_padding_5;
1473 };
1474
1475 struct mdt_rec_setxattr {
1476         __u32           sx_opcode;
1477         __u32           sx_cap;
1478         __u32           sx_fsuid;
1479         __u32           sx_fsuid_h;
1480         __u32           sx_fsgid;
1481         __u32           sx_fsgid_h;
1482         __u32           sx_suppgid1;
1483         __u32           sx_suppgid1_h;
1484         __u32           sx_suppgid2;
1485         __u32           sx_suppgid2_h;
1486         struct lu_fid   sx_fid;
1487         __u64           sx_padding_1; /* These three members are lu_fid size */
1488         __u32           sx_padding_2;
1489         __u32           sx_padding_3;
1490         __u64           sx_valid;
1491         __u64           sx_padding_4;
1492         __u64           sx_padding_5;
1493         __u64           sx_padding_6;
1494         __u64           sx_padding_7;
1495         __u32           sx_size;
1496         __u32           sx_flags;
1497         __u32           sx_padding_8;
1498         __u32           sx_padding_9;
1499         __u32           sx_padding_10;
1500         __u32           sx_padding_11;
1501 };
1502
1503 /*
1504  * capa related definitions
1505  */
1506 #define CAPA_HMAC_MAX_LEN       64
1507 #define CAPA_HMAC_KEY_MAX_LEN   56
1508
1509 /* NB take care when changing the sequence of elements this struct,
1510  * because the offset info is used in find_capa() */
1511 struct lustre_capa {
1512         struct lu_fid   lc_fid;         /** fid */
1513         __u64           lc_opc;         /** operations allowed */
1514         __u64           lc_uid;         /** file owner */
1515         __u64           lc_gid;         /** file group */
1516         __u32           lc_flags;       /** HMAC algorithm & flags */
1517         __u32           lc_keyid;       /** key# used for the capability */
1518         __u32           lc_timeout;     /** capa timeout value (sec) */
1519         __u32           lc_expiry;      /** expiry time (sec) */
1520         __u8            lc_hmac[CAPA_HMAC_MAX_LEN];   /** HMAC */
1521 } __attribute__((packed));
1522
1523 /*
1524  *  LOV data structures
1525  */
1526
1527 #define LOV_MIN_STRIPE_BITS 16   /* maximum PAGE_SIZE (ia64), power of 2 */
1528 #define LOV_MIN_STRIPE_SIZE (1<<LOV_MIN_STRIPE_BITS)
1529 #define LOV_MAX_STRIPE_COUNT  160   /* until bug 4424 is fixed */
1530 #define LOV_V1_INSANE_STRIPE_COUNT 65532 /* maximum stripe count bz13933 */
1531
1532 #define LOV_MAX_UUID_BUFFER_SIZE  8192
1533 /* The size of the buffer the lov/mdc reserves for the
1534  * array of UUIDs returned by the MDS.  With the current
1535  * protocol, this will limit the max number of OSTs per LOV */
1536
1537 #define LOV_DESC_MAGIC 0xB0CCDE5C
1538
1539 /* LOV settings descriptor (should only contain static info) */
1540 struct lov_desc {
1541         __u32 ld_tgt_count;                /* how many OBD's */
1542         __u32 ld_active_tgt_count;         /* how many active */
1543         __u32 ld_default_stripe_count;     /* how many objects are used */
1544         __u32 ld_pattern;                  /* default PATTERN_RAID0 */
1545         __u64 ld_default_stripe_size;      /* in bytes */
1546         __u64 ld_default_stripe_offset;    /* in bytes */
1547         __u32 ld_padding_0;                /* unused */
1548         __u32 ld_qos_maxage;               /* in second */
1549         __u32 ld_padding_1;                /* also fix lustre_swab_lov_desc */
1550         __u32 ld_padding_2;                /* also fix lustre_swab_lov_desc */
1551         struct obd_uuid ld_uuid;
1552 };
1553
1554 #define ld_magic ld_active_tgt_count       /* for swabbing from llogs */
1555
1556 extern void lustre_swab_lov_desc (struct lov_desc *ld);
1557
1558 /*
1559  *   LDLM requests:
1560  */
1561 /* opcodes -- MUST be distinct from OST/MDS opcodes */
1562 typedef enum {
1563         LDLM_ENQUEUE     = 101,
1564         LDLM_CONVERT     = 102,
1565         LDLM_CANCEL      = 103,
1566         LDLM_BL_CALLBACK = 104,
1567         LDLM_CP_CALLBACK = 105,
1568         LDLM_GL_CALLBACK = 106,
1569         LDLM_LAST_OPC
1570 } ldlm_cmd_t;
1571 #define LDLM_FIRST_OPC LDLM_ENQUEUE
1572
1573 #define RES_NAME_SIZE 4
1574 struct ldlm_res_id {
1575         __u64 name[RES_NAME_SIZE];
1576 };
1577
1578 extern void lustre_swab_ldlm_res_id (struct ldlm_res_id *id);
1579
1580 /* lock types */
1581 typedef enum {
1582         LCK_MINMODE = 0,
1583         LCK_EX = 1,
1584         LCK_PW = 2,
1585         LCK_PR = 4,
1586         LCK_CW = 8,
1587         LCK_CR = 16,
1588         LCK_NL = 32,
1589         LCK_GROUP = 64,
1590         LCK_MAXMODE
1591 } ldlm_mode_t;
1592
1593 #define LCK_MODE_NUM    7
1594
1595 typedef enum {
1596         LDLM_PLAIN     = 10,
1597         LDLM_EXTENT    = 11,
1598         LDLM_FLOCK     = 12,
1599         LDLM_IBITS     = 13,
1600         LDLM_MAX_TYPE
1601 } ldlm_type_t;
1602
1603 #define LDLM_MIN_TYPE LDLM_PLAIN
1604
1605 struct ldlm_extent {
1606         __u64 start;
1607         __u64 end;
1608         __u64 gid;
1609 };
1610
1611 static inline int ldlm_extent_overlap(struct ldlm_extent *ex1,
1612                                       struct ldlm_extent *ex2)
1613 {
1614         return (ex1->start <= ex2->end) && (ex2->start <= ex1->end);
1615 }
1616
1617 struct ldlm_inodebits {
1618         __u64 bits;
1619 };
1620
1621 struct ldlm_flock {
1622         __u64 start;
1623         __u64 end;
1624         __u64 blocking_export;  /* not actually used over the wire */
1625         __u32 blocking_pid;     /* not actually used over the wire */
1626         __u32 pid;
1627 };
1628
1629 /* it's important that the fields of the ldlm_extent structure match
1630  * the first fields of the ldlm_flock structure because there is only
1631  * one ldlm_swab routine to process the ldlm_policy_data_t union. if
1632  * this ever changes we will need to swab the union differently based
1633  * on the resource type. */
1634
1635 typedef union {
1636         struct ldlm_extent l_extent;
1637         struct ldlm_flock  l_flock;
1638         struct ldlm_inodebits l_inodebits;
1639 } ldlm_policy_data_t;
1640
1641 extern void lustre_swab_ldlm_policy_data (ldlm_policy_data_t *d);
1642
1643 struct ldlm_intent {
1644         __u64 opc;
1645 };
1646
1647 extern void lustre_swab_ldlm_intent (struct ldlm_intent *i);
1648
1649 struct ldlm_resource_desc {
1650         ldlm_type_t lr_type;
1651         __u32 lr_padding;       /* also fix lustre_swab_ldlm_resource_desc */
1652         struct ldlm_res_id lr_name;
1653 };
1654
1655 extern void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r);
1656
1657 struct ldlm_lock_desc {
1658         struct ldlm_resource_desc l_resource;
1659         ldlm_mode_t l_req_mode;
1660         ldlm_mode_t l_granted_mode;
1661         ldlm_policy_data_t l_policy_data;
1662 };
1663
1664 extern void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l);
1665
1666 #define LDLM_LOCKREQ_HANDLES 2
1667 #define LDLM_ENQUEUE_CANCEL_OFF 1
1668
1669 struct ldlm_request {
1670         __u32 lock_flags;
1671         __u32 lock_count;
1672         struct ldlm_lock_desc lock_desc;
1673         struct lustre_handle lock_handle[LDLM_LOCKREQ_HANDLES];
1674 };
1675
1676 /* If LDLM_ENQUEUE, 1 slot is already occupied, 1 is available.
1677  * Otherwise, 2 are available. */
1678 #define ldlm_request_bufsize(count,type)                                \
1679 ({                                                                      \
1680         int _avail = LDLM_LOCKREQ_HANDLES;                              \
1681         _avail -= (type == LDLM_ENQUEUE ? LDLM_ENQUEUE_CANCEL_OFF : 0); \
1682         sizeof(struct ldlm_request) +                                   \
1683         (count - _avail > 0 ? count - _avail : 0) *                     \
1684         sizeof(struct lustre_handle);                                   \
1685 })
1686
1687 extern void lustre_swab_ldlm_request (struct ldlm_request *rq);
1688
1689 struct ldlm_reply {
1690         __u32 lock_flags;
1691         __u32 lock_padding;     /* also fix lustre_swab_ldlm_reply */
1692         struct ldlm_lock_desc lock_desc;
1693         struct lustre_handle lock_handle;
1694         __u64  lock_policy_res1;
1695         __u64  lock_policy_res2;
1696 };
1697
1698 extern void lustre_swab_ldlm_reply (struct ldlm_reply *r);
1699
1700
1701 /*
1702  * Opcodes for mountconf (mgs and mgc)
1703  */
1704 typedef enum {
1705         MGS_CONNECT = 250,
1706         MGS_DISCONNECT,
1707         MGS_EXCEPTION,         /* node died, etc. */
1708         MGS_TARGET_REG,        /* whenever target starts up */
1709         MGS_TARGET_DEL,
1710         MGS_SET_INFO,
1711         MGS_LAST_OPC
1712 } mgs_cmd_t;
1713 #define MGS_FIRST_OPC MGS_CONNECT
1714
1715 #define MGS_PARAM_MAXLEN 1024
1716 #define KEY_SET_INFO "set_info"
1717
1718 struct mgs_send_param {
1719         char             mgs_param[MGS_PARAM_MAXLEN];
1720 };
1721
1722 /* We pass this info to the MGS so it can write config logs */
1723 #define MTI_NAME_MAXLEN 64
1724 #define MTI_PARAM_MAXLEN 4096
1725 #define MTI_NIDS_MAX 32
1726 struct mgs_target_info {
1727         __u32            mti_lustre_ver;
1728         __u32            mti_stripe_index;
1729         __u32            mti_config_ver;
1730         __u32            mti_flags;
1731         __u32            mti_nid_count;
1732         __u32            padding;                    /* 64 bit align */
1733         char             mti_fsname[MTI_NAME_MAXLEN];
1734         char             mti_svname[MTI_NAME_MAXLEN];
1735         char             mti_uuid[sizeof(struct obd_uuid)];
1736         __u64            mti_nids[MTI_NIDS_MAX];     /* host nids (lnet_nid_t)*/
1737         char             mti_params[MTI_PARAM_MAXLEN];
1738 };
1739
1740 extern void lustre_swab_mgs_target_info(struct mgs_target_info *oinfo);
1741
1742 /* Config marker flags (in config log) */
1743 #define CM_START       0x01
1744 #define CM_END         0x02
1745 #define CM_SKIP        0x04
1746 #define CM_UPGRADE146  0x08
1747 #define CM_EXCLUDE     0x10
1748 #define CM_START_SKIP (CM_START | CM_SKIP)
1749
1750 struct cfg_marker {
1751         __u32             cm_step;       /* aka config version */
1752         __u32             cm_flags;
1753         __u32             cm_vers;       /* lustre release version number */
1754         __u32             padding;       /* 64 bit align */
1755         __u64             cm_createtime; /*when this record was first created */
1756         __u64             cm_canceltime; /*when this record is no longer valid*/
1757         char              cm_tgtname[MTI_NAME_MAXLEN];
1758         char              cm_comment[MTI_NAME_MAXLEN];
1759 };
1760
1761 extern void lustre_swab_cfg_marker(struct cfg_marker *marker,
1762                                    int swab, int size);
1763
1764 /*
1765  * Opcodes for multiple servers.
1766  */
1767
1768 typedef enum {
1769         OBD_PING = 400,
1770         OBD_LOG_CANCEL,
1771         OBD_QC_CALLBACK,
1772         OBD_LAST_OPC
1773 } obd_cmd_t;
1774 #define OBD_FIRST_OPC OBD_PING
1775
1776 /* catalog of log objects */
1777
1778 /* Identifier for a single log object */
1779 struct llog_logid {
1780         __u64                   lgl_oid;
1781         __u64                   lgl_ogr;
1782         __u32                   lgl_ogen;
1783 } __attribute__((packed));
1784
1785 /* Records written to the CATALOGS list */
1786 #define CATLIST "CATALOGS"
1787 struct llog_catid {
1788         struct llog_logid       lci_logid;
1789         __u32                   lci_padding1;
1790         __u32                   lci_padding2;
1791         __u32                   lci_padding3;
1792 } __attribute__((packed));
1793
1794 /*join file lov mds md*/
1795 struct lov_mds_md_join {
1796         struct lov_mds_md lmmj_md;
1797         /*join private info*/
1798         struct llog_logid lmmj_array_id; /*array object id*/
1799         __u32  lmmj_extent_count;        /*array extent count*/
1800 };
1801
1802 /* Log data record types - there is no specific reason that these need to
1803  * be related to the RPC opcodes, but no reason not to (may be handy later?)
1804  */
1805 #define LLOG_OP_MAGIC 0x10600000
1806 #define LLOG_OP_MASK  0xfff00000
1807
1808 typedef enum {
1809         LLOG_PAD_MAGIC   = LLOG_OP_MAGIC | 0x00000,
1810         OST_SZ_REC       = LLOG_OP_MAGIC | 0x00f00,
1811         OST_RAID1_REC    = LLOG_OP_MAGIC | 0x01000,
1812         MDS_UNLINK_REC   = LLOG_OP_MAGIC | 0x10000 | (MDS_REINT << 8) | REINT_UNLINK,
1813         MDS_SETATTR_REC  = LLOG_OP_MAGIC | 0x10000 | (MDS_REINT << 8) | REINT_SETATTR,
1814         MDS_SETATTR64_REC= LLOG_OP_MAGIC | 0x90000 | (MDS_REINT << 8) | REINT_SETATTR,
1815         OBD_CFG_REC      = LLOG_OP_MAGIC | 0x20000,
1816         PTL_CFG_REC      = LLOG_OP_MAGIC | 0x30000, /* obsolete */
1817         LLOG_GEN_REC     = LLOG_OP_MAGIC | 0x40000,
1818         LLOG_JOIN_REC    = LLOG_OP_MAGIC | 0x50000,
1819         LLOG_HDR_MAGIC   = LLOG_OP_MAGIC | 0x45539,
1820         LLOG_LOGID_MAGIC = LLOG_OP_MAGIC | 0x4553b,
1821 } llog_op_type;
1822
1823 /*
1824  * for now, continue to support old pad records which have 0 for their
1825  * type but still need to be swabbed for their length
1826  */
1827 #define LLOG_REC_HDR_NEEDS_SWABBING(r)                                  \
1828         (((r)->lrh_type & __swab32(LLOG_OP_MASK)) ==                    \
1829          __swab32(LLOG_OP_MAGIC) ||                                     \
1830          (((r)->lrh_type == 0) && ((r)->lrh_len > LLOG_CHUNK_SIZE)))
1831
1832 /* Log record header - stored in little endian order.
1833  * Each record must start with this struct, end with a llog_rec_tail,
1834  * and be a multiple of 256 bits in size.
1835  */
1836 struct llog_rec_hdr {
1837         __u32                   lrh_len;
1838         __u32                   lrh_index;
1839         __u32                   lrh_type;
1840         __u32                   padding;
1841 };
1842
1843 struct llog_rec_tail {
1844         __u32 lrt_len;
1845         __u32 lrt_index;
1846 };
1847
1848 struct llog_logid_rec {
1849         struct llog_rec_hdr     lid_hdr;
1850         struct llog_logid       lid_id;
1851         __u32                   padding1;
1852         __u32                   padding2;
1853         __u32                   padding3;
1854         __u32                   padding4;
1855         __u32                   padding5;
1856         struct llog_rec_tail    lid_tail;
1857 } __attribute__((packed));
1858
1859 /* MDS extent description
1860  * It is for joined file extent info, each extent info for joined file
1861  * just like (start, end, lmm).
1862  */
1863 struct mds_extent_desc {
1864         __u64                   med_start; /* extent start */
1865         __u64                   med_len;   /* extent length */
1866         struct lov_mds_md       med_lmm;   /* extent's lmm  */
1867 };
1868 /*Joined file array extent log record*/
1869 struct llog_array_rec {
1870         struct llog_rec_hdr     lmr_hdr;
1871         struct mds_extent_desc  lmr_med;
1872         struct llog_rec_tail    lmr_tail;
1873 };
1874
1875 struct llog_create_rec {
1876         struct llog_rec_hdr     lcr_hdr;
1877         struct ll_fid           lcr_fid;
1878         obd_id                  lcr_oid;
1879         obd_count               lcr_ogr;
1880         __u32                   padding;
1881         struct llog_rec_tail    lcr_tail;
1882 } __attribute__((packed));
1883
1884 struct llog_orphan_rec {
1885         struct llog_rec_hdr     lor_hdr;
1886         obd_id                  lor_oid;
1887         obd_count               lor_ogen;
1888         __u32                   padding;
1889         struct llog_rec_tail    lor_tail;
1890 } __attribute__((packed));
1891
1892 struct llog_unlink_rec {
1893         struct llog_rec_hdr     lur_hdr;
1894         obd_id                  lur_oid;
1895         obd_count               lur_ogr;
1896         obd_count               lur_count; /* to destroy the lost precreated */
1897         struct llog_rec_tail    lur_tail;
1898 } __attribute__((packed));
1899
1900 struct llog_setattr_rec {
1901         struct llog_rec_hdr     lsr_hdr;
1902         obd_id                  lsr_oid;
1903         obd_count               lsr_ogr;
1904         __u32                   lsr_uid;
1905         __u32                   lsr_gid;
1906         __u32                   padding;
1907         struct llog_rec_tail    lsr_tail;
1908 } __attribute__((packed));
1909
1910 struct llog_setattr64_rec {
1911         struct llog_rec_hdr     lsr_hdr;
1912         obd_id                  lsr_oid;
1913         obd_count               lsr_ogr;
1914         __u32                   padding;
1915         __u32                   lsr_uid;
1916         __u32                   lsr_uid_h;
1917         __u32                   lsr_gid;
1918         __u32                   lsr_gid_h;
1919         struct llog_rec_tail    lsr_tail;
1920 } __attribute__((packed));
1921
1922 struct llog_size_change_rec {
1923         struct llog_rec_hdr     lsc_hdr;
1924         struct ll_fid           lsc_fid;
1925         __u32                   lsc_io_epoch;
1926         __u32                   padding;
1927         struct llog_rec_tail    lsc_tail;
1928 } __attribute__((packed));
1929
1930 struct llog_gen {
1931         __u64 mnt_cnt;
1932         __u64 conn_cnt;
1933 } __attribute__((packed));
1934
1935 struct llog_gen_rec {
1936         struct llog_rec_hdr     lgr_hdr;
1937         struct llog_gen         lgr_gen;
1938         struct llog_rec_tail    lgr_tail;
1939 };
1940 /* On-disk header structure of each log object, stored in little endian order */
1941 #define LLOG_CHUNK_SIZE         8192
1942 #define LLOG_HEADER_SIZE        (96)
1943 #define LLOG_BITMAP_BYTES       (LLOG_CHUNK_SIZE - LLOG_HEADER_SIZE)
1944
1945 #define LLOG_MIN_REC_SIZE       (24) /* round(llog_rec_hdr + llog_rec_tail) */
1946
1947 /* flags for the logs */
1948 #define LLOG_F_ZAP_WHEN_EMPTY   0x1
1949 #define LLOG_F_IS_CAT           0x2
1950 #define LLOG_F_IS_PLAIN         0x4
1951
1952 struct llog_log_hdr {
1953         struct llog_rec_hdr     llh_hdr;
1954         __u64                   llh_timestamp;
1955         __u32                   llh_count;
1956         __u32                   llh_bitmap_offset;
1957         __u32                   llh_size;
1958         __u32                   llh_flags;
1959         __u32                   llh_cat_idx;
1960         /* for a catalog the first plain slot is next to it */
1961         struct obd_uuid         llh_tgtuuid;
1962         __u32                   llh_reserved[LLOG_HEADER_SIZE/sizeof(__u32) - 23];
1963         __u32                   llh_bitmap[LLOG_BITMAP_BYTES/sizeof(__u32)];
1964         struct llog_rec_tail    llh_tail;
1965 } __attribute__((packed));
1966
1967 #define LLOG_BITMAP_SIZE(llh)  ((llh->llh_hdr.lrh_len -         \
1968                                  llh->llh_bitmap_offset -       \
1969                                  sizeof(llh->llh_tail)) * 8)
1970
1971 /* log cookies are used to reference a specific log file and a record therein */
1972 struct llog_cookie {
1973         struct llog_logid       lgc_lgl;
1974         __u32                   lgc_subsys;
1975         __u32                   lgc_index;
1976         __u32                   lgc_padding;
1977 } __attribute__((packed));
1978
1979 /* llog protocol */
1980 typedef enum {
1981         LLOG_ORIGIN_HANDLE_CREATE       = 501,
1982         LLOG_ORIGIN_HANDLE_NEXT_BLOCK   = 502,
1983         LLOG_ORIGIN_HANDLE_READ_HEADER  = 503,
1984         LLOG_ORIGIN_HANDLE_WRITE_REC    = 504,
1985         LLOG_ORIGIN_HANDLE_CLOSE        = 505,
1986         LLOG_ORIGIN_CONNECT             = 506,
1987         LLOG_CATINFO                    = 507,  /* for lfs catinfo */
1988         LLOG_ORIGIN_HANDLE_PREV_BLOCK   = 508,
1989         LLOG_ORIGIN_HANDLE_DESTROY      = 509,  /* for destroy llog object*/
1990         LLOG_LAST_OPC
1991 } llog_cmd_t;
1992 #define LLOG_FIRST_OPC LLOG_ORIGIN_HANDLE_CREATE
1993
1994 struct llogd_body {
1995         struct llog_logid  lgd_logid;
1996         __u32 lgd_ctxt_idx;
1997         __u32 lgd_llh_flags;
1998         __u32 lgd_index;
1999         __u32 lgd_saved_index;
2000         __u32 lgd_len;
2001         __u64 lgd_cur_offset;
2002 } __attribute__((packed));
2003
2004 struct llogd_conn_body {
2005         struct llog_gen         lgdc_gen;
2006         struct llog_logid       lgdc_logid;
2007         __u32                   lgdc_ctxt_idx;
2008 } __attribute__((packed));
2009
2010 struct lov_user_ost_data_join {   /* per-stripe data structure */
2011         __u64 l_extent_start;     /* extent start*/
2012         __u64 l_extent_end;       /* extent end*/
2013         __u64 l_object_id;        /* OST object ID */
2014         __u64 l_object_gr;        /* OST object group (creating MDS number) */
2015         __u32 l_ost_gen;          /* generation of this OST index */
2016         __u32 l_ost_idx;          /* OST index in LOV */
2017 } __attribute__((packed));
2018
2019 struct lov_user_md_join {         /* LOV EA user data (host-endian) */
2020         __u32 lmm_magic;          /* magic number = LOV_MAGIC_JOIN */
2021         __u32 lmm_pattern;        /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
2022         __u64 lmm_object_id;      /* LOV object ID */
2023         __u64 lmm_object_gr;      /* LOV object group */
2024         __u32 lmm_stripe_size;    /* size of stripe in bytes */
2025         __u32 lmm_stripe_count;   /* num stripes in use for this object */
2026         __u32 lmm_extent_count;   /* extent count of lmm*/
2027         __u64 lmm_tree_id;        /* mds tree object id */
2028         __u64 lmm_tree_gen;       /* mds tree object gen */
2029         struct llog_logid lmm_array_id; /* mds extent desc llog object id */
2030         struct lov_user_ost_data_join lmm_objects[0]; /* per-stripe data */
2031 } __attribute__((packed));
2032
2033
2034 struct obdo {
2035         obd_valid               o_valid;        /* hot fields in this obdo */
2036         obd_id                  o_id;
2037         obd_gr                  o_gr;
2038         obd_id                  o_fid;
2039         obd_size                o_size;         /* o_size-o_blocks == ost_lvb */
2040         obd_time                o_mtime;
2041         obd_time                o_atime;
2042         obd_time                o_ctime;
2043         obd_blocks              o_blocks;       /* brw: cli sent cached bytes */
2044         obd_size                o_grant;
2045
2046         /* 32-bit fields start here: keep an even number of them via padding */
2047         obd_blksize             o_blksize;      /* optimal IO blocksize */
2048         obd_mode                o_mode;         /* brw: cli sent cache remain */
2049         obd_uid                 o_uid;
2050         obd_gid                 o_gid;
2051         obd_flag                o_flags;
2052         obd_count               o_nlink;        /* brw: checksum */
2053         obd_count               o_generation;
2054         obd_count               o_misc;         /* brw: o_dropped */
2055         __u32                   o_easize;       /* epoch in ost writes */
2056         __u32                   o_mds;
2057         __u32                   o_stripe_idx;   /* holds stripe idx */
2058         __u32                   o_padding_1;
2059         struct lustre_handle    o_handle;       /* brw: lock handle to prolong locks */
2060         struct llog_cookie      o_lcookie;      /* destroy: unlink cookie from MDS */
2061
2062         __u64                   o_padding_2;
2063         __u64                   o_padding_3;
2064         __u64                   o_padding_4;
2065         __u64                   o_padding_5;
2066         __u64                   o_padding_6;
2067 };
2068
2069 #define o_dirty   o_blocks
2070 #define o_undirty o_mode
2071 #define o_dropped o_misc
2072 #define o_cksum   o_nlink
2073
2074 extern void lustre_swab_obdo (struct obdo *o);
2075
2076 /* request structure for OST's */
2077 struct ost_body {
2078         struct  obdo oa;
2079 };
2080
2081 /* Key for FIEMAP to be used in get_info calls */
2082 struct ll_fiemap_info_key {
2083         char    name[8];
2084         struct  obdo oa;
2085         struct  ll_user_fiemap fiemap;
2086 };
2087
2088 extern void lustre_swab_ost_body (struct ost_body *b);
2089 extern void lustre_swab_ost_last_id(obd_id *id);
2090 extern void lustre_swab_fiemap(struct ll_user_fiemap *fiemap);
2091
2092 extern void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum);
2093 extern void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum);
2094 extern void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod,
2095                                             int stripe_count);
2096 extern void lustre_swab_lov_user_md_join(struct lov_user_md_join *lumj);
2097
2098 /* llog_swab.c */
2099 extern void lustre_swab_llogd_body (struct llogd_body *d);
2100 extern void lustre_swab_llog_hdr (struct llog_log_hdr *h);
2101 extern void lustre_swab_llogd_conn_body (struct llogd_conn_body *d);
2102 extern void lustre_swab_llog_rec(struct llog_rec_hdr  *rec,
2103                                  struct llog_rec_tail *tail);
2104
2105 struct lustre_cfg;
2106 extern void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg);
2107
2108 /* this will be used when OBD_CONNECT_CHANGE_QS is set */
2109 struct qunit_data {
2110         __u32 qd_id;    /* ID appiles to (uid, gid) */
2111         __u32 qd_flags; /* LQUOTA_FLAGS_* affect the responding bits */
2112         __u64 qd_count; /* acquire/release count (bytes for block quota) */
2113         __u64 qd_qunit; /* when a master returns the reply to a slave, it will
2114                          * contain the current corresponding qunit size */
2115         __u64 padding;
2116 };
2117
2118 #define QDATA_IS_GRP(qdata)    ((qdata)->qd_flags & LQUOTA_FLAGS_GRP)
2119 #define QDATA_IS_BLK(qdata)    ((qdata)->qd_flags & LQUOTA_FLAGS_BLK)
2120 #define QDATA_IS_ADJBLK(qdata) ((qdata)->qd_flags & LQUOTA_FLAGS_ADJBLK)
2121 #define QDATA_IS_ADJINO(qdata) ((qdata)->qd_flags & LQUOTA_FLAGS_ADJINO)
2122 #define QDATA_IS_CHANGE_QS(qdata) ((qdata)->qd_flags & LQUOTA_FLAGS_CHG_QS)
2123
2124 #define QDATA_SET_GRP(qdata)    ((qdata)->qd_flags |= LQUOTA_FLAGS_GRP)
2125 #define QDATA_SET_BLK(qdata)    ((qdata)->qd_flags |= LQUOTA_FLAGS_BLK)
2126 #define QDATA_SET_ADJBLK(qdata) ((qdata)->qd_flags |= LQUOTA_FLAGS_ADJBLK)
2127 #define QDATA_SET_ADJINO(qdata) ((qdata)->qd_flags |= LQUOTA_FLAGS_ADJINO)
2128 #define QDATA_SET_CHANGE_QS(qdata) ((qdata)->qd_flags |= LQUOTA_FLAGS_CHG_QS)
2129
2130 #define QDATA_CLR_GRP(qdata)        ((qdata)->qd_flags &= ~LQUOTA_FLAGS_GRP)
2131 #define QDATA_CLR_CHANGE_QS(qdata)  ((qdata)->qd_flags &= ~LQUOTA_FLAGS_CHG_QS)
2132
2133 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 9, 0, 0)
2134 /* this will be used when OBD_CONNECT_QUOTA64 is set */
2135 struct qunit_data_old2 {
2136         __u32 qd_id; /* ID appiles to (uid, gid) */
2137         __u32 qd_flags; /* Quota type (USRQUOTA, GRPQUOTA) occupy one bit;
2138                          * Block quota or file quota occupy one bit */
2139         __u64 qd_count; /* acquire/release count (bytes for block quota) */
2140 };
2141 #else
2142 #warning "remove quota code above for format absolete in new release"
2143 #endif
2144
2145 extern void lustre_swab_qdata(struct qunit_data *d);
2146 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 9, 0, 0)
2147 extern void lustre_swab_qdata_old2(struct qunit_data_old2 *d);
2148 #else
2149 #warning "remove quota code above for format absolete in new release"
2150 #endif
2151 extern int quota_get_qdata(void*req, struct qunit_data *qdata,
2152                            int is_req, int is_exp);
2153 extern int quota_copy_qdata(void *request, struct qunit_data *qdata,
2154                             int is_req, int is_exp);
2155
2156 typedef enum {
2157         QUOTA_DQACQ     = 601,
2158         QUOTA_DQREL     = 602,
2159         QUOTA_LAST_OPC
2160 } quota_cmd_t;
2161 #define QUOTA_FIRST_OPC QUOTA_DQACQ
2162
2163
2164 enum seq_rpc_opc {
2165         SEQ_QUERY                       = 700,
2166         SEQ_LAST_OPC,
2167         SEQ_FIRST_OPC                   = SEQ_QUERY
2168 };
2169
2170 enum seq_op {
2171         SEQ_ALLOC_SUPER = 0,
2172         SEQ_ALLOC_META = 1
2173 };
2174
2175
2176 #define JOIN_FILE_ALIGN 4096
2177
2178 #define QUOTA_REQUEST   1
2179 #define QUOTA_REPLY     0
2180 #define QUOTA_EXPORT    1
2181 #define QUOTA_IMPORT    0
2182
2183 /* quota check function */
2184 #define QUOTA_RET_OK           0 /* return successfully */
2185 #define QUOTA_RET_NOQUOTA      1 /* not support quota */
2186 #define QUOTA_RET_NOLIMIT      2 /* quota limit isn't set */
2187 #define QUOTA_RET_ACQUOTA      4 /* need to acquire extra quota */
2188
2189 extern int quota_get_qunit_data_size(__u64 flag);
2190 #endif