From: Bobi Jam Date: Tue, 12 Jun 2018 11:28:16 +0000 (+0800) Subject: LU-11212 lod: preserve mirror ID on mirror extension X-Git-Tag: 2.11.55~39 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F38%2F32938%2F7;p=fs%2Flustre-release.git LU-11212 lod: preserve mirror ID on mirror extension When merging/expanding existing mirrors of a FLR file, we need keep its existing mirror's mirror ID. Signed-off-by: Bobi Jam Change-Id: If139076c37c33bb1a330e1a5e997f8f56015fd9a Reviewed-on: https://review.whamcloud.com/32938 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index 91b901b..4c367bb 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -2898,8 +2898,12 @@ static int lod_declare_layout_merge(const struct lu_env *env, offset += le32_to_cpu(lcme->lcme_size); - if (mirror_count == 1) { - /* new mirrored file, create new mirror ID */ + if (mirror_count == 1 && + mirror_id_of(le32_to_cpu(lcme->lcme_id)) == 0) { + /* Add mirror from a non-flr file, create new mirror ID. + * Otherwise, keep existing mirror's component ID, used + * for mirror extension. + */ id = pflr_id(1, i + 1); lcme->lcme_id = cpu_to_le32(id); } @@ -4906,16 +4910,28 @@ int lod_striped_create(const struct lu_env *env, struct dt_object *dt, LASSERT(lo->ldo_comp_cnt != 0 && lo->ldo_comp_entries != NULL); - mirror_id = lo->ldo_mirror_count > 1 ? 1 : 0; + mirror_id = 0; /* non-flr file's mirror_id is 0 */ + if (lo->ldo_mirror_count > 1) { + for (i = 0; i < lo->ldo_comp_cnt; i++) { + lod_comp = &lo->ldo_comp_entries[i]; + if (lod_comp->llc_id != LCME_ID_INVAL && + mirror_id_of(lod_comp->llc_id) > mirror_id) + mirror_id = mirror_id_of(lod_comp->llc_id); + } + } /* create all underlying objects */ for (i = 0; i < lo->ldo_comp_cnt; i++) { lod_comp = &lo->ldo_comp_entries[i]; - if (lod_comp->llc_extent.e_start == 0 && i > 0) /* new mirror */ - ++mirror_id; - if (lod_comp->llc_id == LCME_ID_INVAL) { + /* only the component of FLR layout with more than 1 + * mirror has mirror ID in its component ID. + */ + if (lod_comp->llc_extent.e_start == 0 && + lo->ldo_mirror_count > 1) + ++mirror_id; + lod_comp->llc_id = lod_gen_component_id(lo, mirror_id, i); if (lod_comp->llc_id == LCME_ID_INVAL) diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index b732065..e906140 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -2161,6 +2161,39 @@ test_202() { } run_test 202 "lfs setstripe --add-component wide striping" +test_203() { + [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return + + local tf=$DIR/$tfile + + #create 2 mirrors + $LFS mirror create -N2 -c1 $tf || error "create FLR file $tf" + #delete first mirror + $LFS mirror split --mirror-id=1 -d $tf || error "delete first mirror" + + $LFS getstripe $tf + local old_id=$($LFS getstripe --mirror-id=2 -I $tf) + local count=$($LFS getstripe --mirror-id=2 -c $tf) || + error "getstripe count of mirror 2" + [[ x$count = x1 ]] || error "mirror 2 stripe count $count is not 1" + + #extend a mirror with 2 OSTs + $LFS mirror extend -N -c2 $tf || error "extend mirror" + $LFS getstripe $tf + + local new_id=$($LFS getstripe --mirror-id=2 -I $tf) + count=$($LFS getstripe --mirror-id=2 -c $tf) || + error "getstripe count of mirror 2" + [[ x$oldid = x$newid ]] || + error "mirror 2 changed ID from $old_id to $new_id" + [[ x$count = x1 ]] || error "mirror 2 stripe count $count is not 1" + + count=$($LFS getstripe --mirror-id=3 -c $tf) || + error "getstripe count of mirror 3" + [[ x$count = x2 ]] || error "mirror 3 stripe count $count is not 2" +} +run_test 203 "mirror file preserve mirror ID" + complete $SECONDS check_and_cleanup_lustre exit_status