Whamcloud - gitweb
LU-3544 fid: do open-by-fid by default
[fs/lustre-release.git] / lustre / include / lustre / lustre_idl.h
index 7fdaa2d..d18b8ca 100644 (file)
@@ -99,6 +99,7 @@
 #include <lustre/lustre_user.h>
 
 #include <lustre/lustre_errno.h>
+#include <lustre_ver.h>
 
 /*
  *  GENERAL STUFF
 #define SEQ_DATA_PORTAL                31
 #define SEQ_CONTROLLER_PORTAL          32
 #define MGS_BULK_PORTAL                33
-#define OST_IDX_PORTAL                34
 
 /* Portal 63 is reserved for the Cray Inc DVS - nic@cray.com, roe@cray.com, n8851@cray.com */
 
@@ -342,8 +342,9 @@ enum lma_incompat {
        LMAI_AGENT              = 0x00000002, /* agent inode */
        LMAI_REMOTE_PARENT      = 0x00000004, /* the parent of the object
                                                 is on the remote MDT */
+       LMAI_STRIPED            = 0x00000008, /* striped directory inode */
 };
-#define LMA_INCOMPAT_SUPP      (LMAI_AGENT | LMAI_REMOTE_PARENT)
+#define LMA_INCOMPAT_SUPP      (LMAI_AGENT | LMAI_REMOTE_PARENT | LMAI_STRIPED)
 
 extern void lustre_lma_swab(struct lustre_mdt_attrs *lma);
 extern void lustre_lma_init(struct lustre_mdt_attrs *lma,
@@ -907,11 +908,6 @@ static inline bool fid_is_sane(const struct lu_fid *fid)
                fid_seq_is_rsvd(fid_seq(fid)));
 }
 
-static inline bool fid_is_zero(const struct lu_fid *fid)
-{
-       return fid_seq(fid) == 0 && fid_oid(fid) == 0;
-}
-
 extern void lustre_swab_lu_fid(struct lu_fid *fid);
 extern void lustre_swab_lu_seq_range(struct lu_seq_range *range);
 
@@ -1397,7 +1393,8 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
                                OBD_CONNECT_LVB_TYPE | OBD_CONNECT_LAYOUTLOCK |\
                                OBD_CONNECT_PINGLESS | OBD_CONNECT_MAX_EASIZE |\
                                OBD_CONNECT_FLOCK_DEAD | \
-                               OBD_CONNECT_DISP_STRIPE | OBD_CONNECT_LFSCK)
+                               OBD_CONNECT_DISP_STRIPE | OBD_CONNECT_LFSCK | \
+                               OBD_CONNECT_OPEN_BY_FID)
 
 #define OST_CONNECT_SUPPORTED  (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \
                                 OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \
@@ -1425,13 +1422,6 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 #define CLIENT_CONNECT_MDT_REQD (OBD_CONNECT_IBITS | OBD_CONNECT_FID | \
                                  OBD_CONNECT_FULL20)
 
