From: John L. Hammond Date: Thu, 6 Jan 2022 15:09:30 +0000 (-0600) Subject: EX-4463 flr: ensure layout generation is incremented on merge X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=2414a8616deb08c6a1f423110eb2d54b9a5a68f7;p=fs%2Flustre-release.git EX-4463 flr: ensure layout generation is incremented on merge In lod_declare_layout_merge(), load the striping before we increment the layout generation. Add sanity-flr:test_51a to check this. Fixes: 6b5a29c0ac94 (Revert "LU-14642 flr: transfer layout version on layout change") Test-Parameters: testlist=sanity-flr envdefinitions=FAIL_ON_ERROR=false,ONLY=51a,ONLY_REPEAT=20 Signed-off-by: John L. Hammond Change-Id: I357501edfd2bc0d710be902df9c40aab53c11824 Reviewed-on: https://review.whamcloud.com/46028 Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index cac183a..e0810e1 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -3414,8 +3414,6 @@ static int lod_declare_layout_merge(const struct lu_env *env, } /* fixup layout information */ - lod_obj_inc_layout_gen(lo); - lcm->lcm_layout_gen = cpu_to_le32(lo->ldo_layout_gen); lcm->lcm_size = cpu_to_le32(size); lcm->lcm_entry_count = cpu_to_le16(cur_entry_count + merge_entry_count); lcm->lcm_mirror_count = cpu_to_le16(mirror_count); @@ -3426,6 +3424,9 @@ static int lod_declare_layout_merge(const struct lu_env *env, if (rc) GOTO(out, rc); + lod_obj_inc_layout_gen(lo); + lcm->lcm_layout_gen = cpu_to_le32(lo->ldo_layout_gen); + rc = lod_sub_declare_xattr_set(env, dt_object_child(dt), buf, XATTR_NAME_LOV, LU_XATTR_REPLACE, th); diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index c864b99..56c0932 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -2665,6 +2665,51 @@ test_50d() { } run_test 50d "mirror rsync keep holes" +test_51a() { + local file="$DIR/$tdir/$tfile" + local mdt_index + local gen1 + local gen2 + + test_mkdir $DIR/$tdir + rm -f -- "$file" + + $LFS mirror create -N -E 1M -c 1 -E eof -c2 "$file" + echo XXX > "$file" + mdt_index=$($LFS getstripe --mdt-index "$file") + echo "mdt_index = $mdt_index" >&2 + + gen1=$($LFS getstripe "$file" | awk '$1 == "lcm_layout_gen:" { print $2; }') + # $LFS getstripe "$file" + echo "gen1 = '$gen1'" >&2 + if [[ -z "$gen1" ]]; then + error "cannot get layout generation of '$file'" + fi + + # I tried do do this with several combinations of sync, + # drop_caches, cancel_lru_locks on the client and mds but they + # didn't reliably reproduce the issue of incorrect layout + # generation after merge. + umount_client $MOUNT || error "cannot unmount '$MOUNT'" + stop mds$((mdt_index + 1)) || error "cannot stop mds$((mdt_index + 1))" + start mds$((mdt_index + 1)) || error "cannot start mds$((mdt_index + 1))" + mount_client $MOUNT || error "cannot mount '$MOUNT'" + + $LFS mirror extend -N -c1 "$file" + gen2=$($LFS getstripe "$file" | awk '$1 == "lcm_layout_gen:" { print $2; }') + echo "gen2 = '$gen2'" >&2 + # $LFS getstripe "$file" + + if [[ -z "$gen2" ]]; then + error "cannot get layout generation of '$file'" + fi + + if ! ((gen1 < gen2)); then + error "mirror extend did not increase layout generation" + fi +} +run_test 51a "mirror extend increases layout generation" + test_60a() { $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' || skip "OST does not support SEEK_HOLE"