Whamcloud - gitweb
A couple of trivial spelling fixes.
[fs/lustre-release.git] / lustre / lov / lov_pack.c
index b02c980..a39e92b 100644 (file)
@@ -105,7 +105,7 @@ void lov_dump_lmm_v3(int level, struct lov_mds_md_v3 *lmm)
         CDEBUG(level,"stripe_size %u, stripe_count %u\n",
                le32_to_cpu(lmm->lmm_stripe_size),
                le32_to_cpu(lmm->lmm_stripe_count));
-        CDEBUG(level,"pool_name "POOLNAMEF"\n", lmm->lmm_pool_name);
+        CDEBUG(level,"pool_name "LOV_POOLNAMEF"\n", lmm->lmm_pool_name);
 
         if (le32_to_cpu(lmm->lmm_stripe_count) <= LOV_V1_INSANE_STRIPE_COUNT) {
                 for (i = 0, lod = lmm->lmm_objects;
@@ -161,7 +161,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
         struct lov_obd *lov = &obd->u.lov;
         struct lov_mds_md_v1 *lmmv1;
         struct lov_mds_md_v3 *lmmv3;
-        int stripe_count = lov->desc.ld_tgt_count;
+        int stripe_count;
         struct lov_ost_data_v1 *lmm_objects;
         int lmm_size, lmm_magic;
         int i;
@@ -179,11 +179,19 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
                 } else {
                         stripe_count = lsm->lsm_stripe_count;
                 }
-        } else if (lmmp && *lmmp) {
-                lmm_magic = le32_to_cpu((*lmmp)->lmm_magic);
         } else {
-                /* lsm == NULL and lmmp == NULL */
-                lmm_magic = LOV_MAGIC;
+                /* No needs to allocated more than LOV_MAX_STRIPE_COUNT.
+                 * Anyway, this is pretty inaccurate since ld_tgt_count now
+                 * represents max index and we should rely on the actual number
+                 * of OSTs instead */
+                stripe_count = min((__u32)LOV_MAX_STRIPE_COUNT,
+                                   lov->desc.ld_tgt_count);
+
+                if (lmmp && *lmmp)
+                        lmm_magic = le32_to_cpu((*lmmp)->lmm_magic);
+                else
+                        /* lsm == NULL and lmmp == NULL */
+                        lmm_magic = LOV_MAGIC;
         }
 
         if ((lmm_magic != LOV_MAGIC_V1) &&
@@ -236,7 +244,8 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
         lmmv1->lmm_stripe_count = cpu_to_le32(stripe_count);
         lmmv1->lmm_pattern = cpu_to_le32(lsm->lsm_pattern);
         if (lsm->lsm_magic == LOV_MAGIC_V3) {
-                strncpy(lmmv3->lmm_pool_name, lsm->lsm_pool_name, MAXPOOLNAME);
+                strncpy(lmmv3->lmm_pool_name, lsm->lsm_pool_name,
+                        LOV_MAXPOOLNAME);
                 lmm_objects = lmmv3->lmm_objects;
         } else {
                 lmm_objects = lmmv1->lmm_objects;
@@ -499,7 +508,7 @@ static int __lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp,
                 (*lsmp)->lsm_stripe_size = lumv1->lmm_stripe_size;
                 if (lmm_magic == LOV_USER_MAGIC_V3)
                         strncpy((*lsmp)->lsm_pool_name, lumv3.lmm_pool_name,
-                                MAXPOOLNAME);
+                                LOV_MAXPOOLNAME);
                 rc = 0;
         }