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