Whamcloud - gitweb
LU-2888 fid: still Use oi_id/oi_seq for log/lov object.
authorwang di <di.wang@intel.com>
Mon, 27 Jan 2014 03:44:48 +0000 (19:44 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 13 Apr 2013 14:24:41 +0000 (10:24 -0400)
Since llog are only used locally on MDS right now, so we will use
oi_id/oi_seq to identfy the log, instead of trying to convert it to
FID, to avoid confusion in ostid_to_fid/fid_to_ostid.

Since pre-2.4 use {oi_id,oi_seq} for FIDs on MDT, which make
it difficult to tell whether it is ostid or FID by only checking
oi_seq, so this patch will separate lmm_oi/FID conversion from
ostid_to_fid.

Signed-off-by: wang di <di.wang@intel.com>
Change-Id: Ie17b11a8a07ed3a44e41d5e88529541cbd33dd2f
Reviewed-on: http://review.whamcloud.com/6044
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
14 files changed:
lustre/include/lustre/lustre_idl.h
lustre/include/lustre_log.h
lustre/liblustre/tests/sanity.c
lustre/lod/lod_lov.c
lustre/lod/lod_object.c
lustre/lov/lov_ea.c
lustre/lov/lov_merge.c
lustre/lov/lov_object.c
lustre/lov/lov_pack.c
lustre/obdecho/echo_client.c
lustre/ofd/ofd_io.c
lustre/ofd/ofd_obd.c
lustre/ptlrpc/pack_generic.c
lustre/utils/liblustreapi.c

index aceaeba..6e285bf 100644 (file)
@@ -1569,6 +1569,66 @@ struct lov_mds_md_v1 {            /* 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 */
 };
 
+/**
+ * Sigh, because pre-2.4 uses
+ * struct lov_mds_md_v1 {
+ *     ........
+ *     __u64 lmm_object_id;
+ *     __u64 lmm_object_seq;
+ *      ......
+ *      }
+ * to identify the LOV(MDT) object, and lmm_object_seq will
+ * be normal_fid, which make it hard to combine these conversion
+ * to ostid_to FID. so we will do lmm_oi/fid conversion separately 
+ *
+ * We can tell the lmm_oi by this way,
+ * 1.8: lmm_object_id = {inode}, lmm_object_gr = 0
+ * 2.1: lmm_object_id = {oid < 128k}, lmm_object_seq = FID_SEQ_NORMAL
+ * 2.4: lmm_oi.f_seq = FID_SEQ_NORMAL, lmm_oi.f_oid = {oid < 128k},
+ *      lmm_oi.f_ver = 0
+ * 
+ * But currently lmm_oi/lsm_oi does not have any "real" usages,
+ * except for printing some information, and the user can always
+ * get the real FID from LMA, besides this multiple case check might
+ * make swab more complicate. So we will keep using id/seq for lmm_oi.
+ */ 
+
+static inline void fid_to_lmm_oi(const struct lu_fid *fid,
+                                struct ost_id *oi)
+{
+       oi->oi.oi_id = fid_oid(fid);
+       oi->oi.oi_seq = fid_seq(fid);
+}
+
+static inline void lmm_oi_set_seq(struct ost_id *oi, __u64 seq)
+{
+       oi->oi.oi_seq = seq;
+}
+
+static inline __u64 lmm_oi_id(struct ost_id *oi)
+{
+       return oi->oi.oi_id;
+}
+
+static inline __u64 lmm_oi_seq(struct ost_id *oi)
+{
+       return oi->oi.oi_seq;
+}
+
+static inline void lmm_oi_le_to_cpu(struct ost_id *dst_oi,
+                                   struct ost_id *src_oi)
+{
+       dst_oi->oi.oi_id = le64_to_cpu(src_oi->oi.oi_id);
+       dst_oi->oi.oi_seq = le64_to_cpu(src_oi->oi.oi_seq);
+}
+
+static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi,
+                                   struct ost_id *src_oi)
+{
+       dst_oi->oi.oi_id = cpu_to_le64(src_oi->oi.oi_id);
+       dst_oi->oi.oi_seq = cpu_to_le64(src_oi->oi.oi_seq);
+}
+
 /* extern void lustre_swab_lov_mds_md(struct lov_mds_md *llm); */
 
 #define MAX_MD_SIZE (sizeof(struct lov_mds_md) + 4 * sizeof(struct lov_ost_data))
 /* extern void lustre_swab_lov_mds_md(struct lov_mds_md *llm); */
 
 #define MAX_MD_SIZE (sizeof(struct lov_mds_md) + 4 * sizeof(struct lov_ost_data))
index e9d3f2c..7c1fc97 100644 (file)
@@ -97,38 +97,30 @@ static inline void logid_to_fid(struct llog_logid *id, struct lu_fid *fid)
        /* For compatibility purposes we identify pre-OSD (~< 2.3.51 MDS)
         * logid's by non-zero ogen (inode generation) and convert them
         * into IGIF */
        /* For compatibility purposes we identify pre-OSD (~< 2.3.51 MDS)
         * logid's by non-zero ogen (inode generation) and convert them
         * into IGIF */
