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>
32 # include <linux/string.h> /* for strncpy, below */
35 # include <asm/types.h>
36 # include <linux/list.h>
41 * this file contains all data structures used in Lustre interfaces:
42 * - obdo and obd_request records
43 * - mds_request records
55 static inline void obd_str2uuid(struct obd_uuid *uuid, char *tmp)
57 strncpy(uuid->uuid, tmp, sizeof(*uuid));
58 uuid->uuid[sizeof(*uuid) - 1] = '\0';
61 /* FOO_REQUEST_PORTAL is for incoming requests on the FOO
62 * FOO_REPLY_PORTAL is for incoming replies on the FOO
63 * FOO_BULK_PORTAL is for incoming bulk on the FOO
66 #define CONNMGR_REQUEST_PORTAL 1
67 #define CONNMGR_REPLY_PORTAL 2
68 //#define OSC_REQUEST_PORTAL 3
69 #define OSC_REPLY_PORTAL 4
70 #define OSC_BULK_PORTAL 5
71 #define OST_REQUEST_PORTAL 6
72 //#define OST_REPLY_PORTAL 7
73 #define OST_BULK_PORTAL 8
74 //#define MDC_REQUEST_PORTAL 9
75 #define MDC_REPLY_PORTAL 10
76 //#define MDC_BULK_PORTAL 11
77 #define MDS_REQUEST_PORTAL 12
78 //#define MDS_REPLY_PORTAL 13
79 #define MDS_BULK_PORTAL 14
80 #define LDLM_CB_REQUEST_PORTAL 15
81 #define LDLM_CB_REPLY_PORTAL 16
82 #define LDLM_CANCEL_REQUEST_PORTAL 17
83 #define LDLM_CANCEL_REPLY_PORTAL 18
84 #define PTLBD_REQUEST_PORTAL 19
85 #define PTLBD_REPLY_PORTAL 20
86 #define PTLBD_BULK_PORTAL 21
87 #define MDS_SETATTR_PORTAL 22
88 #define MDS_READPAGE_PORTAL 23
94 #define SVC_STOPPING 16
95 #define SVC_STOPPED 32
97 #define LUSTRE_CONN_NEW 1
98 #define LUSTRE_CONN_CON 2
99 #define LUSTRE_CONN_RECOVD 3
100 #define LUSTRE_CONN_FULL 4
103 #define PTL_RPC_MSG_REQUEST 4711
104 #define PTL_RPC_MSG_ERR 4712
105 #define PTL_RPC_MSG_REPLY 4713
107 #define PTLRPC_MSG_MAGIC (cpu_to_le32(0x0BD00BD0))
108 #define PTLRPC_MSG_VERSION (cpu_to_le32(0x00040001))
110 struct lustre_handle {
114 #define DEAD_HANDLE_MAGIC 0xdeadbeefcafebabe
116 static inline void ptlrpc_invalidate_handle(struct lustre_handle *hdl)
118 hdl->addr = hdl->cookie = 0; /* XXX invalid enough? */
121 /* we depend on this structure to be 8-byte aligned */
124 __u64 cookie; /* security token */
130 __u64 last_committed;
138 /* Flags that are operation-specific go in the top 16 bits. */
139 #define MSG_OP_FLAG_MASK 0xffff0000
140 #define MSG_OP_FLAG_SHIFT 16
142 /* Flags that apply to all requests are in the bottom 16 bits */
143 #define MSG_GEN_FLAG_MASK 0x0000ffff
144 #define MSG_LAST_REPLAY 1
147 static inline int lustre_msg_get_flags(struct lustre_msg *msg)
149 return (msg->flags & MSG_GEN_FLAG_MASK);
152 static inline void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
154 msg->flags |= MSG_GEN_FLAG_MASK & flags;
157 static inline void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
159 msg->flags &= ~MSG_GEN_FLAG_MASK;
160 lustre_msg_add_flags(msg, flags);
163 static inline int lustre_msg_get_op_flags(struct lustre_msg *msg)
165 return (msg->flags >> MSG_OP_FLAG_SHIFT);
168 static inline void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
170 msg->flags |= ((flags & MSG_GEN_FLAG_MASK) << MSG_OP_FLAG_SHIFT);
173 static inline void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
175 msg->flags &= ~MSG_OP_FLAG_MASK;
176 lustre_msg_add_op_flags(msg, flags);
180 * Flags for all connect opcodes (MDS_CONNECT, OST_CONNECT)
183 #define MSG_CONNECT_RECOVERING 0x1
184 #define MSG_CONNECT_RECONNECT 0x2
185 #define MSG_CONNECT_REPLAYABLE 0x4
188 * OST requests: OBDO & OBD request records
192 #define OST_REPLY 0 /* reply ? */
193 #define OST_GETATTR 1
194 #define OST_SETATTR 2
198 #define OST_DESTROY 6
199 #define OST_GET_INFO 7
200 #define OST_CONNECT 8
201 #define OST_DISCONNECT 9
205 #define OST_STATFS 13
206 #define OST_SAN_READ 14
207 #define OST_SAN_WRITE 15
208 #define OST_SYNCFS 16
211 typedef uint64_t obd_id;
212 typedef uint64_t obd_gr;
213 typedef uint64_t obd_time;
214 typedef uint64_t obd_size;
215 typedef uint64_t obd_off;
216 typedef uint64_t obd_blocks;
217 typedef uint32_t obd_blksize;
218 typedef uint32_t obd_mode;
219 typedef uint32_t obd_uid;
220 typedef uint32_t obd_gid;
221 typedef uint64_t obd_rdev;
222 typedef uint32_t obd_flag;
223 typedef uint32_t obd_count;
225 #define OBD_FL_INLINEDATA (0x00000001)
226 #define OBD_FL_OBDMDEXISTS (0x00000002)
228 #define OBD_INLINESZ 60
229 #define FD_OSTDATA_SIZE 32
230 #if (FD_OSTDATA_SIZE > OBD_INLINESZ)
231 # error FD_OSTDATA_SIZE must be smaller than OBD_INLINESZ
234 /* Note: 64-bit types are 64-bit aligned in structure */
244 obd_blksize o_blksize;
250 obd_count o_generation;
251 obd_flag o_valid; /* hot fields in this obdo */
254 char o_inline[OBD_INLINESZ];
257 struct lov_object_id { /* per-child structure */
261 #define LOV_MAGIC 0x0BD00BD0
265 __u64 lmm_object_id; /* lov object id */
266 __u32 lmm_stripe_size; /* size of the stripe */
267 __u32 lmm_stripe_offset; /* starting stripe offset in lmm_objects */
268 __u16 lmm_stripe_count; /* number of stipes in use for this object */
269 __u16 lmm_ost_count; /* how many OST idx are in this LOV md */
270 struct lov_object_id lmm_objects[0];
273 #define OBD_MD_FLALL (0xffffffff)
274 #define OBD_MD_FLID (0x00000001) /* object ID */
275 #define OBD_MD_FLATIME (0x00000002) /* access time */
276 #define OBD_MD_FLMTIME (0x00000004) /* data modification time */
277 #define OBD_MD_FLCTIME (0x00000008) /* change time */
278 #define OBD_MD_FLSIZE (0x00000010) /* size */
279 #define OBD_MD_FLBLOCKS (0x00000020) /* allocated blocks count */
280 #define OBD_MD_FLBLKSZ (0x00000040) /* block size */
281 #define OBD_MD_FLMODE (0x00000080) /* access bits (mode & ~S_IFMT) */
282 #define OBD_MD_FLTYPE (0x00000100) /* object type (mode & S_IFMT) */
283 #define OBD_MD_FLUID (0x00000200) /* user ID */
284 #define OBD_MD_FLGID (0x00000400) /* group ID */
285 #define OBD_MD_FLFLAGS (0x00000800) /* flags word */
286 #define OBD_MD_FLOBDFLG (0x00001000)
287 #define OBD_MD_FLNLINK (0x00002000) /* link count */
288 #define OBD_MD_FLGENER (0x00004000) /* generation number */
289 #define OBD_MD_FLINLINE (0x00008000) /* inline data */
290 #define OBD_MD_FLRDEV (0x00010000) /* device number */
291 #define OBD_MD_FLEASIZE (0x00020000) /* extended attribute data */
292 #define OBD_MD_LINKNAME (0x00040000) /* symbolic link target */
293 #define OBD_MD_FLHANDLE (0x00080000) /* file handle */
294 #define OBD_MD_FLCKSUM (0x00100000) /* bulk data checksum */
295 #define OBD_MD_FLNOTOBD (~(OBD_MD_FLOBDFLG | OBD_MD_FLBLOCKS | OBD_MD_LINKNAME|\
296 OBD_MD_FLEASIZE | OBD_MD_FLHANDLE | OBD_MD_FLCKSUM))
311 /* ost_body.data values for OST_BRW */
313 #define OBD_BRW_READ 0x1
314 #define OBD_BRW_WRITE 0x2
315 #define OBD_BRW_RWMASK (OBD_BRW_READ | OBD_BRW_WRITE)
316 #define OBD_BRW_CREATE 0x4
318 #define OBD_OBJECT_EOF 0xffffffffffffffffULL
327 struct niobuf_remote {
332 } __attribute__((packed));
334 /* request structure for OST's */
336 #define OST_REQ_HAS_OA1 0x1
347 #define MDS_GETATTR 33
348 #define MDS_GETATTR_NAME 34
351 #define MDS_READPAGE 37
352 #define MDS_CONNECT 38
353 #define MDS_DISCONNECT 39
354 #define MDS_GETSTATUS 40
355 #define MDS_STATFS 41
356 #define MDS_GETLOVINFO 42
361 #define REINT_SETATTR 1
362 #define REINT_CREATE 2
364 #define REINT_UNLINK 4
365 #define REINT_RENAME 5
369 #define IT_INTENT_EXEC 1
370 #define IT_OPEN_LOOKUP (1 << 1)
371 #define IT_OPEN_NEG (1 << 2)
372 #define IT_OPEN_POS (1 << 3)
373 #define IT_OPEN_CREATE (1 << 4)
374 #define IT_OPEN_OPEN (1 << 5)
376 #define REINT_OPCODE_MASK 0xff /* opcodes must fit into this mask */
377 #define REINT_REPLAYING 0x1000 /* masked into the opcode to indicate replay */
386 #define MDS_STATUS_CONN 1
387 #define MDS_STATUS_LOV 2
389 struct mds_status_req {
394 struct mds_fileh_body {
396 struct lustre_handle f_handle;
399 struct mds_conn_status {
400 struct ll_fid rootfid;
402 __u64 last_committed;
404 /* XXX preallocated quota & obj fields here */
410 struct lustre_handle handle;
412 __u64 blocks; /* XID, in the case of MDS_READPAGE */
413 __u32 ino; /* make this a __u64 */
431 /* This is probably redundant with OBD_MD_FLEASIZE, but we need an audit */
432 #define MDS_OPEN_HAS_EA 1 /* this open has an EA, for a delayed create*/
434 /* MDS update records */
437 //struct mds_update_record_hdr {
441 struct mds_rec_setattr {
448 struct ll_fid sa_fid;
460 struct mds_rec_create {
465 __u32 cr_flags; /* for use with open */
467 struct ll_fid cr_fid;
468 struct ll_fid cr_replayfid;
476 struct mds_rec_link {
482 struct ll_fid lk_fid1;
483 struct ll_fid lk_fid2;
486 struct mds_rec_unlink {
494 struct ll_fid ul_fid1;
495 struct ll_fid ul_fid2;
498 struct mds_rec_rename {
505 struct ll_fid rn_fid1;
506 struct ll_fid rn_fid2;
511 * LOV data structures
518 __u32 ld_tgt_count; /* how many OBD's */
519 __u32 ld_active_tgt_count; /* how many active */
520 __u32 ld_default_stripe_count; /* how many objects are used */
521 __u64 ld_default_stripe_size; /* in bytes */
522 __u64 ld_default_stripe_offset; /* in bytes */
523 __u32 ld_pattern; /* RAID 0,1 etc */
524 struct obd_uuid ld_uuid;
530 /* opcodes -- MUST be distinct from OST/MDS opcodes */
531 #define LDLM_ENQUEUE 101
532 #define LDLM_CONVERT 102
533 #define LDLM_CANCEL 103
534 #define LDLM_BL_CALLBACK 104
535 #define LDLM_CP_CALLBACK 105
537 #define RES_NAME_SIZE 3
538 #define RES_VERSION_SIZE 4
541 __u64 name[RES_NAME_SIZE];
563 /* Note this unaligned structure; as long as it's only used in ldlm_request
564 * below, we're probably fine. */
565 struct ldlm_resource_desc {
567 struct ldlm_res_id lr_name;
568 __u32 lr_version[RES_VERSION_SIZE];
571 struct ldlm_lock_desc {
572 struct ldlm_resource_desc l_resource;
573 ldlm_mode_t l_req_mode;
574 ldlm_mode_t l_granted_mode;
575 struct ldlm_extent l_extent;
576 __u32 l_version[RES_VERSION_SIZE];
579 struct ldlm_request {
581 struct ldlm_lock_desc lock_desc;
582 struct lustre_handle lock_handle1;
583 struct lustre_handle lock_handle2;
589 struct ldlm_res_id lock_resource_name;
590 struct lustre_handle lock_handle;
591 struct ldlm_extent lock_extent; /* XXX make this policy 1 &2 */
592 __u64 lock_policy_res1;
593 __u64 lock_policy_res2;
597 * ptlbd, portal block device requests