Whamcloud - gitweb
LU-6349 idl: clean up and document ptlrpc structures
[fs/lustre-release.git] / lustre / include / uapi / linux / lustre / lustre_user.h
index c538657..d840295 100644 (file)
 # include <linux/lustre/lustre_fiemap.h>
 #endif /* __KERNEL__ */
 
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
 /*
  * This is a temporary solution of adding quota type.
  * Should be removed as soon as system header is updated.
@@ -116,29 +120,30 @@ enum obd_statfs_state {
        OS_STATE_ENOINO         = 0x00000040, /**< not enough inodes */
 };
 
+/** filesystem statistics/attributes for target device */
 struct obd_statfs {
-       __u64           os_type;
-       __u64           os_blocks;
-       __u64           os_bfree;
-       __u64           os_bavail;
-       __u64           os_files;
-       __u64           os_ffree;
-       __u8            os_fsid[40];
-       __u32           os_bsize;
-       __u32           os_namelen;
-       __u64           os_maxbytes;
-       __u32           os_state;       /**< obd_statfs_state OS_STATE_* flag */
-       __u32           os_fprecreated; /* objs available now to the caller */
+       __u64           os_type;        /* EXT4_SUPER_MAGIC, UBERBLOCK_MAGIC */
+       __u64           os_blocks;      /* total size in #os_bsize blocks */
+       __u64           os_bfree;       /* number of unused blocks */
+       __u64           os_bavail;      /* blocks available for allocation */
+       __u64           os_files;       /* total number of objects */
+       __u64           os_ffree;       /* # objects that could be created */
+       __u8            os_fsid[40];    /* identifier for filesystem */
+       __u32           os_bsize;       /* block size in bytes for os_blocks */
+       __u32           os_namelen;     /* maximum length of filename in bytes*/
+       __u64           os_maxbytes;    /* maximum object size in bytes */
+       __u32           os_state;       /**< obd_statfs_state OS_STATE_* flag */
+       __u32           os_fprecreated; /* objs available now to the caller */
                                        /* used in QoS code to find preferred
                                         * OSTs */
-       __u32           os_spare2;
-       __u32           os_spare3;
-       __u32           os_spare4;
-       __u32           os_spare5;
-       __u32           os_spare6;
-       __u32           os_spare7;
-       __u32           os_spare8;
-       __u32           os_spare9;
+       __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;
 };
 
 /**
@@ -201,7 +206,7 @@ struct filter_fid {
 /* Userspace should treat lu_fid as opaque, and only use the following methods
  * to print or parse them.  Other functions (e.g. compare, swab) could be moved
  * here from lustre_idl.h if needed. */
