From: Giuseppe Di Natale Date: Mon, 8 Jan 2018 16:50:39 +0000 (-0800) Subject: LU-10462 lod: Correct lfs --component-add striping X-Git-Tag: 2.10.58~49 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=b7285d387c78fbd11579c577230593ba1b0be84e LU-10462 lod: Correct lfs --component-add striping lfs --component-add -E -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 Change-Id: I178f13be81ee546f44edcdadcf7086a1a57f7e9a Reviewed-on: https://review.whamcloud.com/30790 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin --- diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index ad19c6b..38918d3 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -1048,6 +1048,18 @@ static int lod_attr_get(const struct lu_env *env, 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) @@ -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; - 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; - 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; @@ -4189,13 +4195,7 @@ static void lod_striping_from_default(struct lod_object *lo, 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) @@ -4428,12 +4428,7 @@ out: 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; diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index 025a058..a64cb98 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -1606,6 +1606,29 @@ test_201() { } 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