Whamcloud - gitweb
WARNING: we currently crash on unmount after the last phase of runtests.
[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];
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_REQUEST_PORTAL     15
72 #define LDLM_REPLY_PORTAL       16
73 #define LDLM_CLI_REQUEST_PORTAL 17
74 #define LDLM_CLI_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_OK           0
92
93 #define PTL_RPC_TYPE_REQUEST     2
94 #define PTL_RPC_TYPE_REPLY       3
95
96 #define PTLRPC_MSG_MAGIC (cpu_to_le32(0x0BD00BD0))
97 #define PTLRPC_MSG_VERSION (cpu_to_le32(0x00040001))
98
99 struct lustre_handle {
100         __u64 addr;
101         __u64 cookie;
102 };
103
104 static inline void ptlrpc_invalidate_handle(struct lustre_handle *hdl)
105 {
106         hdl->addr = hdl->cookie = 0; /* XXX invalid enough? */
107 }
108
109 /* we depend on this structure to be 8-byte aligned */
110 struct lustre_msg {
111         __u64 addr;
112         __u64 cookie; /* security token */
113         __u32 magic;
114         __u32 type;
115         __u32 version;
116         __u32 opc;
117         __u64 last_xid;
118         __u64 last_committed;
119         __u64 transno;
120         __u32 status;
121         __u32 bufcount;
122         __u32 buflens[0];
123 };
124
125 #define CONNMGR_REPLY   0
126 #define CONNMGR_CONNECT 1
127
128 /*
129  *   OST requests: OBDO & OBD request records
130  */
131
132 /* opcodes */
133 #define OST_REPLY      0        /* reply ? */
134 #define OST_GETATTR    1
135 #define OST_SETATTR    2
136 #define OST_READ       3
137 #define OST_WRITE      4
138 #define OST_CREATE     5 
139 #define OST_DESTROY    6 
140 #define OST_GET_INFO   7 
141 #define OST_CONNECT    8 
142 #define OST_DISCONNECT 9 
143 #define OST_PUNCH      10
144 #define OST_OPEN       11
145 #define OST_CLOSE      12
146 #define OST_STATFS     13
147
148
149 typedef uint64_t        obd_id;
150 typedef uint64_t        obd_gr;
151 typedef uint64_t        obd_time;
152 typedef uint64_t        obd_size;
153 typedef uint64_t        obd_off;
154 typedef uint64_t        obd_blocks;
155 typedef uint32_t        obd_blksize;
156 typedef uint32_t        obd_mode;
157 typedef uint32_t        obd_uid;
158 typedef uint32_t        obd_gid;
159 typedef uint64_t        obd_rdev;
160 typedef uint32_t        obd_flag;
161 typedef uint32_t        obd_count;
162
163 #define OBD_FL_INLINEDATA       (0x00000001)
164 #define OBD_FL_OBDMDEXISTS      (0x00000002)
165
166 #define OBD_INLINESZ    60
167
168 /* Note: 64-bit types are 64-bit aligned in structure */
169 struct obdo {
170         obd_id                  o_id;
171         obd_gr                  o_gr;
172         obd_time                o_atime;
173         obd_time                o_mtime;
174         obd_time                o_ctime;
175         obd_size                o_size;
176         obd_blocks              o_blocks;
177         obd_rdev                o_rdev;
178         obd_blksize             o_blksize;
179         obd_mode                o_mode;
180         obd_uid                 o_uid;
181         obd_gid                 o_gid;
182         obd_flag                o_flags;
183         obd_count               o_nlink;
184         obd_count               o_generation;
185         obd_flag                o_valid;        /* hot fields in this obdo */
186         obd_flag                o_obdflags;
187         __u32                   o_easize;
188         char                    o_inline[OBD_INLINESZ];
189 };
190
191 struct lov_object_id { /* per-child structure */
192         __u64 l_object_id;
193 };
194
195 #define LOV_MAGIC  0x0BD00BD0
196
197 struct lov_mds_md {
198         __u32 lmd_magic;
199         __u32 lmd_easize;          /* packed size of extended */
200         __u64 lmd_object_id;       /* lov object id */
201         __u64 lmd_stripe_offset;   /* offset of the stripe */ 
202         __u64 lmd_stripe_size;     /* size of the stripe */
203         __u32 lmd_stripe_count;    /* how many objects are being striped */
204         __u32 lmd_stripe_pattern;  /* per-lov object stripe pattern */
205         struct lov_object_id lmd_objects[0];
206 };
207
208 #define OBD_MD_FLALL    (0xffffffff)
209 #define OBD_MD_FLID     (0x00000001)
210 #define OBD_MD_FLATIME  (0x00000002)
211 #define OBD_MD_FLMTIME  (0x00000004)
212 #define OBD_MD_FLCTIME  (0x00000008)
213 #define OBD_MD_FLSIZE   (0x00000010)
214 #define OBD_MD_FLBLOCKS (0x00000020)
215 #define OBD_MD_FLBLKSZ  (0x00000040)
216 #define OBD_MD_FLMODE   (0x00000080)
217 #define OBD_MD_FLTYPE   (0x00000100)
218 #define OBD_MD_FLUID    (0x00000200)
219 #define OBD_MD_FLGID    (0x00000400)
220 #define OBD_MD_FLFLAGS  (0x00000800)
221 #define OBD_MD_FLOBDFLG (0x00001000)
222 #define OBD_MD_FLNLINK  (0x00002000)
223 #define OBD_MD_FLGENER  (0x00004000)
224 #define OBD_MD_FLINLINE (0x00008000)
225 #define OBD_MD_FLRDEV   (0x00010000)
226 #define OBD_MD_FLEASIZE (0x00020000)
227 #define OBD_MD_LINKNAME (0x00040000)
228 #define OBD_MD_FLNOTOBD (~(OBD_MD_FLOBDFLG | OBD_MD_FLBLOCKS | OBD_MD_LINKNAME))
229
230 struct obd_statfs {
231         __u64           os_type;
232         __u64           os_blocks;
233         __u64           os_bfree;
234         __u64           os_bavail;
235         __u64           os_files;
236         __u64           os_ffree;
237         __u8            os_fsid[40];
238         __u32           os_bsize;
239         __u32           os_namelen;
240         __u32           os_spare[12];
241 };
242
243 /* ost_body.data values for OST_BRW */
244
245 #define OBD_BRW_READ    0x1
246 #define OBD_BRW_WRITE   0x2
247 #define OBD_BRW_RWMASK  (OBD_BRW_READ | OBD_BRW_WRITE)
248 #define OBD_BRW_CREATE  0x4
249
250 struct obd_ioobj {
251         obd_id    ioo_id;
252         obd_gr    ioo_gr;
253         __u32     ioo_type;
254         __u32     ioo_bufcnt;
255 };
256
257 struct niobuf_remote {
258         __u64 offset;
259         __u32 len;
260         __u32 xid;
261         __u32 flags;
262 };
263
264 #define CONNMGR_REPLY   0
265 #define CONNMGR_CONNECT 1
266
267 struct connmgr_body {
268         __u64 conn;
269         __u64 conn_token;
270         __u32 generation;
271         __u8  conn_uuid[37];
272 };
273
274 /* request structure for OST's */
275
276 #define OST_REQ_HAS_OA1  0x1
277
278 struct ost_body {
279         struct  obdo oa;
280 };
281
282 /*
283  *   MDS REQ RECORDS
284  */
285
286 /* opcodes */
287 #define MDS_GETATTR    1
288 #define MDS_OPEN       2
289 #define MDS_CLOSE      3
290 #define MDS_REINT      4
291 #define MDS_READPAGE   6
292 #define MDS_CONNECT    7
293 #define MDS_DISCONNECT 8
294 #define MDS_GETSTATUS  9
295 #define MDS_STATFS     10
296 #define MDS_GETLOVINFO 11
297
298 #define REINT_SETATTR  1
299 #define REINT_CREATE   2
300 #define REINT_LINK     3
301 #define REINT_UNLINK   4
302 #define REINT_RENAME   5
303 #define REINT_RECREATE 6
304 #define REINT_MAX      6
305
306 struct ll_fid {
307         __u64 id;
308         __u32 generation;
309         __u32 f_type;
310 };
311
312
313 #define MDS_STATUS_CONN 1
314 #define MDS_STATUS_LOV 2
315
316 struct mds_status_req { 
317         __u32  flags;
318         __u32  repbuf;
319 };
320
321 struct mds_fileh_body { 
322         struct ll_fid f_fid;
323         struct lustre_handle f_handle;
324 };
325
326 struct mds_conn_status { 
327         struct ll_fid rootfid;
328         __u64          xid;
329         __u64          last_committed;
330         __u64          last_rcvd;
331         /* XXX preallocated quota & obj fields here */
332 };
333
334 struct mds_body {
335         struct ll_fid  fid1;
336         struct ll_fid  fid2;
337         __u64          size;
338         __u64          extra;
339         __u32          valid;
340         __u32          mode;
341         __u32          uid;
342         __u32          gid;
343         __u32          mtime;
344         __u32          ctime;
345         __u32          atime;
346         __u32          flags;
347         __u32          major;
348         __u32          minor;
349         __u32          ino;
350         __u32          nlink;
351         __u32          generation;
352         __u32          last_xidnomore;
353 };
354
355 /* MDS update records */
356
357
358 //struct mds_update_record_hdr {
359 //        __u32 ur_opcode;
360 //};
361
362 struct mds_rec_setattr {
363         __u32           sa_opcode;
364         __u32           sa_valid;
365         struct ll_fid   sa_fid;
366         __u32           sa_mode;
367         __u32           sa_uid;
368         __u32           sa_gid;
369         __u32           sa_attr_flags;
370         __u64           sa_size;
371         __u64           sa_atime;
372         __u64           sa_mtime;
373         __u64           sa_ctime;
374 };
375
376 struct mds_rec_create {
377         __u32           cr_opcode;
378         __u32           cr_mode;
379         struct ll_fid   cr_fid;
380         __u32           cr_uid;
381         __u32           cr_gid;
382         __u64           cr_time;
383         __u64           cr_rdev;
384 };
385
386 struct mds_rec_link {
387         __u32           lk_opcode;
388         __u32           lk_reserved;
389         struct ll_fid   lk_fid1;
390         struct ll_fid   lk_fid2;
391 };
392
393 struct mds_rec_unlink {
394         __u32           ul_opcode;
395         __u32           ul_mode;
396         struct ll_fid   ul_fid1;
397         struct ll_fid   ul_fid2;
398 };
399
400 struct mds_rec_rename {
401         __u32           rn_opcode;
402         __u32           rn_reserved;
403         struct ll_fid   rn_fid1;
404         struct ll_fid   rn_fid2;
405 };
406
407
408 /* 
409  *  LOV data structures
410  */
411
412 #define LOV_RAID0   0
413 #define LOV_RAIDRR  1
414
415 struct lov_desc { 
416         __u32 ld_tgt_count;                /* how many OBD's */
417         __u32 ld_default_stripe_count;     /* how many objects are used */
418         __u64 ld_default_stripe_size;      /* in bytes */
419         __u64 ld_default_stripe_offset;    /* in bytes */
420         __u32 ld_pattern;                  /* RAID 0,1 etc */
421          uuid_t ld_uuid;
422 }; 
423
424 /*
425  *   LDLM requests:
426  */
427 /* opcodes -- MUST be distinct from OST/MDS opcodes */
428 #define LDLM_ENQUEUE       101
429 #define LDLM_CONVERT       102
430 #define LDLM_CANCEL        103
431 #define LDLM_BL_CALLBACK   104
432 #define LDLM_CP_CALLBACK   105
433
434 #define RES_NAME_SIZE 3
435 #define RES_VERSION_SIZE 4
436
437 /* lock types */
438 typedef enum {
439         LCK_EX = 1,
440         LCK_PW,
441         LCK_PR,
442         LCK_CW,
443         LCK_CR,
444         LCK_NL
445 } ldlm_mode_t;
446
447 struct ldlm_extent {
448         __u64 start;
449         __u64 end;
450 };
451
452 struct ldlm_intent {
453         __u64 opc;
454 };
455
456 /* Note this unaligned structure; as long as it's only used in ldlm_request
457  * below, we're probably fine. */
458 struct ldlm_resource_desc {
459         __u32 lr_type;
460         __u64 lr_name[RES_NAME_SIZE];
461         __u32 lr_version[RES_VERSION_SIZE];
462 };
463
464 struct ldlm_lock_desc {
465         struct ldlm_resource_desc l_resource;
466         ldlm_mode_t l_req_mode;
467         ldlm_mode_t l_granted_mode;
468         struct ldlm_extent l_extent;
469         __u32 l_version[RES_VERSION_SIZE];
470 };
471
472 struct ldlm_request {
473         __u32 lock_flags;
474         struct ldlm_lock_desc lock_desc;
475         struct lustre_handle lock_handle1;
476         struct lustre_handle lock_handle2;
477 };
478
479 struct ldlm_reply {
480         __u32 lock_flags;
481         __u32 lock_mode;
482         __u64 lock_resource_name[RES_NAME_SIZE];
483         struct lustre_handle lock_handle;
484         struct ldlm_extent lock_extent;   /* XXX make this policy 1 &2 */
485         __u64  lock_policy_res1;
486         __u64  lock_policy_res2;
487 };
488 #endif