-#define OBD_OCD_VERSION(major,minor,patch,fix) (((major)<<24) + ((minor)<<16) +\
-                                                ((patch)<<8) + (fix))
-#define OBD_OCD_VERSION_MAJOR(version) ((int)((version)>>24)&255)
-#define OBD_OCD_VERSION_MINOR(version) ((int)((version)>>16)&255)
-#define OBD_OCD_VERSION_PATCH(version) ((int)((version)>>8)&255)
-#define OBD_OCD_VERSION_FIX(version)   ((int)(version)&255)
-
 /* This structure is used for both request and reply.
  *
  * If we eventually have separate connect data for different types, which we
@@ -1579,11 +1569,21 @@ enum obdo_flags {
         OBD_FL_LOCAL_MASK   = 0xF0000000,
 };
 
-#define LOV_MAGIC_V1      0x0BD10BD0
-#define LOV_MAGIC         LOV_MAGIC_V1
-#define LOV_MAGIC_JOIN_V1 0x0BD20BD0
-#define LOV_MAGIC_V3      0x0BD30BD0
-#define LOV_MAGIC_MIGRATE 0x0BD40BD0
+/*
+ * All LOV EA magics should have the same postfix, if some new version
+ * Lustre instroduces new LOV EA magic, then when down-grade to an old
+ * Lustre, even though the old version system does not recognizes such
+ * new magic, it still can distinguish the corrupted cases by checking
+ * the magic's postfix.
+ */
+#define LOV_MAGIC_MAGIC 0x0BD0
+#define LOV_MAGIC_MASK  0xFFFF
+
+#define LOV_MAGIC_V1           (0x0BD10000 | LOV_MAGIC_MAGIC)
+#define LOV_MAGIC_JOIN_V1      (0x0BD20000 | LOV_MAGIC_MAGIC)
+#define LOV_MAGIC_V3           (0x0BD30000 | LOV_MAGIC_MAGIC)
+#define LOV_MAGIC_MIGRATE      (0x0BD40000 | LOV_MAGIC_MAGIC)
+#define LOV_MAGIC              LOV_MAGIC_V1
 
 /*
  * magic for fully defined striping
@@ -1600,14 +1600,6 @@ enum obdo_flags {
 #define LOV_MAGIC_V1_DEF  0x0CD10BD0
 #define LOV_MAGIC_V3_DEF  0x0CD30BD0
 
-#define LOV_PATTERN_RAID0      0x001   /* stripes are used round-robin */
-#define LOV_PATTERN_RAID1      0x002   /* stripes are mirrors of each other */
-#define LOV_PATTERN_FIRST      0x100   /* first stripe is not in round-robin */
-#define LOV_PATTERN_CMOBD      0x200
-
-#define LOV_PATTERN_F_MASK     0xffff0000
-#define LOV_PATTERN_F_RELEASED 0x80000000 /* HSM released file */
-
 #define lov_pattern(pattern)           (pattern & ~LOV_PATTERN_F_MASK)
 #define lov_pattern_flags(pattern)     (pattern & LOV_PATTERN_F_MASK)
 
@@ -1700,6 +1692,12 @@ static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi,
 #define MAX_MD_SIZE (sizeof(struct lov_mds_md) + 4 * sizeof(struct lov_ost_data))
 #define MIN_MD_SIZE (sizeof(struct lov_mds_md) + 1 * sizeof(struct lov_ost_data))
 
+/* This is the default MDT reply size allocated, should the striping be bigger,
+ * it will be reallocated in mdt_fix_reply.
+ * 100 stripes is a bit less than 2.5k of data */
+#define DEF_REP_MD_SIZE (sizeof(struct lov_mds_md) + \
+                        100 * sizeof(struct lov_ost_data))
+
 #define XATTR_NAME_ACL_ACCESS   "system.posix_acl_access"
 #define XATTR_NAME_ACL_DEFAULT  "system.posix_acl_default"
 #define XATTR_USER_PREFIX       "user."
@@ -1717,6 +1715,7 @@ static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi,
 #define XATTR_NAME_SOM         "trusted.som"
 #define XATTR_NAME_HSM         "trusted.hsm"
 #define XATTR_NAME_LFSCK_NAMESPACE "trusted.lfsck_namespace"
