Whamcloud - gitweb
LU-2792 fld: add dot_seq into in_fldb check
[fs/lustre-release.git] / lustre / include / lustre / lustre_idl.h
index d701085..a19a8d9 100644 (file)
@@ -354,6 +354,27 @@ struct hsm_attrs {
 };
 extern void lustre_hsm_swab(struct hsm_attrs *attrs);
 
+struct ost_id {
+       obd_id  oi_id;
+       obd_seq oi_seq;
+};
+
+static inline void ostid_cpu_to_le(struct ost_id *src_oi,
+                                  struct ost_id *dst_oi)
+{
+       dst_oi->oi_id = cpu_to_le64(src_oi->oi_id);
+       dst_oi->oi_seq = cpu_to_le64(src_oi->oi_seq);
+}
+
+static inline void ostid_le_to_cpu(struct ost_id *src_oi,
+                                  struct ost_id *dst_oi)
+{
+       dst_oi->oi_id = le64_to_cpu(src_oi->oi_id);
+       dst_oi->oi_seq = le64_to_cpu(src_oi->oi_seq);
+}
+
+extern void lustre_swab_ost_id(struct ost_id *oid);
+
 /**
  * fid constants
  */
@@ -399,29 +420,34 @@ static inline obd_id fid_ver_oid(const struct lu_fid *fid)
  * http://arch.lustre.org/index.php?title=Interoperability_fids_zfs#NEW.0
  */
 enum fid_seq {
-        FID_SEQ_OST_MDT0   = 0,
-        FID_SEQ_LLOG       = 1,
-        FID_SEQ_ECHO       = 2,
-        FID_SEQ_OST_MDT1   = 3,
-        FID_SEQ_OST_MAX    = 9, /* Max MDT count before OST_on_FID */
-        FID_SEQ_RSVD       = 11,
-        FID_SEQ_IGIF       = 12,
-        FID_SEQ_IGIF_MAX   = 0x0ffffffffULL,
-        FID_SEQ_IDIF       = 0x100000000ULL,
-        FID_SEQ_IDIF_MAX   = 0x1ffffffffULL,
-        /* Normal FID sequence starts from this value, i.e. 1<<33 */
-        FID_SEQ_START      = 0x200000000ULL,
+       FID_SEQ_OST_MDT0        = 0,
+       FID_SEQ_LLOG            = 1,
+       FID_SEQ_ECHO            = 2,
+       FID_SEQ_OST_MDT1        = 3,
+       FID_SEQ_OST_MAX         = 9, /* Max MDT count before OST_on_FID */
+       FID_SEQ_RSVD            = 11,
+       FID_SEQ_IGIF            = 12,
+       FID_SEQ_IGIF_MAX        = 0x0ffffffffULL,
+       FID_SEQ_IDIF            = 0x100000000ULL,
+       FID_SEQ_IDIF_MAX        = 0x1ffffffffULL,
+       /* Normal FID sequence starts from this value, i.e. 1<<33 */
+       FID_SEQ_START           = 0x200000000ULL,
        /* sequence for local pre-defined FIDs listed in local_oid */
-        FID_SEQ_LOCAL_FILE = 0x200000001ULL,
-        FID_SEQ_DOT_LUSTRE = 0x200000002ULL,
+       FID_SEQ_LOCAL_FILE      = 0x200000001ULL,
+       FID_SEQ_DOT_LUSTRE      = 0x200000002ULL,
        /* sequence is used for local named objects FIDs generated
         * by local_object_storage library */
-       FID_SEQ_LOCAL_NAME = 0x200000003ULL,
-        FID_SEQ_SPECIAL    = 0x200000004ULL,
-        FID_SEQ_QUOTA      = 0x200000005ULL,
-        FID_SEQ_QUOTA_GLB  = 0x200000006ULL,
-        FID_SEQ_NORMAL     = 0x200000400ULL,
-        FID_SEQ_LOV_DEFAULT= 0xffffffffffffffffULL
+       FID_SEQ_LOCAL_NAME      = 0x200000003ULL,
+       /* Because current FLD will only cache the fid sequence, instead
+        * of oid on the client side, if the FID needs to be exposed to
+        * clients sides, it needs to make sure all of fids under one
+        * sequence will be located in one MDT. */
+       FID_SEQ_SPECIAL         = 0x200000004ULL,
+       FID_SEQ_QUOTA           = 0x200000005ULL,
+       FID_SEQ_QUOTA_GLB       = 0x200000006ULL,
+       FID_SEQ_ROOT            = 0x200000007ULL,  /* Located on MDT0 */
+       FID_SEQ_NORMAL          = 0x200000400ULL,
+       FID_SEQ_LOV_DEFAULT     = 0xffffffffffffffffULL
 };
 
 #define OBIF_OID_MAX_BITS           32
