* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* (Un)packing of OST requests
+ *
+ * We assume all nodes are either little-endian or big-endian, and we
+ * always send messages in the sender's native format. The receiver
+ * detects the message format by checking the 'magic' field of the message
+ * (see lustre_msg_swabbed() below).
+ *
+ * Each wire type has corresponding 'lustre_swab_xxxtypexxx()' routines,
+ * implemented either here, inline (trivial implementations) or in
+ * ptlrpc/pack_generic.c. These 'swabbers' convert the type from "other"
+ * endian, in-place in the message buffer.
+ *
+ * A swabber takes a single pointer argument. The caller must already have
+ * verified that the length of the message buffer >= sizeof (type).
+ *
+ * For variable length types, a second 'lustre_swab_v_xxxtypexxx()' routine
+ * may be defined that swabs just the variable part, after the caller has
+ * verified that the message buffer is large enough.
*/
#ifndef _LUSTRE_IDL_H_
# include <linux/types.h>
# include <linux/list.h>
# include <linux/string.h> /* for strncpy, below */
+# include <asm/byteorder.h>
+#else
+#ifdef __CYGWIN__
+# include <sys/types.h>
#else
-# define __KERNEL__
# include <asm/types.h>
-# include <linux/list.h>
-# undef __KERNEL__
# include <stdint.h>
#endif
+# include <portals/list.h>
+#endif
/*
* this file contains all data structures used in Lustre interfaces:
* - obdo and obd_request records
__u8 uuid[37];
};
+static inline int obd_uuid_equals(struct obd_uuid *u1, struct obd_uuid *u2)
+{
+ return strcmp(u1->uuid, u2->uuid) == 0;
+}
+
static inline void obd_str2uuid(struct obd_uuid *uuid, char *tmp)
{
strncpy(uuid->uuid, tmp, sizeof(*uuid));
uuid->uuid[sizeof(*uuid) - 1] = '\0';
}
+extern struct obd_uuid lctl_fake_uuid;
+
/* FOO_REQUEST_PORTAL is for incoming requests on the FOO
* FOO_REPLY_PORTAL is for incoming replies on the FOO
* FOO_BULK_PORTAL is for incoming bulk on the FOO
#define CONNMGR_REPLY_PORTAL 2
//#define OSC_REQUEST_PORTAL 3
#define OSC_REPLY_PORTAL 4
-#define OSC_BULK_PORTAL 5
+//#define OSC_BULK_PORTAL 5
#define OST_REQUEST_PORTAL 6
//#define OST_REPLY_PORTAL 7
#define OST_BULK_PORTAL 8
#define LUSTRE_CONN_NEW 1
#define LUSTRE_CONN_CON 2
-#define LUSTRE_CONN_RECOVD 3
-#define LUSTRE_CONN_FULL 4
+#define LUSTRE_CONN_NOTCONN 3
+#define LUSTRE_CONN_RECOVD 4
+#define LUSTRE_CONN_FULL 5
/* packet types */
#define PTL_RPC_MSG_REQUEST 4711
#define PTL_RPC_MSG_ERR 4712
#define PTL_RPC_MSG_REPLY 4713
-#define PTLRPC_MSG_MAGIC (cpu_to_le32(0x0BD00BD0))
-#define PTLRPC_MSG_VERSION (cpu_to_le32(0x00040001))
+#define PTLRPC_MSG_MAGIC 0x0BD00BD0
+#define PTLRPC_MSG_VERSION 0x00040002
struct lustre_handle {
- __u64 addr;
__u64 cookie;
};
#define DEAD_HANDLE_MAGIC 0xdeadbeefcafebabe
-static inline void ptlrpc_invalidate_handle(struct lustre_handle *hdl)
-{
- hdl->addr = hdl->cookie = 0; /* XXX invalid enough? */
-}
-
/* we depend on this structure to be 8-byte aligned */
+/* this type is only endian-adjusted in lustre_unpack_msg() */
struct lustre_msg {
- __u64 addr;
- __u64 cookie; /* security token */
+ struct lustre_handle handle;
__u32 magic;
__u32 type;
__u32 version;
__u64 last_committed;
__u64 transno;
__u32 status;
- __u32 bufcount;
__u32 flags;
+ __u32 bufcount;
__u32 buflens[0];
};
+static inline int lustre_msg_swabbed (struct lustre_msg *msg)
+{
+ return (msg->magic == __swab32 (PTLRPC_MSG_MAGIC));
+}
+
/* Flags that are operation-specific go in the top 16 bits. */
#define MSG_OP_FLAG_MASK 0xffff0000
#define MSG_OP_FLAG_SHIFT 16
#define OST_SAN_READ 14
#define OST_SAN_WRITE 15
#define OST_SYNCFS 16
+/* When adding OST RPC opcodes, please update
+ * LAST/FIRST macros used in ptlrpc/ptlrpc_internals.h */
+#define OST_LAST_OPC (OST_SYNCFS+1)
+#define OST_FIRST_OPC OST_REPLY
typedef uint64_t obd_id;
#define OBD_FL_OBDMDEXISTS (0x00000002)
#define OBD_INLINESZ 60
-#define FD_OSTDATA_SIZE 32
-#if (FD_OSTDATA_SIZE > OBD_INLINESZ)
-# error FD_OSTDATA_SIZE must be smaller than OBD_INLINESZ
-#endif
+#define FD_OSTDATA_SIZE sizeof(struct obd_client_handle)
/* Note: 64-bit types are 64-bit aligned in structure */
struct obdo {
obd_size o_size;
obd_blocks o_blocks;
obd_rdev o_rdev;
- obd_blksize o_blksize;
+ obd_blksize o_blksize; /* optimal IO blocksize */
obd_mode o_mode;
obd_uid o_uid;
obd_gid o_gid;
char o_inline[OBD_INLINESZ];
};
+extern void lustre_swab_obdo (struct obdo *o);
+
struct lov_object_id { /* per-child structure */
__u64 l_object_id;
};
__u8 os_fsid[40];
__u32 os_bsize;
__u32 os_namelen;
- __u32 os_spare[12];
+ __u64 os_maxbytes;
+ __u32 os_spare[10];
};
+extern void lustre_swab_obd_statfs (struct obd_statfs *os);
+
/* ost_body.data values for OST_BRW */
-#define OBD_BRW_READ 0x1
-#define OBD_BRW_WRITE 0x2
-#define OBD_BRW_RWMASK (OBD_BRW_READ | OBD_BRW_WRITE)
-#define OBD_BRW_CREATE 0x4
-#define OBD_BRW_SYNC 0x8
+#define OBD_BRW_READ 0x01
+#define OBD_BRW_WRITE 0x02
+#define OBD_BRW_RWMASK (OBD_BRW_READ | OBD_BRW_WRITE)
+#define OBD_BRW_CREATE 0x04
+#define OBD_BRW_SYNC 0x08
+#define OBD_BRW_CHECK 0x10
#define OBD_OBJECT_EOF 0xffffffffffffffffULL
__u32 ioo_bufcnt;
} __attribute__((packed));
+extern void lustre_swab_obd_ioobj (struct obd_ioobj *ioo);
+
+/* multiple of 8 bytes => can array */
struct niobuf_remote {
__u64 offset;
__u32 len;
- __u32 xid;
__u32 flags;
} __attribute__((packed));
+extern void lustre_swab_niobuf_remote (struct niobuf_remote *nbr);
+
/* request structure for OST's */
#define OST_REQ_HAS_OA1 0x1
struct obdo oa;
};
+extern void lustre_swab_ost_body (struct ost_body *b);
+
/*
* MDS REQ RECORDS
*/
#define MDS_GETSTATUS 40
#define MDS_STATFS 41
#define MDS_GETLOVINFO 42
+/* When adding MDS RPC opcodes, please update
+ * LAST/FIRST macros used in ptlrpc/ptlrpc_internals.h */
+#define MDS_LAST_OPC (MDS_GETLOVINFO+1)
+#define MDS_FIRST_OPC MDS_GETATTR
/*
* Do not exceed 63
*/
#define IT_OPEN_CREATE (1 << 4)
#define IT_OPEN_OPEN (1 << 5)
-#define REINT_OPCODE_MASK 0xff /* opcodes must fit into this mask */
-#define REINT_REPLAYING 0x1000 /* masked into the opcode to indicate replay */
-
struct ll_fid {
__u64 id;
__u32 generation;
__u32 f_type;
};
+extern void lustre_swab_ll_fid (struct ll_fid *fid);
#define MDS_STATUS_CONN 1
#define MDS_STATUS_LOV 2
__u32 repbuf;
};
+extern void lustre_swab_mds_status_req (struct mds_status_req *r);
+
struct mds_fileh_body {
struct ll_fid f_fid;
struct lustre_handle f_handle;
};
-struct mds_conn_status {
- struct ll_fid rootfid;
- __u64 xid;
- __u64 last_committed;
- __u64 last_rcvd;
- /* XXX preallocated quota & obj fields here */
-};
+extern void lustre_swab_mds_fileh_body (struct mds_fileh_body *f);
struct mds_body {
struct ll_fid fid1;
struct ll_fid fid2;
struct lustre_handle handle;
- __u64 size;
+ __u64 size; /* Offset, in the case of MDS_READPAGE */
__u64 blocks; /* XID, in the case of MDS_READPAGE */
__u32 ino; /* make this a __u64 */
__u32 valid;
__u32 atime;
__u32 flags;
__u32 rdev;
- __u32 nlink;
+ __u32 nlink; /* #bytes to read in the case of MDS_READPAGE */
__u32 generation;
__u32 suppgid;
+ __u32 eadatasize;
};
+extern void lustre_swab_mds_body (struct mds_body *b);
+
/* This is probably redundant with OBD_MD_FLEASIZE, but we need an audit */
#define MDS_OPEN_HAS_EA 1 /* this open has an EA, for a delayed create*/
/* MDS update records */
-
//struct mds_update_record_hdr {
// __u32 ur_opcode;
//};
__u32 sa_suppgid;
};
+extern void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa);
+
struct mds_rec_create {
__u32 cr_opcode;
__u32 cr_fsuid;
__u32 cr_suppgid;
};
+extern void lustre_swab_mds_rec_create (struct mds_rec_create *cr);
+
struct mds_rec_link {
__u32 lk_opcode;
__u32 lk_fsuid;
__u32 lk_fsgid;
__u32 lk_cap;
- __u32 lk_suppgid;
+ __u32 lk_suppgid1;
+ __u32 lk_suppgid2;
struct ll_fid lk_fid1;
struct ll_fid lk_fid2;
};
+extern void lustre_swab_mds_rec_link (struct mds_rec_link *lk);
+
struct mds_rec_unlink {
__u32 ul_opcode;
__u32 ul_fsuid;
struct ll_fid ul_fid2;
};
+extern void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul);
+
struct mds_rec_rename {
__u32 rn_opcode;
__u32 rn_fsuid;
struct ll_fid rn_fid2;
};
+extern void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn);
/*
* LOV data structures
#define LOV_RAID0 0
#define LOV_RAIDRR 1
+#define LOV_MAX_UUID_BUFFER_SIZE 8192
+/* The size of the buffer the lov/mdc reserves for the
+ * array of UUIDs returned by the MDS. With the current
+ * protocol, this will limit the max number of OSTs per LOV */
+
struct lov_desc {
__u32 ld_tgt_count; /* how many OBD's */
__u32 ld_active_tgt_count; /* how many active */
struct obd_uuid ld_uuid;
};
+extern void lustre_swab_lov_desc (struct lov_desc *ld);
+
/*
* LDLM requests:
*/
#define LDLM_CANCEL 103
#define LDLM_BL_CALLBACK 104
#define LDLM_CP_CALLBACK 105
+/* When adding LDLM RPC opcodes, please update
+ * LAST/FIRST macros used in ptlrpc/ptlrpc_internals.h */
+#define LDLM_LAST_OPC (LDLM_CP_CALLBACK+1)
+#define LDLM_FIRST_OPC LDLM_ENQUEUE
#define RES_NAME_SIZE 3
#define RES_VERSION_SIZE 4
__u64 name[RES_NAME_SIZE];
};
+extern void lustre_swab_ldlm_res_id (struct ldlm_res_id *id);
+
/* lock types */
typedef enum {
LCK_EX = 1,
__u64 end;
};
+extern void lustre_swab_ldlm_extent (struct ldlm_extent *e);
+
struct ldlm_intent {
__u64 opc;
};
+extern void lustre_swab_ldlm_intent (struct ldlm_intent *i);
+
/* Note this unaligned structure; as long as it's only used in ldlm_request
* below, we're probably fine. */
struct ldlm_resource_desc {
__u32 lr_version[RES_VERSION_SIZE];
};
+extern void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r);
+
struct ldlm_lock_desc {
struct ldlm_resource_desc l_resource;
ldlm_mode_t l_req_mode;
__u32 l_version[RES_VERSION_SIZE];
};
+extern void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l);
+
struct ldlm_request {
__u32 lock_flags;
struct ldlm_lock_desc lock_desc;
struct lustre_handle lock_handle2;
};
+extern void lustre_swab_ldlm_request (struct ldlm_request *rq);
+
struct ldlm_reply {
__u32 lock_flags;
__u32 lock_mode;
__u64 lock_policy_res2;
};
+extern void lustre_swab_ldlm_reply (struct ldlm_reply *r);
+
/*
* ptlbd, portal block device requests
*/
PTLBD_QUERY = 200,
PTLBD_READ = 201,
PTLBD_WRITE = 202,
+ PTLBD_FLUSH = 203,
+ PTLBD_CONNECT = 204,
+ PTLBD_DISCONNECT = 205,
} ptlbd_cmd_t;
+/* When adding PTLBD RPC opcodes, please update
+ * LAST/FIRST macros used in ptlrpc/ptlrpc_internals.h */
+#define PTLBD_LAST_OPC (PTLBD_FLUSH+1)
+#define PTLBD_FIRST_OPC PTLBD_QUERY
struct ptlbd_op {
__u16 op_cmd;
__u32 op_block_cnt;
};
+extern void lustre_swab_ptlbd_op (struct ptlbd_op *op);
+
struct ptlbd_niob {
__u64 n_xid;
__u64 n_block_nr;
__u32 n_length;
};
+extern void lustre_swab_ptlbd_niob (struct ptlbd_niob *n);
+
struct ptlbd_rsp {
__u16 r_status;
__u16 r_error_cnt;
};
+
+extern void lustre_swab_ptlbd_rsp (struct ptlbd_rsp *r);
+
+/*
+ * Opcodes for multiple servers.
+ */
+
+#define OBD_PING 400
+
#endif