-       if (id->lgl_ogen == 0)
-               ostid_to_fid(fid, &id->lgl_oi, 0);
-       else
-               lu_igif_build(fid, ostid_id(&id->lgl_oi), id->lgl_ogen);
+       if (id->lgl_ogen == 0) {
+               fid->f_seq = id->lgl_oi.oi.oi_seq;
+               fid->f_oid = id->lgl_oi.oi.oi_id;
+               fid->f_ver = 0;
+       } else {
+               lu_igif_build(fid, id->lgl_oi.oi.oi_id, id->lgl_ogen);
+       }
 }
 
 static inline void fid_to_logid(struct lu_fid *fid, struct llog_logid *id)
 {
 }
 
 static inline void fid_to_logid(struct lu_fid *fid, struct llog_logid *id)
 {
-       if (fid_is_igif(fid)) {
-               /* See above lu_igif_build */
-               ostid_set_id(&id->lgl_oi, fid->f_seq);
-               id->lgl_ogen = fid->f_oid;
-       } else {
-               fid_to_ostid(fid, &id->lgl_oi);
-               id->lgl_ogen = 0;
-       }
+       id->lgl_oi.oi.oi_seq = fid->f_seq;
+       id->lgl_oi.oi.oi_id = fid->f_oid;
+       id->lgl_ogen = 0;
 }
 
 static inline void logid_set_id(struct llog_logid *log_id, __u64 id)
 {
 }
 
 static inline void logid_set_id(struct llog_logid *log_id, __u64 id)
 {
-       if (log_id->lgl_ogen == 0)
-               ostid_set_id(&log_id->lgl_oi, id);
-       else
-               log_id->lgl_oi.oi.oi_id = id;
+       log_id->lgl_oi.oi.oi_id = id;
 }
 
 static inline __u64 logid_id(struct llog_logid *log_id)
 {
 }
 
 static inline __u64 logid_id(struct llog_logid *log_id)
 {
-       if (log_id->lgl_ogen == 0)
-               return ostid_id(&log_id->lgl_oi);
-       else
-               return log_id->lgl_oi.oi.oi_id;
+       return log_id->lgl_oi.oi.oi_id;
 }
 
 struct llog_handle;
 }
 
 struct llog_handle;