@@ -478,11 +504,38 @@ static inline int fid_seq_is_rsvd(const __u64 seq)
         return (seq > FID_SEQ_OST_MDT0 && seq <= FID_SEQ_RSVD);
 };
 
+static inline int fid_seq_is_special(const __u64 seq)
+{
+       return seq == FID_SEQ_SPECIAL;
+};
+
+static inline int fid_seq_is_local_file(const __u64 seq)
+{
+       return seq == FID_SEQ_LOCAL_FILE;
+};
+
+static inline int fid_seq_is_root(const __u64 seq)
+{
+       return seq == FID_SEQ_ROOT;
+}
+
+static inline int fid_seq_is_dot(const __u64 seq)
+{
+       return seq == FID_SEQ_DOT_LUSTRE;
+}
+
 static inline int fid_is_mdt0(const struct lu_fid *fid)
 {
         return fid_seq_is_mdt0(fid_seq(fid));
 }
 
+static inline void lu_root_fid(struct lu_fid *fid)
+{
+       fid->f_seq = FID_SEQ_ROOT;
+       fid->f_oid = 1;
+       fid->f_ver = 0;
+}
+
 /**
  * Check if a fid is igif or not.
  * \param fid the fid to be tested.
@@ -513,10 +566,10 @@ static inline int fid_is_idif(const struct lu_fid *fid)
         return fid_seq_is_idif(fid_seq(fid));
 }
 
-struct ost_id {
-        obd_id                 oi_id;
-        obd_seq                oi_seq;
-};
+static inline int fid_is_local_file(const struct lu_fid *fid)
+{
+       return fid_seq_is_local_file(fid_seq(fid));
+}
 
 static inline int fid_seq_is_norm(const __u64 seq)
 {
@@ -634,7 +687,7 @@ static inline void ostid_idif_pack(const struct lu_fid *fid,
 }
 
 /* pack a non-IDIF FID into an ostid (id/seq) for the wire/disk */
