Whamcloud - gitweb
- documentation updates for the collaborative cache
[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 uuid_t[37]; /* deprecated */
51 typedef __u8 obd_uuid_t[37];
52
53 /* FOO_REQUEST_PORTAL is for incoming requests on the FOO
54  * FOO_REPLY_PORTAL   is for incoming replies on the FOO
55  * FOO_BULK_PORTAL    is for incoming bulk on the FOO
56  */
57
58 #define CONNMGR_REQUEST_PORTAL  1
59 #define CONNMGR_REPLY_PORTAL    2
60 #define OSC_REQUEST_PORTAL      3
61 #define OSC_REPLY_PORTAL        4
62 #define OSC_BULK_PORTAL         5
63 #define OST_REQUEST_PORTAL      6
64 #define OST_REPLY_PORTAL        7
65 #define OST_BULK_PORTAL         8
66 #define MDC_REQUEST_PORTAL      9
67 #define MDC_REPLY_PORTAL        10
68 #define MDC_BULK_PORTAL         11
69 #define MDS_REQUEST_PORTAL      12
70 #define MDS_REPLY_PORTAL        13
71 #define MDS_BULK_PORTAL         14
72 #define LDLM_REQUEST_PORTAL     15
73 #define LDLM_REPLY_PORTAL       16
74 #define LDLM_CLI_REQUEST_PORTAL 17
75 #define LDLM_CLI_REPLY_PORTAL   18
76
77 #define SVC_KILLED               1
78 #define SVC_EVENT                2
79 #define SVC_SIGNAL               4
80 #define SVC_RUNNING              8
81 #define SVC_STOPPING            16
82 #define SVC_STOPPED             32
83
84 #define LUSTRE_CONN_NEW          1
85 #define LUSTRE_CONN_CON          2
86 #define LUSTRE_CONN_RECOVD       3
87 #define LUSTRE_CONN_FULL         4
88
89 /* packet types */
90 #define PTL_RPC_MSG_REQUEST 4711
91 #define PTL_RPC_MSG_ERR     4712
92 #define PTL_RPC_MSG_REPLY   4713
93
94 #define PTLRPC_MSG_MAGIC (cpu_to_le32(0x0BD00BD0))
95 #define PTLRPC_MSG_VERSION (cpu_to_le32(0x00040001))
96
97 struct lustre_handle {
98         __u64 addr;
99         __u64 cookie;
100 };
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 buflens[0];
121 };
122
123 #define CONNMGR_REPLY   0
124 #define CONNMGR_CONNECT 1
125
126 /*
127  *   OST requests: OBDO & OBD request records
128  */
129
130 /* opcodes */
131 #define OST_REPLY      0        /* reply ? */
132 #define OST_GETATTR    1
133 #define OST_SETATTR    2
134 #define OST_READ       3
135 #define OST_WRITE      4
136 #define OST_CREATE     5 
137 #define OST_DESTROY    6 
138 #define OST_GET_INFO   7 
139 #define OST_CONNECT    8 
140 #define OST_DISCONNECT 9 
141 #define OST_PUNCH      10
142 #define OST_OPEN       11
143 #define OST_CLOSE      12
144 #define OST_STATFS     13
145
146
147 typedef uint64_t        obd_id;
148 typedef uint64_t        obd_gr;
149 typedef uint64_t        obd_time;
150 typedef uint64_t        obd_size;
151 typedef uint64_t        obd_off;
152 typedef uint64_t        obd_blocks;
153 typedef uint32_t        obd_blksize;
154 typedef uint32_t        obd_mode;
155 typedef uint32_t        obd_uid;
156 typedef uint32_t        obd_gid;
157 typedef uint64_t        obd_rdev;
158 typedef uint32_t        obd_flag;
159 typedef uint32_t        obd_count;
160
161 #define OBD_FL_INLINEDATA       (0x00000001)
162 #define OBD_FL_OBDMDEXISTS      (0x00000002)
163
164 #define OBD_INLINESZ    60
165
166 /* Note: 64-bit types are 64-bit aligned in structure */
167 struct obdo {
168         obd_id                  o_id;
169         obd_gr                  o_gr;
170         obd_time                o_atime;
171         obd_time                o_mtime;
172         obd_time                o_ctime;
173         obd_size                o_size;
174         obd_blocks              o_blocks;
175         obd_rdev                o_rdev;
176         obd_blksize             o_blksize;
177         obd_mode                o_mode;
178         obd_uid                 o_uid;
179         obd_gid                 o_gid;
180         obd_flag                o_flags;
181         obd_count               o_nlink;
182         obd_count               o_generation;
183         obd_flag                o_valid;        /* hot fields in this obdo */
184         obd_flag                o_obdflags;
185         __u32                   o_easize;
186         char                    o_inline[OBD_INLINESZ];
187 };
188
189 struct lov_object_id { /* per-child structure */
190         __u64 l_object_id;
191 };
192
193 #define LOV_MAGIC  0x0BD00BD0
194
195 struct lov_mds_md {
196         __u32 lmm_magic;
197         __u32 lmm_easize;          /* packed size of extended */
198         __u64 lmm_object_id;       /* lov object id */
199         __u32 lmm_stripe_offset;   /* starting stripe offset in lmd_objects */
200         __u32 lmm_stripe_count;    /* number of stipes in use for this object */
201         __u64 lmm_stripe_size;     /* size of the stripe */
202         __u32 lmm_ost_count;       /* how many OSTs are in this LOV */
203         __u32 lmm_stripe_pattern;  /* per-lov object stripe pattern */
204         struct lov_object_id lmm_objects[0];
205 };
206
207 #define OBD_MD_FLALL    (0xffffffff)
208 #define OBD_MD_FLID     (0x00000001)    /* object ID */
209 #define OBD_MD_FLATIME  (0x00000002)    /* access time */
210 #define OBD_MD_FLMTIME  (0x00000004)    /* data modification time */
211 #define OBD_MD_FLCTIME  (0x00000008)    /* change time */
212 #define OBD_MD_FLSIZE   (0x00000010)    /* size */
213 #define OBD_MD_FLBLOCKS (0x00000020)    /* allocated blocks count */
214 #define OBD_MD_FLBLKSZ  (0x00000040)    /* block size */
215 #define OBD_MD_FLMODE   (0x00000080)    /* access bits (mode & ~S_IFMT) */
216 #define OBD_MD_FLTYPE   (0x00000100)    /* object type (mode & S_IFMT) */
217 #define OBD_MD_FLUID    (0x00000200)    /* user ID */
218 #define OBD_MD_FLGID    (0x00000400)    /* group ID */
219 #define OBD_MD_FLFLAGS  (0x00000800)    /* flags word */
220 #define OBD_MD_FLOBDFLG (0x00001000)
221 #define OBD_MD_FLNLINK  (0x00002000)    /* link count */
222 #define OBD_MD_FLGENER  (0x00004000)    /* generation number */
223 #define OBD_MD_FLINLINE (0x00008000)    /* inline data */
224 #define OBD_MD_FLRDEV   (0x00010000)    /* device number */
225 #define OBD_MD_FLEASIZE (0x00020000)    /* extended attribute data */
226 #define OBD_MD_LINKNAME (0x00040000)    /* symbolic link target */
227 #define OBD_MD_FLNOTOBD (~(OBD_MD_FLOBDFLG | OBD_MD_FLBLOCKS | OBD_MD_LINKNAME))
228
229 struct obd_statfs {
230         __u64           os_type;
231         __u64           os_blocks;
232         __u64           os_bfree;
233         __u64           os_bavail;
234         __u64           os_files;
235         __u64           os_ffree;
236         __u8            os_fsid[40];
237         __u32           os_bsize;
238         __u32           os_namelen;
239         __u32           os_spare[12];
240 };
241
242 /* ost_body.data values for OST_BRW */
243
244 #define OBD_BRW_READ    0x1
245 #define OBD_BRW_WRITE   0x2
246 #define OBD_BRW_RWMASK  (OBD_BRW_READ | OBD_BRW_WRITE)
247 #define OBD_BRW_CREATE  0x4
248
249 #define OBD_PUNCH_EOF 0xffffffffffffffffULL
250
251 struct obd_ioobj {
252         obd_id    ioo_id;
253         obd_gr    ioo_gr;
254         __u32     ioo_type;
255         __u32     ioo_bufcnt;
256 };
257
258 struct niobuf_remote {
259         __u64 offset;
260         __u32 len;
261         __u32 xid;
262         __u32 flags;
263 };
264
265 #define CONNMGR_REPLY   0
266 #define CONNMGR_CONNECT 1
267
268 struct connmgr_body {
269         __u64 conn;
270         __u64 conn_token;
271         __u32 generation;
272         obd_uuid_t conn_uuid;
273 };
274
275 /* request structure for OST's */
276
277 #define OST_REQ_HAS_OA1  0x1
278
279 struct ost_body {
280         struct  obdo oa;
281 };
282
283 /*
284  *   MDS REQ RECORDS
285  */
286
287 /* opcodes */
288 #define MDS_GETATTR    1
289 #define MDS_OPEN       2
290 #define MDS_CLOSE      3
291 #define MDS_REINT      4
292 #define MDS_READPAGE   6
293 #define MDS_CONNECT    7
294 #define MDS_DISCONNECT 8
295 #define MDS_GETSTATUS  9
296 #define MDS_STATFS     10
297 #define MDS_GETLOVINFO 11
298
299 #define REINT_SETATTR  1
300 #define REINT_CREATE   2
301 #define REINT_LINK     3
302 #define REINT_UNLINK   4
303 #define REINT_RENAME   5
304 #define REINT_RECREATE 6
305 #define REINT_MAX      6
306
307 struct ll_fid {
308         __u64 id;
309         __u32 generation;
310         __u32 f_type;
311 };
312
313
314 #define MDS_STATUS_CONN 1
315 #define MDS_STATUS_LOV 2
316
317 struct mds_status_req { 
318         __u32  flags;
319         __u32  repbuf;
320 };
321
322 struct mds_fileh_body { 
323         struct ll_fid f_fid;
324         struct lustre_handle f_handle;
325 };
326
327 struct mds_conn_status { 
328         struct ll_fid rootfid;
329         __u64          xid;
330         __u64          last_committed;
331         __u64          last_rcvd;
332         /* XXX preallocated quota & obj fields here */
333 };
334
335 struct mds_body {
336         __u32          fsuid;
337         __u32          fsgid;
338         struct ll_fid  fid1;
339         struct ll_fid  fid2;
340         __u64          size;
341         __u64          extra;
342         __u32          valid;
343         __u32          mode;
344         __u32          uid;
345         __u32          gid;
346         __u32          mtime;
347         __u32          ctime;
348         __u32          atime;
349         __u32          flags;
350         __u32          major;
351         __u32          minor;
352         __u32          ino;
353         __u32          nlink;
354         __u32          generation;
355         __u32          last_xidnomore;
356 };
357
358 /* MDS update records */
359
360
361 //struct mds_update_record_hdr {
362 //        __u32 ur_opcode;
363 //};
364
365 struct mds_rec_setattr {
366         __u32           sa_opcode;
367         __u32           sa_fsuid;
368         __u32           sa_fsgid;
369         __u32           sa_valid;
370         struct ll_fid   sa_fid;
371         __u32           sa_mode;
372         __u32           sa_uid;
373         __u32           sa_gid;
374         __u32           sa_attr_flags;
375         __u64           sa_size;
376         __u64           sa_atime;
377         __u64           sa_mtime;
378         __u64           sa_ctime;
379 };
380
381 struct mds_rec_create {
382         __u32           cr_opcode;
383         __u32           cr_fsuid;
384         __u32           cr_fsgid;
385         __u32           cr_mode;
386         struct ll_fid   cr_fid;
387         __u32           cr_uid;
388         __u32           cr_gid;
389         __u64           cr_time;
390         __u64           cr_rdev;
391 };
392
393 struct mds_rec_link {
394         __u32           lk_opcode;
395         __u32           lk_fsuid;
396         __u32           lk_fsgid;
397         __u32           lk_reserved;
398         struct ll_fid   lk_fid1;
399         struct ll_fid   lk_fid2;
400 };
401
402 struct mds_rec_unlink {
403         __u32           ul_opcode;
404         __u32           ul_fsuid;
405         __u32           ul_fsgid;
406         __u32           ul_mode;
407         struct ll_fid   ul_fid1;
408         struct ll_fid   ul_fid2;
409 };
410
411 struct mds_rec_rename {
412         __u32           rn_opcode;
413         __u32           rn_fsuid;
414         __u32           rn_fsgid;
415         __u32           rn_reserved;
416         struct ll_fid   rn_fid1;
417         struct ll_fid   rn_fid2;
418 };
419
420
421 /*
422  *  LOV data structures
423  */
424
425 #define LOV_RAID0   0
426 #define LOV_RAIDRR  1
427
428 struct lov_desc {
429         __u32 ld_tgt_count;                /* how many OBD's */
430         __u32 ld_default_stripe_count;     /* how many objects are used */
431         __u64 ld_default_stripe_size;      /* in bytes */
432         __u64 ld_default_stripe_offset;    /* in bytes */
433         __u32 ld_pattern;                  /* RAID 0,1 etc */
434         obd_uuid_t ld_uuid;
435 };
436
437 /*
438  *   LDLM requests:
439  */
440 /* opcodes -- MUST be distinct from OST/MDS opcodes */
441 #define LDLM_ENQUEUE       101
442 #define LDLM_CONVERT       102
443 #define LDLM_CANCEL        103
444 #define LDLM_BL_CALLBACK   104
445 #define LDLM_CP_CALLBACK   105
446
447 #define RES_NAME_SIZE 3
448 #define RES_VERSION_SIZE 4
449
450 /* lock types */
451 typedef enum {
452         LCK_EX = 1,
453         LCK_PW,
454         LCK_PR,
455         LCK_CW,
456         LCK_CR,
457         LCK_NL
458 } ldlm_mode_t;
459
460 struct ldlm_extent {
461         __u64 start;
462         __u64 end;
463 };
464
465 struct ldlm_intent {
466         __u64 opc;
467 };
468
469 /* Note this unaligned structure; as long as it's only used in ldlm_request
470  * below, we're probably fine. */
471 struct ldlm_resource_desc {
472         __u32 lr_type;
473         __u64 lr_name[RES_NAME_SIZE];
474         __u32 lr_version[RES_VERSION_SIZE];
475 };
476
477 struct ldlm_lock_desc {
478         struct ldlm_resource_desc l_resource;
479         ldlm_mode_t l_req_mode;
480         ldlm_mode_t l_granted_mode;
481         struct ldlm_extent l_extent;
482         __u32 l_version[RES_VERSION_SIZE];
483 };
484
485 struct ldlm_request {
486         __u32 lock_flags;
487         struct ldlm_lock_desc lock_desc;
488         struct lustre_handle lock_handle1;
489         struct lustre_handle lock_handle2;
490 };
491
492 struct ldlm_reply {
493         __u32 lock_flags;
494         __u32 lock_mode;
495         __u64 lock_resource_name[RES_NAME_SIZE];
496         struct lustre_handle lock_handle;
497         struct ldlm_extent lock_extent;   /* XXX make this policy 1 &2 */
498         __u64  lock_policy_res1;
499         __u64  lock_policy_res2;
500 };
501 #endif