+run_test 4a "Auto trigger OI scrub if bad OI mapping was found (1)"
+
+test_4b() {
+ [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
+ skip "ldiskfs special test" && return
+
+ scrub_prep 5 1
+ echo "starting MDTs with OI scrub disabled"
+ scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
+ scrub_check_flags 4 recreated,inconsistent
+ mount_client $MOUNT || error "(5) Fail to start client!"
+ scrub_enable_auto
+ full_scrub_ratio 10
+ full_scrub_threshold_rate 10000
+ scrub_check_data 6
+ sleep 3
+
+ scrub_check_status 7 completed
+ scrub_check_flags 8 ""
+
+ local -a updated0
+ for n in $(seq $MDSCOUNT); do
+ updated0[$n]=$(scrub_status $n |
+ awk '/^prior_updated/ { print $2 }')
+
+ echo "OI scrub on MDS$n status for the 1st time:"
+ do_facet mds$n $LCTL get_param -n \
+ osd-*.$(facet_svc mds$n).oi_scrub
+ done
+
+ scrub_check_data2 sanity-scrub.sh 9
+ sleep 3
+
+ scrub_check_status 10 completed
+ scrub_check_flags 11 ""
+
+ local -a updated1
+ for n in $(seq $MDSCOUNT); do
+ updated1[$n]=$(scrub_status $n |
+ awk '/^prior_updated/ { print $2 }')
+
+ echo "OI scrub on MDS$n status for the 2nd time:"
+ do_facet mds$n $LCTL get_param -n \
+ osd-*.$(facet_svc mds$n).oi_scrub
+
+ [ ${updated0[$n]} -lt ${updated1[$n]} ] ||
+ error "(12) Auto trigger full scrub unexpectedly"
+ done
+
+ for n in $(seq $MDSCOUNT); do
+ ls -l $DIR/$tdir/mds$n/*.sh > /dev/null ||
+ error "(13) fail to ls"
+ done
+ sleep 3
+
+ scrub_check_status 14 completed
+ scrub_check_flags 15 ""
+
+ for n in $(seq $MDSCOUNT); do
+ updated0[$n]=$(scrub_status $n |
+ awk '/^prior_updated/ { print $2 }')
+
+ echo "OI scrub on MDS$n status for the 3rd time:"
+ do_facet mds$n $LCTL get_param -n \
+ osd-*.$(facet_svc mds$n).oi_scrub
+
+ [ ${updated0[$n]} -gt ${updated1[$n]} ] ||
+ error "(16) Auto trigger full scrub unexpectedly"
+ done
+
+ for n in $(seq $MDSCOUNT); do
+ ls -l $DIR/$tdir/mds$n/d_${tfile}/ || error "(17) fail to ls"
+ done
+ sleep 3
+
+ for n in $(seq $MDSCOUNT); do
+ updated1[$n]=$(scrub_status $n |
+ awk '/^prior_updated/ { print $2 }')
+ [ ${updated0[$n]} -eq ${updated1[$n]} ] || {
+ echo "OI scrub on MDS$n status for the 4th time:"
+ do_facet mds$n $LCTL get_param -n \
+ osd-*.$(facet_svc mds$n).oi_scrub
+
+ error "(18) NOT auto trigger full scrub as expected"
+ }
+ done
+}
+run_test 4b "Auto trigger OI scrub if bad OI mapping was found (2)"
+
+test_4c() {
+ [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
+ skip "ldiskfs special test" && return
+
+ scrub_prep 500 1
+ echo "starting MDTs with OI scrub disabled"
+ scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
+ scrub_check_flags 4 recreated,inconsistent
+ mount_client $MOUNT || error "(5) Fail to start client!"
+ scrub_enable_auto
+ full_scrub_ratio 2
+ full_scrub_threshold_rate 20
+ scrub_check_data 6
+ sleep 3
+
+ scrub_check_status 7 completed
+ scrub_check_flags 8 ""
+
+ local -a updated0
+ for n in $(seq $MDSCOUNT); do
+ updated0[$n]=$(scrub_status $n |
+ awk '/^prior_updated/ { print $2 }')
+
+ echo "OI scrub on MDS$n status for the 1st time:"
+ do_facet mds$n $LCTL get_param -n \
+ osd-*.$(facet_svc mds$n).oi_scrub
+ done
+
+ scrub_check_data2 sanity-scrub.sh 9
+ sleep 3
+
+ scrub_check_status 10 completed
+ scrub_check_flags 11 ""
+
+ local -a updated1
+ for n in $(seq $MDSCOUNT); do
+ updated1[$n]=$(scrub_status $n |
+ awk '/^prior_updated/ { print $2 }')
+
+ echo "OI scrub on MDS$n status for the 2nd time:"
+ do_facet mds$n $LCTL get_param -n \
+ osd-*.$(facet_svc mds$n).oi_scrub
+
+ [ ${updated0[$n]} -lt ${updated1[$n]} ] ||
+ error "(12) Auto trigger full scrub unexpectedly"
+ done
+
+ for n in $(seq $MDSCOUNT); do
+ ls -l $DIR/$tdir/mds$n/*.sh > /dev/null ||
+ error "(13) fail to ls"
+ done
+ sleep 3
+
+ scrub_check_status 14 completed
+ scrub_check_flags 15 ""
+
+ for n in $(seq $MDSCOUNT); do
+ updated0[$n]=$(scrub_status $n |
+ awk '/^prior_updated/ { print $2 }')
+
+ echo "OI scrub on MDS$n status for the 3rd time:"
+ do_facet mds$n $LCTL get_param -n \
+ osd-*.$(facet_svc mds$n).oi_scrub
+
+ [ ${updated0[$n]} -gt ${updated1[$n]} ] ||
+ error "(16) Auto trigger full scrub unexpectedly"
+ done
+
+ for n in $(seq $MDSCOUNT); do
+ ls -l $DIR/$tdir/mds$n/${tfile}1 || error "(17) fail to ls"
+ done
+ sleep 3
+
+ for n in $(seq $MDSCOUNT); do
+ updated1[$n]=$(scrub_status $n |
+ awk '/^prior_updated/ { print $2 }')
+ [ ${updated0[$n]} -eq ${updated1[$n]} ] || {
+ echo "OI scrub on MDS$n status for the 4th time:"
+ do_facet mds$n $LCTL get_param -n \
+ osd-*.$(facet_svc mds$n).oi_scrub
+
+ error "(18) NOT auto trigger full scrub as expected"
+ }
+ done
+}
+run_test 4c "Auto trigger OI scrub if bad OI mapping was found (3)"