Whamcloud - gitweb
LU-3345 llapi: add user space method for lov_user_md
authorjcl <jacques-charles.lafoucriere@cea.fr>
Wed, 15 May 2013 11:16:41 +0000 (13:16 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 10 Jun 2013 23:22:20 +0000 (19:22 -0400)
move lov_mds_md_size from obd_lov.h to lustre_idl.h
to have it close to lov_mds_md definition.

add lov_user_md_size() to compute lum size so
llapi and user space utils do not use kernel internal
definitions/methods

Signed-off-by: JC Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Change-Id: I01825efb4521bf90293239054a32fd66f85bcaf2
Reviewed-on: http://review.whamcloud.com/6345
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/include/lustre/lustre_idl.h
lustre/include/lustre/lustre_user.h
lustre/include/obd_lov.h
lustre/tests/ll_dirstripe_verify.c
lustre/utils/lfs.c
lustre/utils/liblustreapi.c

index b9fd5a7..174fd42 100644 (file)
@@ -1674,6 +1674,17 @@ struct lov_mds_md_v3 {            /* LOV EA mds/wire data (little-endian) */
        struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */
 };
 
        struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */
 };
 
+static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic)
+{
+       if (lmm_magic == LOV_MAGIC_V3)
+               return sizeof(struct lov_mds_md_v3) +
+                               stripes * sizeof(struct lov_ost_data_v1);
+       else
+               return sizeof(struct lov_mds_md_v1) +
+                               stripes * sizeof(struct lov_ost_data_v1);
+}
+
+
 #define OBD_MD_FLID        (0x00000001ULL) /* object ID */
 #define OBD_MD_FLATIME     (0x00000002ULL) /* access time */
 #define OBD_MD_FLMTIME     (0x00000004ULL) /* data modification time */
 #define OBD_MD_FLID        (0x00000001ULL) /* object ID */
 #define OBD_MD_FLATIME     (0x00000002ULL) /* access time */
 #define OBD_MD_FLMTIME     (0x00000004ULL) /* data modification time */
index 4b74f94..9de0815 100644 (file)
@@ -358,6 +358,16 @@ struct lov_user_md_v3 {           /* LOV EA user data (host-endian) */
        struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
 } __attribute__((packed));
 
        struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
 } __attribute__((packed));
 
+static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic)
+{
+       if (lmm_magic == LOV_USER_MAGIC_V3)
+               return sizeof(struct lov_user_md_v3) +
+                               stripes * sizeof(struct lov_user_ost_data_v1);
+       else
+               return sizeof(struct lov_user_md_v1) +
+                               stripes * sizeof(struct lov_user_ost_data_v1);
+}
+
 /* Compile with -D_LARGEFILE64_SOURCE or -D_GNU_SOURCE (or #define) to
  * use this.  It is unsafe to #define those values in this header as it
  * is possible the application has already #included <sys/stat.h>. */
 /* Compile with -D_LARGEFILE64_SOURCE or -D_GNU_SOURCE (or #define) to
  * use this.  It is unsafe to #define those values in this header as it
  * is possible the application has already #included <sys/stat.h>. */
index 1ee3675..dfb2631 100644 (file)
@@ -44,16 +44,6 @@ static inline int lov_stripe_md_size(__u16 stripes)
         return sizeof(struct lov_stripe_md) + stripes*sizeof(struct lov_oinfo*);
 }
 
         return sizeof(struct lov_stripe_md) + stripes*sizeof(struct lov_oinfo*);
 }
 
-static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic)
-{
-        if (lmm_magic == LOV_MAGIC_V3)
-                return sizeof(struct lov_mds_md_v3) +
-                        stripes * sizeof(struct lov_ost_data_v1);
-        else
-                return sizeof(struct lov_mds_md_v1) +
-                        stripes * sizeof(struct lov_ost_data_v1);
-}
-
 struct lov_version_size {
         __u32   lvs_magic;
         size_t  lvs_lmm_size;
 struct lov_version_size {
         __u32   lvs_magic;
         size_t  lvs_lmm_size;
index 9a98b9f..d5269b4 100644 (file)
@@ -245,14 +245,15 @@ int main(int argc, char **argv)
                 return rc;
         }
 
                 return rc;
         }
 
-        lum_size = lov_mds_md_size(MAX_LOV_UUID_COUNT, LOV_MAGIC);
-        if ((lum_dir = (struct lov_user_md *)malloc(lum_size)) == NULL) {
-                rc = -ENOMEM;
-                llapi_error(LLAPI_MSG_ERROR, rc,
-                            "error: can't allocate %d bytes "
-                            "for dir EA", lum_size);
-                goto cleanup;
-        }
+       lum_size = lov_user_md_size(MAX_LOV_UUID_COUNT, LOV_USER_MAGIC);
+       lum_dir = (struct lov_user_md *)malloc(lum_size);
+       if (lum_dir == NULL) {
+               rc = -ENOMEM;
+               llapi_error(LLAPI_MSG_ERROR, rc,
+                           "error: can't allocate %d bytes "
+                           "for dir EA", lum_size);
+               goto cleanup;
+       }
 
         rc = llapi_file_get_stripe(argv[1], lum_dir);
         if (rc) {
 
         rc = llapi_file_get_stripe(argv[1], lum_dir);
         if (rc) {
index 5b2e45e..f258453 100644 (file)
@@ -355,7 +355,7 @@ static int lfs_migrate(char *name, unsigned long long stripe_size,
        int                      have_gl = 0;
 
        /* find the right size for the IO and allocate the buffer */
        int                      have_gl = 0;
 
        /* find the right size for the IO and allocate the buffer */
-       lumsz = lov_mds_md_size(LOV_MAX_STRIPE_COUNT, LOV_MAGIC_V3);
+       lumsz = lov_user_md_size(LOV_MAX_STRIPE_COUNT, LOV_USER_MAGIC_V3);
        lum = malloc(lumsz);
        if (lum == NULL) {
                rc = -ENOMEM;
        lum = malloc(lumsz);
        if (lum == NULL) {
                rc = -ENOMEM;
index 155f5c3..ce51960 100644 (file)
@@ -524,7 +524,7 @@ static int get_param_lmv(const char *path,
 
 static int get_mds_md_size(const char *path)
 {
 
 static int get_mds_md_size(const char *path)
 {
-       int md_size = lov_mds_md_size(LOV_MAX_STRIPE_COUNT, LOV_MAGIC_V3);
+       int md_size = lov_user_md_size(LOV_MAX_STRIPE_COUNT, LOV_USER_MAGIC_V3);
        char buf[80];
        int rc;
 
        char buf[80];
        int rc;
 
@@ -3098,7 +3098,7 @@ static int cb_getstripe(char *path, DIR *parent, DIR *d, void *data,
                         * The object_seq needs to be set for the "(Default)"
                         * prefix to be displayed. */
                        struct lov_user_md *lmm = &param->lmd->lmd_lmm;
                         * The object_seq needs to be set for the "(Default)"
                         * prefix to be displayed. */
                        struct lov_user_md *lmm = &param->lmd->lmd_lmm;
-                       lmm->lmm_magic = LOV_MAGIC_V1;
+                       lmm->lmm_magic = LOV_USER_MAGIC_V1;
                        if (!param->raw)
                                ostid_set_seq(&lmm->lmm_oi,
                                              FID_SEQ_LOV_DEFAULT);
                        if (!param->raw)
                                ostid_set_seq(&lmm->lmm_oi,
                                              FID_SEQ_LOV_DEFAULT);