-typedef struct lu_fid lustre_fid;
+struct lu_fid;
 
 enum lma_compat {
        LMAC_HSM         = 0x00000001,
@@ -315,6 +320,31 @@ struct ll_futimes_3 {
 };
 
 /*
+ * Maximum number of mirrors currently implemented.
+ */
+#define LUSTRE_MIRROR_COUNT_MAX                16
+
+/* Lease types for use as arg and return of LL_IOC_{GET,SET}_LEASE ioctl. */
+enum ll_lease_mode {
+       LL_LEASE_RDLCK  = 0x01,
+       LL_LEASE_WRLCK  = 0x02,
+       LL_LEASE_UNLCK  = 0x04,
+};
+
+enum ll_lease_flags {
+       LL_LEASE_RESYNC         = 0x1,
+       LL_LEASE_RESYNC_DONE    = 0x2,
+};
+
+#define IOC_IDS_MAX    4096
+struct ll_ioc_lease {
+       __u32           lil_mode;
+       __u32           lil_flags;
+       __u32           lil_count;
+       __u32           lil_ids[0];
+};
+
+/*
  * The ioctl naming rules:
  * LL_*     - works on the currently opened filehandle instead of parent dir
  * *_OBD_*  - gets data for both OSC or MDC (LOV, LMV indirectly)
@@ -353,6 +383,7 @@ struct ll_futimes_3 {
 #define LL_IOC_GET_CONNECT_FLAGS        _IOWR('f', 174, __u64 *)
 #define LL_IOC_GET_MDTIDX               _IOR ('f', 175, int)
 #define LL_IOC_FUTIMES_3               _IOWR('f', 176, struct ll_futimes_3)
+#define LL_IOC_FLR_SET_MIRROR          _IOW ('f', 177, long)
 /*     lustre_ioctl.h                  177-210 */
 #define LL_IOC_HSM_STATE_GET           _IOR('f', 211, struct hsm_user_state)
 #define LL_IOC_HSM_STATE_SET           _IOW('f', 212, struct hsm_state_set)
@@ -370,7 +401,8 @@ struct ll_futimes_3 {
 #define LL_IOC_LMV_SETSTRIPE           _IOWR('f', 240, struct lmv_user_md)
 #define LL_IOC_LMV_GETSTRIPE           _IOWR('f', 241, struct lmv_user_md)
 #define LL_IOC_REMOVE_ENTRY            _IOWR('f', 242, __u64)
-#define LL_IOC_SET_LEASE               _IOWR('f', 243, long)
+#define LL_IOC_SET_LEASE               _IOWR('f', 243, struct ll_ioc_lease)
+#define LL_IOC_SET_LEASE_OLD           _IOWR('f', 243, long)
 #define LL_IOC_GET_LEASE               _IO('f', 244)
 #define LL_IOC_HSM_IMPORT              _IOWR('f', 245, struct hsm_user_import)
 #define LL_IOC_LMV_SET_DEFAULT_STRIPE  _IOWR('f', 246, struct lmv_user_md)
@@ -397,13 +429,6 @@ struct fsxattr {
 #define LL_IOC_FSSETXATTR              FS_IOC_FSSETXATTR
 
 
-/* Lease types for use as arg and return of LL_IOC_{GET,SET}_LEASE ioctl. */
-enum ll_lease_type {
-       LL_LEASE_RDLCK  = 0x1,
-       LL_LEASE_WRLCK  = 0x2,
-       LL_LEASE_UNLCK  = 0x4,
-};
-
 #define LL_STATFS_LMV          1
 #define LL_STATFS_LOV          2
 #define LL_STATFS_NODELAY      4
@@ -441,7 +466,8 @@ enum ll_lease_type {
 #define LOV_USER_MAGIC_SPECIFIC 0x0BD50BD0     /* for specific OSTs */
 #define LOV_USER_MAGIC_COMP_V1 0x0BD60BD0
 
-#define LMV_USER_MAGIC    0x0CD30CD0    /*default lmv magic*/
+#define LMV_USER_MAGIC         0x0CD30CD0    /* default lmv magic */
+#define LMV_USER_MAGIC_V0      0x0CD20CD0    /* old default lmv magic*/
 
 #define LOV_PATTERN_NONE       0x000
 #define LOV_PATTERN_RAID0      0x001
@@ -978,7 +1004,8 @@ enum changelog_rec_flags {
        CLF_VERSION     = 0x1000,
        CLF_RENAME      = 0x2000,
        CLF_JOBID       = 0x4000,
-       CLF_SUPPORTED   = CLF_VERSION | CLF_RENAME | CLF_JOBID
+       CLF_EXTRA_FLAGS = 0x8000,
+       CLF_SUPPORTED   = CLF_VERSION | CLF_RENAME | CLF_JOBID | CLF_EXTRA_FLAGS
 };
 
 
@@ -1063,28 +1090,43 @@ static inline void hsm_set_cl_error(int *flags, int error)
        *flags |= (error << CLF_HSM_ERR_L);
 }
 
+enum changelog_rec_extra_flags {
+       CLFE_INVALID    = 0,
+       CLFE_UIDGID     = 0x0001,
+       CLFE_SUPPORTED  = CLFE_UIDGID
+};
+
 enum changelog_send_flag {
        /* Not yet implemented */
-       CHANGELOG_FLAG_FOLLOW   = 0x01,
+       CHANGELOG_FLAG_FOLLOW      = 0x01,
        /* Blocking IO makes sense in case of slow user parsing of the records,
         * but it also prevents us from cleaning up if the records are not
         * consumed. */
-       CHANGELOG_FLAG_BLOCK    = 0x02,
+       CHANGELOG_FLAG_BLOCK       = 0x02,
        /* Pack jobid into the changelog records if available. */
-       CHANGELOG_FLAG_JOBID    = 0x04,
+       CHANGELOG_FLAG_JOBID       = 0x04,
+       /* Pack additional flag bits into the changelog record */
+       CHANGELOG_FLAG_EXTRA_FLAGS = 0x08,
+};
+
+enum changelog_send_extra_flag {
+       /* Pack uid/gid into the changelog record */
+       CHANGELOG_EXTRA_FLAG_UIDGID = 0x01,
 };
 
 #define CR_MAXSIZE cfs_size_round(2 * NAME_MAX + 2 + \
-                                 changelog_rec_offset(CLF_SUPPORTED))
+                                 changelog_rec_offset(CLF_SUPPORTED, \
+                                                       CLFE_SUPPORTED))
 
 /* 31 usable bytes string + null terminator. */
 #define LUSTRE_JOBID_SIZE      32
 
 /* This is the minimal changelog record. It can contain extensions
  * such as rename fields or process jobid. Its exact content is described
- * by the cr_flags.
+ * by the cr_flags and cr_extra_flags.
  *
- * Extensions are packed in the same order as their corresponding flags.
+ * Extensions are packed in the same order as their corresponding flags,
+ * then in the same order as their corresponding extra flags.
  */
 struct changelog_rec {
        __u16                   cr_namelen;
@@ -1094,16 +1136,16 @@ struct changelog_rec {
        __u64                   cr_prev;  /**< last index for this target fid */
        __u64                   cr_time;
        union {
-               lustre_fid      cr_tfid;        /**< target fid */
+               struct lu_fid   cr_tfid;        /**< target fid */
                __u32           cr_markerflags; /**< CL_MARK flags */
        };
-       lustre_fid              cr_pfid;        /**< parent fid */
+       struct lu_fid           cr_pfid;        /**< parent fid */
 };
 
 /* Changelog extension for RENAME. */
 struct changelog_ext_rename {
-       lustre_fid              cr_sfid;     /**< source fid, or zero */
-       lustre_fid              cr_spfid;    /**< source parent fid, or zero */
+       struct lu_fid           cr_sfid;     /**< source fid, or zero */
+       struct lu_fid           cr_spfid;    /**< source parent fid, or zero */
 };
 
 /* Changelog extension to include JOBID. */
@@ -1111,8 +1153,22 @@ struct changelog_ext_jobid {
        char    cr_jobid[LUSTRE_JOBID_SIZE];    /**< zero-terminated string. */
 };
 
+/* Changelog extension to include additional flags. */
+struct changelog_ext_extra_flags {
+       __u64 cr_extra_flags; /* Additional CLFE_* flags */
+};
+
+/* Changelog extra extension to include UID/GID. */
+struct changelog_ext_uidgid {
+       __u64   cr_uid;
+       __u64   cr_gid;
+};
+
+static inline struct changelog_ext_extra_flags *changelog_rec_extra_flags(
+       const struct changelog_rec *rec);
 
-static inline size_t changelog_rec_offset(enum changelog_rec_flags crf)
+static inline size_t changelog_rec_offset(enum changelog_rec_flags crf,
+                                         enum changelog_rec_extra_flags cref)
 {
        size_t size = sizeof(struct changelog_rec);
 
@@ -1122,12 +1178,23 @@ static inline size_t changelog_rec_offset(enum changelog_rec_flags crf)
        if (crf & CLF_JOBID)
                size += sizeof(struct changelog_ext_jobid);
 
+       if (crf & CLF_EXTRA_FLAGS) {
+               size += sizeof(struct changelog_ext_extra_flags);
+               if (cref & CLFE_UIDGID)
+                       size += sizeof(struct changelog_ext_uidgid);
+       }
+
        return size;
 }
 
 static inline size_t changelog_rec_size(const struct changelog_rec *rec)
 {
-       return changelog_rec_offset(rec->cr_flags);
+       enum changelog_rec_extra_flags cref = CLFE_INVALID;
+
+       if (rec->cr_flags & CLF_EXTRA_FLAGS)
+               cref = changelog_rec_extra_flags(rec)->cr_extra_flags;
+
+       return changelog_rec_offset(rec->cr_flags, cref);
 }
 
 static inline size_t changelog_rec_varsize(const struct changelog_rec *rec)
@@ -1141,7 +1208,8 @@ struct changelog_ext_rename *changelog_rec_rename(const struct changelog_rec *re
        enum changelog_rec_flags crf = rec->cr_flags & CLF_VERSION;
 
        return (struct changelog_ext_rename *)((char *)rec +
-                                              changelog_rec_offset(crf));
+                                              changelog_rec_offset(crf,
+                                                                CLFE_INVALID));
 }
 
 /* The jobid follows the rename extension, if present */
@@ -1152,14 +1220,46 @@ struct changelog_ext_jobid *changelog_rec_jobid(const struct changelog_rec *rec)
                                        (CLF_VERSION | CLF_RENAME);
 
        return (struct changelog_ext_jobid *)((char *)rec +
-                                             changelog_rec_offset(crf));
+                                             changelog_rec_offset(crf,
+                                                                CLFE_INVALID));
 }
 
