Whamcloud - gitweb
LU-10462 lod: Correct lfs --component-add striping 90/30790/4
authorGiuseppe Di Natale <dinatale2@llnl.gov>
Mon, 8 Jan 2018 16:50:39 +0000 (08:50 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 25 Jan 2018 04:48:01 +0000 (04:48 +0000)
lfs --component-add -E <end> -c -1 would apply the default
stripe count to a file when it should be striping across
all OSTs. This was due to incorrect handling of sentinel
values in various portions of lod_object.

Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Change-Id: I178f13be81ee546f44edcdadcf7086a1a57f7e9a
Reviewed-on: https://review.whamcloud.com/30790
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lod/lod_object.c
lustre/tests/sanity-flr.sh

index ad19c6b..38918d3 100644 (file)
@@ -1048,6 +1048,18 @@ static int lod_attr_get(const struct lu_env *env,
        return dt_attr_get(env, dt_object_child(dt), attr);
 }
 
        return dt_attr_get(env, dt_object_child(dt), attr);
 }
 
+static inline void lod_adjust_stripe_info(struct lod_layout_component *comp,
+                                         struct lov_desc *desc)
+{
+       if (comp->llc_pattern != LOV_PATTERN_MDT) {
+               if (!comp->llc_stripe_count)
+                       comp->llc_stripe_count =
+                               desc->ld_default_stripe_count;
+       }
+       if (comp->llc_stripe_size <= 0)
+               comp->llc_stripe_size = desc->ld_default_stripe_size;
+}
+
 int lod_obj_for_each_stripe(const struct lu_env *env, struct lod_object *lo,
                            struct thandle *th,
                            struct lod_obj_stripe_cb_data *data)
 int lod_obj_for_each_stripe(const struct lu_env *env, struct lod_object *lo,
                            struct thandle *th,
                            struct lod_obj_stripe_cb_data *data)
@@ -2366,14 +2378,8 @@ static int lod_declare_layout_add(const struct lu_env *env,
                lod_comp->llc_flags = comp_v1->lcm_entries[i].lcme_flags;
 
                lod_comp->llc_stripe_count = v1->lmm_stripe_count;
                lod_comp->llc_flags = comp_v1->lcm_entries[i].lcme_flags;
 
                lod_comp->llc_stripe_count = v1->lmm_stripe_count;
-               if (!lod_comp->llc_stripe_count ||
-                   lod_comp->llc_stripe_count == (__u16)-1)
-                       lod_comp->llc_stripe_count =
-                               desc->ld_default_stripe_count;
                lod_comp->llc_stripe_size = v1->lmm_stripe_size;
                lod_comp->llc_stripe_size = v1->lmm_stripe_size;
-               if (!lod_comp->llc_stripe_size)
-                       lod_comp->llc_stripe_size =
-                               desc->ld_default_stripe_size;
+               lod_adjust_stripe_info(lod_comp, desc);
 
                if (v1->lmm_magic == LOV_USER_MAGIC_V3) {
                        v3 = (struct lov_user_md_v3 *) v1;
 
                if (v1->lmm_magic == LOV_USER_MAGIC_V3) {
                        v3 = (struct lov_user_md_v3 *) v1;
@@ -4189,13 +4195,7 @@ static void lod_striping_from_default(struct lod_object *lo,
                        if (!lo->ldo_is_composite)
                                continue;
 
                        if (!lo->ldo_is_composite)
                                continue;
 
-                       if (obj_comp->llc_stripe_count <= 0 &&
-                           obj_comp->llc_pattern != LOV_PATTERN_MDT)
-                               obj_comp->llc_stripe_count =
-                                       desc->ld_default_stripe_count;
-                       if (obj_comp->llc_stripe_size <= 0)
-                               obj_comp->llc_stripe_size =
-                                       desc->ld_default_stripe_size;
+                       lod_adjust_stripe_info(obj_comp, desc);
                }
        } else if (lds->lds_dir_def_striping_set && S_ISDIR(mode)) {
                if (lo->ldo_dir_stripe_count == 0)
                }
        } else if (lds->lds_dir_def_striping_set && S_ISDIR(mode)) {
                if (lo->ldo_dir_stripe_count == 0)
@@ -4428,12 +4428,7 @@ out:
                LASSERT(!lc->ldo_is_composite);
                lod_comp = &lc->ldo_comp_entries[0];
                desc = &d->lod_desc;
                LASSERT(!lc->ldo_is_composite);
                lod_comp = &lc->ldo_comp_entries[0];
                desc = &d->lod_desc;
-               if (lod_comp->llc_stripe_count <= 0)
-                       lod_comp->llc_stripe_count =
-                               desc->ld_default_stripe_count;
-               if (lod_comp->llc_stripe_size <= 0)
-                       lod_comp->llc_stripe_size =
-                               desc->ld_default_stripe_size;
+               lod_adjust_stripe_info(lod_comp, desc);
        }
 
        EXIT;
        }
 
        EXIT;
index 025a058..a64cb98 100644 (file)
@@ -1606,6 +1606,29 @@ test_201() {
 }
 run_test 201 "FLR data mover"
 
 }
 run_test 201 "FLR data mover"
 
+test_202() {
+       [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
+
+       local tf=$DIR/$tfile
+       local ids
+
+       $LFS setstripe -E 1M -c 1 $tf
+       ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
+       verify_comp_attr stripe-count $tf ${ids[0]} 1
+
+       $LFS setstripe --component-add -E 2M -c -1 $tf
+       ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
+       verify_comp_attr stripe-count $tf ${ids[0]} 1
+       verify_comp_attr stripe-count $tf ${ids[1]} -1
+
+       dd if=/dev/zero of=$tf bs=1M count=2
+       ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
+       verify_comp_attr stripe-count $tf ${ids[0]} 1
+       verify_comp_attr stripe-count $tf ${ids[1]} $OSTCOUNT
+}
+run_test 202 "lfs setstripe --add-component wide striping"
+
+
 complete $SECONDS
 check_and_cleanup_lustre
 exit_status
 complete $SECONDS
 check_and_cleanup_lustre
 exit_status