-static inline void ostid_fid_pack(const struct lu_fid *fid,
+static inline void ostid_normal_fid_pack(const struct lu_fid *fid,
                                   struct ost_id *ostid)
 {
         ostid->oi_seq = fid_seq(fid);
@@ -645,17 +698,17 @@ static inline void ostid_fid_pack(const struct lu_fid *fid,
 static inline int fid_ostid_pack(const struct lu_fid *fid,
                                  struct ost_id *ostid)
 {
-        if (unlikely(fid_seq_is_igif(fid->f_seq))) {
-                CERROR("bad IGIF, "DFID"\n", PFID(fid));
-                return -EBADF;
-        }
+       if (unlikely(fid_seq_is_igif(fid->f_seq))) {
+               CERROR("bad IGIF, "DFID"\n", PFID(fid));
+               return -EBADF;
+       }
 
-        if (fid_is_idif(fid))
-                ostid_idif_pack(fid, ostid);
-        else
-                ostid_fid_pack(fid, ostid);
+       if (fid_is_idif(fid))
+               ostid_idif_pack(fid, ostid);
+       else
+               ostid_normal_fid_pack(fid, ostid);
 
-        return 0;
+       return 0;
 }
 
 /* extract OST sequence (group) from a wire ost_id (id/seq) pair */
@@ -729,50 +782,46 @@ static inline void lu_igif_build(struct lu_fid *fid, __u32 ino, __u32 gen)
  */
 static inline void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src)
 {
-        /* check that all fields are converted */
-        CLASSERT(sizeof *src ==
-                 sizeof fid_seq(src) +
-                 sizeof fid_oid(src) + sizeof fid_ver(src));
-        LASSERTF(fid_is_igif(src) || fid_ver(src) == 0, DFID"\n", PFID(src));
-        dst->f_seq = cpu_to_le64(fid_seq(src));
-        dst->f_oid = cpu_to_le32(fid_oid(src));
-        dst->f_ver = cpu_to_le32(fid_ver(src));
+       /* check that all fields are converted */
+       CLASSERT(sizeof *src ==
+                sizeof fid_seq(src) +
+                sizeof fid_oid(src) + sizeof fid_ver(src));
+       dst->f_seq = cpu_to_le64(fid_seq(src));
+       dst->f_oid = cpu_to_le32(fid_oid(src));
+       dst->f_ver = cpu_to_le32(fid_ver(src));
 }
 
 static inline void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src)
 {
-        /* check that all fields are converted */
-        CLASSERT(sizeof *src ==
-                 sizeof fid_seq(src) +
-                 sizeof fid_oid(src) + sizeof fid_ver(src));
-        dst->f_seq = le64_to_cpu(fid_seq(src));
-        dst->f_oid = le32_to_cpu(fid_oid(src));
-        dst->f_ver = le32_to_cpu(fid_ver(src));
-        LASSERTF(fid_is_igif(dst) || fid_ver(dst) == 0, DFID"\n", PFID(dst));
+       /* check that all fields are converted */
+       CLASSERT(sizeof *src ==
+                sizeof fid_seq(src) +
+                sizeof fid_oid(src) + sizeof fid_ver(src));
+       dst->f_seq = le64_to_cpu(fid_seq(src));
+       dst->f_oid = le32_to_cpu(fid_oid(src));
+       dst->f_ver = le32_to_cpu(fid_ver(src));
 }
 
 static inline void fid_cpu_to_be(struct lu_fid *dst, const struct lu_fid *src)
 {
-        /* check that all fields are converted */
-        CLASSERT(sizeof *src ==
-                 sizeof fid_seq(src) +
-                 sizeof fid_oid(src) + sizeof fid_ver(src));
-        LASSERTF(fid_is_igif(src) || fid_ver(src) == 0, DFID"\n", PFID(src));
-        dst->f_seq = cpu_to_be64(fid_seq(src));
-        dst->f_oid = cpu_to_be32(fid_oid(src));
-        dst->f_ver = cpu_to_be32(fid_ver(src));
+       /* check that all fields are converted */
+       CLASSERT(sizeof *src ==
+                sizeof fid_seq(src) +
+                sizeof fid_oid(src) + sizeof fid_ver(src));
+       dst->f_seq = cpu_to_be64(fid_seq(src));
+       dst->f_oid = cpu_to_be32(fid_oid(src));
+       dst->f_ver = cpu_to_be32(fid_ver(src));
 }
 
 static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src)
 {
-        /* check that all fields are converted */
-        CLASSERT(sizeof *src ==
-                 sizeof fid_seq(src) +
-                 sizeof fid_oid(src) + sizeof fid_ver(src));
-        dst->f_seq = be64_to_cpu(fid_seq(src));
-        dst->f_oid = be32_to_cpu(fid_oid(src));
-        dst->f_ver = be32_to_cpu(fid_ver(src));
-        LASSERTF(fid_is_igif(dst) || fid_ver(dst) == 0, DFID"\n", PFID(dst));
+       /* check that all fields are converted */
+       CLASSERT(sizeof *src ==
+                sizeof fid_seq(src) +
+                sizeof fid_oid(src) + sizeof fid_ver(src));
+       dst->f_seq = be64_to_cpu(fid_seq(src));
+       dst->f_oid = be32_to_cpu(fid_oid(src));
+       dst->f_ver = be32_to_cpu(fid_ver(src));
 }
 
 static inline int fid_is_sane(const struct lu_fid *fid)
