Whamcloud - gitweb
LU-2482 layout: introduce new layout for released files
[fs/lustre-release.git] / lustre / lov / lov_pack.c
index 47e0127..282b184 100644 (file)
@@ -169,13 +169,15 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
         if (lsm) {
                 /* If we are just sizing the EA, limit the stripe count
                  * to the actual number of OSTs in this filesystem. */
-                if (!lmmp) {
-                        stripe_count = lov_get_stripecnt(lov, lmm_magic,
-                                                         lsm->lsm_stripe_count);
-                        lsm->lsm_stripe_count = stripe_count;
-                } else {
-                        stripe_count = lsm->lsm_stripe_count;
-                }
+               if (!lmmp) {
+                       stripe_count = lov_get_stripecnt(lov, lmm_magic,
+                                                       lsm->lsm_stripe_count);
+                       lsm->lsm_stripe_count = stripe_count;
+               } else if (!lsm_is_released(lsm)) {
+                       stripe_count = lsm->lsm_stripe_count;
+               } else {
+                       stripe_count = 0;
+               }
         } else {
                 /* No need to allocate more than maximum supported stripes.
                  * Anyway, this is pretty inaccurate since ld_tgt_count now
@@ -328,7 +330,8 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, __u16 stripe_count,
         (*lsmp)->lsm_pattern = pattern;
         (*lsmp)->lsm_pool_name[0] = '\0';
         (*lsmp)->lsm_layout_gen = 0;
-        (*lsmp)->lsm_oinfo[0]->loi_ost_idx = ~0;
+       if (stripe_count > 0)
+               (*lsmp)->lsm_oinfo[0]->loi_ost_idx = ~0;
 
         for (i = 0; i < stripe_count; i++)
                 loi_init((*lsmp)->lsm_oinfo[i]);
@@ -362,6 +365,7 @@ int lov_unpackmd(struct obd_export *exp,  struct lov_stripe_md **lsmp,
         int rc = 0, lsm_size;
         __u16 stripe_count;
         __u32 magic;
+       __u32 pattern;
         ENTRY;
 
         /* If passed an MDS struct use values from there, otherwise defaults */
@@ -387,8 +391,8 @@ int lov_unpackmd(struct obd_export *exp,  struct lov_stripe_md **lsmp,
                 RETURN(0);
         }
 
-        lsm_size = lov_alloc_memmd(lsmp, stripe_count, LOV_PATTERN_RAID0,
-                                   magic);
+       pattern = le32_to_cpu(lmm->lmm_pattern);
+        lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic);
         if (lsm_size < 0)
                 RETURN(lsm_size);
 
@@ -433,7 +437,7 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size,
                         lov->desc.ld_pattern : LOV_PATTERN_RAID0;
         }
 
-        if (lumv1->lmm_pattern != LOV_PATTERN_RAID0) {
+        if (lov_pattern(lumv1->lmm_pattern) != LOV_PATTERN_RAID0) {
                 CDEBUG(D_IOCTL, "bad userland stripe pattern: %#x\n",
                        lumv1->lmm_pattern);
                 RETURN(-EINVAL);
@@ -493,6 +497,9 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size,
                 }
         }
 
+       if (lumv1->lmm_pattern & LOV_PATTERN_F_RELEASED)
+               stripe_count = 0;
+
         rc = lov_alloc_memmd(lsmp, stripe_count, lumv1->lmm_pattern, lmm_magic);
 
         if (rc >= 0) {