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