@@ -791,17 +840,12 @@ static inline int fid_is_zero(const struct lu_fid *fid)
 extern void lustre_swab_lu_fid(struct lu_fid *fid);
 extern void lustre_swab_lu_seq_range(struct lu_seq_range *range);
 
-static inline int lu_fid_eq(const struct lu_fid *f0,
-                            const struct lu_fid *f1)
+static inline int lu_fid_eq(const struct lu_fid *f0, const struct lu_fid *f1)
 {
-        /* Check that there is no alignment padding. */
-        CLASSERT(sizeof *f0 ==
-                 sizeof f0->f_seq + sizeof f0->f_oid + sizeof f0->f_ver);
-        LASSERTF((fid_is_igif(f0) || fid_is_idif(f0)) ||
-                 fid_ver(f0) == 0, DFID, PFID(f0));
-        LASSERTF((fid_is_igif(f1) || fid_is_idif(f1)) ||
-                 fid_ver(f1) == 0, DFID, PFID(f1));
-        return memcmp(f0, f1, sizeof *f0) == 0;
+       /* Check that there is no alignment padding. */
+       CLASSERT(sizeof *f0 ==
+                sizeof f0->f_seq + sizeof f0->f_oid + sizeof f0->f_ver);
+       return memcmp(f0, f1, sizeof *f0) == 0;
 }
 
 #define __diff_normalize(val0, val1)                            \