+#define XATTR_NAME_MAX_LEN     32 /* increase this, if there is longer name. */
 
 struct lov_mds_md_v3 {            /* LOV EA mds/wire data (little-endian) */
        __u32 lmm_magic;          /* magic number = LOV_MAGIC_V3 */
@@ -1880,7 +1879,7 @@ extern void lustre_swab_obd_statfs (struct obd_statfs *os);
                                      * space for unstable pages; asking
                                      * it to sync quickly */
 
-#define OBD_OBJECT_EOF 0xffffffffffffffffULL
+#define OBD_OBJECT_EOF LUSTRE_EOF
 
 #define OST_MIN_PRECREATE 32
 #define OST_MAX_PRECREATE 20000
@@ -1951,15 +1950,15 @@ extern void lustre_swab_ost_lvb(struct ost_lvb *lvb);
  */
 
 #ifndef QUOTABLOCK_BITS
-#define QUOTABLOCK_BITS 10
+# define QUOTABLOCK_BITS LUSTRE_QUOTABLOCK_BITS
 #endif
 
 #ifndef QUOTABLOCK_SIZE
-#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
+# define QUOTABLOCK_SIZE LUSTRE_QUOTABLOCK_SIZE
 #endif
 
 #ifndef toqb
-#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
+# define toqb lustre_stoqb
 #endif
 
 /* The lquota_id structure is an union of all the possible identifier types that
@@ -1985,12 +1984,6 @@ struct obd_quotactl {
 
 extern void lustre_swab_obd_quotactl(struct obd_quotactl *q);
 
-#define Q_QUOTACHECK   0x800100 /* deprecated as of 2.4 */
-#define Q_INITQUOTA    0x800101 /* deprecated as of 2.4  */
-#define Q_GETOINFO     0x800102 /* get obd quota info */
-#define Q_GETOQUOTA    0x800103 /* get obd quotas */
-#define Q_FINVALIDATE  0x800104 /* deprecated as of 2.4 */
-
 #define Q_COPY(out, in, member) (out)->member = (in)->member
 
 #define QCTL_COPY(out, in)             \
@@ -2140,8 +2133,8 @@ typedef enum {
        MDS_DISCONNECT          = 39,
        MDS_GETSTATUS           = 40,
        MDS_STATFS              = 41,
-       MDS_PIN                 = 42,
-       MDS_UNPIN               = 43,
+       MDS_PIN                 = 42, /* obsolete, never used in a release */
+       MDS_UNPIN               = 43, /* obsolete, never used in a release */
        MDS_SYNC                = 44,
        MDS_DONE_WRITING        = 45,
        MDS_SET_INFO            = 46,
@@ -2150,7 +2143,7 @@ typedef enum {
        MDS_GETXATTR            = 49,
        MDS_SETXATTR            = 50, /* obsolete, now it's MDS_REINT op */
        MDS_WRITEPAGE           = 51,
-       MDS_IS_SUBDIR           = 52,
+       MDS_IS_SUBDIR           = 52, /* obsolete, never used in a release */
        MDS_GET_INFO            = 53,
        MDS_HSM_STATE_GET       = 54,
        MDS_HSM_STATE_SET       = 55,
@@ -2314,42 +2307,42 @@ enum md_transient_state {
 };
 
 struct mdt_body {
-        struct lu_fid  fid1;
-        struct lu_fid  fid2;
-        struct lustre_handle handle;
-        __u64          valid;
-        __u64          size;   /* Offset, in the case of MDS_READPAGE */
-       obd_time        mtime;
-       obd_time        atime;
-       obd_time        ctime;
-        __u64          blocks; /* XID, in the case of MDS_READPAGE */
-        __u64          ioepoch;
-       __u64          t_state; /* transient file state defined in
-                                * enum md_transient_state
-                                * was "ino" until 2.4.0 */
-        __u32          fsuid;
-        __u32          fsgid;
-        __u32          capability;
-        __u32          mode;
-        __u32          uid;
-        __u32          gid;
-        __u32          flags; /* from vfs for pin/unpin, LUSTRE_BFLAG close */
-        __u32          rdev;
-        __u32          nlink; /* #bytes to read in the case of MDS_READPAGE */
-       __u32          unused2; /* was "generation" until 2.4.0 */
-        __u32          suppgid;
-        __u32          eadatasize;
-        __u32          aclsize;
-        __u32          max_mdsize;
-        __u32          max_cookiesize;
-        __u32          uid_h; /* high 32-bits of uid, for FUID */
-        __u32          gid_h; /* high 32-bits of gid, for FUID */
-        __u32          padding_5; /* also fix lustre_swab_mdt_body */
-        __u64          padding_6;
-        __u64          padding_7;
-        __u64          padding_8;
-        __u64          padding_9;
-        __u64          padding_10;
+       struct lu_fid mbo_fid1;
+       struct lu_fid mbo_fid2;
+       struct lustre_handle mbo_handle;
+       __u64   mbo_valid;
+       __u64   mbo_size; /* Offset, in the case of MDS_READPAGE */
+       obd_time mbo_mtime;
+       obd_time mbo_atime;
+       obd_time mbo_ctime;
+       __u64   mbo_blocks; /* XID, in the case of MDS_READPAGE */
+       __u64   mbo_ioepoch;
+       __u64   mbo_t_state; /* transient file state defined in
+                             * enum md_transient_state
+                             * was "ino" until 2.4.0 */
+       __u32   mbo_fsuid;
+       __u32   mbo_fsgid;
+       __u32   mbo_capability;
+       __u32   mbo_mode;
+       __u32   mbo_uid;
+       __u32   mbo_gid;
+       __u32   mbo_flags;
+       __u32   mbo_rdev;
+       __u32   mbo_nlink; /* #bytes to read in the case of MDS_READPAGE */
+       __u32   mbo_unused2; /* was "generation" until 2.4.0 */
+       __u32   mbo_suppgid;
+       __u32   mbo_eadatasize;
+       __u32   mbo_aclsize;
+       __u32   mbo_max_mdsize;
+       __u32   mbo_max_cookiesize;
+       __u32   mbo_uid_h; /* high 32-bits of uid, for FUID */
+       __u32   mbo_gid_h; /* high 32-bits of gid, for FUID */
+       __u32   mbo_padding_5; /* also fix lustre_swab_mdt_body */
+       __u64   mbo_padding_6;
+       __u64   mbo_padding_7;
+       __u64   mbo_padding_8;
+       __u64   mbo_padding_9;
+       __u64   mbo_padding_10;
 }; /* 216 */
 
 extern void lustre_swab_mdt_body (struct mdt_body *b);
@@ -2487,6 +2480,12 @@ extern void lustre_swab_mdt_rec_setattr (struct mdt_rec_setattr *sa);
                                              */
 #define MDS_OPEN_RELEASE   02000000000000ULL /* Open the file for HSM release */
 
+/* lustre internal open flags, which should not be set from user space */
+#define MDS_OPEN_FL_INTERNAL (MDS_OPEN_HAS_EA | MDS_OPEN_HAS_OBJS |    \
+                             MDS_OPEN_OWNEROVERRIDE | MDS_OPEN_LOCK |  \
+                             MDS_OPEN_BY_FID | MDS_OPEN_LEASE |        \
+                             MDS_OPEN_RELEASE)
+
 /* permission for create non-directory file */
 #define MAY_CREATE      (1 << 7)
 /* permission for create directory file */
@@ -2725,20 +2724,41 @@ struct lmv_desc {
 
 extern void lustre_swab_lmv_desc (struct lmv_desc *ld);
 
-/* lmv structures */
-#define LMV_MAGIC_V1   0x0CD10CD0    /* normal stripe lmv magic */
-#define LMV_USER_MAGIC 0x0CD20CD0    /* default lmv magic*/
-#define LMV_MAGIC_MIGRATE      0x0CD30CD0    /* migrate stripe lmv magic */
+/* LMV layout EA, and it will be stored both in master and slave object */
+struct lmv_mds_md_v1 {
+       __u32 lmv_magic;
+       __u32 lmv_stripe_count;
+       __u32 lmv_master_mdt_index;     /* On master object, it is master
+                                        * MDT index, on slave object, it
+                                        * is stripe index of the slave obj */
+       __u32 lmv_hash_type;            /* dir stripe policy, i.e. indicate
+                                        * which hash function to be used,
+                                        * Note: only lower 16 bits is being
+                                        * used for now. Higher 16 bits will
+                                        * be used to mark the object status,
+                                        * for example migrating or dead. */
+       __u32 lmv_layout_version;       /* Used for directory restriping */
+       __u32 lmv_padding;
+       struct lu_fid   lmv_master_fid; /* The FID of the master object, which
+                                        * is the namespace-visible dir FID */
+       char lmv_pool_name[LOV_MAXPOOLNAME];    /* pool name */
+       struct lu_fid lmv_stripe_fids[0];       /* FIDs for each stripe */
+};
+
+#define LMV_MAGIC_V1   0x0CD20CD0    /* normal stripe lmv magic */
 #define LMV_MAGIC      LMV_MAGIC_V1
 
-enum lmv_hash_type {
-       LMV_HASH_TYPE_ALL_CHARS = 1,
-       LMV_HASH_TYPE_FNV_1A_64 = 2,
-       LMV_HASH_TYPE_MIGRATION = 3,
-};
+/* #define LMV_USER_MAGIC 0x0CD30CD0 */
+#define LMV_MAGIC_STRIPE 0x0CD40CD0 /* magic for dir sub_stripe */
 
-#define LMV_HASH_NAME_ALL_CHARS        "all_char"
-#define LMV_HASH_NAME_FNV_1A_64        "fnv_1a_64"
+/* Right now only the lower part(0-16bits) of lmv_hash_type is being used,
+ * and the higher part will be the flag to indicate the status of object,
+ * for example the object is being migrated. And the hash function
+ * might be interpreted differently with different flags. */
+#define LMV_HASH_TYPE_MASK 0x0000ffff
+
+#define LMV_HASH_FLAG_MIGRATION        0x80000000
+#define LMV_HASH_FLAG_DEAD     0x40000000
 
 /**
  * The FNV-1a hash algorithm is as follows:
@@ -2768,18 +2788,6 @@ static inline __u64 lustre_hash_fnv_1a_64(const void *buf, size_t size)
        return hash;
 }
 
-struct lmv_mds_md_v1 {
-       __u32 lmv_magic;
-       __u32 lmv_stripe_count;         /* stripe count */
-       __u32 lmv_master_mdt_index;     /* master MDT index */
-       __u32 lmv_hash_type;            /* dir stripe policy, i.e. indicate
-                                        * which hash function to be used */
-       __u32 lmv_layout_version;       /* Used for directory restriping */
-       __u32 lmv_padding;
-       char lmv_pool_name[LOV_MAXPOOLNAME];    /* pool name */
-       struct lu_fid lmv_stripe_fids[0];       /* FIDs for each stripe */
-};
-
 union lmv_mds_md {
        __u32                    lmv_magic;
        struct lmv_mds_md_v1     lmv_md_v1;
@@ -2791,8 +2799,7 @@ extern void lustre_swab_lmv_mds_md(union lmv_mds_md *lmm);
 static inline int lmv_mds_md_size(int stripe_count, unsigned int lmm_magic)
 {
        switch (lmm_magic) {
-       case LMV_MAGIC_V1:
-       case LMV_MAGIC_MIGRATE: {
+       case LMV_MAGIC_V1:{
                struct lmv_mds_md_v1 *lmm1;
 
                return sizeof(*lmm1) + stripe_count *
@@ -2807,7 +2814,6 @@ static inline int lmv_mds_md_stripe_count_get(const union lmv_mds_md *lmm)
 {
        switch (le32_to_cpu(lmm->lmv_magic)) {
        case LMV_MAGIC_V1:
-       case LMV_MAGIC_MIGRATE:
                return le32_to_cpu(lmm->lmv_md_v1.lmv_stripe_count);
        case LMV_USER_MAGIC:
                return le32_to_cpu(lmm->lmv_user_md.lum_stripe_count);
@@ -2821,7 +2827,6 @@ static inline int lmv_mds_md_stripe_count_set(union lmv_mds_md *lmm,
 {
        switch (le32_to_cpu(lmm->lmv_magic)) {
        case LMV_MAGIC_V1:
-       case LMV_MAGIC_MIGRATE:
                lmm->lmv_md_v1.lmv_stripe_count = cpu_to_le32(stripe_count);
                break;
        case LMV_USER_MAGIC:
@@ -3246,6 +3251,12 @@ struct llog_rec_tail {
        (rec->lrh_len - sizeof(struct llog_rec_hdr) -           \
         sizeof(struct llog_rec_tail))
 
+static inline void *rec_tail(struct llog_rec_hdr *rec)
+{
+       return (void *)((char *)rec + rec->lrh_len -
+                       sizeof(struct llog_rec_tail));
+}
+
 struct llog_logid_rec {
        struct llog_rec_hdr     lid_hdr;
        struct llog_logid       lid_id;
@@ -3280,7 +3291,7 @@ struct llog_setattr64_rec {
        __u32                   lsr_uid_h;
        __u32                   lsr_gid;
        __u32                   lsr_gid_h;
-       __u64                   lsr_padding;
+       __u64                   lsr_valid;
        struct llog_rec_tail    lsr_tail;
 } __attribute__((packed));
 
@@ -3703,6 +3714,7 @@ enum idx_info_flags {
        II_FL_VARKEY    = 1 << 1, /* keys can be of variable size */
        II_FL_VARREC    = 1 << 2, /* records can be of variable size */
        II_FL_NONUNQ    = 1 << 3, /* index supports non-unique keys */
+       II_FL_NOKEY     = 1 << 4, /* client doesn't care about key */
 };
 
 #define LIP_MAGIC 0x8A6D6B6C
@@ -3807,6 +3819,16 @@ static inline int capa_for_oss(struct lustre_capa *c)
         return (c->lc_opc & CAPA_OPC_INDEX_LOOKUP) == 0;
 }
 
+static inline bool lovea_slot_is_dummy(const struct lov_ost_data_v1 *obj)
+{
+       /* zero area does not care about the bytes-order. */
+       if (obj->l_ost_oi.oi.oi_id == 0 && obj->l_ost_oi.oi.oi_seq == 0 &&
+           obj->l_ost_idx == 0 && obj->l_ost_gen == 0)
+               return true;
+
+       return false;
+}
+
 /* lustre_capa::lc_hmac_alg */
 enum {
         CAPA_HMAC_ALG_SHA1 = 1, /**< sha1 algorithm */
@@ -3950,6 +3972,7 @@ enum update_type {
        OUT_INDEX_INSERT        = 10,
        OUT_INDEX_DELETE        = 11,
        OUT_WRITE               = 12,
+       OUT_XATTR_DEL           = 13,
        OUT_LAST
 };