+test_12() {
+ echo "stopall"
+ stopall > /dev/null
+ echo "formatall"
+ formatall > /dev/null
+ echo "setupall"
+ setupall > /dev/null
+
+ mkdir -p $DIR/$tdir
+ $SETSTRIPE -c 1 -i 0 $DIR/$tdir
+
+ #define OBD_FAIL_OSD_COMPAT_INVALID_ENTRY 0x195
+ do_facet ost1 $LCTL set_param fail_loc=0x195
+ createmany -o $DIR/$tdir/f 1000
+
+ echo "stopall"
+ stopall > /dev/null
+
+ #define OBD_FAIL_OST_NODESTROY 0x233
+ do_facet ost1 $LCTL set_param fail_loc=0x233
+
+ echo "setupall"
+ setupall > /dev/null
+
+ local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
+ [ "$STATUS" == "init" ] ||
+ error "(1) Expect 'init', but got '$STATUS'"
+
+ ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(2) ls should fail"
+
+ sleep 3
+ local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
+ [ "$STATUS" == "completed" ] ||
+ error "(3) Expect 'completed', but got '$STATUS'"
+
+ do_facet ost1 $LCTL set_param fail_loc=0
+ ls -ail $DIR/$tdir > /dev/null 2>&1 || error "(4) ls should succeed"
+}
+run_test 12 "OI scrub can rebuild invalid /O entries"
+
+test_13() {
+ echo "stopall"
+ stopall > /dev/null
+ echo "formatall"
+ formatall > /dev/null
+ echo "setupall"
+ setupall > /dev/null
+
+ mkdir -p $DIR/$tdir
+ $SETSTRIPE -c 1 -i 0 $DIR/$tdir
+
+ #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196
+ do_facet ost1 $LCTL set_param fail_loc=0x196
+ createmany -o $DIR/$tdir/f 1000
+ do_facet ost1 $LCTL set_param fail_loc=0
+
+ echo "stopall"
+ stopall > /dev/null
+ echo "setupall"
+ setupall > /dev/null
+
+ local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
+ [ "$STATUS" == "init" ] ||
+ error "(1) Expect 'init', but got '$STATUS'"
+
+ ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(2) ls should fail"
+
+ $START_SCRUB_ON_OST || error "(3) Fail to start OI scrub on OST!"
+ sleep 3
+ local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
+ [ "$STATUS" == "completed" ] ||
+ error "(4) Expect 'completed', but got '$STATUS'"
+
+ ls -ail $DIR/$tdir > /dev/null 2>&1 || error "(5) ls should succeed"
+}
+run_test 13 "OI scrub can rebuild missed /O entries"
+
+test_14() {
+ echo "stopall"
+ stopall > /dev/null
+ echo "formatall"
+ formatall > /dev/null
+ echo "setupall"
+ setupall > /dev/null
+
+ mkdir -p $DIR/$tdir
+ $SETSTRIPE -c 1 -i 0 $DIR/$tdir
+
+ #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196
+ do_facet ost1 $LCTL set_param fail_loc=0x196
+ createmany -o $DIR/$tdir/f 64
+ do_facet ost1 $LCTL set_param fail_loc=0
+
+ echo "stopall"
+ stopall > /dev/null
+ echo "setupall"
+ setupall > /dev/null
+
+ local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
+ [ "$STATUS" == "init" ] ||
+ error "(1) Expect 'init', but got '$STATUS'"
+
+ ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(2) ls should fail"
+
+ echo "stopall"
+ stopall > /dev/null
+
+ echo "run e2fsck"
+ run_e2fsck $(facet_host ost1) $(ostdevname 1) "-y" ||
+ error "(3) Fail to run e2fsck error"
+
+ echo "setupall"
+ setupall > /dev/null
+
+ local LF_REPAIRED=$($SHOW_SCRUB_ON_OST |
+ awk '/^lf_reparied/ { print $2 }')
+ [ $LF_REPAIRED -gt 0 ] ||
+ error "(4) Some entry under /lost+found should be repaired"
+
+ ls -ail $DIR/$tdir > /dev/null 2>&1 || error "(5) ls should succeed"
+}
+run_test 14 "OI scrub can repair objects under lost+found"
+
+test_15() {
+ # skip test_15 for LU-4182
+ [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return
+ scrub_prep 20
+ scrub_backup_restore 1
+ echo "starting MDTs with OI scrub disabled"
+ scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
+ scrub_check_status 3 init
+ scrub_check_flags 4 inconsistent
+
+ # run under dryrun mode
+ scrub_start 5 --dryrun
+ sleep 3
+ scrub_check_status 6 completed
+ scrub_check_flags 7 inconsistent
+ scrub_check_params 8 dryrun
+ scrub_check_repaired 9 20
+
+ # run under dryrun mode again
+ scrub_start 10 --dryrun
+ sleep 3
+ scrub_check_status 11 completed
+ scrub_check_flags 12 inconsistent
+ scrub_check_params 13 dryrun
+ scrub_check_repaired 14 20
+
+ # run under normal mode
+ #
+ # Lustre-2.x (x <= 5) used "-n off" to disable dryrun which does not
+ # work under Lustre-2.y (y >=6), the test scripts should be fixed as
+ # "-noff" or "--dryrun=off".
+ scrub_start 15 --dryrun=off
+ sleep 3
+ scrub_check_status 16 completed
+ scrub_check_flags 17 ""
+ scrub_check_params 18 ""
+ scrub_check_repaired 19 20
+
+ # run under normal mode again
+ scrub_start 20 --dryrun=off
+ sleep 3
+ scrub_check_status 21 completed
+ scrub_check_flags 22 ""
+ scrub_check_params 23 ""
+ scrub_check_repaired 24 0
+}
+run_test 15 "Dryrun mode OI scrub"