X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fsanity-scrub.sh;h=45bc281acc359def5b33923389f2d1368f1035d0;hb=65319af8d2d9b6df6264a41e3a6dd5368c55f3cc;hp=aa32eb721f1a79ab5f6a2489218d739f38927933;hpb=7cecfcffae9737f929a2cbc8067e093a4f85c3ba;p=fs%2Flustre-release.git diff --git a/lustre/tests/sanity-scrub.sh b/lustre/tests/sanity-scrub.sh index aa32eb7..45bc281 100644 --- a/lustre/tests/sanity-scrub.sh +++ b/lustre/tests/sanity-scrub.sh @@ -17,8 +17,6 @@ init_test_env $@ . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh} init_logging -[ "${MDSFSTYPE:-$FSTYPE}" != "ldiskfs" ] && - skip "test OI scrub only for ldiskfs" && exit 0 require_dsh_mds || exit 0 SAVED_MDSSIZE=${MDSSIZE} @@ -29,6 +27,14 @@ MDSSIZE=100000 OSTSIZE=100000 check_and_setup_lustre + +[ $(facet_fstype $SINGLEMDS) != ldiskfs ] && + skip "test OI scrub only for ldiskfs" && check_and_cleanup_lustre && + exit 0 +[[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.2.90) ]] && + skip "Need MDS version at least 2.2.90" && check_and_cleanup_lustre && + exit 0 + build_test_filter MDT_DEV="${FSNAME}-MDT0000" @@ -82,6 +88,46 @@ run_test 0 "Do not auto trigger OI scrub for non-backup/restore case" test_1a() { scrub_prep 0 + echo "start $SINGLEMDS without disabling OI scrub" + start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null || + error "(1) Fail to start MDS!" + + local STATUS=$($SHOW_SCRUB | awk '/^status/ { print $2 }') + [ "$STATUS" == "init" ] || + error "(2) Expect 'init', but got '$STATUS'" + + local FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }') + [ -z "$FLAGS" ] || error "(3) Expect empty flags, but got '$FLAGS'" + + mount_client $MOUNT || error "(4) Fail to start client!" + + #define OBD_FAIL_OSD_FID_MAPPING 0x193 + do_facet $SINGLEMDS $LCTL set_param fail_loc=0x193 + # update .lustre OI mapping + touch $MOUNT/.lustre + do_facet $SINGLEMDS $LCTL set_param fail_loc=0 + + umount_client $MOUNT || error "(5) Fail to stop client!" + + echo "stop $SINGLEMDS" + stop $SINGLEMDS > /dev/null || error "(6) Fail to stop MDS!" + + echo "start $SINGLEMDS with disabling OI scrub" + start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_NOSCRUB > /dev/null || + error "(7) Fail to start MDS!" + + local STATUS=$($SHOW_SCRUB | awk '/^status/ { print $2 }') + [ "$STATUS" == "init" ] || + error "(8) Expect 'init', but got '$STATUS'" + + local FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }') + [ "$FLAGS" == "inconsistent" ] || + error "(9) Expect 'inconsistent', but got '$FLAGS'" +} +run_test 1a "Auto trigger initial OI scrub when server mounts" + +test_1b() { + scrub_prep 0 mds_remove_ois || error "(1) Fail to remove/recreate!" echo "start $SINGLEMDS without disabling OI scrub" @@ -98,9 +144,9 @@ test_1a() { diff -q $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh || error "(5) File diff failed unexpected!" } -run_test 1a "Trigger OI scrub when MDT mounts for OI files remove/recreate case" +run_test 1b "Trigger OI scrub when MDT mounts for OI files remove/recreate case" -test_1b() { +test_1c() { local index # OI files to be removed: @@ -120,7 +166,7 @@ test_1b() { local FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }') [ "$FLAGS" == "recreated" ] || - error "(3) Expect 'recreated', but got '$STATUS'" + error "(3) Expect 'recreated', but got '$FLAGS'" $START_SCRUB || error "(4) Fail to start OI scrub!" sleep 3 @@ -133,7 +179,7 @@ test_1b() { error "(6) Expect empty flags, but got '$FLAGS'" done } -run_test 1b "Auto detect kinds of OI file(s) removed/recreated cases" +run_test 1c "Auto detect kinds of OI file(s) removed/recreated cases" test_2() { scrub_prep 0 @@ -322,7 +368,8 @@ test_6() { diff -q $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh || error "(6) File diff failed unexpected!" - sleep 8 + # Sleep 5 sec to guarantee at least one object processed by OI scrub + sleep 5 # Fail the OI scrub to guarantee there is at least one checkpoint #define OBD_FAIL_OSD_SCRUB_FATAL 0x192 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x80000192 @@ -347,7 +394,7 @@ test_6() { #define OBD_FAIL_OSD_SCRUB_CRASH 0x191 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x80000191 sleep 4 - local POSITION0=$($SHOW_SCRUB | \ + local POSITION0=$($SHOW_SCRUB | awk '/^last_checkpoint_position/ {print $2}') POSITION0=$((POSITION0 + 1)) @@ -365,7 +412,7 @@ test_6() { [ "$STATUS" == "scanning" ] || error "(13) Expect 'scanning', but got '$STATUS'" - local POSITION1=$($SHOW_SCRUB | \ + local POSITION1=$($SHOW_SCRUB | awk '/^latest_start_position/ {print $2}') [ $POSITION0 -eq $POSITION1 ] || error "(14) Expect position: $POSITION0, but got $POSITION1" @@ -481,6 +528,11 @@ test_8() { run_test 8 "Control OI scrub manually" test_9() { + if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then + skip "Testing on UP system, the speed may be inaccurate." + return 0 + fi + scrub_prep 8000 mds_backup_restore || error "(1) Fail to backup/restore!" @@ -515,12 +567,15 @@ test_9() { [ "$STATUS" == "scanning" ] || error "(9) Expect 'scanning', but got '$STATUS'" - # Do NOT ignore that there are 1024 pre-fetched items. - # So the max speed may be (1024 + 100 * 10) / 10. - # And there may be time error, so the max speed may be more large. local SPEED=$($SHOW_SCRUB | awk '/^average_speed/ { print $2 }') - [ $SPEED -gt 220 ] && - error "(10) Unexpected speed $SPEED, should not more than 220" + # Do NOT ignore that there are 1024 pre-fetched items. + # And there may be time error, normally it should be less than 2. + # We allow another 10% schedule error. + # + # SPEED1 = (pre-fetched + 100 * (time - 2)) / time * 1.1 + local SPEED1=$(((1024 + 100 * (10 + 2)) / 10 * 11 / 10)) + [ $SPEED -lt $SPEED1 ] || + error "(10) Got speed $SPEED, expected less than $SPEED1" # adjust speed limit do_facet $SINGLEMDS \ @@ -528,12 +583,19 @@ test_9() { sleep 10 SPEED=$($SHOW_SCRUB | awk '/^average_speed/ { print $2 }') - [ $SPEED -lt 220 ] && - error "(11) Unexpected speed $SPEED, should not less than 220" - - # (1024 + 100 * 10 + 300 * 10) / 20 - [ $SPEED -gt 270 ] && - error "(12) Unexpected speed $SPEED, should not more than 270" + # SPEED1 = (pre-fetched + 100 * (time1 - 2) + 300 * (time2 - 2)) / \ + # (time1 + time2) * 0.9 + SPEED1=$(((1024 + 100 * (10 - 2) + 300 * (10 - 2)) / \ + (10 + 10) * 9 / 10)) + [ $SPEED -gt $SPEED1 ] || + error "(11) Got speed $SPEED, expected more than $SPEED1" + + # SPEED1 = (pre-fetched + 100 * (time1 + 2) + 300 * (time2 + 2)) / \ + # (time1 + time2) * 1.1 + SPEED1=$(((1024 + 100 * (10 + 2) + 300 * (10 + 2)) / \ + (10 + 10) * 11 / 10)) + [ $SPEED -lt $SPEED1 ] || + error "(12) Got speed $SPEED, expected less than $SPEED1" do_facet $SINGLEMDS \ $LCTL set_param -n mdd.${MDT_DEV}.lfsck_speed_limit 0 @@ -670,13 +732,53 @@ test_10b() { } run_test 10b "non-stopped OI scrub should auto restarts after MDS remount (2)" -# restore the ${facet}_MKFS_OPTS variables -for facet in MGS MDS OST; do - opts=SAVED_${facet}_MKFS_OPTS - if [[ -n ${!opts} ]]; then - eval ${facet}_MKFS_OPTS=\"${!opts}\" - fi -done +test_11() { + echo "stopall" + stopall > /dev/null + echo "formatall" + formatall > /dev/null + echo "setupall" + setupall > /dev/null + + local CREATED=100 + local tname=`date +%s` + rm -rf $MOUNT/$tname > /dev/null + mkdir $MOUNT/$tname || error "(1) Fail to mkdir $MOUNT/$tname" + + createmany -o $MOUNT/$tname/f $CREATED || error "(2) Fail to create!" + + # reset OI scrub start point by force + $START_SCRUB -r || error "(3) Fail to start OI scrub!" + sleep 3 + local STATUS=$($SHOW_SCRUB | awk '/^status/ { print $2 }') + [ "$STATUS" == "completed" ] || + error "(4) Expect 'completed', but got '$STATUS'" + + # OI scrub should skip the new created objects for the first accessing + local SKIPPED=$($SHOW_SCRUB | awk '/^noscrub/ { print $2 }') + # notice we're creating a new llog for every OST on every startup + # new features can make this even less stable, so we only check + # that the number of skipped files is less than 2x the number of files + local MAXIMUM=$((CREATED * 2)) + local MINIMUM=$((CREATED + 1)) # files + directory + [ $SKIPPED -ge $MAXIMUM -o $SKIPPED -lt $MINIMUM ] && + error "(5) Expect [ $MINIMUM , $MAXIMUM ) objects skipped, got $SKIPPED" + + # reset OI scrub start point by force + $START_SCRUB -r || error "(6) Fail to start OI scrub!" + sleep 3 + STATUS=$($SHOW_SCRUB | awk '/^status/ { print $2 }') + [ "$STATUS" == "completed" ] || + error "(7) Expect 'completed', but got '$STATUS'" + + # OI scrub should skip the new created object only once + SKIPPED=$($SHOW_SCRUB | awk '/^noscrub/ { print $2 }') + [ $SKIPPED -eq 0 ] || + error "(8) Expect 0 objects skipped, but got $SKIPPED" + + rm -rf $MOUNT/$tname > /dev/null +} +run_test 11 "OI scrub skips the new created objects only once" # restore MDS/OST size MDSSIZE=${SAVED_MDSSIZE} @@ -685,5 +787,5 @@ OSTSIZE=${SAVED_OSTSIZE} # cleanup the system at last formatall -complete $(basename $0) $SECONDS +complete $SECONDS exit_status