Whamcloud - gitweb
*** empty log message ***
[fs/lustre-release.git] / lustre / lov / lov_pack.c
index f0c84bb..5f14160 100644 (file)
@@ -48,12 +48,20 @@ void lov_dump_lmm_v1(int level, struct lov_mds_md_v1 *lmm)
         CDEBUG(level,"stripe_size %u, stripe_count %u\n",
                le32_to_cpu(lmm->lmm_stripe_size),
                le32_to_cpu(lmm->lmm_stripe_count));
-        for (i = 0, lod = lmm->lmm_objects;
-             i < le32_to_cpu(lmm->lmm_stripe_count); i++, lod++)
-                CDEBUG(level, "stripe %u idx %u subobj "LPX64"/"LPX64"\n",
-                       i, le32_to_cpu(lod->l_ost_idx),
-                       le64_to_cpu(lod->l_object_gr),
-                       le64_to_cpu(lod->l_object_id));
+
+        if (le32_to_cpu(lmm->lmm_stripe_count) <= LOV_V1_INSANE_STRIPE_COUNT) {
+                for (i = 0, lod = lmm->lmm_objects;
+                     i < (int)le32_to_cpu(lmm->lmm_stripe_count); i++, lod++)
+                         CDEBUG(level,
+                                "stripe %u idx %u subobj "LPX64"/"LPX64"\n",
+                                i, le32_to_cpu(lod->l_ost_idx),
+                                le64_to_cpu(lod->l_object_gr),
+                                le64_to_cpu(lod->l_object_id));
+        } else {
+                CDEBUG(level, "bad stripe_count %u > max_stripe_count %u\n",
+                       le32_to_cpu(lmm->lmm_stripe_count),
+                       LOV_V1_INSANE_STRIPE_COUNT);
+        }
 }
 
 void lov_dump_lmm_join(int level, struct lov_mds_md_join *lmmj)
@@ -100,7 +108,12 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
                                lsm->lsm_magic, LOV_MAGIC);
                         RETURN(-EINVAL);
                 }
-                stripe_count = lsm->lsm_stripe_count;
+                if (!lmmp) {
+                        stripe_count = lov_get_stripecnt(lov, lsm->lsm_stripe_count);
+                        lsm->lsm_stripe_count = stripe_count;
+                } else {
+                        stripe_count = lsm->lsm_stripe_count;
+                }
         }
 
         /* XXX LOV STACKING call into osc for sizes */
@@ -150,7 +163,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
 }
 
 /* Find the max stripecount we should use */
-int lov_get_stripecnt(struct lov_obd *lov, int stripe_count)
+int lov_get_stripecnt(struct lov_obd *lov, __u32 stripe_count)
 {
         if (!stripe_count)
                 stripe_count = lov->desc.ld_default_stripe_count;
@@ -319,10 +332,10 @@ static int __lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp,
                 lum.lmm_stripe_size = LOV_MIN_STRIPE_SIZE;
         }
 
-        if ((lum.lmm_stripe_offset >= lov->desc.ld_active_tgt_count) &&
+        if ((lum.lmm_stripe_offset >= lov->desc.ld_tgt_count) &&
             (lum.lmm_stripe_offset != (typeof(lum.lmm_stripe_offset))(-1))) {
-                CDEBUG(D_IOCTL, "stripe offset %u > number of active OSTs %u\n",
-                       lum.lmm_stripe_offset, lov->desc.ld_active_tgt_count);
+                CDEBUG(D_IOCTL, "stripe offset %u > number of OSTs %u\n",
+                       lum.lmm_stripe_offset, lov->desc.ld_tgt_count);
                 RETURN(-EINVAL);
         }
         stripe_count = lov_get_stripecnt(lov, lum.lmm_stripe_count);