Whamcloud - gitweb
LU-11367 som: integrate LSOM with lfs find
[fs/lustre-release.git] / lustre / include / uapi / linux / lustre / lustre_user.h
index 1ca6449..7b99c49 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
@@ -193,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
@@ -437,6 +477,8 @@ struct ll_ioc_lease_id {
 #define LL_IOC_FID2MDTIDX              _IOWR('f', 248, struct lu_fid)
 #define LL_IOC_GETPARENT               _IOWR('f', 249, struct getparent)
 #define LL_IOC_LADVISE                 _IOR('f', 250, struct llapi_lu_ladvise)
+#define LL_IOC_HEAT_GET                        _IOWR('f', 251, struct lu_heat)
+#define LL_IOC_HEAT_SET                        _IOW('f', 252, long)
 
 #ifndef        FS_IOC_FSGETXATTR
 /*
@@ -463,11 +505,13 @@ struct fsxattr {
 #define LL_STATFS_LOV          2
 #define LL_STATFS_NODELAY      4
 
-#define IOC_MDC_TYPE            'i'
-#define IOC_MDC_LOOKUP          _IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
-#define IOC_MDC_GETFILESTRIPE   _IOWR(IOC_MDC_TYPE, 21, struct lov_user_md *)
-#define IOC_MDC_GETFILEINFO     _IOWR(IOC_MDC_TYPE, 22, struct lov_user_mds_data *)
-#define LL_IOC_MDC_GETINFO      _IOWR(IOC_MDC_TYPE, 23, struct lov_user_mds_data *)
+#define IOC_MDC_TYPE           'i'
+#define IOC_MDC_LOOKUP         _IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
+#define IOC_MDC_GETFILESTRIPE  _IOWR(IOC_MDC_TYPE, 21, struct lov_user_md *)
+#define IOC_MDC_GETFILEINFO_OLD        _IOWR(IOC_MDC_TYPE, 22, struct lov_user_mds_data_v1 *)
+#define IOC_MDC_GETFILEINFO    _IOWR(IOC_MDC_TYPE, 22, struct lov_user_mds_data)
+#define LL_IOC_MDC_GETINFO_OLD _IOWR(IOC_MDC_TYPE, 23, struct lov_user_mds_data_v1 *)
+#define LL_IOC_MDC_GETINFO     _IOWR(IOC_MDC_TYPE, 23, struct lov_user_mds_data)
 
 #define MAX_OBD_NAME 128 /* If this changes, a NEW ioctl must be added */
 
@@ -478,6 +522,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)
@@ -511,6 +558,8 @@ struct fsxattr {
 #define LOV_PATTERN_F_RELEASED 0x80000000 /* HSM released file */
 #define LOV_PATTERN_DEFAULT    0xffffffff
 
+#define LOV_OFFSET_DEFAULT      ((__u16)-1)
+
 static inline bool lov_pattern_supported(__u32 pattern)
 {
        return (pattern & ~LOV_PATTERN_F_RELEASED) == LOV_PATTERN_RAID0 ||
@@ -655,6 +704,7 @@ struct lov_comp_md_entry_v1 {
 #define SEQ_ID_MASK            SEQ_ID_MAX
 /* bit 30:16 of lcme_id is used to store mirror id */
 #define MIRROR_ID_MASK         0x7FFF0000
+#define MIRROR_ID_NEG          0x8000
 #define MIRROR_ID_SHIFT                16
 
 static inline __u32 pflr_id(__u16 mirror_id, __u16 seqid)
@@ -709,11 +759,17 @@ static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic)
  * use this.  It is unsafe to #define those values in this header as it
  * is possible the application has already #included <sys/stat.h>. */
 #ifdef HAVE_LOV_USER_MDS_DATA
-#define lov_user_mds_data lov_user_mds_data_v1
+#define lov_user_mds_data lov_user_mds_data_v2
 struct lov_user_mds_data_v1 {
        lstat_t lmd_st;                 /* MDS stat struct */
        struct lov_user_md_v1 lmd_lmm;  /* LOV EA V1 user data */
 } __attribute__((packed));
+
+struct lov_user_mds_data_v2 {
+       lstat_t lmd_st;                 /* MDS stat struct */
+       __u64 lmd_flags;                /* MDS stat flags */
+       struct lov_user_md_v1 lmd_lmm;  /* LOV EA V1 user data */
+} __attribute__((packed));
 #endif
 
 struct lmv_user_mds_data {
@@ -906,6 +962,7 @@ static inline char *qtype_name(int qtype)
 }
 
 #define IDENTITY_DOWNCALL_MAGIC 0x6d6dd629
+#define SEPOL_DOWNCALL_MAGIC 0x8b8bb842
 
 /* permission */
 #define N_PERMS_MAX      64
@@ -927,6 +984,13 @@ struct identity_downcall_data {
        __u32                            idd_groups[0];
 };
 
+struct sepol_downcall_data {
+       __u32          sdd_magic;
+       time_t         sdd_sepol_mtime;
+       __u16          sdd_sepol_len;
+       char           sdd_sepol[0];
+};
+
 #ifdef NEED_QUOTA_DEFS
 #ifndef QIF_BLIMITS
 #define QIF_BLIMITS     1
@@ -1018,25 +1082,25 @@ struct lustre_swap_layouts {
  * Only the first 12 bits are currently saved.
  */
 enum la_valid {
-       LA_ATIME = 1 << 0,
-       LA_MTIME = 1 << 1,
-       LA_CTIME = 1 << 2,
-       LA_SIZE  = 1 << 3,
-       LA_MODE  = 1 << 4,
-       LA_UID   = 1 << 5,
-       LA_GID   = 1 << 6,
-       LA_BLOCKS = 1 << 7,
-       LA_TYPE   = 1 << 8,
-       LA_FLAGS  = 1 << 9,
-       LA_NLINK  = 1 << 10,
-       LA_RDEV   = 1 << 11,
-       LA_BLKSIZE = 1 << 12,
-       LA_KILL_SUID = 1 << 13,
-       LA_KILL_SGID = 1 << 14,
-       LA_PROJID    = 1 << 15,
-       LA_LAYOUT_VERSION = 1 << 16,
-       LA_LSIZE = 1 << 17,
-       LA_LBLOCKS = 1 << 18,
+       LA_ATIME        = 1 << 0,       /* 0x00001 */
+       LA_MTIME        = 1 << 1,       /* 0x00002 */
+       LA_CTIME        = 1 << 2,       /* 0x00004 */
+       LA_SIZE         = 1 << 3,       /* 0x00008 */
+       LA_MODE         = 1 << 4,       /* 0x00010 */
+       LA_UID          = 1 << 5,       /* 0x00020 */
+       LA_GID          = 1 << 6,       /* 0x00040 */
+       LA_BLOCKS       = 1 << 7,       /* 0x00080 */
+       LA_TYPE         = 1 << 8,       /* 0x00100 */
+       LA_FLAGS        = 1 << 9,       /* 0x00200 */
+       LA_NLINK        = 1 << 10,      /* 0x00400 */
+       LA_RDEV         = 1 << 11,      /* 0x00800 */
+       LA_BLKSIZE      = 1 << 12,      /* 0x01000 */
+       LA_KILL_SUID    = 1 << 13,      /* 0x02000 */
+       LA_KILL_SGID    = 1 << 14,      /* 0x04000 */
+       LA_PROJID       = 1 << 15,      /* 0x08000 */
+       LA_LAYOUT_VERSION = 1 << 16,    /* 0x10000 */
+       LA_LSIZE        = 1 << 17,      /* 0x20000 */
+       LA_LBLOCKS      = 1 << 18,      /* 0x40000 */
        /**
         * Attributes must be transmitted to OST objects
         */
@@ -1140,16 +1204,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,
 };
 
 
@@ -1209,29 +1274,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 {
@@ -1326,7 +1394,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;
 };
@@ -2094,7 +2162,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 {
@@ -2102,17 +2169,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 {
@@ -2132,6 +2198,36 @@ enum lockahead_results {
        LLA_RESULT_SAME,
 };
 
+enum lu_heat_flag_bit {
+       LU_HEAT_FLAG_BIT_INVALID = 0,
+       LU_HEAT_FLAG_BIT_OFF,
+       LU_HEAT_FLAG_BIT_CLEAR,
+};
+
+#define LU_HEAT_FLAG_CLEAR     (1 << LU_HEAT_FLAG_BIT_CLEAR)
+#define LU_HEAT_FLAG_OFF       (1 << LU_HEAT_FLAG_BIT_OFF)
+
+enum obd_heat_type {
+       OBD_HEAT_READSAMPLE     = 0,
+       OBD_HEAT_WRITESAMPLE    = 1,
+       OBD_HEAT_READBYTE       = 2,
+       OBD_HEAT_WRITEBYTE      = 3,
+       OBD_HEAT_COUNT
+};
+
+#define LU_HEAT_NAMES {                                        \
+       [OBD_HEAT_READSAMPLE]   = "readsample",         \
+       [OBD_HEAT_WRITESAMPLE]  = "writesample",        \
+       [OBD_HEAT_READBYTE]     = "readbyte",           \
+       [OBD_HEAT_WRITEBYTE]    = "writebyte",          \
+}
+
+struct lu_heat {
+       __u32 lh_count;
+       __u32 lh_flags;
+       __u64 lh_heat[0];
+};
+
 #if defined(__cplusplus)
 }
 #endif