Whamcloud - gitweb
LU-8602 gss: Properly port gss to newer crypto api.
[fs/lustre-release.git] / lustre / include / uapi / linux / lustre / lustre_user.h
index 46c72b4..e273457 100644 (file)
@@ -42,6 +42,7 @@
  * @{
  */
 
+#include <linux/kernel.h>
 #include <linux/types.h>
 
 #ifdef __KERNEL__
 # include <linux/lustre/lustre_fiemap.h>
 #endif /* __KERNEL__ */
 
+/* Handle older distros */
+#ifndef __ALIGN_KERNEL
+# define __ALIGN_KERNEL(x, a)   __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
+# define __ALIGN_KERNEL_MASK(x, mask)   (((x) + (mask)) & ~(mask))
+#endif
+
 #if defined(__cplusplus)
 extern "C" {
 #endif
@@ -80,35 +87,31 @@ extern "C" {
 };
 #define PRJQUOTA 2
 
-#if defined(__x86_64__) || defined(__ia64__) || defined(__ppc64__) || \
-    defined(__craynv) || defined(__mips64__) || defined(__powerpc64__) || \
-    defined(__aarch64__)
-typedef struct stat    lstat_t;
-# define lstat_f       lstat
-# define fstat_f       fstat
-# define fstatat_f     fstatat
-# define HAVE_LOV_USER_MDS_DATA
-#elif defined(__USE_LARGEFILE64) || defined(__KERNEL__)
-typedef struct stat64  lstat_t;
-# define lstat_f       lstat64
-# define fstat_f       fstat64
-# define fstatat_f     fstatat64
-# define HAVE_LOV_USER_MDS_DATA
+/*
+ * We need to always use 64bit version because the structure
+ * is shared across entire cluster where 32bit and 64bit machines
+ * are co-existing.
+ */
+#if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64)
+typedef struct stat64   lstat_t;
+#define lstat_f  lstat64
+#define fstat_f         fstat64
+#define fstatat_f       fstatat64
+#else
+typedef struct stat     lstat_t;
+#define lstat_f  lstat
+#define fstat_f         fstat
+#define fstatat_f       fstatat
 #endif
 
+#define HAVE_LOV_USER_MDS_DATA
+
 #define LUSTRE_EOF 0xffffffffffffffffULL
 
 /* for statfs() */
 #define LL_SUPER_MAGIC 0x0BD00BD0
 
-#ifndef FSFILT_IOC_GETFLAGS
-#define FSFILT_IOC_GETFLAGS               _IOR('f', 1, long)
-#define FSFILT_IOC_SETFLAGS               _IOW('f', 2, long)
-#define FSFILT_IOC_GETVERSION             _IOR('f', 3, long)
-#define FSFILT_IOC_SETVERSION             _IOW('f', 4, long)
-#define FSFILT_IOC_GETVERSION_OLD         _IOR('v', 1, long)
-#define FSFILT_IOC_SETVERSION_OLD         _IOW('v', 2, long)
-#endif
+#define FSFILT_IOC_GETVERSION          _IOR('f', 3, long)
 
 /* FIEMAP flags supported by Lustre */
 #define LUSTRE_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_DEVICE_ORDER)
@@ -116,8 +119,10 @@ typedef struct stat64      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 */
@@ -136,14 +141,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;
 };
 
 /**
@@ -283,8 +288,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 {
@@ -347,6 +361,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
@@ -430,7 +454,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
@@ -487,9 +513,8 @@ struct fsxattr {
 
 static inline bool lov_pattern_supported(__u32 pattern)
 {
-       return pattern == LOV_PATTERN_RAID0 ||
-              pattern == LOV_PATTERN_MDT ||
-              pattern == (LOV_PATTERN_RAID0 | LOV_PATTERN_F_RELEASED);
+       return (pattern & ~LOV_PATTERN_F_RELEASED) == LOV_PATTERN_RAID0 ||
+              (pattern & ~LOV_PATTERN_F_RELEASED) == LOV_PATTERN_MDT;
 }
 
 #define LOV_MAXPOOLNAME 15
@@ -579,15 +604,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
@@ -612,7 +646,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
@@ -678,11 +714,6 @@ 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_v3 {
-       lstat_t lmd_st;                 /* MDS stat struct */
-       struct lov_user_md_v3 lmd_lmm;  /* LOV EA V3 user data */
-} __attribute__((packed));
 #endif
 
 struct lmv_user_mds_data {
@@ -722,8 +753,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 {
@@ -833,6 +868,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)
@@ -892,9 +949,9 @@ struct identity_downcall_data {
 #define LUSTRE_VOLATILE_HDR    ".\x0c\x13\x14\x12:VOLATILE"
 #define LUSTRE_VOLATILE_HDR_LEN        14
 
-typedef enum lustre_quota_version {
+enum lustre_quota_version {
        LUSTRE_QUOTA_V2 = 1
-} lustre_quota_version_t;
+};
 
 /* XXX: same as if_dqinfo struct in kernel */
 struct obd_dqinfo {
@@ -978,16 +1035,16 @@ 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
         */
        LA_REMOTE_ATTR_SET = (LA_UID | LA_GID | LA_PROJID | LA_LAYOUT_VERSION)
 };
 
-#ifndef FMODE_READ
-#define FMODE_READ               00000001
-#define FMODE_WRITE              00000002
-#endif
+#define MDS_FMODE_READ           00000001
+#define MDS_FMODE_WRITE          00000002
 
 #define MDS_FMODE_CLOSED         00000000
 #define MDS_FMODE_EXEC           00000004
@@ -996,7 +1053,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
@@ -1040,6 +1097,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 */
@@ -1209,9 +1267,9 @@ enum changelog_send_extra_flag {
        CHANGELOG_EXTRA_FLAG_XATTR  = 0x08,
 };
 
-#define CR_MAXSIZE cfs_size_round(2 * NAME_MAX + 2 + \
+#define CR_MAXSIZE __ALIGN_KERNEL(2 * NAME_MAX + 2 + \
                                  changelog_rec_offset(CLF_SUPPORTED, \
-                                                       CLFE_SUPPORTED))
+                                                      CLFE_SUPPORTED), 8)
 
 /* 31 usable bytes string + null terminator. */
 #define LUSTRE_JOBID_SIZE      32