index 9652a6b..814a75f 100644 (file)
@@ -1257,9 +1257,9 @@ int t55(char *name)
         if (opt_verbose) {
                printf("lmm_magic:          0x%08X\n",  lum->lmm_magic);
                printf("lmm_object_id:      "LPX64"\n",
         if (opt_verbose) {
                printf("lmm_magic:          0x%08X\n",  lum->lmm_magic);
                printf("lmm_object_id:      "LPX64"\n",
-                                               ostid_id(&lum->lmm_oi));
+                                               lmm_oi_id(&lum->lmm_oi));
                printf("lmm_object_seq:     "LPX64"\n",
                printf("lmm_object_seq:     "LPX64"\n",
-                                               ostid_seq(&lum->lmm_oi));
+                                               lmm_oi_seq(&lum->lmm_oi));
                printf("lmm_stripe_count:   %u\n", (int)lum->lmm_stripe_count);
                printf("lmm_stripe_size:    %u\n",      lum->lmm_stripe_size);
                printf("lmm_stripe_pattern: %x\n",      lum->lmm_pattern);
                printf("lmm_stripe_count:   %u\n", (int)lum->lmm_stripe_count);
                printf("lmm_stripe_size:    %u\n",      lum->lmm_stripe_size);
                printf("lmm_stripe_pattern: %x\n",      lum->lmm_pattern);
@@ -1325,9 +1325,9 @@ int t55(char *name)
        if (opt_verbose) {
                printf("lmm_magic:          0x%08X\n",  lum->lmm_magic);
                printf("lmm_object_id:      "LPX64"\n",
        if (opt_verbose) {
                printf("lmm_magic:          0x%08X\n",  lum->lmm_magic);
                printf("lmm_object_id:      "LPX64"\n",
-                                               ostid_id(&lum->lmm_oi));
+                                               lmm_oi_id(&lum->lmm_oi));
                printf("lmm_object_seq:     "LPX64"\n",
                printf("lmm_object_seq:     "LPX64"\n",
-                                               ostid_seq(&lum->lmm_oi));
+                                               lmm_oi_seq(&lum->lmm_oi));
                printf("lmm_stripe_count:   %u\n", (int)lum->lmm_stripe_count);
                printf("lmm_stripe_size:    %u\n",      lum->lmm_stripe_size);
                printf("lmm_stripe_pattern: %x\n",      lum->lmm_pattern);
                printf("lmm_stripe_count:   %u\n", (int)lum->lmm_stripe_count);
                printf("lmm_stripe_size:    %u\n",      lum->lmm_stripe_size);
                printf("lmm_stripe_pattern: %x\n",      lum->lmm_pattern);
index 9c8b751..fefa3c7 100644 (file)
@@ -518,8 +518,8 @@ int lod_generate_and_set_lovea(const struct lu_env *env,
 
        lmm->lmm_magic = cpu_to_le32(magic);
        lmm->lmm_pattern = cpu_to_le32(LOV_PATTERN_RAID0);
 
        lmm->lmm_magic = cpu_to_le32(magic);
        lmm->lmm_pattern = cpu_to_le32(LOV_PATTERN_RAID0);
-       fid_to_ostid(fid, &lmm->lmm_oi);
-       ostid_cpu_to_le(&lmm->lmm_oi, &lmm->lmm_oi);
+       fid_to_lmm_oi(fid, &lmm->lmm_oi);
+       lmm_oi_cpu_to_le(&lmm->lmm_oi, &lmm->lmm_oi);
        lmm->lmm_stripe_size = cpu_to_le32(lo->ldo_stripe_size);
        lmm->lmm_stripe_count = cpu_to_le16(lo->ldo_stripenr);
        lmm->lmm_layout_gen = 0;
        lmm->lmm_stripe_size = cpu_to_le32(lo->ldo_stripe_size);
        lmm->lmm_stripe_count = cpu_to_le16(lo->ldo_stripenr);
        lmm->lmm_layout_gen = 0;
@@ -691,7 +691,9 @@ int lod_initialize_objects(const struct lu_env *env, struct lod_object *lo,
        for (i = 0; i < lo->ldo_stripenr; i++) {
                ostid_le_to_cpu(&objs[i].l_ost_oi, &info->lti_ostid);
                idx = le64_to_cpu(objs[i].l_ost_idx);
        for (i = 0; i < lo->ldo_stripenr; i++) {
                ostid_le_to_cpu(&objs[i].l_ost_oi, &info->lti_ostid);
                idx = le64_to_cpu(objs[i].l_ost_idx);
-               ostid_to_fid(&info->lti_fid, &info->lti_ostid, idx);
+               rc = ostid_to_fid(&info->lti_fid, &info->lti_ostid, idx);
+               if (rc != 0)
+                       GOTO(out, rc);
                LASSERTF(fid_is_sane(&info->lti_fid), ""DFID" insane!\n",
                         PFID(&info->lti_fid));
                /*
                LASSERTF(fid_is_sane(&info->lti_fid), ""DFID" insane!\n",
                         PFID(&info->lti_fid));
                /*
index 8fa06a6..bbbb3a2 100644 (file)
@@ -393,7 +393,7 @@ static int lod_xattr_get(const struct lu_env *env, struct dt_object *dt,
                        rc = sizeof(struct lov_user_md_v1);
                } else if (buf->lb_len >= sizeof(struct lov_user_md_v1)) {
                        lum->lmm_magic = LOV_USER_MAGIC_V1;
                        rc = sizeof(struct lov_user_md_v1);
                } else if (buf->lb_len >= sizeof(struct lov_user_md_v1)) {
                        lum->lmm_magic = LOV_USER_MAGIC_V1;
-                       ostid_set_seq(&lum->lmm_oi, FID_SEQ_LOV_DEFAULT);
+                       lmm_oi_set_seq(&lum->lmm_oi, FID_SEQ_LOV_DEFAULT);
                        lum->lmm_pattern = desc->ld_pattern;
                        lum->lmm_stripe_size = desc->ld_default_stripe_size;
                        lum->lmm_stripe_count = desc->ld_default_stripe_count;
                        lum->lmm_pattern = desc->ld_pattern;
                        lum->lmm_stripe_size = desc->ld_default_stripe_size;
                        lum->lmm_stripe_count = desc->ld_default_stripe_count;
@@ -930,8 +930,8 @@ static int lod_declare_object_create(const struct lu_env *env,
 
                v3->lmm_magic = cpu_to_le32(LOV_MAGIC_V3);
                v3->lmm_pattern = cpu_to_le32(LOV_PATTERN_RAID0);
 
                v3->lmm_magic = cpu_to_le32(LOV_MAGIC_V3);
                v3->lmm_pattern = cpu_to_le32(LOV_PATTERN_RAID0);
-               fid_to_ostid(lu_object_fid(&dt->do_lu), &v3->lmm_oi);
-               ostid_cpu_to_le(&v3->lmm_oi, &v3->lmm_oi);
+               fid_to_lmm_oi(lu_object_fid(&dt->do_lu), &v3->lmm_oi);
+               lmm_oi_cpu_to_le(&v3->lmm_oi, &v3->lmm_oi);
                v3->lmm_stripe_size = cpu_to_le32(lo->ldo_def_stripe_size);
                v3->lmm_stripe_count = cpu_to_le32(lo->ldo_def_stripenr);
                v3->lmm_stripe_offset = cpu_to_le16(lo->ldo_def_stripe_offset);
                v3->lmm_stripe_size = cpu_to_le32(lo->ldo_def_stripe_size);
                v3->lmm_stripe_count = cpu_to_le32(lo->ldo_def_stripenr);
                v3->lmm_stripe_offset = cpu_to_le16(lo->ldo_def_stripe_offset);
index 9f7a423..06e4d9b 100644 (file)
@@ -68,7 +68,7 @@ static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes,
                 return -EINVAL;
         }
 
                 return -EINVAL;
         }
 
-       if (ostid_id(&lmm->lmm_oi) == 0) {
+       if (lmm_oi_id(&lmm->lmm_oi) == 0) {
                CERROR("zero object id\n");
                lov_dump_lmm(D_WARNING, lmm);
                return -EINVAL;
                CERROR("zero object id\n");
                lov_dump_lmm(D_WARNING, lmm);
                return -EINVAL;
@@ -140,7 +140,7 @@ static void lsm_unpackmd_common(struct lov_stripe_md *lsm,
         * This supposes lov_mds_md_v1/v3 first fields are
         * are the same
         */
         * This supposes lov_mds_md_v1/v3 first fields are
         * are the same
         */
-       ostid_le_to_cpu(&lmm->lmm_oi, &lsm->lsm_oi);
+       lmm_oi_le_to_cpu(&lsm->lsm_oi, &lmm->lmm_oi);
        lsm->lsm_stripe_size = le32_to_cpu(lmm->lmm_stripe_size);
        lsm->lsm_pattern = le32_to_cpu(lmm->lmm_pattern);
        lsm->lsm_layout_gen = le16_to_cpu(lmm->lmm_layout_gen);
        lsm->lsm_stripe_size = le32_to_cpu(lmm->lmm_stripe_size);
        lsm->lsm_pattern = le32_to_cpu(lmm->lmm_pattern);
        lsm->lsm_layout_gen = le16_to_cpu(lmm->lmm_layout_gen);
index 3607283..b302efa 100644 (file)
@@ -63,17 +63,16 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm,
        obd_time current_ctime = lvb->lvb_ctime;
        int i;
        int rc = 0;
        obd_time current_ctime = lvb->lvb_ctime;
        int i;
        int rc = 0;
-       struct lu_fid fid = {0};
 
        LASSERT_SPIN_LOCKED(&lsm->lsm_lock);
 #ifdef __KERNEL__
        LASSERT(lsm->lsm_lock_owner == cfs_curproc_pid());
 #endif
 
 
        LASSERT_SPIN_LOCKED(&lsm->lsm_lock);
 #ifdef __KERNEL__
        LASSERT(lsm->lsm_lock_owner == cfs_curproc_pid());
 #endif
 
-       ostid_to_fid(&fid, &lsm->lsm_oi, 0);
-       CDEBUG(D_INODE, "MDT FID "DFID" initial value: s="LPU64" m="LPU64
-              " a="LPU64" c="LPU64" b="LPU64"\n", PFID(&fid), lvb->lvb_size,
-              lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks);
+       CDEBUG(D_INODE, "MDT ID "DOSTID" initial value: s="LPU64" m="LPU64
+              " a="LPU64" c="LPU64" b="LPU64"\n", POSTID(&lsm->lsm_oi),
+              lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime,
+              lvb->lvb_blocks);
        for (i = 0; i < lsm->lsm_stripe_count; i++) {
                 struct lov_oinfo *loi = lsm->lsm_oinfo[i];
                 obd_size lov_size, tmpsize;
        for (i = 0; i < lsm->lsm_stripe_count; i++) {
                 struct lov_oinfo *loi = lsm->lsm_oinfo[i];
                 obd_size lov_size, tmpsize;
@@ -103,8 +102,8 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm,
                 if (loi->loi_lvb.lvb_ctime > current_ctime)
                         current_ctime = loi->loi_lvb.lvb_ctime;
 
                 if (loi->loi_lvb.lvb_ctime > current_ctime)
                         current_ctime = loi->loi_lvb.lvb_ctime;
 
-               CDEBUG(D_INODE, "MDT FID "DFID" on OST[%u]: s="LPU64" m="LPU64
-                      " a="LPU64" c="LPU64" b="LPU64"\n", PFID(&fid),
+               CDEBUG(D_INODE, "MDT ID "DOSTID" on OST[%u]: s="LPU64" m="LPU64
+                      " a="LPU64" c="LPU64" b="LPU64"\n", POSTID(&lsm->lsm_oi),
                       loi->loi_ost_idx, loi->loi_lvb.lvb_size,
                       loi->loi_lvb.lvb_mtime, loi->loi_lvb.lvb_atime,
                       loi->loi_lvb.lvb_ctime, loi->loi_lvb.lvb_blocks);
                       loi->loi_ost_idx, loi->loi_lvb.lvb_size,
                       loi->loi_lvb.lvb_mtime, loi->loi_lvb.lvb_atime,
                       loi->loi_lvb.lvb_ctime, loi->loi_lvb.lvb_blocks);
@@ -131,7 +130,6 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm,
 int lov_merge_lvb(struct obd_export *exp,
                   struct lov_stripe_md *lsm, struct ost_lvb *lvb, int kms_only)
 {
 int lov_merge_lvb(struct obd_export *exp,
                   struct lov_stripe_md *lsm, struct ost_lvb *lvb, int kms_only)
 {
-       struct lu_fid fid = {0};
        int   rc;
        __u64 kms;
 
        int   rc;
        __u64 kms;
 
@@ -142,9 +140,8 @@ int lov_merge_lvb(struct obd_export *exp,
        if (kms_only)
                lvb->lvb_size = kms;
 
        if (kms_only)
                lvb->lvb_size = kms;
 
-       ostid_to_fid(&fid, &lsm->lsm_oi, 0);
-       CDEBUG(D_INODE, "merged for FID "DFID" s="LPU64" m="LPU64" a="LPU64
-              " c="LPU64" b="LPU64"\n", PFID(&fid), lvb->lvb_size,
+       CDEBUG(D_INODE, "merged for ID "DOSTID" s="LPU64" m="LPU64" a="LPU64
+              " c="LPU64" b="LPU64"\n", POSTID(&lsm->lsm_oi), lvb->lvb_size,
               lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks);
        RETURN(rc);
 }
               lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks);
        RETURN(rc);
 }
index ed13cbc..139399d 100644 (file)
@@ -230,7 +230,11 @@ static int lov_init_raid0(const struct lu_env *env,
                         struct lov_oinfo *oinfo = lsm->lsm_oinfo[i];
                         int ost_idx = oinfo->loi_ost_idx;
 
                         struct lov_oinfo *oinfo = lsm->lsm_oinfo[i];
                         int ost_idx = oinfo->loi_ost_idx;
 
-                        ostid_to_fid(ofid, &oinfo->loi_oi, oinfo->loi_ost_idx);
+                        result = ostid_to_fid(ofid, &oinfo->loi_oi,
+                                             oinfo->loi_ost_idx);
+                       if (result != 0)
+                               GOTO(out, result);
+
                         subdev = lovsub2cl_dev(dev->ld_target[ost_idx]);
                         subconf->u.coc_oinfo = oinfo;
                         LASSERTF(subdev != NULL, "not init ost %d\n", ost_idx);
                         subdev = lovsub2cl_dev(dev->ld_target[ost_idx]);
                         subconf->u.coc_oinfo = oinfo;
                         LASSERTF(subdev != NULL, "not init ost %d\n", ost_idx);
@@ -250,6 +254,7 @@ static int lov_init_raid0(const struct lu_env *env,
                 }
         } else
                 result = -ENOMEM;
                 }
         } else
                 result = -ENOMEM;
+out:
         RETURN(result);
 }
 
         RETURN(result);
 }
 
index c3ef8c0..d5f829c 100644 (file)
@@ -59,7 +59,7 @@ static void lov_dump_lmm_common(int level, void *lmmp)
        struct lov_mds_md *lmm = lmmp;
        struct ost_id   oi;
 
        struct lov_mds_md *lmm = lmmp;
        struct ost_id   oi;
 
-       ostid_le_to_cpu(&lmm->lmm_oi, &oi);
+       lmm_oi_le_to_cpu(&oi, &lmm->lmm_oi);
        CDEBUG(level, "objid "DOSTID", magic 0x%08x, pattern %#x\n",
               POSTID(&oi), le32_to_cpu(lmm->lmm_magic),
               le32_to_cpu(lmm->lmm_pattern));
        CDEBUG(level, "objid "DOSTID", magic 0x%08x, pattern %#x\n",
               POSTID(&oi), le32_to_cpu(lmm->lmm_magic),
               le32_to_cpu(lmm->lmm_pattern));
@@ -222,7 +222,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
         /* lmmv1 and lmmv3 point to the same struct and have the
          * same first fields
          */
         /* lmmv1 and lmmv3 point to the same struct and have the
          * same first fields
          */
-       ostid_cpu_to_le(&lsm->lsm_oi, &lmmv1->lmm_oi);
+       lmm_oi_cpu_to_le(&lmmv1->lmm_oi, &lsm->lsm_oi);
         lmmv1->lmm_stripe_size = cpu_to_le32(lsm->lsm_stripe_size);
         lmmv1->lmm_stripe_count = cpu_to_le16(stripe_count);
         lmmv1->lmm_pattern = cpu_to_le32(lsm->lsm_pattern);
         lmmv1->lmm_stripe_size = cpu_to_le32(lsm->lsm_stripe_size);
         lmmv1->lmm_stripe_count = cpu_to_le16(stripe_count);
         lmmv1->lmm_pattern = cpu_to_le32(lsm->lsm_pattern);
index cb89ac4..dfe1cee 100644 (file)
@@ -1079,7 +1079,8 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d,
         struct cl_object   *obj;
         struct lu_fid *fid;
         int refcheck;
         struct cl_object   *obj;
         struct lu_fid *fid;
         int refcheck;
-        ENTRY;
+       int rc;
+       ENTRY;
 
        LASSERT(lsmp);
        lsm = *lsmp;
 
        LASSERT(lsmp);
        lsm = *lsmp;
@@ -1114,7 +1115,9 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d,
         conf->eoc_md = lsmp;
 
         fid  = &info->eti_fid;
         conf->eoc_md = lsmp;
 
         fid  = &info->eti_fid;
-       ostid_to_fid(fid, &lsm->lsm_oi, 0);
+       rc = ostid_to_fid(fid, &lsm->lsm_oi, 0);
+       if (rc != 0)
+               GOTO(out, eco = ERR_PTR(rc));
 
        /* In the function below, .hs_keycmp resolves to
         * lu_obj_hop_keycmp() */
 
        /* In the function below, .hs_keycmp resolves to
         * lu_obj_hop_keycmp() */
@@ -2183,7 +2186,10 @@ static int echo_md_handler(struct echo_device *ed, int command,
                 int stripe_count = (int)data->ioc_obdo2.o_misc;
                 int stripe_index = (int)data->ioc_obdo2.o_stripe_idx;
 
                 int stripe_count = (int)data->ioc_obdo2.o_misc;
                 int stripe_index = (int)data->ioc_obdo2.o_stripe_idx;
 
-               ostid_to_fid(fid, &data->ioc_obdo1.o_oi, 0);
+               rc = ostid_to_fid(fid, &data->ioc_obdo1.o_oi, 0);
+               if (rc != 0)
+                       break;
+
                /* In the function below, .hs_keycmp resolves to
                 * lu_obj_hop_keycmp() */
                /* coverity[overrun-buffer-val] */
                /* In the function below, .hs_keycmp resolves to
                 * lu_obj_hop_keycmp() */
                /* coverity[overrun-buffer-val] */
index 8655093..598a551 100644 (file)
@@ -243,7 +243,10 @@ int ofd_preprw(const struct lu_env* env, int cmd, struct obd_export *exp,
        LASSERT(objcount == 1);
        LASSERT(obj->ioo_bufcnt > 0);
 
        LASSERT(objcount == 1);
        LASSERT(obj->ioo_bufcnt > 0);
 
-       ostid_to_fid(&info->fti_fid, &oa->o_oi, 0);
+       rc = ostid_to_fid(&info->fti_fid, &oa->o_oi, 0);
+       if (unlikely(rc != 0))
+               RETURN(rc);
+
        if (cmd == OBD_BRW_WRITE) {
                rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oa->o_oi),
                                   capa, CAPA_OPC_OSS_WRITE);
        if (cmd == OBD_BRW_WRITE) {
                rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oa->o_oi),
                                   capa, CAPA_OPC_OSS_WRITE);
@@ -502,7 +505,9 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp,
 
        LASSERT(npages > 0);
 
 
        LASSERT(npages > 0);
 
-       ostid_to_fid(&info->fti_fid, &oa->o_oi, 0);
+       rc = ostid_to_fid(&info->fti_fid, &oa->o_oi, 0);
+       if (unlikely(rc != 0))
+               RETURN(rc);
        if (cmd == OBD_BRW_WRITE) {
                /* Don't update timestamps if this write is older than a
                 * setattr which modifies the timestamps. b=10150 */
        if (cmd == OBD_BRW_WRITE) {
                /* Don't update timestamps if this write is older than a
                 * setattr which modifies the timestamps. b=10150 */
index 1bc3ccd..ba5ff4d 100644 (file)
@@ -589,7 +589,9 @@ static int ofd_get_info(const struct lu_env *env, struct obd_export *exp,
                }
 
                info = ofd_info_init(env, exp);
                }
 
                info = ofd_info_init(env, exp);
-               ostid_to_fid(&info->fti_fid, &fm_key->oa.o_oi, 0);
+               rc = ostid_to_fid(&info->fti_fid, &fm_key->oa.o_oi, 0);
+               if (rc != 0)
+                       RETURN(rc);
                CDEBUG(D_INODE, "get FIEMAP of object "DFID"\n",
                       PFID(&info->fti_fid));
 
                CDEBUG(D_INODE, "get FIEMAP of object "DFID"\n",
                       PFID(&info->fti_fid));
 
@@ -642,12 +644,15 @@ static int ofd_get_info(const struct lu_env *env, struct obd_export *exp,
                if (IS_ERR(oseq))
                        GOTO(out_fini, rc = PTR_ERR(oseq));
 
                if (IS_ERR(oseq))
                        GOTO(out_fini, rc = PTR_ERR(oseq));
 
-               ostid_to_fid(fid, &oseq->os_oi,
+               rc = ostid_to_fid(fid, &oseq->os_oi,
                             ofd->ofd_lut.lut_lsd.lsd_osd_index);
                             ofd->ofd_lut.lut_lsd.lsd_osd_index);
+               if (rc != 0)
+                       GOTO(out_put, rc);
 
                CDEBUG(D_HA, "%s: LAST FID is "DFID"\n", ofd_name(ofd),
                       PFID(fid));
                *vallen = sizeof(*fid);
 
                CDEBUG(D_HA, "%s: LAST FID is "DFID"\n", ofd_name(ofd),
                       PFID(fid));
                *vallen = sizeof(*fid);
+out_put:
                ofd_seq_put(&env, oseq);
 out_fini:
                lu_env_fini(&env);
                ofd_seq_put(&env, oseq);
 out_fini:
                lu_env_fini(&env);
@@ -829,9 +834,11 @@ int ofd_setattr(const struct lu_env *env, struct obd_export *exp,
        info = ofd_info_init(env, exp);
        ofd_oti2info(info, oti);
 
        info = ofd_info_init(env, exp);
        ofd_oti2info(info, oti);
 
-       ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0);
-       ost_fid_build_resid(&info->fti_fid, &info->fti_resid);
+       rc = ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0);
+       if (rc != 0)
+               RETURN(rc);
 
 
+       ost_fid_build_resid(&info->fti_fid, &info->fti_resid);
        rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oa->o_oi),
                           oinfo_capa(oinfo), CAPA_OPC_META_WRITE);
        if (rc)
        rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oa->o_oi),
                           oinfo_capa(oinfo), CAPA_OPC_META_WRITE);
        if (rc)
@@ -915,7 +922,9 @@ static int ofd_punch(const struct lu_env *env, struct obd_export *exp,
        info = ofd_info_init(env, exp);
        ofd_oti2info(info, oti);
 
        info = ofd_info_init(env, exp);
        ofd_oti2info(info, oti);
 
-       ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0);
+       rc = ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0);
+       if (rc != 0)
+               RETURN(rc);
        ost_fid_build_resid(&info->fti_fid, &info->fti_resid);
 
        CDEBUG(D_INODE, "calling punch for object "DFID", valid = "LPX64
        ost_fid_build_resid(&info->fti_fid, &info->fti_resid);
 
        CDEBUG(D_INODE, "calling punch for object "DFID", valid = "LPX64
@@ -1058,7 +1067,12 @@ int ofd_destroy(const struct lu_env *env, struct obd_export *exp,
        while (count > 0) {
                int lrc;
 
        while (count > 0) {
                int lrc;
 
-               ostid_to_fid(&info->fti_fid, &oa->o_oi, 0);
+               lrc = ostid_to_fid(&info->fti_fid, &oa->o_oi, 0);
+               if (lrc != 0) {
+                       if (rc == 0)
+                               rc = lrc;
+                       GOTO(out, rc);
+               }
                lrc = ofd_destroy_by_fid(env, ofd, &info->fti_fid, 0);
                if (lrc == -ENOENT) {
                        CDEBUG(D_INODE,
                lrc = ofd_destroy_by_fid(env, ofd, &info->fti_fid, 0);
                if (lrc == -ENOENT) {
                        CDEBUG(D_INODE,
@@ -1094,6 +1108,7 @@ int ofd_destroy(const struct lu_env *env, struct obd_export *exp,
                info->fti_transno = 0;
        }
        ofd_info2oti(info, oti);
                info->fti_transno = 0;
        }
        ofd_info2oti(info, oti);
+out:
        RETURN(rc);
 }
 
        RETURN(rc);
 }
 
@@ -1128,7 +1143,9 @@ static int ofd_orphans_destroy(const struct lu_env *env,
 
        for (ostid_set_id(&oi, last); ostid_id(&oi) > end_id;
                          ostid_dec_id(&oi)) {
 
        for (ostid_set_id(&oi, last); ostid_id(&oi) > end_id;
                          ostid_dec_id(&oi)) {
-               ostid_to_fid(&info->fti_fid, &oi, 0);
+               rc = ostid_to_fid(&info->fti_fid, &oi, 0);
+               if (rc != 0)
+                       GOTO(out_put, rc);
                rc = ofd_destroy_by_fid(env, ofd, &info->fti_fid, 1);
                if (rc && rc != -ENOENT) /* this is pretty fatal... */
                        CEMERG("error destroying precreated id "DOSTID": %d\n",
                rc = ofd_destroy_by_fid(env, ofd, &info->fti_fid, 1);
                if (rc && rc != -ENOENT) /* this is pretty fatal... */
                        CEMERG("error destroying precreated id "DOSTID": %d\n",
@@ -1151,6 +1168,7 @@ static int ofd_orphans_destroy(const struct lu_env *env,
                ostid_set_id(&oa->o_oi, last);
                rc = 0;
        }
                ostid_set_id(&oa->o_oi, last);
                rc = 0;
        }
+out_put:
        ofd_seq_put(env, oseq);
        RETURN(rc);
 }
        ofd_seq_put(env, oseq);
        RETURN(rc);
 }
@@ -1346,7 +1364,9 @@ int ofd_getattr(const struct lu_env *env, struct obd_export *exp,
 
        info = ofd_info_init(env, exp);
 
 
        info = ofd_info_init(env, exp);
 
-       ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0);
+       rc = ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0);
+       if (rc != 0)
+               GOTO(out, rc);
        rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oinfo->oi_oa->o_oi),
                           oinfo_capa(oinfo), CAPA_OPC_META_READ);
        if (rc)
        rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oinfo->oi_oa->o_oi),
                           oinfo_capa(oinfo), CAPA_OPC_META_READ);
        if (rc)
@@ -1391,7 +1411,9 @@ static int ofd_sync(const struct lu_env *env, struct obd_export *exp,
        }
 
        info = ofd_info_init(env, exp);
        }
 
        info = ofd_info_init(env, exp);
-       ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0);
+       rc = ostid_to_fid(&info->fti_fid, &oinfo->oi_oa->o_oi, 0);
+       if (rc != 0)
+               GOTO(out, rc);
 
        rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oinfo->oi_oa->o_oi),
                           oinfo_capa(oinfo), CAPA_OPC_OSS_TRUNC);
 
        rc = ofd_auth_capa(exp, &info->fti_fid, ostid_seq(&oinfo->oi_oa->o_oi),
                           oinfo_capa(oinfo), CAPA_OPC_OSS_TRUNC);
index 1182531..f2cd2bc 100644 (file)
@@ -2150,20 +2150,26 @@ static void print_lum (struct lov_user_md *lum)
        CDEBUG(D_OTHER, "lov_user_md %p:\n", lum);
        CDEBUG(D_OTHER, "\tlmm_magic: %#x\n", lum->lmm_magic);
        CDEBUG(D_OTHER, "\tlmm_pattern: %#x\n", lum->lmm_pattern);
        CDEBUG(D_OTHER, "lov_user_md %p:\n", lum);
        CDEBUG(D_OTHER, "\tlmm_magic: %#x\n", lum->lmm_magic);
        CDEBUG(D_OTHER, "\tlmm_pattern: %#x\n", lum->lmm_pattern);
-       CDEBUG(D_OTHER, "\tlmm_object_id: "LPU64"\n", ostid_id(&lum->lmm_oi));
-       CDEBUG(D_OTHER, "\tlmm_object_gr: "LPU64"\n", ostid_seq(&lum->lmm_oi));
+       CDEBUG(D_OTHER, "\tlmm_object_id: "LPU64"\n", lmm_oi_id(&lum->lmm_oi));
+       CDEBUG(D_OTHER, "\tlmm_object_gr: "LPU64"\n", lmm_oi_seq(&lum->lmm_oi));
        CDEBUG(D_OTHER, "\tlmm_stripe_size: %#x\n", lum->lmm_stripe_size);
        CDEBUG(D_OTHER, "\tlmm_stripe_count: %#x\n", lum->lmm_stripe_count);
        CDEBUG(D_OTHER, "\tlmm_stripe_offset/lmm_layout_gen: %#x\n",
                        lum->lmm_stripe_offset);
 }
 
        CDEBUG(D_OTHER, "\tlmm_stripe_size: %#x\n", lum->lmm_stripe_size);
        CDEBUG(D_OTHER, "\tlmm_stripe_count: %#x\n", lum->lmm_stripe_count);
        CDEBUG(D_OTHER, "\tlmm_stripe_offset/lmm_layout_gen: %#x\n",
                        lum->lmm_stripe_offset);
 }
 
