Whamcloud - gitweb
LU-819 utils: Fix lfs getstripe -M
[fs/lustre-release.git] / lustre / include / lustre / lustre_user.h
index 14dff87..f2a52cb 100644 (file)
@@ -30,6 +30,9 @@
  * Use is subject to license terms.
  */
 /*
+ * Copyright (c) 2011 Whamcloud, Inc.
+ */
+/*
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  *
@@ -46,6 +49,9 @@
  * @{
  */
 
+#ifndef __KERNEL__
+#include <libcfs/posix/posix-types.h>
+#endif
 #include <lustre/ll_fiemap.h>
 #if defined(__linux__)
 #include <linux/lustre_user.h>
@@ -115,20 +121,26 @@ struct obd_statfs {
  * *STRIPE* - set/get lov_user_md
  * *INFO    - set/get lov_user_mds_data
  */
-/* see <lustre_obd.h> for ioctl numberss 101-150 */
+/* see <lustre_lib.h> for ioctl numberss 101-150 */
 #define LL_IOC_GETFLAGS                 _IOR ('f', 151, long)
 #define LL_IOC_SETFLAGS                 _IOW ('f', 152, long)
 #define LL_IOC_CLRFLAGS                 _IOW ('f', 153, long)
+/* LL_IOC_LOV_SETSTRIPE: See also OBD_IOC_LOV_SETSTRIPE */
 #define LL_IOC_LOV_SETSTRIPE            _IOW ('f', 154, long)
+/* LL_IOC_LOV_GETSTRIPE: See also OBD_IOC_LOV_GETSTRIPE */
 #define LL_IOC_LOV_GETSTRIPE            _IOW ('f', 155, long)
+/* LL_IOC_LOV_SETEA: See also OBD_IOC_LOV_SETEA */
 #define LL_IOC_LOV_SETEA                _IOW ('f', 156, long)
 #define LL_IOC_RECREATE_OBJ             _IOW ('f', 157, long)
 #define LL_IOC_RECREATE_FID             _IOW ('f', 157, struct lu_fid)
 #define LL_IOC_GROUP_LOCK               _IOW ('f', 158, long)
 #define LL_IOC_GROUP_UNLOCK             _IOW ('f', 159, long)
+/* LL_IOC_QUOTACHECK: See also OBD_IOC_QUOTACHECK */
 #define LL_IOC_QUOTACHECK               _IOW ('f', 160, int)
+/* LL_IOC_POLL_QUOTACHECK: See also OBD_IOC_POLL_QUOTACHECK */
 #define LL_IOC_POLL_QUOTACHECK          _IOR ('f', 161, struct if_quotacheck *)
-#define LL_IOC_QUOTACTL                 _IOWR('f', 162, struct if_quotactl *)
+/* LL_IOC_QUOTACTL: See also OBD_IOC_QUOTACTL */
+#define LL_IOC_QUOTACTL                 _IOWR('f', 162, struct if_quotactl)
 #define IOC_OBD_STATFS                  _IOWR('f', 164, struct obd_statfs *)
 #define IOC_LOV_GETINFO                 _IOWR('f', 165, struct lov_user_mds_data *)
 #define LL_IOC_FLUSHCTX                 _IOW ('f', 166, long)
@@ -136,16 +148,16 @@ struct obd_statfs {
 #define LL_IOC_GETOBDCOUNT              _IOR ('f', 168, long)
 #define LL_IOC_LLOOP_ATTACH             _IOWR('f', 169, long)
 #define LL_IOC_LLOOP_DETACH             _IOWR('f', 170, long)
-#define LL_IOC_LLOOP_INFO               _IOWR('f', 171, long)
+#define LL_IOC_LLOOP_INFO               _IOWR('f', 171, struct lu_fid)
 #define LL_IOC_LLOOP_DETACH_BYDEV       _IOWR('f', 172, long)
 #define LL_IOC_PATH2FID                 _IOR ('f', 173, long)
 #define LL_IOC_GET_CONNECT_FLAGS        _IOWR('f', 174, __u64 *)
 #define LL_IOC_GET_MDTIDX               _IOR ('f', 175, int)
 #define LL_IOC_HSM_CT_START             _IOW ('f', 176,struct lustre_kernelcomm)
-/* see <lustre_obd.h> for ioctl numbers 177-210 */
+/* see <lustre_lib.h> for ioctl numbers 177-210 */
 
 
-#define LL_STATFS_MDC           1
+#define LL_STATFS_LMV           1
 #define LL_STATFS_LOV           2
 
 #define IOC_MDC_TYPE            'i'
@@ -158,12 +170,17 @@ struct obd_statfs {
 #define LL_IOC_OBD_STATFS       IOC_OBD_STATFS
 #define IOC_MDC_GETSTRIPE       IOC_MDC_GETFILESTRIPE
 
+
+#define MAX_OBD_NAME 128 /* If this changes, a NEW ioctl must be added */
+
 #define O_LOV_DELAY_CREATE 0100000000  /* hopefully this does not conflict */
 
-#define LL_FILE_IGNORE_LOCK             0x00000001
-#define LL_FILE_GROUP_LOCKED            0x00000002
-#define LL_FILE_READAHEAD               0x00000004
-#define LL_FILE_RMTACL                  0x00000008
+#define LL_FILE_IGNORE_LOCK     0x00000001
+#define LL_FILE_GROUP_LOCKED    0x00000002
+#define LL_FILE_READAHEA        0x00000004
+#define LL_FILE_LOCKED_DIRECTIO 0x00000008 /* client-side locks with dio */
+#define LL_FILE_LOCKLESS_IO     0x00000010 /* server-side locks with cio */
+#define LL_FILE_RMTACL          0x00000020
 
 #define LOV_USER_MAGIC_V1 0x0BD10BD0
 #define LOV_USER_MAGIC    LOV_USER_MAGIC_V1
@@ -186,6 +203,7 @@ struct lov_user_ost_data_v1 {     /* per-stripe data structure */
 } __attribute__((packed));
 
 #define lov_user_md lov_user_md_v1
+#define lmm_stripe_offset u.lum_stripe_offset
 struct lov_user_md_v1 {           /* LOV EA user data (host-endian) */
         __u32 lmm_magic;          /* magic number = LOV_USER_MAGIC_V1 */
         __u32 lmm_pattern;        /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
@@ -193,7 +211,12 @@ struct lov_user_md_v1 {           /* LOV EA user data (host-endian) */
         __u64 lmm_object_seq;     /* LOV object seq */
         __u32 lmm_stripe_size;    /* size of stripe in bytes */
         __u16 lmm_stripe_count;   /* num stripes in use for this object */
-        __u16 lmm_stripe_offset;  /* starting stripe offset in lmm_objects */
+        union {
+                __u16 lum_stripe_offset;  /* starting stripe offset in
+                                           * lmm_objects, use when writing */
+                __u16 lum_layout_gen;     /* layout generation number
+                                           * used when reading */
+        } u;
         struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
 } __attribute__((packed,  __may_alias__));
 
@@ -204,7 +227,12 @@ struct lov_user_md_v3 {           /* LOV EA user data (host-endian) */
         __u64 lmm_object_seq;     /* LOV object seq */
         __u32 lmm_stripe_size;    /* size of stripe in bytes */
         __u16 lmm_stripe_count;   /* num stripes in use for this object */
-        __u16 lmm_stripe_offset;  /* starting stripe offset in lmm_objects */
+        union {
+                __u16 lum_stripe_offset;  /* starting stripe offset in
+                                           * lmm_objects, use when writing */
+                __u16 lum_layout_gen;     /* layout generation number
+                                           * used when reading */
+        } u;
         char  lmm_pool_name[LOV_MAXPOOLNAME]; /* pool name */
         struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
 } __attribute__((packed));
@@ -237,11 +265,13 @@ struct ll_fid {
                            * OST for saving into EA. */
 };
 
+#define UUID_MAX        40
 struct obd_uuid {
-        char uuid[40];
+        char uuid[UUID_MAX];
 };
 
-static inline int obd_uuid_equals(struct obd_uuid *u1, struct obd_uuid *u2)
+static inline int obd_uuid_equals(const struct obd_uuid *u1,
+                                  const struct obd_uuid *u2)
 {
         return strcmp((char *)u1->uuid, (char *)u2->uuid) == 0;
 }
@@ -362,7 +392,7 @@ struct if_quotacheck {
         struct obd_uuid         obd_uuid;
 };
 
-#define IDENTITY_DOWNCALL_MAGIC 0x6d6dd620
+#define IDENTITY_DOWNCALL_MAGIC 0x6d6dd629
 
 /* permission */
 #define N_PERMS_MAX      64
@@ -370,6 +400,7 @@ struct if_quotacheck {
 struct perm_downcall_data {
         __u64 pdd_nid;
         __u32 pdd_perm;
+        __u32 pdd_padding;
 };
 
 struct identity_downcall_data {
@@ -378,8 +409,8 @@ struct identity_downcall_data {
         __u32                            idd_uid;
         __u32                            idd_gid;
         __u32                            idd_nperms;
-        struct perm_downcall_data idd_perms[N_PERMS_MAX];
         __u32                            idd_ngroups;
+        struct perm_downcall_data idd_perms[N_PERMS_MAX];
         __u32                            idd_groups[0];
 };
 
@@ -435,7 +466,7 @@ struct obd_dqblk {
         __u64 dqb_btime;
         __u64 dqb_itime;
         __u32 dqb_valid;
-        __u32 padding;
+        __u32 dqb_padding;
 };
 
 enum {
@@ -519,9 +550,10 @@ static inline const char *changelog_type2str(int type) {
 #define CLF_HSM_SPARE_H     15
 #define CLF_HSM_LAST        15
 
-#define CLF_GET_BITS(_b, _h, _l) \
- _b &= (0xFFFF << (CLF_HSM_LAST - _h)); \
- _b = _b >> (_l + CLF_HSM_LAST - _h)
+/* Remove bits higher than _h, then extract the value
+ * between _h and _l by shifting lower weigth to bit 0. */
+#define CLF_GET_BITS(_b, _h, _l) (((_b << (CLF_HSM_LAST - _h)) & 0xFFFF) \
+                                   >> (CLF_HSM_LAST - _h + _l))
 
 #define CLF_HSM_SUCCESS      0x00
 #define CLF_HSM_MAXERROR     0x7E
@@ -543,11 +575,7 @@ enum hsm_event {
 
 static inline enum hsm_event hsm_get_cl_event(__u16 flags)
 {
-        enum hsm_event he;
-
-        CLF_GET_BITS(flags, CLF_HSM_EVENT_H, CLF_HSM_EVENT_L);
-        he = flags;
-        return he;
+        return CLF_GET_BITS(flags, CLF_HSM_EVENT_H, CLF_HSM_EVENT_L);
 }
 
 static inline void hsm_set_cl_event(int *flags, enum hsm_event he)
@@ -557,8 +585,7 @@ static inline void hsm_set_cl_event(int *flags, enum hsm_event he)
 
 static inline __u16 hsm_get_cl_flags(int flags)
 {
-        CLF_GET_BITS(flags, CLF_HSM_FLAG_H, CLF_HSM_FLAG_L);
-        return flags;
+        return CLF_GET_BITS(flags, CLF_HSM_FLAG_H, CLF_HSM_FLAG_L);
 }
 
 static inline void hsm_set_cl_flags(int *flags, int bits)
@@ -568,8 +595,7 @@ static inline void hsm_set_cl_flags(int *flags, int bits)
 
 static inline int hsm_get_cl_error(int flags)
 {
-        CLF_GET_BITS(flags, CLF_HSM_ERR_H, CLF_HSM_ERR_L);
-        return flags;
+        return CLF_GET_BITS(flags, CLF_HSM_ERR_H, CLF_HSM_ERR_L);
 }
 
 static inline void hsm_set_cl_error(int *flags, int error)
@@ -796,8 +822,6 @@ static inline char *hai_dump_data_field(struct hsm_action_item *hai,
         int i, sz, data_len;
         char *ptr;
 
-        LASSERT(len > 0);
-
         ptr = buffer;
         sz = len;
         data_len = hai->hai_len - sizeof(*hai);
@@ -856,7 +880,6 @@ static inline int hal_size(struct hsm_action_list *hal)
         int i, sz;
         struct hsm_action_item *hai;
 
-        LASSERT(hal->hal_version == HAL_VERSION);
         sz = sizeof(*hal) + cfs_size_round(strlen(hal->hal_fsname));
         hai = hai_zero(hal);
         for (i = 0 ; i < hal->hal_count ; i++) {