-/* The name follows the rename and jobid extensions, if present */
+/* The additional flags follow the rename and jobid extensions, if present */
+static inline
+struct changelog_ext_extra_flags *changelog_rec_extra_flags(
+       const struct changelog_rec *rec)
+{
+       enum changelog_rec_flags crf = rec->cr_flags &
+               (CLF_VERSION | CLF_RENAME | CLF_JOBID);
+
+       return (struct changelog_ext_extra_flags *)((char *)rec +
+                                                changelog_rec_offset(crf,
+                                                                CLFE_INVALID));
+}
+
+/* The uid/gid is the first extra extension */
+static inline
+struct changelog_ext_uidgid *changelog_rec_uidgid(
+       const struct changelog_rec *rec)
+{
+       enum changelog_rec_flags crf = rec->cr_flags &
+               (CLF_VERSION | CLF_RENAME | CLF_JOBID | CLF_EXTRA_FLAGS);
+
+       return (struct changelog_ext_uidgid *)((char *)rec +
+                                              changelog_rec_offset(crf,
+                                                                CLFE_INVALID));
+}
+
+/* The name follows the rename, jobid  and extra flags extns, if present */
 static inline char *changelog_rec_name(const struct changelog_rec *rec)
 {
-       return (char *)rec + changelog_rec_offset(rec->cr_flags &
-                                                 CLF_SUPPORTED);
+       enum changelog_rec_extra_flags cref = CLFE_INVALID;
+
+       if (rec->cr_flags & CLF_EXTRA_FLAGS)
+               cref = changelog_rec_extra_flags(rec)->cr_extra_flags;
+
+       return (char *)rec + changelog_rec_offset(rec->cr_flags & CLF_SUPPORTED,
+                                                 cref & CLFE_SUPPORTED);
 }
 
 static inline size_t changelog_rec_snamelen(const struct changelog_rec *rec)
