Whamcloud - gitweb
LU-11625 ofd: handle upgraded filter_fid properly
[fs/lustre-release.git] / lustre / include / uapi / linux / lustre / lustre_user.h
index d5c3564..a747e45 100644 (file)
 # include <linux/version.h>
 # include <uapi/linux/lustre/lustre_fiemap.h>
 #else /* !__KERNEL__ */
-# define NEED_QUOTA_DEFS
 # include <limits.h>
 # include <stdbool.h>
 # include <stdio.h> /* snprintf() */
 # include <string.h>
-# include <sys/quota.h>
+# define NEED_QUOTA_DEFS
+/* # include <sys/quota.h> - this causes complaints about caddr_t */
 # include <sys/stat.h>
 # include <linux/lustre/lustre_fiemap.h>
 #endif /* __KERNEL__ */
@@ -85,7 +85,15 @@ extern "C" {
     "project", /* PRJQUOTA */ \
     "undefined", \
 };
+#ifndef USRQUOTA
+#define USRQUOTA 0
+#endif
+#ifndef GRPQUOTA
+#define GRPQUOTA 1
+#endif
+#ifndef PRJQUOTA
 #define PRJQUOTA 2
+#endif
 
 /*
  * We need to always use 64bit version because the structure
@@ -119,8 +127,10 @@ typedef struct stat     lstat_t;
 enum obd_statfs_state {
        OS_STATE_DEGRADED       = 0x00000001, /**< RAID degraded/rebuilding */
        OS_STATE_READONLY       = 0x00000002, /**< filesystem is read-only */
+       OS_STATE_NOPRECREATE    = 0x00000004, /**< no object precreation */
        OS_STATE_ENOSPC         = 0x00000020, /**< not enough free space */
        OS_STATE_ENOINO         = 0x00000040, /**< not enough inodes */
+       OS_STATE_SUM            = 0x00000100, /**< aggregated for all tagrets */
 };
 
 /** filesystem statistics/attributes for target device */
