From e468c285e0d801e1f2ef6772e43df1465666c649 Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Wed, 8 Apr 2020 11:07:47 +0300 Subject: [PATCH] LU-13426 mdd: correctly swap OIs during migration While swapping layouts mdd_swap_layouts() swaps also OI(FID) and uses lmm->lmm_oi directly in one place which is wrong if corresponding layout is composite. Layout OI should be taken by using mdd_get_lmm_oi() which handles all layout types correctly. Patch fixes that by using mdd_get_lmm_oi() instead of direct access to lmm_oi field. Signed-off-by: Mikhail Pershin Change-Id: I6a7dc9ece3b272f75a5f206b32937cf9f674ead9 Reviewed-on: https://review.whamcloud.com/38172 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Lai Siyao --- lustre/mdd/mdd_object.c | 5 ++++- lustre/tests/sanity.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 1313f59..beab56b 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -2460,10 +2460,13 @@ static int mdd_swap_layouts(const struct lu_env *env, struct md_object *obj1, /* set the file specific informations in lmm */ if (fst_lmm != NULL) { + struct ost_id temp_oi; + saved_oi = &info->mti_oa.o_oi; mdd_get_lmm_oi(fst_lmm, saved_oi); + mdd_get_lmm_oi(snd_lmm, &temp_oi); mdd_set_lmm_gen(fst_lmm, &snd_gen); - mdd_set_lmm_oi(fst_lmm, &snd_lmm->lmm_oi); + mdd_set_lmm_oi(fst_lmm, &temp_oi); mdd_set_lmm_oi(snd_lmm, saved_oi); } else { if ((snd_lmm->lmm_magic & cpu_to_le32(LOV_MAGIC_MASK)) == diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 1b32ad1..6f91998 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -7148,6 +7148,46 @@ test_56xe() { } run_test 56xe "migrate a composite layout file" +test_56xf() { + [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs" + + [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] || + skip "Need server version at least 2.13.53" + + local dir=$DIR/$tdir + local f_comp=$dir/$tfile + local layout="-E 1M -c1 -E -1 -c2" + local fid_before="" + local fid_after="" + + test_mkdir "$dir" || error "cannot create dir $dir" + $LFS setstripe $layout $f_comp || + error "cannot setstripe $f_comp with layout $layout" + fid_before=$($LFS getstripe --fid $f_comp) + dd if=/dev/zero of=$f_comp bs=1M count=4 + + # 1. migrate a comp layout file to a comp layout + $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate" + fid_after=$($LFS getstripe --fid $f_comp) + [ "$fid_before" == "$fid_after" ] || + error "comp-to-comp migrate: $fid_before != $fid_after" + + # 2. migrate a comp layout file to a plain layout + $LFS migrate -c2 $f_comp || + error "cannot migrate $f_comp by lfs migrate" + fid_after=$($LFS getstripe --fid $f_comp) + [ "$fid_before" == "$fid_after" ] || + error "comp-to-plain migrate: $fid_before != $fid_after" + + # 3. migrate a plain layout file to a comp layout + $LFS migrate $layout $f_comp || + error "cannot migrate $f_comp by lfs migrate" + fid_after=$($LFS getstripe --fid $f_comp) + [ "$fid_before" == "$fid_after" ] || + error "plain-to-comp migrate: $fid_before != $fid_after" +} +run_test 56xf "FID is not lost during migration of a composite layout file" + test_56y() { [ $MDS1_VERSION -lt $(version_code 2.4.53) ] && skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" -- 1.8.3.1