Whamcloud - gitweb
b=16098
[fs/lustre-release.git] / lustre / include / lustre / lustre_idl.h
index f8061b9..3be6942 100644 (file)
@@ -1,7 +1,39 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *   This file is part of Lustre, http://www.lustre.org
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see [sun.com URL with a
+ * copy of GPLv2].
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/include/lustre/lustre_idl.h
  *
  * Lustre wire protocol definitions.
  *
 #ifndef _LUSTRE_IDL_H_
 #define _LUSTRE_IDL_H_
 
-#include <libcfs/kp30.h>
+#include <libcfs/libcfs.h>
 
-#if defined(__linux__)
-#include <linux/lustre_types.h>
-#elif defined(__APPLE__)
-#include <darwin/lustre_types.h>
-#elif defined(__WINNT__)
-#include <winnt/lustre_types.h>
-#else
-#error Unsupported operating system.
-#endif
+#include <lustre/types.h>
 
 /* Defn's shared with user-space. */
 #include <lustre/lustre_user.h>
@@ -196,7 +220,7 @@ static inline int range_is_exhausted(struct lu_range *r)
 struct lu_fid {
         __u64 f_seq;  /* holds fid sequence. Lustre should support 2 ^ 64
                        * objects, thus even if one sequence has one object we
-                       * reach this value. */
+                       * will never reach this value. */
         __u32 f_oid;  /* fid number within its sequence. */
         __u32 f_ver;  /* holds fid version. */
 };
@@ -205,8 +229,6 @@ struct lu_fid {
  * fid constants
  */
 enum {
-        LUSTRE_ROOT_FID_SEQ  = 1ULL, /* XXX: should go into mkfs. */
-
         /* initial fid id value */
         LUSTRE_FID_INIT_OID  = 1UL
 };
@@ -229,19 +251,55 @@ static inline __u32 fid_ver(const struct lu_fid *fid)
         return fid->f_ver;
 }
 
-static inline int fid_seq_is_sane(__u64 seq)
-{
-        return seq != 0;
-}
-
 static inline void fid_zero(struct lu_fid *fid)
 {
         memset(fid, 0, sizeof(*fid));
 }
 
+/* Normal FID sequence starts from this value, i.e. 1<<33 */
+#define FID_SEQ_START  0x200000000ULL
+
+/* IDIF sequence starts from this value, i.e. 1<<32 */
+#define IDIF_SEQ_START 0x100000000ULL
+
+/**
+ * Check if a fid is igif or not.
+ * \param fid the fid to be tested.
+ * \return true if the fid is a igif; otherwise false. 
+ */
 static inline int fid_is_igif(const struct lu_fid *fid)
 {
-        return fid_seq(fid) == LUSTRE_ROOT_FID_SEQ;
+        return fid_seq(fid) > 0 && fid_seq(fid) < IDIF_SEQ_START;
+}
+
+/**
+ * Check if a fid is idif or not.
+ * \param fid the fid to be tested.
+ * \return true if the fid is a idif; otherwise false. 
+ */
+static inline int fid_is_idif(const struct lu_fid *fid)
+{
+        return fid_seq(fid) >= IDIF_SEQ_START  && fid_seq(fid) < FID_SEQ_START;
+}
+
+/**
+ * Get inode number from a igif.
+ * \param fid a igif to get inode number from.
+ * \return inode number for the igif.
+ */
+static inline ino_t lu_igif_ino(const struct lu_fid *fid)
+{
+        return fid_seq(fid);
+}
+
+/**
+ * Get inode generation from a igif.
+ * \param fid a igif to get inode generation from.
+ * \return inode generation for the igif.
+ */ 
+static inline __u32 lu_igif_gen(const struct lu_fid *fid)
+{
+        return fid_oid(fid);
 }
 
 #define DFID "[0x%16.16"LPF64"x/0x%8.8x:0x%8.8x]"