+static void lustre_swab_lmm_oi(struct ost_id *oi)
+{
+       __swab64s(&oi->oi.oi_id);
+       __swab64s(&oi->oi.oi_seq);
+}
+
 static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum)
 {
        ENTRY;
        __swab32s(&lum->lmm_magic);
        __swab32s(&lum->lmm_pattern);
 static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum)
 {
        ENTRY;
        __swab32s(&lum->lmm_magic);
        __swab32s(&lum->lmm_pattern);
-       lustre_swab_ost_id(&lum->lmm_oi);
+       lustre_swab_lmm_oi(&lum->lmm_oi);
        __swab32s(&lum->lmm_stripe_size);
        __swab16s(&lum->lmm_stripe_count);
        __swab16s(&lum->lmm_stripe_offset);
        __swab32s(&lum->lmm_stripe_size);
        __swab16s(&lum->lmm_stripe_count);
        __swab16s(&lum->lmm_stripe_offset);
@@ -2196,7 +2202,7 @@ void lustre_swab_lov_mds_md(struct lov_mds_md *lmm)
        CDEBUG(D_IOCTL, "swabbing lov_mds_md\n");
        __swab32s(&lmm->lmm_magic);
        __swab32s(&lmm->lmm_pattern);
        CDEBUG(D_IOCTL, "swabbing lov_mds_md\n");
        __swab32s(&lmm->lmm_magic);
        __swab32s(&lmm->lmm_pattern);
-       lustre_swab_ost_id(&lmm->lmm_oi);
+       lustre_swab_lmm_oi(&lmm->lmm_oi);
        __swab32s(&lmm->lmm_stripe_size);
        __swab16s(&lmm->lmm_stripe_count);
        __swab16s(&lmm->lmm_layout_gen);
        __swab32s(&lmm->lmm_stripe_size);
        __swab16s(&lmm->lmm_stripe_count);
        __swab16s(&lmm->lmm_layout_gen);
index 7204833..79ba8db 100644 (file)
@@ -2021,8 +2021,8 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
         char nl = is_dir ? ' ' : '\n';
         int rc;
 
         char nl = is_dir ? ' ' : '\n';
         int rc;
 
-       if (is_dir && ostid_seq(&lum->lmm_oi) == FID_SEQ_LOV_DEFAULT) {
-               ostid_set_seq_mdt0(&lum->lmm_oi);
+       if (is_dir && lmm_oi_seq(&lum->lmm_oi) == FID_SEQ_LOV_DEFAULT) {
+               lmm_oi_set_seq(&lum->lmm_oi, 0);
                if (verbose & VERBOSE_DETAIL)
                        llapi_printf(LLAPI_MSG_NORMAL, "(Default) ");
        }
                if (verbose & VERBOSE_DETAIL)
                        llapi_printf(LLAPI_MSG_NORMAL, "(Default) ");
        }
@@ -2034,9 +2034,9 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
                llapi_printf(LLAPI_MSG_NORMAL, "lmm_magic:          0x%08X\n",
                             lum->lmm_magic);
                llapi_printf(LLAPI_MSG_NORMAL, "lmm_seq:            "LPX64"\n",
                llapi_printf(LLAPI_MSG_NORMAL, "lmm_magic:          0x%08X\n",
                             lum->lmm_magic);
                llapi_printf(LLAPI_MSG_NORMAL, "lmm_seq:            "LPX64"\n",
-                            ostid_seq(&lum->lmm_oi));
+                            lmm_oi_seq(&lum->lmm_oi));
                llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_id:      "LPX64"\n",
                llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_id:      "LPX64"\n",
-                            ostid_id(&lum->lmm_oi));
+                            lmm_oi_id(&lum->lmm_oi));
        }
 
         if (verbose & VERBOSE_COUNT) {
        }
 
         if (verbose & VERBOSE_COUNT) {