@@ -833,11 +877,27 @@ static inline int lu_fid_cmp(const struct lu_fid *f0,
  * enumeration.
  */
 enum lu_dirent_attrs {
-        LUDA_FID        = 0x0001,
-        LUDA_TYPE       = 0x0002,
-        LUDA_64BITHASH  = 0x0004,
+       LUDA_FID                = 0x0001,
+       LUDA_TYPE               = 0x0002,
+       LUDA_64BITHASH          = 0x0004,
+
+       /* The following attrs are used for MDT interanl only,
+        * not visible to client */
+
+       /* Verify the dirent consistency */
+       LUDA_VERIFY             = 0x8000,
+       /* Only check but not repair the dirent inconsistency */
+       LUDA_VERIFY_DRYRUN      = 0x4000,
+       /* The dirent has been repaired, or to be repaired (dryrun). */
+       LUDA_REPAIR             = 0x2000,
+       /* The system is upgraded, has beed or to be repaired (dryrun). */
+       LUDA_UPGRADE            = 0x1000,
+       /* Ignore this record, go to next directly. */
+       LUDA_IGNORE             = 0x0800,
 };
 
+#define LU_DIRENT_ATTRS_MASK   0xf800
+
 /**
  * Layout of readdir pages, as transmitted on wire.
  */
@@ -1179,6 +1239,7 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 #define OBD_CONNECT_NANOSEC_TIME 0x800000000000ULL /* nanosecond timestamps */
 #define OBD_CONNECT_LIGHTWEIGHT 0x1000000000000ULL/* lightweight connection */
 #define OBD_CONNECT_SHORTIO     0x2000000000000ULL/* short io */
+#define OBD_CONNECT_PINGLESS   0x4000000000000ULL/* pings not required */
 /* XXX README XXX:
  * Please DO NOT add flag values here before first ensuring that this same
  * flag value is not in use on some other branch.  Please clear any such
@@ -1218,7 +1279,8 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
                                OBD_CONNECT_64BITHASH | OBD_CONNECT_JOBSTATS | \
                                OBD_CONNECT_EINPROGRESS | \
                                OBD_CONNECT_LIGHTWEIGHT | OBD_CONNECT_UMASK | \
-                               OBD_CONNECT_LVB_TYPE | OBD_CONNECT_LAYOUTLOCK)
+                               OBD_CONNECT_LVB_TYPE | OBD_CONNECT_LAYOUTLOCK |\
+                               OBD_CONNECT_PINGLESS)
 #define OST_CONNECT_SUPPORTED  (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \
                                 OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \
                                 OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_INDEX | \
@@ -1234,11 +1296,12 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
                                OBD_CONNECT_EINPROGRESS | \
                                OBD_CONNECT_JOBSTATS | \
                                OBD_CONNECT_LIGHTWEIGHT | OBD_CONNECT_LVB_TYPE|\
-                               OBD_CONNECT_LAYOUTLOCK | OBD_CONNECT_FID)
+                               OBD_CONNECT_LAYOUTLOCK | OBD_CONNECT_FID | \
+                               OBD_CONNECT_PINGLESS)
 #define ECHO_CONNECT_SUPPORTED (0)
 #define MGS_CONNECT_SUPPORTED  (OBD_CONNECT_VERSION | OBD_CONNECT_AT | \
                                OBD_CONNECT_FULL20 | OBD_CONNECT_IMP_RECOV | \
-                               OBD_CONNECT_MNE_SWAB)
+                               OBD_CONNECT_MNE_SWAB | OBD_CONNECT_PINGLESS)
 
 /* Features required for this version of the client to work with server */
 #define CLIENT_CONNECT_MDT_REQD (OBD_CONNECT_IBITS | OBD_CONNECT_FID | \
@@ -1256,11 +1319,11 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
  * If we eventually have separate connect data for different types, which we
  * almost certainly will, then perhaps we stick a union in here. */
 struct obd_connect_data_v1 {
-        __u64 ocd_connect_flags; /* OBD_CONNECT_* per above */
-        __u32 ocd_version;       /* lustre release version number */
-        __u32 ocd_grant;         /* initial cache grant amount (bytes) */
-        __u32 ocd_index;         /* LOV index to connect to */
-        __u32 ocd_brw_size;      /* Maximum BRW size in bytes */
+       __u64 ocd_connect_flags; /* OBD_CONNECT_* per above */
+       __u32 ocd_version;       /* lustre release version number */
+       __u32 ocd_grant;         /* initial cache grant amount (bytes) */
+       __u32 ocd_index;         /* LOV index to connect to */
+       __u32 ocd_brw_size;      /* Maximum BRW size in bytes, must be 2^n */
         __u64 ocd_ibits_known;   /* inode bits this client understands */
         __u8  ocd_blocksize;     /* log2 of the backend filesystem blocksize */
         __u8  ocd_inodespace;    /* log2 of the per-inode space consumption */
@@ -1275,11 +1338,11 @@ struct obd_connect_data_v1 {
 };
 
 struct obd_connect_data {
-        __u64 ocd_connect_flags; /* OBD_CONNECT_* per above */
-        __u32 ocd_version;       /* lustre release version number */
-        __u32 ocd_grant;         /* initial cache grant amount (bytes) */
-        __u32 ocd_index;         /* LOV index to connect to */
-        __u32 ocd_brw_size;      /* Maximum BRW size in bytes */
+       __u64 ocd_connect_flags; /* OBD_CONNECT_* per above */
+       __u32 ocd_version;       /* lustre release version number */
+       __u32 ocd_grant;         /* initial cache grant amount (bytes) */
+       __u32 ocd_index;         /* LOV index to connect to */
+       __u32 ocd_brw_size;      /* Maximum BRW size in bytes */
         __u64 ocd_ibits_known;   /* inode bits this client understands */
         __u8  ocd_blocksize;     /* log2 of the backend filesystem blocksize */
         __u8  ocd_inodespace;    /* log2 of the per-inode space consumption */
@@ -1462,6 +1525,7 @@ struct lov_mds_md_v1 {            /* LOV EA mds/wire data (little-endian) */
 #define XATTR_NAME_VERSION      "trusted.version"
 #define XATTR_NAME_SOM         "trusted.som"
 #define XATTR_NAME_HSM         "trusted.hsm"
+#define XATTR_NAME_LFSCK_NAMESPACE "trusted.lfsck_namespace"
 
 
 struct lov_mds_md_v3 {            /* LOV EA mds/wire data (little-endian) */
@@ -1591,11 +1655,19 @@ extern void lustre_swab_obd_statfs (struct obd_statfs *os);
 #define OST_MAX_PRECREATE 20000
 
 struct obd_ioobj {
-       struct ost_id   ioo_oid;
-       __u32           ioo_type;
-       __u32           ioo_bufcnt;
+       struct ost_id   ioo_oid;        /* object ID, if multi-obj BRW */
+       __u32           ioo_max_brw;    /* low 16 bits were o_mode before 2.4,
+                                        * now (PTLRPC_BULK_OPS_COUNT - 1) in
+                                        * high 16 bits in 2.4 and later */
+       __u32           ioo_bufcnt;     /* number of niobufs for this object */
 };
 
+#define IOOBJ_MAX_BRW_BITS     16
+#define IOOBJ_TYPE_MASK                ((1U << IOOBJ_MAX_BRW_BITS) - 1)
+#define ioobj_max_brw_get(ioo) (((ioo)->ioo_max_brw >> IOOBJ_MAX_BRW_BITS) + 1)
+#define ioobj_max_brw_set(ioo, num)                                    \
+do { (ioo)->ioo_max_brw = ((num) - 1) << IOOBJ_MAX_BRW_BITS; } while (0)
+
 #define ioo_id ioo_oid.oi_id
 #define ioo_seq        ioo_oid.oi_seq
 
@@ -1859,6 +1931,7 @@ typedef enum {
        MDS_HSM_REQUEST         = 58,
        MDS_HSM_CT_REGISTER     = 59,
        MDS_HSM_CT_UNREGISTER   = 60,
+       MDS_SWAP_LAYOUTS        = 61,
        MDS_LAST_OPC
 } mds_cmd_t;
 
@@ -1878,14 +1951,14 @@ typedef enum {
  */
 
 typedef enum {
-        REINT_SETATTR  = 1,
-        REINT_CREATE   = 2,
-        REINT_LINK     = 3,
-        REINT_UNLINK   = 4,
-        REINT_RENAME   = 5,
-        REINT_OPEN     = 6,
-        REINT_SETXATTR = 7,
-//      REINT_CLOSE    = 8,
+       REINT_SETATTR  = 1,
+       REINT_CREATE   = 2,
+       REINT_LINK     = 3,
+       REINT_UNLINK   = 4,
+       REINT_RENAME   = 5,
+       REINT_OPEN     = 6,
+       REINT_SETXATTR = 7,
+       REINT_RMENTRY  = 8,
 //      REINT_WRITE    = 9,
         REINT_MAX
 } mds_reint_t, mdt_reint_t;
@@ -1909,8 +1982,9 @@ extern void lustre_swab_generic_32s (__u32 *val);
 #define MDS_INODELOCK_UPDATE 0x000002       /* size, links, timestamps */
 #define MDS_INODELOCK_OPEN   0x000004       /* For opened files */
 #define MDS_INODELOCK_LAYOUT 0x000008       /* for layout */
+#define MDS_INODELOCK_PERM   0x000010       /* for permission */
 
-#define MDS_INODELOCK_MAXSHIFT 3
+#define MDS_INODELOCK_MAXSHIFT 4
 /* This FULL lock is useful to take on unlink sort of operations */
 #define MDS_INODELOCK_FULL ((1<<(MDS_INODELOCK_MAXSHIFT+1))-1)
 
@@ -3432,5 +3506,14 @@ struct update_reply {
 void lustre_swab_update_buf(struct update_buf *ub);
 void lustre_swab_update_reply_buf(struct update_reply *ur);
 
+/** layout swap request structure
+ * fid1 and fid2 are in mdt_body
+ */
+struct mdc_swap_layouts {
+       __u64           msl_flags;
+} __packed;
+
+void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl);
+
 #endif
 /** @} lustreidl */