From 4e4751d5bf7af565f9fc41f5001dae81f67be891 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Fri, 24 Aug 2018 14:49:06 +0800 Subject: [PATCH] LU-11279 lod: reset ostlist properly in lod_get_default_lov_striping Ostlist might be allocated previously, and we should reset them properly, otherwise, it will pollute new default setting and cause unexpected behavior. Test-Parameters: trivial testlist=sanity,sanity,sanity,sanity,sanity,sanity,sanity,sanity,sanity Change-Id: I9b7acb5f05ec4b371da99f68b9647f0b75cd7021 Signed-off-by: Wang Shilong Reviewed-on: https://review.whamcloud.com/33069 Reviewed-by: Andreas Dilger Reviewed-by: Bobi Jam Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/lod/lod_lov.c | 3 ++- lustre/lod/lod_object.c | 19 +++++++++++++++---- lustre/lod/lod_qos.c | 4 +++- lustre/tests/sanity.sh | 11 +++++++++-- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 2849beb..9e25dc4 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -896,7 +896,8 @@ static int lod_gen_component_ea(const struct lu_env *env, PFID(&info->lti_fid), rc); RETURN(rc); } - } else if (lod_comp->llc_ostlist.op_array) { + } else if (lod_comp->llc_ostlist.op_array && + lod_comp->llc_ostlist.op_count) { /* user specified ost list */ ost_idx = lod_comp->llc_ostlist.op_array[i]; } diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index f41b6e2..908f675 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -4031,9 +4031,12 @@ int lod_comp_copy_ost_lists(struct lod_layout_component *lod_comp, v3->lmm_stripe_offset = v3->lmm_objects[0].l_ost_idx; if (lod_comp->llc_ostlist.op_array) { - if (lod_comp->llc_ostlist.op_count == - v3->lmm_stripe_count) + if (lod_comp->llc_ostlist.op_size >= + v3->lmm_stripe_count * sizeof(__u32)) { + lod_comp->llc_ostlist.op_count = + v3->lmm_stripe_count; goto skip; + } OBD_FREE(lod_comp->llc_ostlist.op_array, lod_comp->llc_ostlist.op_size); } @@ -4076,7 +4079,7 @@ static int lod_get_default_lov_striping(const struct lu_env *env, __u16 comp_cnt; __u16 mirror_cnt; bool composite; - int rc, i; + int rc, i, j; ENTRY; lds->lds_def_striping_set = 0; @@ -4182,6 +4185,11 @@ static int lod_get_default_lov_striping(const struct lu_env *env, rc = lod_comp_copy_ost_lists(lod_comp, v3); if (rc) RETURN(rc); + } else if (lod_comp->llc_ostlist.op_array && + lod_comp->llc_ostlist.op_count) { + for (j = 0; j < lod_comp->llc_ostlist.op_count; j++) + lod_comp->llc_ostlist.op_array[j] = -1; + lod_comp->llc_ostlist.op_count = 0; } } @@ -4302,7 +4310,8 @@ static void lod_striping_from_default(struct lod_object *lo, } /* copy ost list */ - if (def_comp->llc_ostlist.op_array) { + if (def_comp->llc_ostlist.op_array && + def_comp->llc_ostlist.op_count) { OBD_ALLOC(obj_comp->llc_ostlist.op_array, obj_comp->llc_ostlist.op_size); if (!obj_comp->llc_ostlist.op_array) @@ -4310,6 +4319,8 @@ static void lod_striping_from_default(struct lod_object *lo, memcpy(obj_comp->llc_ostlist.op_array, def_comp->llc_ostlist.op_array, obj_comp->llc_ostlist.op_size); + } else if (def_comp->llc_ostlist.op_array) { + obj_comp->llc_ostlist.op_array = NULL; } /* diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index 4ab9643..cf578b54 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -1216,6 +1216,7 @@ static int lod_alloc_ost_list(const struct lu_env *env, struct lod_object *lo, LASSERT(lo->ldo_comp_cnt > comp_idx && lo->ldo_comp_entries != NULL); lod_comp = &lo->ldo_comp_entries[comp_idx]; LASSERT(lod_comp->llc_ostlist.op_array); + LASSERT(lod_comp->llc_ostlist.op_count); rc = lod_qos_ost_in_use_clear(env, lod_comp->llc_stripe_count); if (rc < 0) @@ -2333,7 +2334,8 @@ int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo, CDEBUG(D_OTHER, "tgt_count %d stripe_count %d\n", d->lod_desc.ld_tgt_count, stripe_len); - if (lod_comp->llc_ostlist.op_array) { + if (lod_comp->llc_ostlist.op_array && + lod_comp->llc_ostlist.op_count) { rc = lod_alloc_ost_list(env, lo, stripe, ost_indices, th, comp_idx); } else if (lod_comp->llc_stripe_offset == LOV_OFFSET_DEFAULT) { diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index c3713b0..2876399 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -2298,8 +2298,8 @@ test_27G() { #LU-10629 run_test 27G "Clear OST pool from stripe" test_27H() { - [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.11.53) ]] && - skip "Need MDS version newer than 2.11.53" + [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.11.54) ]] && + skip "Need MDS version newer than 2.11.54" [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" test_mkdir $DIR/$tdir $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed" @@ -2313,6 +2313,13 @@ test_27H() { (( $($LFS getstripe -y $DIR/$tdir/$tfile | egrep -c "l_ost_idx: [02]$") == "2" )) || error "expected l_ost_idx: [02]$ not matched" + + # make sure ost list have been cleared + local stripesize=$($GETSTRIPE -S $DIR/$tdir) + $LFS setstripe -S $((stripesize * 4)) -i 1 \ + -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe" + touch $DIR/$tdir/f3 + $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed" } run_test 27H "Set specific OSTs stripe" -- 1.8.3.1