@@ -1651,14 +1709,14 @@ enum hsm_states {
 #define HSM_FLAGS_MASK  (HSM_USER_MASK | HSM_STATUS_MASK)
 
 /**
- * HSM request progress state
+ * HSM request progress state
  */
 enum hsm_progress_states {
+       HPS_NONE        = 0,
        HPS_WAITING     = 1,
        HPS_RUNNING     = 2,
        HPS_DONE        = 3,
 };
-#define HPS_NONE       0
 
 static inline const char *hsm_progress_state2name(enum hsm_progress_states s)
 {
@@ -1869,7 +1927,7 @@ static inline char *hai_dump_data_field(const struct hsm_action_item *hai,
 struct hsm_action_list {
        __u32 hal_version;
        __u32 hal_count;       /* number of hai's to follow */
-       __u64 hal_compound_id; /* returned by coordinator */
+       __u64 hal_compound_id; /* returned by coordinator, ignored */
        __u64 hal_flags;
        __u32 hal_archive_id; /* which archive backend */
        __u32 padding1;
@@ -1878,27 +1936,20 @@ struct hsm_action_list {
           boundaries. See hai_zero */
 } __attribute__((packed));
 
-#ifndef HAVE_CFS_SIZE_ROUND
-static inline int cfs_size_round (int val)
-{
-       return (val + 7) & (~0x7);
-}
-#define HAVE_CFS_SIZE_ROUND
-#endif
-
 /* Return pointer to first hai in action list */
 static inline struct hsm_action_item *hai_first(struct hsm_action_list *hal)
 {
-       return (struct hsm_action_item *)(hal->hal_fsname +
-                                         cfs_size_round(strlen(hal-> \
-                                                               hal_fsname)
-                                                        + 1));
+       size_t offset = __ALIGN_KERNEL(strlen(hal->hal_fsname) + 1, 8);
+
+       return (struct hsm_action_item *)(hal->hal_fsname + offset);
 }
+
 /* Return pointer to next hai */
 static inline struct hsm_action_item * hai_next(struct hsm_action_item *hai)
 {
-       return (struct hsm_action_item *)((char *)hai +
-                                         cfs_size_round(hai->hai_len));
+       size_t offset = __ALIGN_KERNEL(hai->hai_len, 8);
+
+       return (struct hsm_action_item *)((char *)hai + offset);
 }
 
 /* Return size of an hsm_action_list */
@@ -1908,10 +1959,10 @@ static inline size_t hal_size(struct hsm_action_list *hal)
        size_t sz;
        struct hsm_action_item *hai;
 
-       sz = sizeof(*hal) + cfs_size_round(strlen(hal->hal_fsname) + 1);
+       sz = sizeof(*hal) + __ALIGN_KERNEL(strlen(hal->hal_fsname) + 1, 8);
        hai = hai_first(hal);
        for (i = 0; i < hal->hal_count ; i++, hai = hai_next(hai))
-               sz += cfs_size_round(hai->hai_len);
+               sz += __ALIGN_KERNEL(hai->hai_len, 8);
 
        return sz;
 }
@@ -2043,7 +2094,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 {
@@ -2051,17 +2101,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 {