Whamcloud - gitweb
LU-2482 layout: introduce new layout for released files
[fs/lustre-release.git] / lustre / lov / lov_ea.c
index af18014..bf6d9eb 100644 (file)
@@ -61,7 +61,7 @@ struct lovea_unpack_args {
 static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes,
                                  __u16 stripe_count)
 {
-       if (stripe_count == 0 || stripe_count > LOV_V1_INSANE_STRIPE_COUNT) {
+       if (stripe_count > LOV_V1_INSANE_STRIPE_COUNT) {
                CERROR("bad stripe count %d\n", stripe_count);
                lov_dump_lmm_common(D_WARNING, lmm);
                return -EINVAL;
@@ -73,7 +73,7 @@ static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes,
                return -EINVAL;
        }
 
-       if (lmm->lmm_pattern != cpu_to_le32(LOV_PATTERN_RAID0)) {
+       if (lov_pattern(le32_to_cpu(lmm->lmm_pattern)) != LOV_PATTERN_RAID0) {
                CERROR("bad striping pattern\n");
                lov_dump_lmm_common(D_WARNING, lmm);
                return -EINVAL;
@@ -201,6 +201,8 @@ static int lsm_lmm_verify_v1(struct lov_mds_md_v1 *lmm, int lmm_bytes,
        }
 
        *stripe_count = le16_to_cpu(lmm->lmm_stripe_count);
+       if (le32_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_F_RELEASED)
+               *stripe_count = 0;
 
        if (lmm_bytes < lov_mds_md_size(*stripe_count, LOV_MAGIC_V1)) {
                CERROR("LOV EA V1 too small: %d, need %d\n",
@@ -217,11 +219,14 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm,
 {
         struct lov_oinfo *loi;
         int i;
+       int stripe_count;
         __u64 stripe_maxbytes = OBD_OBJECT_EOF;
 
         lsm_unpackmd_common(lsm, lmm);
 
-       for (i = 0; i < lsm->lsm_stripe_count; i++) {
+       stripe_count = lsm_is_released(lsm) ? 0 : lsm->lsm_stripe_count;
+
+       for (i = 0; i < stripe_count; i++) {
                /* XXX LOV STACKING call down to osc_unpackmd() */
                loi = lsm->lsm_oinfo[i];
                ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi);
@@ -243,9 +248,11 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm,
                                  &stripe_maxbytes);
         }
 
-        lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count;
+       lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count;
+       if (lsm->lsm_stripe_count == 0)
+               lsm->lsm_maxbytes = stripe_maxbytes * lov->desc.ld_tgt_count;
 
-        return 0;
+       return 0;
 }
 
 const struct lsm_operations lsm_v1_ops = {
@@ -271,6 +278,8 @@ static int lsm_lmm_verify_v3(struct lov_mds_md *lmmv1, int lmm_bytes,
        }
 
        *stripe_count = le16_to_cpu(lmm->lmm_stripe_count);
+       if (le32_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_F_RELEASED)
+               *stripe_count = 0;
 
        if (lmm_bytes < lov_mds_md_size(*stripe_count, LOV_MAGIC_V3)) {
                CERROR("LOV EA V3 too small: %d, need %d\n",
@@ -289,18 +298,22 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm,
         struct lov_mds_md_v3 *lmm;
         struct lov_oinfo *loi;
         int i;
+       int stripe_count;
         __u64 stripe_maxbytes = OBD_OBJECT_EOF;
        int cplen = 0;
 
         lmm = (struct lov_mds_md_v3 *)lmmv1;
 
         lsm_unpackmd_common(lsm, (struct lov_mds_md_v1 *)lmm);
+
+       stripe_count = lsm_is_released(lsm) ? 0 : lsm->lsm_stripe_count;
+
        cplen = strlcpy(lsm->lsm_pool_name, lmm->lmm_pool_name,
                        sizeof(lsm->lsm_pool_name));
        if (cplen >= sizeof(lsm->lsm_pool_name))
                return -E2BIG;
 
-        for (i = 0; i < lsm->lsm_stripe_count; i++) {
+        for (i = 0; i < stripe_count; i++) {
                 /* XXX LOV STACKING call down to osc_unpackmd() */
                 loi = lsm->lsm_oinfo[i];
                ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi);
@@ -322,9 +335,11 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm,
                                  &stripe_maxbytes);
         }
 
-        lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count;
+       lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count;
+       if (lsm->lsm_stripe_count == 0)
+               lsm->lsm_maxbytes = stripe_maxbytes * lov->desc.ld_tgt_count;
 
-        return 0;
+       return 0;
 }
 
 const struct lsm_operations lsm_v3_ops = {