@@ -322,7 +380,7 @@ static inline int fid_is_sane(const struct lu_fid *fid)
 {
         return
                 fid != NULL &&
-                ((fid_seq_is_sane(fid_seq(fid)) && fid_oid(fid) != 0
+                ((fid_seq(fid) >= FID_SEQ_START && fid_oid(fid) != 0
                                                 && fid_ver(fid) == 0) ||
                 fid_is_igif(fid));
 }
@@ -354,13 +412,14 @@ struct lu_dirent {
         __u64         lde_hash;
         __u16         lde_reclen;
         __u16         lde_namelen;
+        __u32         lde_pad0;
         char          lde_name[0];
 };
 
 struct lu_dirpage {
         __u64            ldp_hash_start;
         __u64            ldp_hash_end;
-        __u16            ldp_flags;
+        __u32            ldp_flags;
         __u32            ldp_pad0;
         struct lu_dirent ldp_entries[0];
 };
@@ -371,7 +430,7 @@ enum lu_dirpage_flags {
 
 static inline struct lu_dirent *lu_dirent_start(struct lu_dirpage *dp)
 {
-        if (le16_to_cpu(dp->ldp_flags) & LDF_EMPTY)
+        if (le32_to_cpu(dp->ldp_flags) & LDF_EMPTY)
                 return NULL;
         else
                 return dp->ldp_entries;
@@ -393,7 +452,7 @@ static inline int lu_dirent_size(struct lu_dirent *ent)
 {
         if (le16_to_cpu(ent->lde_reclen) == 0) {
                 return (sizeof(*ent) +
-                        le16_to_cpu(ent->lde_namelen) + 3) & ~3;
+                        le16_to_cpu(ent->lde_namelen) + 7) & ~7;
         }
         return le16_to_cpu(ent->lde_reclen);
 }
@@ -422,23 +481,8 @@ static inline void lustre_handle_copy(struct lustre_handle *tgt,
         tgt->cookie = src->cookie;
 }
 
-/* we depend on this structure to be 8-byte aligned */
-/* this type is only endian-adjusted in lustre_unpack_msg() */
-struct lustre_msg_v1 {
-        struct lustre_handle lm_handle;
-        __u32 lm_magic;
-        __u32 lm_type;
-        __u32 lm_version;
-        __u32 lm_opc;
-        __u64 lm_last_xid;
-        __u64 lm_last_committed;
-        __u64 lm_transno;
-        __u32 lm_status;
-        __u32 lm_flags;
-        __u32 lm_conn_cnt;
-        __u32 lm_bufcount;
-        __u32 lm_buflens[0];
-};
+/* flags for lm_flags */
+#define MSGHDR_AT_SUPPORT               0x1
 
 #define lustre_msg lustre_msg_v2
 /* we depend on this structure to be 8-byte aligned */
@@ -448,8 +492,8 @@ struct lustre_msg_v2 {
         __u32 lm_secflvr;
         __u32 lm_magic;
         __u32 lm_repsize;
-        __u32 lm_timeout;
-        __u32 lm_padding_1;
+        __u32 lm_cksum;
+        __u32 lm_flags;
         __u32 lm_padding_2;
         __u32 lm_padding_3;
         __u32 lm_buflens[0];
@@ -469,8 +513,8 @@ struct ptlrpc_body {
         __u32 pb_flags;
         __u32 pb_op_flags;
         __u32 pb_conn_cnt;
-        __u32 pb_padding_1;
-        __u32 pb_padding_2;
+        __u32 pb_timeout;  /* for req, the deadline, for rep, the service est */
+        __u32 pb_service_time; /* for rep, actual service time */
         __u32 pb_limit;
         __u64 pb_slv;
 };
@@ -502,12 +546,16 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 #define MSG_OP_FLAG_SHIFT  16
 
 /* Flags that apply to all requests are in the bottom 16 bits */
-#define MSG_GEN_FLAG_MASK      0x0000ffff
-#define MSG_LAST_REPLAY        1
-#define MSG_RESENT             2
-#define MSG_REPLAY             4
-#define MSG_REQ_REPLAY_DONE    8
-#define MSG_LOCK_REPLAY_DONE  16
+#define MSG_GEN_FLAG_MASK     0x0000ffff
+#define MSG_LAST_REPLAY           0x0001
+#define MSG_RESENT                0x0002
+#define MSG_REPLAY                0x0004
+/* #define MSG_AT_SUPPORT         0x0008
+ * This was used in early prototypes of adaptive timeouts, and while there
+ * shouldn't be any users of that code there also isn't a need for using this
+ * bits. Defer usage until at least 1.10 to avoid potential conflict. */
+#define MSG_REQ_REPLAY_DONE       0x0010
+#define MSG_LOCK_REPLAY_DONE      0x0020
 
 /*
  * Flags for all connect opcodes (MDS_CONNECT, OST_CONNECT)
@@ -572,16 +620,16 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
                                 OBD_CONNECT_MDS_CAPA | OBD_CONNECT_OSS_CAPA | \
                                 OBD_CONNECT_MDS_MDS | OBD_CONNECT_CANCELSET | \
                                 OBD_CONNECT_FID | \
-                                LRU_RESIZE_CONNECT_FLAG)
+                                LRU_RESIZE_CONNECT_FLAG | OBD_CONNECT_AT)
 #define OST_CONNECT_SUPPORTED  (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \
                                 OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \
                                 OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_INDEX | \
                                 OBD_CONNECT_BRW_SIZE | OBD_CONNECT_QUOTA64 | \
                                 OBD_CONNECT_OSS_CAPA | OBD_CONNECT_CANCELSET | \
-                                OBD_CONNECT_FID | OBD_CONNECT_CKSUM | \
-                                LRU_RESIZE_CONNECT_FLAG)
+                                OBD_CONNECT_CKSUM | LRU_RESIZE_CONNECT_FLAG | \
+                                OBD_CONNECT_AT)
 #define ECHO_CONNECT_SUPPORTED (0)
-#define MGS_CONNECT_SUPPORTED  (OBD_CONNECT_VERSION | OBD_CONNECT_FID)
+#define MGS_CONNECT_SUPPORTED  (OBD_CONNECT_VERSION | OBD_CONNECT_AT)
 
 #define MAX_QUOTA_COUNT32 (0xffffffffULL)
 
@@ -1149,7 +1197,7 @@ struct mds_body {
         __u32          eadatasize;
         __u32          aclsize;
         __u32          max_mdsize;
-        __u32          max_cookiesize; /* also fix lustre_swab_mds_body */
+        __u32          max_cookiesize;
         __u32          padding_4; /* also fix lustre_swab_mds_body */
 };
 
@@ -1341,7 +1389,8 @@ enum {
         MDS_CHECK_SPLIT  = 1 << 0,
         MDS_CROSS_REF    = 1 << 1,
         MDS_VTX_BYPASS   = 1 << 2,
-        MDS_PERM_BYPASS  = 1 << 3
+        MDS_PERM_BYPASS  = 1 << 3,
+        MDS_SOM          = 1 << 4
 };
 
 struct mds_rec_join {
@@ -1535,7 +1584,7 @@ struct mdt_rec_setxattr {
         __u32           sx_padding_2;
         __u32           sx_padding_3;
         __u64           sx_valid;
-        __u64           sx_padding_4;
+        __u64           sx_time;
         __u64           sx_padding_5;
         __u64           sx_padding_6;
         __u64           sx_padding_7;