Whamcloud - gitweb
Add module refcounts for filesystem interface modules.
[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 <linux/list.h>
35 # undef __KERNEL__
36 # include <stdint.h>
37 #endif
38 /*
39  * this file contains all data structures used in Lustre interfaces:
40  * - obdo and obd_request records
41  * - mds_request records
42  * - ldlm data
43  * - ioctl's
44  */
45
46 /*
47  *  GENERAL STUFF
48  */
49 typedef __u8 uuid_t[37];
50
51 /* FOO_REQUEST_PORTAL is for incoming requests on the FOO
52  * FOO_REPLY_PORTAL   is for incoming replies on the FOO
53  * FOO_BULK_PORTAL    is for incoming bulk on the FOO
54  */
55
56 #define CONNMGR_REQUEST_PORTAL  1
57 #define CONNMGR_REPLY_PORTAL    2
58 #define OSC_REQUEST_PORTAL      3
59 #define OSC_REPLY_PORTAL        4
60 #define OSC_BULK_PORTAL         5
61 #define OST_REQUEST_PORTAL      6
62 #define OST_REPLY_PORTAL        7
63 #define OST_BULK_PORTAL         8
64 #define MDC_REQUEST_PORTAL      9
65 #define MDC_REPLY_PORTAL        10
66 #define MDC_BULK_PORTAL         11
67 #define MDS_REQUEST_PORTAL      12
68 #define MDS_REPLY_PORTAL        13
69 #define MDS_BULK_PORTAL         14
70 #define LDLM_REQUEST_PORTAL     15
71 #define LDLM_REPLY_PORTAL       16
72 #define LDLM_CLI_REQUEST_PORTAL 17
73 #define LDLM_CLI_REPLY_PORTAL   18
74
75 #define SVC_KILLED               1
76 #define SVC_EVENT                2
77 #define SVC_SIGNAL               4
78 #define SVC_RUNNING              8
79 #define SVC_STOPPING            16
80 #define SVC_STOPPED             32
81
82 #define RECOVD_STOPPING          1  /* how cleanup tells recovd to quit */
83 #define RECOVD_IDLE              2  /* normal state */
84 #define RECOVD_STOPPED           4  /* after recovd has stopped */
85 #define RECOVD_FAIL              8  /* RPC timeout: wakeup recovd, sets flag */
86 #define RECOVD_TIMEOUT          16  /* set when recovd detects a timeout */
87 #define RECOVD_UPCALL_WAIT      32  /* an upcall has been placed */
88 #define RECOVD_UPCALL_ANSWER    64  /* an upcall has been answered */
89
90 #define LUSTRE_CONN_NEW          1
91 #define LUSTRE_CONN_CON          2
92 #define LUSTRE_CONN_RECOVD       3
93 #define LUSTRE_CONN_FULL         4
94
95 /* packet types */
96 #define PTL_RPC_MSG_REQUEST 4711
97 #define PTL_RPC_MSG_ERR 4712
98 #define PTL_RPC_MSG_OK           0
99
100 #define PTL_RPC_TYPE_REQUEST     2
101 #define PTL_RPC_TYPE_REPLY       3
102
103 #define PTLRPC_MSG_MAGIC (cpu_to_le32(0x0BD00BD0))
104 #define PTLRPC_MSG_VERSION (cpu_to_le32(0x00040001))
105
106 struct lustre_handle {
107         __u64 addr;
108         __u64 cookie;
109 };
110
111 /* we depend on this structure to be 8-byte aligned */
112 struct lustre_msg {
113         __u64 addr;
114         __u64 cookie; /* security token */
115         __u32 magic;
116         __u32 version;
117         __u64 last_rcvd;
118         __u64 last_committed;
119         __u64 transno;
120         __u32 opc;
121         __u32 status;
122         __u32 type;
123         __u32   bufcount;
124         __u32   buflens[0];
125 };
126
127 #define CONNMGR_REPLY   0
128 #define CONNMGR_CONNECT 1
129
130 /*
131  *   OST requests: OBDO & OBD request records
132  */
133
134 /* opcodes */
135 #define OST_REPLY      0        /* reply ? */
136 #define OST_GETATTR    1
137 #define OST_SETATTR    2
138 #define OST_BRW        3
139 #define OST_CREATE     4
140 #define OST_DESTROY    5
141 #define OST_GET_INFO   6
142 #define OST_CONNECT    7
143 #define OST_DISCONNECT 8
144 #define OST_PUNCH      9
145 #define OST_OPEN      10
146 #define OST_CLOSE     11
147 #define OST_STATFS    12
148
149
150 typedef uint64_t        obd_id;
151 typedef uint64_t        obd_gr;
152 typedef uint64_t        obd_time;
153 typedef uint64_t        obd_size;
154 typedef uint64_t        obd_off;
155 typedef uint64_t        obd_blocks;
156 typedef uint32_t        obd_blksize;
157 typedef uint32_t        obd_mode;
158 typedef uint32_t        obd_uid;
159 typedef uint32_t        obd_gid;
160 typedef uint64_t        obd_rdev;
161 typedef uint32_t        obd_flag;
162 typedef uint32_t        obd_count;
163
164 #define OBD_FL_INLINEDATA       (0x00000001)
165 #define OBD_FL_OBDMDEXISTS      (0x00000002)
166 #define OBD_FL_CREATEONOPEN     (0x00000004)
167
168 #define OBD_INLINESZ    60
169 #define OBD_OBDMDSZ     60
170 /* Note: 64-bit types are 64-bit aligned in structure */
171 struct obdo {
172         obd_id                  o_id;
173         obd_gr                  o_gr;
174         obd_time                o_atime;
175         obd_time                o_mtime;
176         obd_time                o_ctime;
177         obd_size                o_size;
178         obd_blocks              o_blocks;
179         obd_rdev                o_rdev;
180         obd_blksize             o_blksize;
181         obd_mode                o_mode;
182         obd_uid                 o_uid;
183         obd_gid                 o_gid;
184         obd_flag                o_flags;
185         obd_count               o_nlink;
186         obd_count               o_generation;
187         obd_flag                o_valid;        /* hot fields in this obdo */
188         obd_flag                o_obdflags;
189         __u32                   o_easize; 
190         char                    o_inline[OBD_INLINESZ];
191 };
192
193 struct lov_object_id { /* per-child structure */
194         __u64 l_object_id;
195 };
196
197 struct lov_stripe_md {
198         __u64 lmd_magic;
199         __u64 lmd_object_id;     /* lov object id */
200         __u64 lmd_stripe_count;
201         __u32 lmd_size;
202         __u32 lmd_stripe_size;
203         __u32 lmd_stripe_pattern;  /* per-lov object stripe pattern */
204         struct lov_object_id lmd_objects[0];
205 };
206
207 #define OBD_MD_FLALL    (0xffffffff)
208 #define OBD_MD_FLID     (0x00000001)
209 #define OBD_MD_FLATIME  (0x00000002)
210 #define OBD_MD_FLMTIME  (0x00000004)
211 #define OBD_MD_FLCTIME  (0x00000008)
212 #define OBD_MD_FLSIZE   (0x00000010)
213 #define OBD_MD_FLBLOCKS (0x00000020)
214 #define OBD_MD_FLBLKSZ  (0x00000040)
215 #define OBD_MD_FLMODE   (0x00000080)
216 #define OBD_MD_FLTYPE   (0x00000100)
217 #define OBD_MD_FLUID    (0x00000200)
218 #define OBD_MD_FLGID    (0x00000400)
219 #define OBD_MD_FLFLAGS  (0x00000800)
220 #define OBD_MD_FLOBDFLG (0x00001000)
221 #define OBD_MD_FLNLINK  (0x00002000)
222 #define OBD_MD_FLGENER  (0x00004000)
223 #define OBD_MD_FLINLINE (0x00008000)
224 #define OBD_MD_FLRDEV   (0x00010000)
225 #define OBD_MD_FLOBJID  (0x00020000)
226 #define OBD_MD_LINKNAME (0x00040000)
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         __u64           os_fsid;
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 struct obd_ioobj {
250         obd_id    ioo_id;
251         obd_gr    ioo_gr;
252         __u32     ioo_type;
253         __u32     ioo_bufcnt;
254 };
255
256 struct niobuf_remote {
257         __u64 offset;
258         __u32 len;
259         __u32 xid;
260         __u32 flags;
261 };
262
263 #define CONNMGR_REPLY   0
264 #define CONNMGR_CONNECT 1
265
266 struct connmgr_body {
267         __u64 conn;
268         __u64 conn_token;
269         __u32 generation;
270         __u8  conn_uuid[37];
271 };
272
273 /* request structure for OST's */
274
275 #define OST_REQ_HAS_OA1  0x1
276
277 struct ost_body {
278         __u32   connid;
279         __u32   data;
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_conn_status { 
323         struct ll_fid rootfid;
324         __u64          xid;
325         __u64          last_committed;
326         __u64          last_rcvd;
327         /* XXX preallocated quota & obj fields here */
328 };
329
330 struct mds_body {
331         struct ll_fid  fid1;
332         struct ll_fid  fid2;
333         __u64          size;
334         __u64          extra;
335         __u32          valid;
336         __u32          mode;
337         __u32          uid;
338         __u32          gid;
339         __u32          mtime;
340         __u32          ctime;
341         __u32          atime;
342         __u32          flags;
343         __u32          major;
344         __u32          minor;
345         __u32          ino;
346         __u32          nlink;
347         __u32          generation;
348         __u32          last_xid;
349 };
350
351 /* MDS update records */
352 struct mds_update_record_hdr {
353         __u32 ur_opcode;
354 };
355
356 struct mds_rec_setattr {
357         __u32           sa_opcode;
358         struct ll_fid   sa_fid;
359         __u32           sa_valid;
360         __u32           sa_mode;
361         __u32           sa_uid;
362         __u32           sa_gid;
363         __u64           sa_size;
364         __u64           sa_atime;
365         __u64           sa_mtime;
366         __u64           sa_ctime;
367         __u32           sa_attr_flags;
368 };
369
370 struct mds_rec_create {
371         __u32           cr_opcode;
372         struct ll_fid   cr_fid;
373         __u32           cr_uid;
374         __u32           cr_gid;
375         __u64           cr_time;
376         __u32           cr_mode;
377         __u64           cr_rdev;
378 };
379
380 struct mds_rec_link {
381         __u32           lk_opcode;
382         struct ll_fid   lk_fid1;
383         struct ll_fid   lk_fid2;
384 };
385
386 struct mds_rec_unlink {
387         __u32           ul_opcode;
388         struct ll_fid   ul_fid1;
389         struct ll_fid   ul_fid2;
390 };
391
392 struct mds_rec_rename {
393         __u32           rn_opcode;
394         struct ll_fid   rn_fid1;
395         struct ll_fid   rn_fid2;
396 };
397
398
399 /* 
400  *  LOV data structures
401  */
402
403 #define LOV_RAID0  0
404 struct lov_desc { 
405         __u32 ld_tgt_count; /* how many OBD's */
406         __u32 ld_default_stripecount;
407         __u32 ld_default_stripesize;   /* in bytes */
408         __u32 ld_pattern; /* RAID 0,1 etc */
409          uuid_t ld_uuid;
410 }; 
411
412 /*
413  *   LDLM requests:
414  */
415
416 /* opcodes */
417 #define LDLM_REPLY         0
418 #define LDLM_ENQUEUE       1
419 #define LDLM_CONVERT       2
420 #define LDLM_CANCEL        3
421 #define LDLM_CALLBACK      4
422
423 #define RES_NAME_SIZE 3
424 #define RES_VERSION_SIZE 4
425
426 /* lock types */
427 typedef enum {
428         LCK_EX = 1,
429         LCK_PW,
430         LCK_PR,
431         LCK_CW,
432         LCK_CR,
433         LCK_NL
434 } ldlm_mode_t;
435
436 struct ldlm_extent {
437         __u64 start;
438         __u64 end;
439 };
440
441 struct ldlm_intent {
442         __u64 opc;
443 };
444
445 struct ldlm_resource_desc {
446         __u32 lr_type;
447         __u64 lr_name[RES_NAME_SIZE];
448         __u64 lr_version[RES_VERSION_SIZE];
449 };
450
451 struct ldlm_lock_desc {
452         struct ldlm_resource_desc l_resource;
453         ldlm_mode_t l_req_mode;
454         ldlm_mode_t l_granted_mode;
455         struct ldlm_extent l_extent;
456         __u32 l_version[RES_VERSION_SIZE];
457 };
458
459 struct ldlm_request {
460         __u32 lock_flags;
461         struct ldlm_lock_desc lock_desc;
462         struct lustre_handle lock_handle1;
463         struct lustre_handle lock_handle2;
464 };
465
466 struct ldlm_reply {
467         __u32 lock_flags;
468         __u64 lock_resource_name[3];
469         struct lustre_handle lock_handle;
470         struct ldlm_extent lock_extent;   /* XXX make this policy 1 &2 */
471         __u64  lock_policy_res1;
472         __u64  lock_policy_res2;
473 };
474 #endif