X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;ds=sidebyside;f=lustre%2Ftests%2Fsanity-flr.sh;h=998e5f09223b7c23eb7a1cb6b31722664f4fab2f;hb=3e59ed26d04da1fa2891b8f5263b0481d7c69f22;hp=a76320611cf21e3105d533fdcafa7d41115d52b8;hpb=8a0554450eaaf86acbc9b6a4c8228dc32ab71b19;p=fs%2Flustre-release.git diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index a763206..998e5f0 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -17,6 +17,7 @@ LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)} . $LUSTRE/tests/test-framework.sh init_test_env $@ . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh} +get_lustre_env init_logging [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] || @@ -87,7 +88,7 @@ start_osts() { verify_mirror_count() { local tf=$1 local expected=$2 - local mirror_count=$(get_mirror_ids $tf) + local mirror_count=$($LFS getstripe -N $tf) [[ $mirror_count = $expected ]] || { $LFS getstripe -v $tf @@ -274,6 +275,16 @@ verify_comp_attrs() { verify_comp_attr_with_parent pool $tf $comp_id } +verify_flr_state() +{ + local tf=$1 + local expected_state=$2 + + local state=$($LFS getstripe -v $tf | awk '/lcm_flags/{ print $2 }') + [ $expected_state = $state ] || + error "expected: $expected_state, actual $state" +} + # command line test cases test_0a() { local td=$DIR/$tdir @@ -381,6 +392,17 @@ test_0b() { verify_comp_attr stripe-count $tf ${ids[5]} $OSTCOUNT verify_comp_attr_with_parent pool $tf ${ids[5]} + if [[ $MDS1_VERSION -ge $(version_code 2.12.56) ]] || + [[ $MDS1_VERSION -ge $(version_code 2.12.2) && + $MDS1_VERSION -lt $(version_code 2.12.50) ]]; then + # LU-11022 - remove mirror by pool name + local=cnt cnt=$($LFS getstripe $tf | grep archive | wc -l) + [ "$cnt" != "1" ] && error "unexpected mirror count $cnt" + $LFS mirror split --pool archive -d $tf || error "delete mirror" + cnt=$($LFS getstripe $tf | grep archive | wc -l) + [ "$cnt" != "0" ] && error "mirror count after removal: $cnt" + fi + # destroy OST pool destroy_test_pools } @@ -667,17 +689,29 @@ test_0g() { cat $tf &> /dev/null || error "error reading file '$tf'" # verify that the data was provided by OST1 where mirror 1 resides - local nr_read=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-ffff*.stats | + local nr_read=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[-0-9a-f]*.stats | awk '/ost_read/{print $2}') [ -n "$nr_read" ] || error "read was not provided by OST1" } run_test 0g "lfs mirror create flags support" test_0h() { - local tf=$DIR/$tfile + [ $MDS1_VERSION -lt $(version_code 2.11.57) ] && + skip "Need MDS version at least 2.11.57" - $LFS mirror create -N -E 1M -S 1M --flags=prefer -E eof -N2 $tf || - error "create mirrored file $tf failed" + local td=$DIR/$tdir + local tf=$td/$tfile + local ids + local i + + # create parent directory + test_mkdir $td || error "mkdir $td failed" + + $LFS setstripe -N -E 1M -S 1M --flags=prefer -E eof -N2 $td || + error "set default mirrored layout on directory $td failed" + + # verify flags are inherited from the directory + touch $tf verify_comp_attr lcme_flags $tf 0x10001 prefer verify_comp_attr lcme_flags $tf 0x10002 prefer @@ -700,6 +734,37 @@ test_0h() { error "error setting flag prefer" verify_comp_attr lcme_flags $tf 0x20003 prefer + + $LFS setstripe --comp-set -I 0x20003 --comp-flags=^prefer $tf || + error "error clearing prefer flag from component 0x20003" + + # MDS disallows setting stale flag on the last non-stale mirror + [[ $MDS1_VERSION -ge $(version_code 2.12.57) ]] || + [[ $MDS1_VERSION -ge $(version_code 2.12.2) && + $MDS1_VERSION -lt $(version_code 2.12.50) ]] || return 0 + + cp /etc/hosts $tf || error "error writing file '$tf'" + + verify_comp_attr lcme_flags $tf 0x10002 prefer + verify_comp_attr lcme_flags $tf 0x20003 stale + verify_comp_attr lcme_flags $tf 0x30004 stale + + ! $LFS setstripe --comp-set -I 0x10002 --comp-flags=^prefer,stale $tf \ + > /dev/null 2>&1 || + error "setting stale flag on component 0x10002 should fail" + + $LFS mirror resync $tf || error "error resync-ing file '$tf'" + + $LFS setstripe --comp-set -I 0x10001 --comp-flags=stale $tf || + error "error setting stale flag on component 0x10001" + $LFS setstripe --comp-set -I 0x20003 --comp-flags=stale $tf || + error "error setting stale flag on component 0x20003" + + ! $LFS setstripe --comp-set -I 0x30004 --comp-flags=stale $tf \ + > /dev/null 2>&1 || + error "setting stale flag on component 0x30004 should fail" + + $LFS mirror resync $tf || error "error resync-ing file '$tf'" } run_test 0h "set, clear and test flags for FLR files" @@ -886,7 +951,7 @@ get_osc_lock_count() { local osc_name local count - osc_name=${FSNAME}-OST$(printf "%04x" $((idx-1)))-osc-'ffff*' + osc_name=${FSNAME}-OST$(printf "%04x" $((idx-1)))-osc-'[-0-9a-f]*' count=$($LCTL get_param -n ldlm.namespaces.$osc_name.lock_count) lock_count=$((lock_count + count)) done @@ -973,7 +1038,7 @@ test_32() { error "extending mirrored file $DIR/$tfile failed" # make sure the mirrored file was created successfully - [ $(get_mirror_ids $DIR/$tfile) -eq 2 ] || + [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] || { $LFS getstripe $DIR/$tfile; error "expected 2 mirrors"; } drop_client_cache @@ -991,7 +1056,7 @@ test_32() { } run_test 32 "data should be mirrored to newly created mirror" -test_33() { +test_33a() { [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return rm -f $DIR/$tfile $DIR/$tfile-2 @@ -1022,7 +1087,7 @@ test_33() { "without verification failed" # make sure that $tfile has two mirrors and $tfile-2 does not exist - [ $(get_mirror_ids $DIR/$tfile) -eq 2 ] || + [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] || { $LFS getstripe $DIR/$tfile; error "expected count 2"; } [[ ! -e $DIR/$tfile-2 ]] || error "$DIR/$tfile-2 was not unlinked" @@ -1051,10 +1116,8 @@ test_33() { start_osts 1 # read file again with ost2 failed - $LCTL set_param ldlm.namespaces.lustre-*-osc-ffff*.lru_size=clear - - fail ost2 & - sleep 1 + stop_osts 2 + drop_client_cache # check size, glimpse should work $CHECKSTAT -t file -s $fsize $DIR/$tfile || @@ -1065,9 +1128,116 @@ test_33() { [[ "$rs" == "ost1" ]] || error "file content error: expected: \"ost1\", actual: \"$rs\"" - wait_osc_import_state client ost2 FULL + start_osts 2 } -run_test 33 "read can choose available mirror to read" +run_test 33a "read can choose available mirror to read" + +test_33b() { + [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return + + rm -f $DIR/$tfile + + stack_trap "rm -f $DIR/$tfile" EXIT + + # create a file with two mirrors on OST0000 and OST0001 + $LFS setstripe -N -Eeof -o0 -N -Eeof -o1 $DIR/$tfile + + # make sure that $tfile has two mirrors + [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] || + { $LFS getstripe $DIR/$tfile; error "expected count 2"; } + + # write 50M + dd if=/dev/urandom of=$DIR/$tfile bs=2M count=25 || + error "write failed for $DIR/$tfile" + $LFS mirror resync $DIR/$tfile || error "resync failed for $DIR/$tfile" + verify_flr_state $DIR/$tfile "ro" + drop_client_cache + + ls -l $DIR/$tfile + + # read file - all OSTs are available + echo "reading file (data can be provided by any ost)... " + local t1=$SECONDS + time cat $DIR/$tfile > /dev/null || error "read all" + local t2=$SECONDS + ra=$((t2 - t1)) + + # read file again with ost1 {OST0000} failed + stop_osts 1 + drop_client_cache + echo "reading file (data should be provided by ost2)..." + t1=$SECONDS + time cat $DIR/$tfile > /dev/null || error "read ost2" + t2=$SECONDS + r1=$((t2 - t1)) + + # remount ost1 + start_osts 1 + + # read file again with ost2 {OST0001} failed + stop_osts 2 + drop_client_cache + + echo "reading file (data should be provided by ost1)..." + t1=$SECONDS + time cat $DIR/$tfile > /dev/null || error "read ost1" + t2=$SECONDS + r2=$((t2 - t1)) + + # remount ost2 + start_osts 2 + + [ $((r1 * 100)) -gt $((ra * 105)) -a $r1 -gt $((ra + 2)) ] && + error "read mirror too slow without ost1, from $ra to $r1" + [ $((r2 * 100)) -gt $((ra * 105)) -a $r2 -gt $((ra + 2)) ] && + error "read mirror too slow without ost2, from $ra to $r2" + + wait_osc_import_ready client ost2 +} +run_test 33b "avoid reading from unhealthy mirror" + +test_33c() { + [[ $OSTCOUNT -lt 3 ]] && skip "need >= 3 OSTs" && return + + rm -f $DIR/$tfile + + stack_trap "rm -f $DIR/$tfile" EXIT + + # create a file with two mirrors + # mirror1: {OST0000, OST0001} + # mirror2: {OST0001, OST0002} + $LFS setstripe -N -Eeof -c2 -o0,1 -N -Eeof -c2 -o1,2 $DIR/$tfile + + # make sure that $tfile has two mirrors + [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] || + { $LFS getstripe $DIR/$tfile; error "expected count 2"; } + + # write 50M + dd if=/dev/urandom of=$DIR/$tfile bs=2M count=25 || + error "write failed for $DIR/$tfile" + $LFS mirror resync $DIR/$tfile || error "resync failed for $DIR/$tfile" + verify_flr_state $DIR/$tfile "ro" + drop_client_cache + + ls -l $DIR/$tfile + + # read file - all OSTs are available + echo "reading file (data can be provided by any ost)... " + time cat $DIR/$tfile > /dev/null || error "read all" + + # read file again with ost2 (OST0001) failed + stop_osts 2 + drop_client_cache + + echo "reading file (data should be provided by ost1 and ost3)..." + time cat $DIR/$tfile > /dev/null || error "read ost1 & ost3" + + # remount ost2 + start_osts 2 + + wait_osc_import_ready client ost2 +} +run_test 33c "keep reading among unhealthy mirrors" test_34a() { [[ $OSTCOUNT -lt 4 ]] && skip "need >= 4 OSTs" && return @@ -1194,7 +1364,7 @@ test_36() { create_file_36 $tf $tf-2 $tf-3 - [ $(get_mirror_ids $tf) -gt 1 ] || error "wrong mirror count" + [ $($LFS getstripe -N $tf) -gt 1 ] || error "wrong mirror count" # test case 1 - check file write and verify layout version $MULTIOP $tf oO_WRONLY:c || @@ -1210,13 +1380,13 @@ test_36() { verify_ost_layout_version $tf # test case 2 - local mds_idx=mds$(($($LFS getstripe -m $tf-2) + 1)) + local mds_facet=mds$(($($LFS getstripe -m $tf-2) + 1)) local delay_sec=10 - do_facet $mds_idx $LCTL set_param fail_val=$delay_sec + do_facet $mds_facet $LCTL set_param fail_val=$delay_sec #define OBD_FAIL_FLR_LV_DELAY 0x1A01 - do_facet $mds_idx $LCTL set_param fail_loc=0x1A01 + do_facet $mds_facet $LCTL set_param fail_loc=0x1A01 # write should take at least $fail_loc seconds and succeed local st=$(date +%s) @@ -1228,19 +1398,19 @@ test_36() { # verify OST layout version verify_ost_layout_version $tf - do_facet $mds_idx $LCTL set_param fail_loc=0 + do_facet $mds_facet $LCTL set_param fail_loc=0 # test case 3 mds_idx=mds$(($($LFS getstripe -m $tf-3) + 1)) #define OBD_FAIL_FLR_LV_INC 0x1A02 - do_facet $mds_idx $LCTL set_param fail_loc=0x1A02 + do_facet $mds_facet $LCTL set_param fail_loc=0x1A02 # write open file should return error $MULTIOP $tf-3 oO_WRONLY:O_SYNC:w1024c && error "write a mirrored file succeeded" || true - do_facet $mds_idx $LCTL set_param fail_loc=0 + do_facet $mds_facet $LCTL set_param fail_loc=0 } run_test 36 "write to mirrored files" @@ -1261,11 +1431,17 @@ create_files_37() { test_37() { + [ $MDS1_VERSION -lt $(version_code 2.11.57) ] && + skip "Need MDS version at least 2.11.57" + local tf=$DIR/$tfile local tf2=$DIR/$tfile-2 local tf3=$DIR/$tfile-3 + local tf4=$DIR/$tfile-4 create_files_37 $((RANDOM + 15 * 1048576)) $tf $tf2 $tf3 + rm -f $tf4 + cp $tf $tf4 # assume the mirror id will be 1, 2, and 3 declare -A checksums @@ -1288,48 +1464,53 @@ test_37() local sum for i in ${mirror_array[@]}; do - sum=$($LFS mirror dump -N $i $tf | md5sum) + $LCTL set_param ldlm.namespaces.*.lru_size=clear > /dev/null + sum=$($LFS mirror read -N $i $tf | md5sum) [ "$sum" = "${checksums[$i]}" ] || error "$i: mismatch: \'${checksums[$i]}\' vs. \'$sum\'" done + # verify mirror write + echo "Verifying mirror write .." + $LFS mirror write -N2 $tf < $tf4 + + sum=$($LFS mirror read -N2 $tf | md5sum) + [[ "$sum" = "${checksums[1]}" ]] || + error "2: mismatch \'${checksums[1]}\' vs. \'$sum\'" + # verify mirror copy, write to this mirrored file will invalidate # the other two mirrors echo "Verifying mirror copy .." local osts=$(comma_list $(osts_nodes)) - # define OBD_FAIL_OST_SKIP_LV_CHECK 0x241 - do_nodes $osts lctl set_param fail_loc=0x241 + if [[ $MDS1_VERSION -lt $(version_code 2.12.3) ]]; then + # define OBD_FAIL_OST_SKIP_LV_CHECK 0x241 + do_nodes $osts lctl set_param fail_loc=0x241 - mirror_io copy -i ${mirror_array[0]} \ - -t $(echo ${mirror_array[@]:1} | tr ' ' ',') $tf || - error "mirror copy error" + mirror_io copy -i ${mirror_array[0]} \ + -t $(echo ${mirror_array[@]:1} | tr ' ' ',') $tf || + error "mirror copy error" - do_nodes $osts lctl set_param fail_loc=0 + do_nodes $osts lctl set_param fail_loc=0 + elif [[ $MDS1_VERSION -lt $(version_code 2.12.50) || + $MDS1_VERSION -gt $(version_code 2.12.52) ]]; then + $LFS mirror copy -i ${mirror_array[0]} -o-1 $tf || + error "mirror copy error" + fi # verify copying is successful by checking checksums remount_client $MOUNT for i in ${mirror_array[@]}; do - sum=$($LFS mirror dump -N $i $tf | md5sum) + sum=$($LFS mirror read -N $i $tf | md5sum) [ "$sum" = "${checksums[1]}" ] || - error "$i: mismatch checksum after copy" + error "$i: mismatch checksum after copy \'$sum\'" done rm -f $tf } run_test 37 "mirror I/O API verification" -verify_flr_state() -{ - local tf=$1 - local expected_state=$2 - - local state=$($LFS getstripe -v $tf | awk '/lcm_flags/{ print $2 }') - [ $expected_state = $state ] || - error "expected: $expected_state, actual $state" -} - test_38() { local tf=$DIR/$tfile local ref=$DIR/${tfile}-ref @@ -1370,7 +1551,7 @@ test_38() { local valid_mirror stale_mirror id mirror_cksum for id in "${mirror_array[@]}"; do - mirror_cksum=$($LFS mirror dump -N $id $tf | md5sum) + mirror_cksum=$($LFS mirror read -N $id $tf | md5sum) [ "$ref_cksum" == "$mirror_cksum" ] && { valid_mirror=$id; continue; } @@ -1383,7 +1564,7 @@ test_38() { mirror_io resync $tf || error "resync failed" verify_flr_state $tf "ro" - mirror_cksum=$($LFS mirror dump -N $stale_mirror $tf | md5sum) + mirror_cksum=$($LFS mirror read -N $stale_mirror $tf | md5sum) [ "$file_cksum" = "$ref_cksum" ] || error "resync failed" # case 2: inject an error to make mirror_io exit after changing @@ -1509,7 +1690,7 @@ test_41() { echo " **verify $tf-1 data consistency in all mirrors" for i in 1 2 3; do - local sum=$($LFS mirror dump -N$i $tf-1 | md5sum) + local sum=$($LFS mirror read -N$i $tf-1 | md5sum) [[ "$sum" = "$sum0" ]] || error "$tf-1.$i: checksum mismatch: $sum != $sum0" done @@ -1755,6 +1936,10 @@ test_44() { verify_flr_state $tf "wp" + # disallow destroying the last non-stale mirror + ! $LFS mirror split --mirror-id 1 -d $tf > /dev/null 2>&1 || + error "destroying mirror 1 should fail" + # synchronize all mirrors of the file $LFS mirror resync $tf || error "mirror resync $tf failed" @@ -1780,8 +1965,17 @@ test_44() { verify_mirror_count $tf 2 verify_mirror_count $tf.mirror~2 1 + $LFS setstripe --comp-set -I 0x30008 --comp-flags=stale $tf || + error "setting stale flag on component 0x30008 failed" + + # disallow destroying the last non-stale mirror + ! $LFS mirror split --mirror-id 4 -d $tf > /dev/null 2>&1 || + error "destroying mirror 4 should fail" + + $LFS mirror resync $tf || error "resynchronizing $tf failed" + $LFS mirror split --mirror-id 3 -d $tf || - error "split and delte mirror 3 failed" + error "destroying mirror 3 failed" verify_mirror_count $tf 1 # verify splitted file contains the same content as the orig file does @@ -1792,7 +1986,7 @@ test_44() { run_test 44 "lfs mirror split check" test_45() { - [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return + [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" local file=$DIR/$tdir/$tfile local dir=$DIR/$tdir/$dir @@ -1804,16 +1998,14 @@ test_45() { -N -E3m -S1m -Eeof -N -E8m -Eeof $file || error "Create $file failed" - echo "getstripe --yaml $file" - $LFS getstripe --yaml $file > $temp || error "getstripe $file failed" - echo "setstripe --yaml=$temp $file.2" - $LFS setstripe --yaml=$temp $file.2 || error "setstripe $file.2 failed" + verify_yaml_layout $file $file.copy $temp "1. FLR file" + rm -f $file $file.copy - echo "compare layout" - local layout1=$(get_layout_param $file) - local layout2=$(get_layout_param $file.2) - [ "$layout1" == "$layout2" ] || - error "FLR file $file/$file.2 layouts are not equal" + $LFS setstripe -N -E1m -S1m -c2 -o0,1 -E2m -Eeof -N -E4m -Eeof \ + -N -E3m -S1m -Eeof -N -E8m --flags=prefer -Eeof $file || + error "Create $file failed" + + verify_yaml_layout $file $file.copy $temp "2. FLR file with flags" } run_test 45 "Verify setstripe/getstripe with YAML with FLR file" @@ -1960,6 +2152,9 @@ test_47() { run_test 47 "Verify mirror obj alloc" test_48() { + [ $MDS1_VERSION -lt $(version_code 2.11.55) ] && + skip "Need MDS version at least 2.11.55" + local tf=$DIR/$tfile rm -f $tf @@ -1988,8 +2183,8 @@ test_48() { verify_flr_state $tf "wp" verify_comp_attr lcme_flags $tf 0x20003 nosync,stale - local sum1=$($LFS mirror dump -N1 $tf | md5sum) - local sum2=$($LFS mirror dump -N2 $tf | md5sum) + local sum1=$($LFS mirror read -N1 $tf | md5sum) + local sum2=$($LFS mirror read -N2 $tf | md5sum) echo " ** verify mirror 2 doesn't change" echo "original checksum: $sum0" @@ -2006,8 +2201,8 @@ test_48() { verify_flr_state $tf "ro" verify_comp_attr lcme_flags $tf 0x20003 nosync,^stale - sum1=$($LFS mirror dump -N1 $tf | md5sum) - sum2=$($LFS mirror dump -N2 $tf | md5sum) + sum1=$($LFS mirror read -N1 $tf | md5sum) + sum2=$($LFS mirror read -N2 $tf | md5sum) echo " ** verify mirror 2 resync-ed" echo "original checksum: $sum0" @@ -2152,9 +2347,9 @@ test_200() { mirror_io resync $tf get_mirror_ids $tf - local csum=$($LFS mirror dump -N ${mirror_array[0]} $tf | md5sum) + local csum=$($LFS mirror read -N ${mirror_array[0]} $tf | md5sum) for id in ${mirror_array[@]:1}; do - [ "$($LFS mirror dump -N $id $tf | md5sum)" = "$csum" ] || + [ "$($LFS mirror read -N $id $tf | md5sum)" = "$csum" ] || error "checksum error for mirror $id" done @@ -2233,7 +2428,9 @@ test_202() { run_test 202 "lfs setstripe --add-component wide striping" test_203() { - [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return + [ $MDS1_VERSION -lt $(version_code 2.11.55) ] && + skip "Need MDS version at least 2.11.55" + [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" local tf=$DIR/$tfile