@@ -139,14 +149,14 @@ struct obd_statfs {
        __u32           os_fprecreated; /* objs available now to the caller */
                                        /* used in QoS code to find preferred
                                         * OSTs */
-       __u32           os_spare2;      /* Unused padding fields.  Remember */
-       __u32           os_spare3;      /* to fix lustre_swab_obd_statfs() */
-       __u32           os_spare4;
-       __u32           os_spare5;
-       __u32           os_spare6;
-       __u32           os_spare7;
-       __u32           os_spare8;
-       __u32           os_spare9;
+       __u32           os_granted;     /* space granted for MDS */
+       __u32           os_spare3;      /* Unused padding fields.  Remember */
+       __u32           os_spare4;      /* to fix lustre_swab_obd_statfs() */
+       __u32           os_spare5;
+       __u32           os_spare6;
+       __u32           os_spare7;
+       __u32           os_spare8;
+       __u32           os_spare9;
 };
 
 /**
@@ -191,15 +201,47 @@ struct ost_layout {
        __u32   ol_comp_id;
 } __attribute__((packed));
 
-/* keep this one for compatibility */
-struct filter_fid_old {
-       struct lu_fid   ff_parent;
-       __u64           ff_objid;
-       __u64           ff_seq;
+/* The filter_fid structure has changed several times over its lifetime.
+ * For a long time "trusted.fid" held the MDT inode parent FID/IGIF and
+ * stripe_index and the "self FID" (objid/seq) to be able to recover the
+ * OST objects in case of corruption.  With the move to 2.4 and OSD-API for
+ * the OST, the "trusted.lma" xattr was added to the OST objects to store
+ * the "self FID" to be consistent with the MDT on-disk format, and the
+ * filter_fid only stored the MDT inode parent FID and stripe index.
+ *
+ * In 2.10, the addition of PFL composite layouts required more information
+ * to be stored into the filter_fid in order to be able to identify which
+ * component the OST object belonged.  As well, the stripe size may vary
+ * between components, so it was no longer safe to assume the stripe size
+ * or stripe_count of a file.  This is also more robust for plain layouts.
+ *
+ * For ldiskfs OSTs that were formatted with 256-byte inodes, there is not
+ * enough space to store both the filter_fid and LMA in the inode, so they
+ * are packed into struct lustre_ost_attrs on disk in trusted.lma to avoid
+ * an extra seek for every OST object access.
+ *
+ * In 2.11, FLR mirror layouts also need to store the layout version and
+ * range so that writes to old versions of the layout are not allowed.
+ * That ensures that mirrored objects are not modified by evicted clients,
+ * and ensures that the components are correctly marked stale on the MDT.
+ */
+struct filter_fid_18_23 {
+       struct lu_fid           ff_parent;      /* stripe_idx in f_ver */
+       __u64                   ff_objid;
+       __u64                   ff_seq;
+};
+
+struct filter_fid_24_29 {
+       struct lu_fid           ff_parent;      /* stripe_idx in f_ver */
+};
+
+struct filter_fid_210 {
+       struct lu_fid           ff_parent;      /* stripe_idx in f_ver */
+       struct ost_layout       ff_layout;
 };
 
 struct filter_fid {
-       struct lu_fid           ff_parent;
+       struct lu_fid           ff_parent;      /* stripe_idx in f_ver */
        struct ost_layout       ff_layout;
        __u32                   ff_layout_version;
        __u32                   ff_range; /* range of layout version that
@@ -286,8 +328,17 @@ struct lustre_ost_attrs {
  */
 #define LMA_OLD_SIZE (sizeof(struct lustre_mdt_attrs) + 5 * sizeof(__u64))
 
-enum {
-       LSOM_FL_VALID = 1 << 0,
+enum lustre_som_flags {
+       /* Unknow or no SoM data, must get size from OSTs. */
+       SOM_FL_UNKNOWN  = 0x0000,
+       /* Known strictly correct, FLR or DoM file (SoM guaranteed). */
+       SOM_FL_STRICT   = 0x0001,
+       /* Known stale - was right at some point in the past, but it is
+        * known (or likely) to be incorrect now (e.g. opened for write). */
+       SOM_FL_STALE    = 0x0002,
+       /* Approximate, may never have been strictly correct,
+        * need to sync SOM data to achieve eventual consistency. */
+       SOM_FL_LAZY     = 0x0004,
 };
 
 struct lustre_som_attrs {
@@ -350,6 +401,16 @@ struct ll_ioc_lease {
        __u32           lil_ids[0];
 };
 
+struct ll_ioc_lease_id {
+       __u32           lil_mode;
+       __u32           lil_flags;
+       __u32           lil_count;
+       __u16           lil_mirror_id;
+       __u16           lil_padding1;
+       __u64           lil_padding2;
+       __u32           lil_ids[0];
+};
+
 /*
  * The ioctl naming rules:
  * LL_*     - works on the currently opened filehandle instead of parent dir
@@ -433,7 +494,9 @@ struct fsxattr {
 #endif
 #define LL_IOC_FSGETXATTR              FS_IOC_FSGETXATTR
 #define LL_IOC_FSSETXATTR              FS_IOC_FSSETXATTR
-#define LL_PROJINHERIT_FL              0x20000000
+#ifndef FS_XFLAG_PROJINHERIT
+#define FS_XFLAG_PROJINHERIT           0x00000200
+#endif
 
 
 #define LL_STATFS_LMV          1
@@ -455,6 +518,9 @@ struct fsxattr {
 /* To be compatible with old statically linked binary we keep the check for
  * the older 0100000000 flag.  This is already removed upstream.  LU-812. */
 #define O_LOV_DELAY_CREATE_1_8 0100000000 /* FMODE_NONOTIFY masked in 2.6.36 */
+#ifndef FASYNC
+#define FASYNC                 00020000   /* fcntl, for BSD compatibility */
+#endif
 #define O_LOV_DELAY_CREATE_MASK        (O_NOCTTY | FASYNC)
 #define O_LOV_DELAY_CREATE             (O_LOV_DELAY_CREATE_1_8 | \
                                         O_LOV_DELAY_CREATE_MASK)
@@ -581,15 +647,24 @@ enum lov_comp_md_entry_flags {
        LCME_FL_PREF_RW = LCME_FL_PREF_RD | LCME_FL_PREF_WR,
        LCME_FL_OFFLINE = 0x00000008,   /* Not used */
        LCME_FL_INIT    = 0x00000010,   /* instantiated */
+       LCME_FL_NOSYNC  = 0x00000020,   /* FLR: no sync for the mirror */
        LCME_FL_NEG     = 0x80000000    /* used to indicate a negative flag,
                                           won't be stored on disk */
 };
 
 #define LCME_KNOWN_FLAGS       (LCME_FL_NEG | LCME_FL_INIT | LCME_FL_STALE | \
-                                LCME_FL_PREF_RW)
+                                LCME_FL_PREF_RW | LCME_FL_NOSYNC)
 /* The flags can be set by users at mirror creation time. */
 #define LCME_USER_FLAGS                (LCME_FL_PREF_RW)
 
+/* The flags are for mirrors */
+#define LCME_MIRROR_FLAGS      (LCME_FL_NOSYNC)
+
+/* These flags have meaning when set in a default layout and will be inherited
+ * from the default/template layout set on a directory.
+ */
+#define LCME_TEMPLATE_FLAGS    (LCME_FL_PREF_RW | LCME_FL_NOSYNC)
+
 /* the highest bit in obdo::o_layout_version is used to mark if the file is
  * being resynced. */
 #define LU_LAYOUT_RESYNC       LCME_FL_NEG
@@ -614,7 +689,9 @@ struct lov_comp_md_entry_v1 {
        __u32                   lcme_offset;    /* offset of component blob,
                                                   start from lov_comp_md_v1 */
        __u32                   lcme_size;      /* size of component blob */
-       __u64                   lcme_padding[2];
+       __u32                   lcme_layout_gen;
+       __u64                   lcme_timestamp; /* snapshot time if applicable*/
+       __u32                   lcme_padding_1;
 } __attribute__((packed));
 
 #define SEQ_ID_MAX             0x0000FFFF
@@ -719,8 +796,12 @@ struct lmv_user_md_v1 {
 
 static inline int lmv_user_md_size(int stripes, int lmm_magic)
 {
-       return sizeof(struct lmv_user_md) +
-                     stripes * sizeof(struct lmv_user_mds_data);
+       int size = sizeof(struct lmv_user_md);
+
+       if (lmm_magic == LMV_USER_MAGIC_SPECIFIC)
+               size += stripes * sizeof(struct lmv_user_mds_data);
+
+       return size;
 }
 
 struct ll_recreate_obj {
@@ -830,6 +911,28 @@ static inline __u64 lustre_stoqb(size_t space)
 /* lustre-specific control commands */
 #define LUSTRE_Q_INVALIDATE  0x80000b     /* deprecated as of 2.4 */
 #define LUSTRE_Q_FINVALIDATE 0x80000c     /* deprecated as of 2.4 */
+#define LUSTRE_Q_GETDEFAULT  0x80000d     /* get default quota */
+#define LUSTRE_Q_SETDEFAULT  0x80000e     /* set default quota */
+
+/* In the current Lustre implementation, the grace time is either the time
+ * or the timestamp to be used after some quota ID exceeds the soft limt,
+ * 48 bits should be enough, its high 16 bits can be used as quota flags.
+ * */
+#define LQUOTA_GRACE_BITS      48
+#define LQUOTA_GRACE_MASK      ((1ULL << LQUOTA_GRACE_BITS) - 1)
+#define LQUOTA_GRACE_MAX       LQUOTA_GRACE_MASK
+#define LQUOTA_GRACE(t)                (t & LQUOTA_GRACE_MASK)
+#define LQUOTA_FLAG(t)         (t >> LQUOTA_GRACE_BITS)
+#define LQUOTA_GRACE_FLAG(t, f)        ((__u64)t | (__u64)f << LQUOTA_GRACE_BITS)
+
+/* different quota flags */
+
+/* the default quota flag, the corresponding quota ID will use the default
+ * quota setting, the hardlimit and softlimit of its quota record in the global
+ * quota file will be set to 0, the low 48 bits of the grace will be set to 0
+ * and high 16 bits will contain this flag (see above comment).
+ * */
+#define LQUOTA_FLAG_DEFAULT    0x0001
 
 #define ALLQUOTA 255       /* set all quota */
 static inline char *qtype_name(int qtype)
@@ -975,6 +1078,8 @@ enum la_valid {
        LA_KILL_SGID = 1 << 14,
        LA_PROJID    = 1 << 15,
        LA_LAYOUT_VERSION = 1 << 16,
+       LA_LSIZE = 1 << 17,
+       LA_LBLOCKS = 1 << 18,
        /**
         * Attributes must be transmitted to OST objects
         */
@@ -991,7 +1096,7 @@ enum la_valid {
 /*     MDS_FMODE_SOM            04000000 obsolete since 2.8.0 */
 
 #define MDS_OPEN_CREATED         00000010
-#define MDS_OPEN_CROSS           00000020
+/*     MDS_OPEN_CROSS           00000020 obsolete in 2.12, internal use only */
 
 #define MDS_OPEN_CREAT           00000100
 #define MDS_OPEN_EXCL            00000200
@@ -1035,6 +1140,7 @@ enum la_valid {
 /********* Changelogs **********/
 /** Changelog record types */
 enum changelog_rec_type {
+       CL_NONE     = -1,
        CL_MARK     = 0,
        CL_CREATE   = 1,  /* namespace */
        CL_MKDIR    = 2,  /* namespace */
@@ -1077,16 +1183,17 @@ static inline const char *changelog_type2str(int type) {
        return NULL;
 }
 
-/* per-record flags */
+/* 12 bits of per-record data can be stored in the bottom of the flags */
 #define CLF_FLAGSHIFT   12
-#define CLF_FLAGMASK    ((1U << CLF_FLAGSHIFT) - 1)
-#define CLF_VERMASK     (~CLF_FLAGMASK)
 enum changelog_rec_flags {
        CLF_VERSION     = 0x1000,
        CLF_RENAME      = 0x2000,
        CLF_JOBID       = 0x4000,
        CLF_EXTRA_FLAGS = 0x8000,
-       CLF_SUPPORTED   = CLF_VERSION | CLF_RENAME | CLF_JOBID | CLF_EXTRA_FLAGS
+       CLF_SUPPORTED   = CLF_VERSION | CLF_RENAME | CLF_JOBID |
+                         CLF_EXTRA_FLAGS,
+       CLF_FLAGMASK    = (1U << CLF_FLAGSHIFT) - 1,
+       CLF_VERMASK     = ~CLF_FLAGMASK,
 };
 
 
@@ -1146,29 +1253,32 @@ static inline enum hsm_event hsm_get_cl_event(__u16 flags)
                                            CLF_HSM_EVENT_L);
 }
 
-static inline void hsm_set_cl_event(int *flags, enum hsm_event he)
+static inline void hsm_set_cl_event(enum changelog_rec_flags *clf_flags,
+                                   enum hsm_event he)
 {
-       *flags |= (he << CLF_HSM_EVENT_L);
+       *clf_flags |= (he << CLF_HSM_EVENT_L);
 }
 
-static inline __u16 hsm_get_cl_flags(int flags)
+static inline __u16 hsm_get_cl_flags(enum changelog_rec_flags clf_flags)
 {
-       return CLF_GET_BITS(flags, CLF_HSM_FLAG_H, CLF_HSM_FLAG_L);
+       return CLF_GET_BITS(clf_flags, CLF_HSM_FLAG_H, CLF_HSM_FLAG_L);
 }
 
-static inline void hsm_set_cl_flags(int *flags, int bits)
+static inline void hsm_set_cl_flags(enum changelog_rec_flags *clf_flags,
+                                   unsigned int bits)
 {
-       *flags |= (bits << CLF_HSM_FLAG_L);
+       *clf_flags |= (bits << CLF_HSM_FLAG_L);
 }
 
-static inline int hsm_get_cl_error(int flags)
+static inline int hsm_get_cl_error(enum changelog_rec_flags clf_flags)
 {
-       return CLF_GET_BITS(flags, CLF_HSM_ERR_H, CLF_HSM_ERR_L);
+       return CLF_GET_BITS(clf_flags, CLF_HSM_ERR_H, CLF_HSM_ERR_L);
 }
 
-static inline void hsm_set_cl_error(int *flags, int error)
+static inline void hsm_set_cl_error(enum changelog_rec_flags *clf_flags,
+                                   unsigned int error)
 {
-       *flags |= (error << CLF_HSM_ERR_L);
+       *clf_flags |= (error << CLF_HSM_ERR_L);
 }
 
 enum changelog_rec_extra_flags {
@@ -1263,7 +1373,7 @@ struct changelog_ext_nid {
        __u32 padding;
 };
 
-/* Changelog extra extension to include OPEN mode. */
+/* Changelog extra extension to include low 32 bits of MDS_OPEN_* flags. */
 struct changelog_ext_openmode {
        __u32 cr_openflags;
 };
@@ -2031,7 +2141,6 @@ enum sk_crypt_alg {
        SK_CRYPT_INVALID        = -1,
        SK_CRYPT_EMPTY          = 0,
        SK_CRYPT_AES256_CTR     = 1,
-       SK_CRYPT_MAX            = 2,
 };
 
 enum sk_hmac_alg {
@@ -2039,17 +2148,16 @@ enum sk_hmac_alg {
        SK_HMAC_EMPTY   = 0,
        SK_HMAC_SHA256  = 1,
        SK_HMAC_SHA512  = 2,
-       SK_HMAC_MAX     = 3,
 };
 
 struct sk_crypt_type {
-       char    *sct_name;
-       size_t   sct_bytes;
+       const char     *sct_name;
+       int             sct_type;
 };
 
 struct sk_hmac_type {
-       char    *sht_name;
-       size_t   sht_bytes;
+       const char     *sht_name;
+       int             sht_type;
 };
 
 enum lock_mode_user {