Whamcloud - gitweb
land b_md onto HEAD. the highlights:
[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  *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  * (Un)packing of OST requests
22  */
23
24 #ifndef _LUSTRE_IDL_H_
25 #define _LUSTRE_IDL_H_
26
27 #ifdef __KERNEL__
28 # include <linux/ioctl.h>
29 # include <asm/types.h>
30 # include <linux/types.h>
31 # include <linux/list.h>
32 #else
33 # define __KERNEL__
34 # include <asm/types.h>
35 # include <linux/list.h>
36 # undef __KERNEL__
37 # include <stdint.h>
38 #endif
39 /*
40  * this file contains all data structures used in Lustre interfaces:
41  * - obdo and obd_request records
42  * - mds_request records
43  * - ldlm data
44  * - ioctl's
45  */
46
47 /*
48  *  GENERAL STUFF
49  */
50 typedef __u8 obd_uuid_t[37];
51
52 /* FOO_REQUEST_PORTAL is for incoming requests on the FOO
53  * FOO_REPLY_PORTAL   is for incoming replies on the FOO
54  * FOO_BULK_PORTAL    is for incoming bulk on the FOO
55  */
56
57 #define CONNMGR_REQUEST_PORTAL  1
58 #define CONNMGR_REPLY_PORTAL    2
59 #define OSC_REQUEST_PORTAL      3
60 #define OSC_REPLY_PORTAL        4
61 #define OSC_BULK_PORTAL         5
62 #define OST_REQUEST_PORTAL      6
63 #define OST_REPLY_PORTAL        7
64 #define OST_BULK_PORTAL         8
65 #define MDC_REQUEST_PORTAL      9
66 #define MDC_REPLY_PORTAL        10
67 #define MDC_BULK_PORTAL         11
68 #define MDS_REQUEST_PORTAL      12
69 #define MDS_REPLY_PORTAL        13
70 #define MDS_BULK_PORTAL         14
71 #define LDLM_CB_REQUEST_PORTAL     15
72 #define LDLM_CB_REPLY_PORTAL       16
73 #define LDLM_CANCEL_REQUEST_PORTAL     17
74 #define LDLM_CANCEL_REPLY_PORTAL       18
75
76 #define SVC_KILLED               1
77 #define SVC_EVENT                2
78 #define SVC_SIGNAL               4
79 #define SVC_RUNNING              8
80 #define SVC_STOPPING            16
81 #define SVC_STOPPED             32
82
83 #define LUSTRE_CONN_NEW          1
84 #define LUSTRE_CONN_CON          2
85 #define LUSTRE_CONN_RECOVD       3
86 #define LUSTRE_CONN_FULL         4
87
88 /* packet types */
89 #define PTL_RPC_MSG_REQUEST 4711
90 #define PTL_RPC_MSG_ERR     4712
91 #define PTL_RPC_MSG_REPLY   4713
92
93 #define PTLRPC_MSG_MAGIC (cpu_to_le32(0x0BD00BD0))
94 #define PTLRPC_MSG_VERSION (cpu_to_le32(0x00040001))
95
96 struct lustre_handle {
97         __u64 addr;
98         __u64 cookie;
99 };
100 #define DEAD_HANDLE_MAGIC 0xdeadbeefcafebabe
101
102 static inline void ptlrpc_invalidate_handle(struct lustre_handle *hdl)
103 {
104         hdl->addr = hdl->cookie = 0; /* XXX invalid enough? */
105 }
106
107 /* we depend on this structure to be 8-byte aligned */
108 struct lustre_msg {
109         __u64 addr;
110         __u64 cookie; /* security token */
111         __u32 magic;
112         __u32 type;
113         __u32 version;
114         __u32 opc;
115         __u64 last_xid;
116         __u64 last_committed;
117         __u64 transno;
118         __u32 status;
119         __u32 bufcount;
120         __u32 flags;
121         __u32 buflens[0];
122 };
123
124 /* Flags that are operation-specific go in the top 16 bits. */
125 #define MSG_OP_FLAG_MASK   0xffff0000
126 #define MSG_OP_FLAG_SHIFT  16
127
128 /* Flags that apply to all requests are in the bottom 16 bits */
129 #define MSG_GEN_FLAG_MASK  0x0000ffff
130 #define MSG_LAST_REPLAY    1
131
132 static inline int lustre_msg_get_flags(struct lustre_msg *msg)
133 {
134         return (msg->flags & MSG_GEN_FLAG_MASK);
135 }
136
137 static inline void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
138 {
139         msg->flags &= ~MSG_GEN_FLAG_MASK;
140         msg->flags |= MSG_GEN_FLAG_MASK & flags;
141 }
142
143 static inline int lustre_msg_get_op_flags(struct lustre_msg *msg)
144 {
145         return (msg->flags >> MSG_OP_FLAG_SHIFT);
146 }
147
148 static inline void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
149 {
150         msg->flags &= ~MSG_OP_FLAG_MASK;
151         msg->flags |= ((flags & MSG_GEN_FLAG_MASK) << MSG_OP_FLAG_SHIFT);
152 }
153
154 #define CONNMGR_REPLY   0
155 #define CONNMGR_CONNECT 1
156
157 /*
158  *   OST requests: OBDO & OBD request records
159  */
160
161 /* opcodes */
162 #define OST_REPLY       0        /* reply ? */
163 #define OST_GETATTR     1
164 #define OST_SETATTR     2
165 #define OST_READ        3
166 #define OST_WRITE       4
167 #define OST_CREATE      5
168 #define OST_DESTROY     6
169 #define OST_GET_INFO    7
170 #define OST_CONNECT     8
171 #define OST_DISCONNECT  9
172 #define OST_PUNCH      10
173 #define OST_OPEN       11
174 #define OST_CLOSE      12
175 #define OST_STATFS     13
176
177
178 typedef uint64_t        obd_id;
179 typedef uint64_t        obd_gr;
180 typedef uint64_t        obd_time;
181 typedef uint64_t        obd_size;
182 typedef uint64_t        obd_off;
183 typedef uint64_t        obd_blocks;
184 typedef uint32_t        obd_blksize;
185 typedef uint32_t        obd_mode;
186 typedef uint32_t        obd_uid;
187 typedef uint32_t        obd_gid;
188 typedef uint64_t        obd_rdev;
189 typedef uint32_t        obd_flag;
190 typedef uint32_t        obd_count;
191
192 #define OBD_FL_INLINEDATA       (0x00000001)
193 #define OBD_FL_OBDMDEXISTS      (0x00000002)
194
195 #define OBD_INLINESZ    60
196
197 /* Note: 64-bit types are 64-bit aligned in structure */
198 struct obdo {
199         obd_id                  o_id;
200         obd_gr                  o_gr;
201         obd_time                o_atime;
202         obd_time                o_mtime;
203         obd_time                o_ctime;
204         obd_size                o_size;
205         obd_blocks              o_blocks;
206         obd_rdev                o_rdev;
207         obd_blksize             o_blksize;
208         obd_mode                o_mode;
209         obd_uid                 o_uid;
210         obd_gid                 o_gid;
211         obd_flag                o_flags;
212         obd_count               o_nlink;
213         obd_count               o_generation;
214         obd_flag                o_valid;        /* hot fields in this obdo */
215         obd_flag                o_obdflags;
216         __u32                   o_easize;
217         char                    o_inline[OBD_INLINESZ];
218 };
219
220 struct lov_object_id { /* per-child structure */
221         __u64 l_object_id;
222 };
223
224 #define LOV_MAGIC  0x0BD00BD0
225
226 struct lov_mds_md {
227         __u32 lmm_magic;
228         __u32 lmm_unused;          /* was packed size of extended attribute */
229         __u64 lmm_object_id;       /* lov object id */
230         __u32 lmm_stripe_offset;   /* starting stripe offset in lmd_objects */
231         __u32 lmm_stripe_count;    /* number of stipes in use for this object */
232         __u64 lmm_stripe_size;     /* size of the stripe */
233         __u32 lmm_ost_count;       /* how many OST idx are in this LOV md */
234         __u32 lmm_stripe_pattern;  /* per-lov object stripe pattern */
235         struct lov_object_id lmm_objects[0];
236 };
237
238 #define OBD_MD_FLALL    (0xffffffff)
239 #define OBD_MD_FLID     (0x00000001)    /* object ID */
240 #define OBD_MD_FLATIME  (0x00000002)    /* access time */
241 #define OBD_MD_FLMTIME  (0x00000004)    /* data modification time */
242 #define OBD_MD_FLCTIME  (0x00000008)    /* change time */
243 #define OBD_MD_FLSIZE   (0x00000010)    /* size */
244 #define OBD_MD_FLBLOCKS (0x00000020)    /* allocated blocks count */
245 #define OBD_MD_FLBLKSZ  (0x00000040)    /* block size */
246 #define OBD_MD_FLMODE   (0x00000080)    /* access bits (mode & ~S_IFMT) */
247 #define OBD_MD_FLTYPE   (0x00000100)    /* object type (mode & S_IFMT) */
248 #define OBD_MD_FLUID    (0x00000200)    /* user ID */
249 #define OBD_MD_FLGID    (0x00000400)    /* group ID */
250 #define OBD_MD_FLFLAGS  (0x00000800)    /* flags word */
251 #define OBD_MD_FLOBDFLG (0x00001000)
252 #define OBD_MD_FLNLINK  (0x00002000)    /* link count */
253 #define OBD_MD_FLGENER  (0x00004000)    /* generation number */
254 #define OBD_MD_FLINLINE (0x00008000)    /* inline data */
255 #define OBD_MD_FLRDEV   (0x00010000)    /* device number */
256 #define OBD_MD_FLEASIZE (0x00020000)    /* extended attribute data */
257 #define OBD_MD_LINKNAME (0x00040000)    /* symbolic link target */
258 #define OBD_MD_FLHANDLE (0x00080000)    /* file handle */
259 #define OBD_MD_FLNOTOBD (~(OBD_MD_FLOBDFLG | OBD_MD_FLBLOCKS | OBD_MD_LINKNAME|\
260                            OBD_MD_FLEASIZE | OBD_MD_FLHANDLE))
261
262 struct obd_statfs {
263         __u64           os_type;
264         __u64           os_blocks;
265         __u64           os_bfree;
266         __u64           os_bavail;
267         __u64           os_files;
268         __u64           os_ffree;
269         __u8            os_fsid[40];
270         __u32           os_bsize;
271         __u32           os_namelen;
272         __u32           os_spare[12];
273 };
274
275 /* ost_body.data values for OST_BRW */
276
277 #define OBD_BRW_READ    0x1
278 #define OBD_BRW_WRITE   0x2
279 #define OBD_BRW_RWMASK  (OBD_BRW_READ | OBD_BRW_WRITE)
280 #define OBD_BRW_CREATE  0x4
281
282 #define OBD_OBJECT_EOF 0xffffffffffffffffULL
283
284 struct obd_ioobj {
285         obd_id               ioo_id;
286         obd_gr               ioo_gr;
287         __u32                ioo_type;
288         __u32                ioo_bufcnt;
289 };
290
291 struct niobuf_remote {
292         __u64 offset;
293         __u32 len;
294         __u32 xid;
295         __u32 flags;
296 };
297
298 #define CONNMGR_REPLY   0
299 #define CONNMGR_CONNECT 1
300
301 struct connmgr_body {
302         __u64 conn;
303         __u64 conn_token;
304         __u32 generation;
305         obd_uuid_t conn_uuid;
306 };
307
308 /* request structure for OST's */
309
310 #define OST_REQ_HAS_OA1  0x1
311
312 struct ost_body {
313         struct  obdo oa;
314 };
315
316 /*
317  *   MDS REQ RECORDS
318  */
319
320 /* opcodes */
321 #define MDS_GETATTR    1
322 #define MDS_OPEN       2
323 #define MDS_CLOSE      3
324 #define MDS_REINT      4
325 #define MDS_READPAGE   6
326 #define MDS_CONNECT    7
327 #define MDS_DISCONNECT 8
328 #define MDS_GETSTATUS  9
329 #define MDS_STATFS     10
330 #define MDS_GETLOVINFO 11
331
332 #define REINT_SETATTR  1
333 #define REINT_CREATE   2
334 #define REINT_LINK     3
335 #define REINT_UNLINK   4
336 #define REINT_RENAME   5
337 #define REINT_MAX      5
338
339 #define REINT_OPCODE_MASK 0xff /* opcodes must fit into this mask */
340 #define REINT_REPLAYING 0x1000 /* masked into the opcode to indicate replay */
341
342 struct ll_fid {
343         __u64 id;
344         __u32 generation;
345         __u32 f_type;
346 };
347
348
349 #define MDS_STATUS_CONN 1
350 #define MDS_STATUS_LOV 2
351
352 struct mds_status_req {
353         __u32  flags;
354         __u32  repbuf;
355 };
356
357 struct mds_fileh_body {
358         struct ll_fid f_fid;
359         struct lustre_handle f_handle;
360 };
361
362 struct mds_conn_status {
363         struct ll_fid rootfid;
364         __u64          xid;
365         __u64          last_committed;
366         __u64          last_rcvd;
367         /* XXX preallocated quota & obj fields here */
368 };
369
370 struct mds_body {
371         struct ll_fid  fid1;
372         struct ll_fid  fid2;
373         struct lustre_handle handle;
374         __u64          size;
375         __u32          ino;   /* make this a __u64 */
376         __u32          valid;
377         __u32          fsuid;
378         __u32          fsgid;
379         __u32          capability;
380         __u32          mode;
381         __u32          uid;
382         __u32          gid;
383         __u32          mtime;
384         __u32          ctime;
385         __u32          atime;
386         __u32          flags;
387         __u32          rdev;
388         __u32          nlink;
389         __u32          generation;
390 };
391
392 /* This is probably redundant with OBD_MD_FLEASIZE, but we need an audit */
393 #define MDS_OPEN_HAS_EA 1 /* this open has an EA, for a delayed create*/
394
395 /* MDS update records */
396
397
398 //struct mds_update_record_hdr {
399 //        __u32 ur_opcode;
400 //};
401
402 struct mds_rec_setattr {
403         __u32           sa_opcode;
404         __u32           sa_fsuid;
405         __u32           sa_fsgid;
406         __u32           sa_cap;
407         __u32           sa_reserved;
408         __u32           sa_valid;
409         struct ll_fid   sa_fid;
410         __u32           sa_mode;
411         __u32           sa_uid;
412         __u32           sa_gid;
413         __u32           sa_attr_flags;
414         __u64           sa_size;
415         __u64           sa_atime;
416         __u64           sa_mtime;
417         __u64           sa_ctime;
418 };
419
420 struct mds_rec_create {
421         __u32           cr_opcode;
422         __u32           cr_fsuid;
423         __u32           cr_fsgid;
424         __u32           cr_cap;
425         __u32           cr_reserved;
426         __u32           cr_mode;
427         struct ll_fid   cr_fid;
428         struct ll_fid   cr_replayfid;
429         __u32           cr_uid;
430         __u32           cr_gid;
431         __u64           cr_time;
432         __u64           cr_rdev;
433 };
434
435 struct mds_rec_link {
436         __u32           lk_opcode;
437         __u32           lk_fsuid;
438         __u32           lk_fsgid;
439         __u32           lk_cap;
440         struct ll_fid   lk_fid1;
441         struct ll_fid   lk_fid2;
442 };
443
444 struct mds_rec_unlink {
445         __u32           ul_opcode;
446         __u32           ul_fsuid;
447         __u32           ul_fsgid;
448         __u32           ul_cap;
449         __u32           ul_reserved;
450         __u32           ul_mode;
451         struct ll_fid   ul_fid1;
452         struct ll_fid   ul_fid2;
453 };
454
455 struct mds_rec_rename {
456         __u32           rn_opcode;
457         __u32           rn_fsuid;
458         __u32           rn_fsgid;
459         __u32           rn_cap;
460         struct ll_fid   rn_fid1;
461         struct ll_fid   rn_fid2;
462 };
463
464
465 /*
466  *  LOV data structures
467  */
468
469 #define LOV_RAID0   0
470 #define LOV_RAIDRR  1
471
472 struct lov_desc {
473         __u32 ld_tgt_count;                /* how many OBD's */
474         __u32 ld_active_tgt_count;         /* how many active */
475         __u32 ld_default_stripe_count;     /* how many objects are used */
476         __u64 ld_default_stripe_size;      /* in bytes */
477         __u64 ld_default_stripe_offset;    /* in bytes */
478         __u32 ld_pattern;                  /* RAID 0,1 etc */
479         obd_uuid_t ld_uuid;
480 };
481
482 /*
483  *   LDLM requests:
484  */
485 /* opcodes -- MUST be distinct from OST/MDS opcodes */
486 #define LDLM_ENQUEUE       101
487 #define LDLM_CONVERT       102
488 #define LDLM_CANCEL        103
489 #define LDLM_BL_CALLBACK   104
490 #define LDLM_CP_CALLBACK   105
491
492 #define RES_NAME_SIZE 3
493 #define RES_VERSION_SIZE 4
494
495 /* lock types */
496 typedef enum {
497         LCK_EX = 1,
498         LCK_PW,
499         LCK_PR,
500         LCK_CW,
501         LCK_CR,
502         LCK_NL
503 } ldlm_mode_t;
504
505 struct ldlm_extent {
506         __u64 start;
507         __u64 end;
508 };
509
510 struct ldlm_intent {
511         __u64 opc;
512 };
513
514 /* Note this unaligned structure; as long as it's only used in ldlm_request
515  * below, we're probably fine. */
516 struct ldlm_resource_desc {
517         __u32 lr_type;
518         __u64 lr_name[RES_NAME_SIZE];
519         __u32 lr_version[RES_VERSION_SIZE];
520 };
521
522 struct ldlm_lock_desc {
523         struct ldlm_resource_desc l_resource;
524         ldlm_mode_t l_req_mode;
525         ldlm_mode_t l_granted_mode;
526         struct ldlm_extent l_extent;
527         __u32 l_version[RES_VERSION_SIZE];
528 };
529
530 struct ldlm_request {
531         __u32 lock_flags;
532         struct ldlm_lock_desc lock_desc;
533         struct lustre_handle lock_handle1;
534         struct lustre_handle lock_handle2;
535 };
536
537 struct ldlm_reply {
538         __u32 lock_flags;
539         __u32 lock_mode;
540         __u64 lock_resource_name[RES_NAME_SIZE];
541         struct lustre_handle lock_handle;
542         struct ldlm_extent lock_extent;   /* XXX make this policy 1 &2 */
543         __u64  lock_policy_res1;
544         __u64  lock_policy_res2;
545 };
546 #endif