@@ -1189,32 +1289,71 @@ static inline char *changelog_rec_sname(const struct changelog_rec *rec)
  * The following assumptions are being made:
  *   - CLF_RENAME will not be removed
  *   - CLF_JOBID will not be added without CLF_RENAME being added too
+ *   - CLF_EXTRA_FLAGS will not be added without CLF_JOBID being added too
  *
  * @param[in,out]  rec         The record to remap.
  * @param[in]      crf_wanted  Flags describing the desired extensions.
+ * @param[in]      cref_want   Flags describing the desired extra extensions.
  */
 static inline void changelog_remap_rec(struct changelog_rec *rec,
-                                      enum changelog_rec_flags crf_wanted)
+                                      enum changelog_rec_flags crf_wanted,
+                                      enum changelog_rec_extra_flags cref_want)
 {
+       char *uidgid_mov = NULL;
+       char *ef_mov;
        char *jid_mov;
        char *rnm_mov;
+       enum changelog_rec_extra_flags cref = CLFE_INVALID;
 
        crf_wanted &= CLF_SUPPORTED;
-
-       if ((rec->cr_flags & CLF_SUPPORTED) == crf_wanted)
-               return;
+       cref_want &= CLFE_SUPPORTED;
+
+       if ((rec->cr_flags & CLF_SUPPORTED) == crf_wanted) {
+               if (!(rec->cr_flags & CLF_EXTRA_FLAGS) ||
+                   (rec->cr_flags & CLF_EXTRA_FLAGS &&
+                   (changelog_rec_extra_flags(rec)->cr_extra_flags &
+                                                       CLFE_SUPPORTED) ==
+                                                                    cref_want))
+                       return;
+       }
 
        /* First move the variable-length name field */
-       memmove((char *)rec + changelog_rec_offset(crf_wanted),
+       memmove((char *)rec + changelog_rec_offset(crf_wanted, cref_want),
                changelog_rec_name(rec), rec->cr_namelen);
 
-       /* Locations of jobid and rename extensions in the remapped record */
+       /* Locations of extensions in the remapped record */
+       if (rec->cr_flags & CLF_EXTRA_FLAGS) {
+               uidgid_mov = (char *)rec +
+                       changelog_rec_offset(crf_wanted & CLF_SUPPORTED,
+                                            CLFE_INVALID);
+               cref = changelog_rec_extra_flags(rec)->cr_extra_flags;
+       }
+
+       ef_mov  = (char *)rec +
+                 changelog_rec_offset(crf_wanted & ~CLF_EXTRA_FLAGS,
+                                      CLFE_INVALID);
        jid_mov = (char *)rec +
-                 changelog_rec_offset(crf_wanted & ~CLF_JOBID);
+                 changelog_rec_offset(crf_wanted &
+                                      ~(CLF_EXTRA_FLAGS | CLF_JOBID),
+                                      CLFE_INVALID);
        rnm_mov = (char *)rec +
-                 changelog_rec_offset(crf_wanted & ~(CLF_JOBID | CLF_RENAME));
+                 changelog_rec_offset(crf_wanted &
+                                      ~(CLF_EXTRA_FLAGS |
+                                        CLF_JOBID |
+                                        CLF_RENAME),
+                                      CLFE_INVALID);
 
        /* Move the extension fields to the desired positions */
+       if ((crf_wanted & CLF_EXTRA_FLAGS) &&
+           (rec->cr_flags & CLF_EXTRA_FLAGS)) {
+               if ((cref_want & CLFE_UIDGID) && (cref & CLFE_UIDGID))
+                       memmove(uidgid_mov, changelog_rec_uidgid(rec),
+                               sizeof(struct changelog_ext_uidgid));
+
+               memmove(ef_mov, changelog_rec_extra_flags(rec),
+                       sizeof(struct changelog_ext_extra_flags));
+       }
+
        if ((crf_wanted & CLF_JOBID) && (rec->cr_flags & CLF_JOBID))
                memmove(jid_mov, changelog_rec_jobid(rec),
                        sizeof(struct changelog_ext_jobid));
@@ -1224,6 +1363,14 @@ static inline void changelog_remap_rec(struct changelog_rec *rec,
                        sizeof(struct changelog_ext_rename));
 
        /* Clear newly added fields */
+       if (uidgid_mov && (cref_want & CLFE_UIDGID) &&
+           !(cref & CLFE_UIDGID))
+               memset(uidgid_mov, 0, sizeof(struct changelog_ext_uidgid));
+
+       if ((crf_wanted & CLF_EXTRA_FLAGS) &&
+           !(rec->cr_flags & CLF_EXTRA_FLAGS))
+               memset(ef_mov, 0, sizeof(struct changelog_ext_extra_flags));
+
        if ((crf_wanted & CLF_JOBID) && !(rec->cr_flags & CLF_JOBID))
                memset(jid_mov, 0, sizeof(struct changelog_ext_jobid));
 
@@ -1232,6 +1379,10 @@ static inline void changelog_remap_rec(struct changelog_rec *rec,
 
        /* Update the record's flags accordingly */
        rec->cr_flags = (rec->cr_flags & CLF_FLAGMASK) | crf_wanted;
+       if (rec->cr_flags & CLF_EXTRA_FLAGS)
+               changelog_rec_extra_flags(rec)->cr_extra_flags =
+                       changelog_rec_extra_flags(rec)->cr_extra_flags |
+                       cref_want;
 }
 
 enum changelog_message_type {
@@ -1242,11 +1393,15 @@ enum changelog_message_type {
 /********* Misc **********/
 
 struct ioc_data_version {
-       __u64 idv_version;
-       __u64 idv_flags;     /* See LL_DV_xxx */
+       __u64   idv_version;
+       __u32   idv_layout_version; /* FLR: layout version for OST objects */
+       __u32   idv_flags;      /* enum ioc_data_version_flags */
+};
+
+enum ioc_data_version_flags {
+       LL_DV_RD_FLUSH  = (1 << 0), /* Flush dirty pages from clients */
+       LL_DV_WR_FLUSH  = (1 << 1), /* Flush all caching pages from clients */
 };
-#define LL_DV_RD_FLUSH (1 << 0) /* Flush dirty pages from clients */
-#define LL_DV_WR_FLUSH (1 << 1) /* Flush all caching pages from clients */
 
 #ifndef offsetof
 #define offsetof(typ, memb)     ((unsigned long)((char *)&(((typ *)0)->memb)))
@@ -1388,7 +1543,7 @@ struct hsm_request {
 };
 
 struct hsm_user_item {
-       lustre_fid        hui_fid;
+       struct lu_fid        hui_fid;
        struct hsm_extent hui_extent;
 } __attribute__((packed));
 
@@ -1458,8 +1613,8 @@ static inline const char *hsm_copytool_action2name(enum hsm_copytool_action  a)
 struct hsm_action_item {
        __u32      hai_len;     /* valid size of this struct */
        __u32      hai_action;  /* hsm_copytool_action, but use known size */
-       lustre_fid hai_fid;     /* Lustre FID to operate on */
-       lustre_fid hai_dfid;    /* fid used for data access */
+       struct lu_fid hai_fid;     /* Lustre FID to operate on */
+       struct lu_fid hai_dfid;    /* fid used for data access */
        struct hsm_extent hai_extent;  /* byte range to operate on */
        __u64      hai_cookie;  /* action cookie from coordinator */
        __u64      hai_gid;     /* grouplock id */
@@ -1569,7 +1724,7 @@ struct hsm_user_import {
 #define HP_FLAG_RETRY     0x02
 
 struct hsm_progress {
-       lustre_fid              hp_fid;
+       struct lu_fid           hp_fid;
        __u64                   hp_cookie;
        struct hsm_extent       hp_extent;
        __u16                   hp_flags;
@@ -1714,6 +1869,10 @@ enum lockahead_results {
        LLA_RESULT_SAME,
 };
 
+#if defined(__cplusplus)
+}
+#endif
+
 /** @} lustreuser */
 
 #endif /* _LUSTRE_USER_H */