1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
21 * (Un)packing of OST requests
24 #ifndef _LUSTRE_IDL_H_
25 #define _LUSTRE_IDL_H_
28 # include <linux/ioctl.h>
29 # include <asm/types.h>
30 # include <linux/types.h>
31 # include <linux/list.h>
34 # include <asm/types.h>
35 # include <linux/list.h>
40 * this file contains all data structures used in Lustre interfaces:
41 * - obdo and obd_request records
42 * - mds_request records
54 static inline void obd_str2uuid(struct obd_uuid *uuid, char *tmp)
56 strncpy(uuid->uuid, tmp, sizeof(uuid->uuid));
57 uuid->uuid[sizeof(uuid->uuid) - 1] = '\0';
60 /* FOO_REQUEST_PORTAL is for incoming requests on the FOO
61 * FOO_REPLY_PORTAL is for incoming replies on the FOO
62 * FOO_BULK_PORTAL is for incoming bulk on the FOO
65 #define CONNMGR_REQUEST_PORTAL 1
66 #define CONNMGR_REPLY_PORTAL 2
67 #define OSC_REQUEST_PORTAL 3
68 #define OSC_REPLY_PORTAL 4
69 #define OSC_BULK_PORTAL 5
70 #define OST_REQUEST_PORTAL 6
71 #define OST_REPLY_PORTAL 7
72 #define OST_BULK_PORTAL 8
73 #define MDC_REQUEST_PORTAL 9
74 #define MDC_REPLY_PORTAL 10
75 #define MDC_BULK_PORTAL 11
76 #define MDS_REQUEST_PORTAL 12
77 #define MDS_REPLY_PORTAL 13
78 #define MDS_BULK_PORTAL 14
79 #define LDLM_CB_REQUEST_PORTAL 15
80 #define LDLM_CB_REPLY_PORTAL 16
81 #define LDLM_CANCEL_REQUEST_PORTAL 17
82 #define LDLM_CANCEL_REPLY_PORTAL 18
83 #define PTLBD_REQUEST_PORTAL 19
84 #define PTLBD_REPLY_PORTAL 20
85 #define PTLBD_BULK_PORTAL 21
86 #define MDS_GETATTR_PORTAL 22
92 #define SVC_STOPPING 16
93 #define SVC_STOPPED 32
95 #define LUSTRE_CONN_NEW 1
96 #define LUSTRE_CONN_CON 2
97 #define LUSTRE_CONN_RECOVD 3
98 #define LUSTRE_CONN_FULL 4
101 #define PTL_RPC_MSG_REQUEST 4711
102 #define PTL_RPC_MSG_ERR 4712
103 #define PTL_RPC_MSG_REPLY 4713
105 #define PTLRPC_MSG_MAGIC (cpu_to_le32(0x0BD00BD0))
106 #define PTLRPC_MSG_VERSION (cpu_to_le32(0x00040001))
108 struct lustre_handle {
112 #define DEAD_HANDLE_MAGIC 0xdeadbeefcafebabe
114 static inline void ptlrpc_invalidate_handle(struct lustre_handle *hdl)
116 hdl->addr = hdl->cookie = 0; /* XXX invalid enough? */
119 /* we depend on this structure to be 8-byte aligned */
122 __u64 cookie; /* security token */
128 __u64 last_committed;
136 /* Flags that are operation-specific go in the top 16 bits. */
137 #define MSG_OP_FLAG_MASK 0xffff0000
138 #define MSG_OP_FLAG_SHIFT 16
140 /* Flags that apply to all requests are in the bottom 16 bits */
141 #define MSG_GEN_FLAG_MASK 0x0000ffff
142 #define MSG_LAST_REPLAY 1
145 static inline int lustre_msg_get_flags(struct lustre_msg *msg)
147 return (msg->flags & MSG_GEN_FLAG_MASK);
150 static inline void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
152 msg->flags |= MSG_GEN_FLAG_MASK & flags;
155 static inline void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
157 msg->flags &= ~MSG_GEN_FLAG_MASK;
158 lustre_msg_add_flags(msg, flags);
161 static inline int lustre_msg_get_op_flags(struct lustre_msg *msg)
163 return (msg->flags >> MSG_OP_FLAG_SHIFT);
166 static inline void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
168 msg->flags |= ((flags & MSG_GEN_FLAG_MASK) << MSG_OP_FLAG_SHIFT);
171 static inline void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
173 msg->flags &= ~MSG_OP_FLAG_MASK;
174 lustre_msg_add_op_flags(msg, flags);
178 * Flags for all connect opcodes (MDS_CONNECT, OST_CONNECT)
181 #define MSG_CONNECT_RECOVERING 0x1
182 #define MSG_CONNECT_RECONNECT 0x2
183 #define MSG_CONNECT_REPLAYABLE 0x4
186 * OST requests: OBDO & OBD request records
190 #define OST_REPLY 0 /* reply ? */
191 #define OST_GETATTR 1
192 #define OST_SETATTR 2
196 #define OST_DESTROY 6
197 #define OST_GET_INFO 7
198 #define OST_CONNECT 8
199 #define OST_DISCONNECT 9
203 #define OST_STATFS 13
206 typedef uint64_t obd_id;
207 typedef uint64_t obd_gr;
208 typedef uint64_t obd_time;
209 typedef uint64_t obd_size;
210 typedef uint64_t obd_off;
211 typedef uint64_t obd_blocks;
212 typedef uint32_t obd_blksize;
213 typedef uint32_t obd_mode;
214 typedef uint32_t obd_uid;
215 typedef uint32_t obd_gid;
216 typedef uint64_t obd_rdev;
217 typedef uint32_t obd_flag;
218 typedef uint32_t obd_count;
220 #define OBD_FL_INLINEDATA (0x00000001)
221 #define OBD_FL_OBDMDEXISTS (0x00000002)
223 #define OBD_INLINESZ 60
225 /* Note: 64-bit types are 64-bit aligned in structure */
235 obd_blksize o_blksize;
241 obd_count o_generation;
242 obd_flag o_valid; /* hot fields in this obdo */
245 char o_inline[OBD_INLINESZ];
248 struct lov_object_id { /* per-child structure */
252 #define LOV_MAGIC 0x0BD00BD0
256 __u64 lmm_object_id; /* lov object id */
257 __u32 lmm_stripe_size; /* size of the stripe */
258 __u32 lmm_stripe_offset; /* starting stripe offset in lmm_objects */
259 __u16 lmm_stripe_count; /* number of stipes in use for this object */
260 __u16 lmm_ost_count; /* how many OST idx are in this LOV md */
261 struct lov_object_id lmm_objects[0];
264 #define OBD_MD_FLALL (0xffffffff)
265 #define OBD_MD_FLID (0x00000001) /* object ID */
266 #define OBD_MD_FLATIME (0x00000002) /* access time */
267 #define OBD_MD_FLMTIME (0x00000004) /* data modification time */
268 #define OBD_MD_FLCTIME (0x00000008) /* change time */
269 #define OBD_MD_FLSIZE (0x00000010) /* size */
270 #define OBD_MD_FLBLOCKS (0x00000020) /* allocated blocks count */
271 #define OBD_MD_FLBLKSZ (0x00000040) /* block size */
272 #define OBD_MD_FLMODE (0x00000080) /* access bits (mode & ~S_IFMT) */
273 #define OBD_MD_FLTYPE (0x00000100) /* object type (mode & S_IFMT) */
274 #define OBD_MD_FLUID (0x00000200) /* user ID */
275 #define OBD_MD_FLGID (0x00000400) /* group ID */
276 #define OBD_MD_FLFLAGS (0x00000800) /* flags word */
277 #define OBD_MD_FLOBDFLG (0x00001000)
278 #define OBD_MD_FLNLINK (0x00002000) /* link count */
279 #define OBD_MD_FLGENER (0x00004000) /* generation number */
280 #define OBD_MD_FLINLINE (0x00008000) /* inline data */
281 #define OBD_MD_FLRDEV (0x00010000) /* device number */
282 #define OBD_MD_FLEASIZE (0x00020000) /* extended attribute data */
283 #define OBD_MD_LINKNAME (0x00040000) /* symbolic link target */
284 #define OBD_MD_FLHANDLE (0x00080000) /* file handle */
285 #define OBD_MD_FLNOTOBD (~(OBD_MD_FLOBDFLG | OBD_MD_FLBLOCKS | OBD_MD_LINKNAME|\
286 OBD_MD_FLEASIZE | OBD_MD_FLHANDLE))
301 /* ost_body.data values for OST_BRW */
303 #define OBD_BRW_READ 0x1
304 #define OBD_BRW_WRITE 0x2
305 #define OBD_BRW_RWMASK (OBD_BRW_READ | OBD_BRW_WRITE)
306 #define OBD_BRW_CREATE 0x4
308 #define OBD_OBJECT_EOF 0xffffffffffffffffULL
317 struct niobuf_remote {
324 /* request structure for OST's */
326 #define OST_REQ_HAS_OA1 0x1
337 #define MDS_GETATTR 1
338 #define MDS_GETATTR_NAME 2
341 #define MDS_READPAGE 6
342 #define MDS_CONNECT 7
343 #define MDS_DISCONNECT 8
344 #define MDS_GETSTATUS 9
345 #define MDS_STATFS 10
346 #define MDS_GETLOVINFO 11
348 #define REINT_SETATTR 1
349 #define REINT_CREATE 2
351 #define REINT_UNLINK 4
352 #define REINT_RENAME 5
356 #define IT_INTENT_EXEC 1
357 #define IT_OPEN_LOOKUP (1 << 1)
358 #define IT_OPEN_NEG (1 << 2)
359 #define IT_OPEN_POS (1 << 3)
360 #define IT_OPEN_CREATE (1 << 4)
361 #define IT_OPEN_OPEN (1 << 5)
363 #define IT_UNLINK (1<<8)
365 #define REINT_OPCODE_MASK 0xff /* opcodes must fit into this mask */
366 #define REINT_REPLAYING 0x1000 /* masked into the opcode to indicate replay */
375 #define MDS_STATUS_CONN 1
376 #define MDS_STATUS_LOV 2
378 struct mds_status_req {
383 struct mds_fileh_body {
385 struct lustre_handle f_handle;
388 struct mds_conn_status {
389 struct ll_fid rootfid;
391 __u64 last_committed;
393 /* XXX preallocated quota & obj fields here */
399 struct lustre_handle handle;
401 __u64 blocks; /* XID, in the case of MDS_READPAGE */
402 __u32 ino; /* make this a __u64 */
420 /* This is probably redundant with OBD_MD_FLEASIZE, but we need an audit */
421 #define MDS_OPEN_HAS_EA 1 /* this open has an EA, for a delayed create*/
423 /* MDS update records */
426 //struct mds_update_record_hdr {
430 struct mds_rec_setattr {
437 struct ll_fid sa_fid;
449 struct mds_rec_create {
454 __u32 cr_flags; /* for use with open */
456 struct ll_fid cr_fid;
457 struct ll_fid cr_replayfid;
465 struct mds_rec_link {
471 struct ll_fid lk_fid1;
472 struct ll_fid lk_fid2;
475 struct mds_rec_unlink {
483 struct ll_fid ul_fid1;
484 struct ll_fid ul_fid2;
487 struct mds_rec_rename {
492 struct ll_fid rn_fid1;
493 struct ll_fid rn_fid2;
498 * LOV data structures
505 __u32 ld_tgt_count; /* how many OBD's */
506 __u32 ld_active_tgt_count; /* how many active */
507 __u32 ld_default_stripe_count; /* how many objects are used */
508 __u64 ld_default_stripe_size; /* in bytes */
509 __u64 ld_default_stripe_offset; /* in bytes */
510 __u32 ld_pattern; /* RAID 0,1 etc */
511 struct obd_uuid ld_uuid;
517 /* opcodes -- MUST be distinct from OST/MDS opcodes */
518 #define LDLM_ENQUEUE 101
519 #define LDLM_CONVERT 102
520 #define LDLM_CANCEL 103
521 #define LDLM_BL_CALLBACK 104
522 #define LDLM_CP_CALLBACK 105
524 #define RES_NAME_SIZE 3
525 #define RES_VERSION_SIZE 4
528 __u64 name[RES_NAME_SIZE];
550 /* Note this unaligned structure; as long as it's only used in ldlm_request
551 * below, we're probably fine. */
552 struct ldlm_resource_desc {
554 struct ldlm_res_id lr_name;
555 __u32 lr_version[RES_VERSION_SIZE];
558 struct ldlm_lock_desc {
559 struct ldlm_resource_desc l_resource;
560 ldlm_mode_t l_req_mode;
561 ldlm_mode_t l_granted_mode;
562 struct ldlm_extent l_extent;
563 __u32 l_version[RES_VERSION_SIZE];
566 struct ldlm_request {
568 struct ldlm_lock_desc lock_desc;
569 struct lustre_handle lock_handle1;
570 struct lustre_handle lock_handle2;
576 struct ldlm_res_id lock_resource_name;
577 struct lustre_handle lock_handle;
578 struct ldlm_extent lock_extent; /* XXX make this policy 1 &2 */
579 __u64 lock_policy_res1;
580 __u64 lock_policy_res2;
584 * ptlbd, portal block device requests