+ for n in $(seq $MDSCOUNT); do
+ echo "stopping mds$n"
+ stop mds$n >/dev/null ||
+ error "($error_id) Failed to stop mds$n"
+ done
+}
+
+scrub_check_status() {
+ local error_id=$1
+ local expected=$2
+ local n
+
+ for n in $(seq $MDSCOUNT); do
+ wait_update_facet mds$n "$LCTL get_param -n \
+ osd-*.$(facet_svc mds$n).oi_scrub |
+ awk '/^status/ { print \\\$2 }'" "$expected" 6 ||
+ error "($error_id) Expected '$expected' on mds$n"
+ done
+}
+
+scrub_check_flags() {
+ local error_id=$1
+ local expected=$2
+ local actual
+ local n
+
+ for n in $(seq $MDSCOUNT); do
+ actual=$(do_facet mds$n $LCTL get_param -n \
+ osd-*.$(facet_svc mds$n).oi_scrub |
+ awk '/^flags/ { print $2 }')
+ if [ "$actual" != "$expected" ]; then
+ error "($error_id) Expected '$expected' on mds$n, but" \
+ "got '$actual'"
+ fi
+ done
+}
+
+scrub_check_params() {
+ local error_id=$1
+ local expected=$2
+ local actual
+ local n
+
+ for n in $(seq $MDSCOUNT); do
+ actual=$(do_facet mds$n $LCTL get_param -n \
+ osd-*.$(facet_svc mds$n).oi_scrub |
+ awk '/^param/ { print $2 }')
+ if [ "$actual" != "$expected" ]; then
+ error "($error_id) Expected '$expected' on mds$n, but" \
+ "got '$actual'"
+ fi
+ done
+}
+
+scrub_check_repaired() {
+ local error_id=$1
+ local expected=$2
+ local dryrun=$3
+ local actual
+ local n
+
+ for n in $(seq $MDSCOUNT); do
+ if [ $dryrun -eq 1 ]; then
+ actual=$(do_facet mds$n $LCTL get_param -n \
+ osd-*.$(facet_svc mds$n).oi_scrub |
+ awk '/^inconsistent:/ { print $2 }')
+ else
+ actual=$(do_facet mds$n $LCTL get_param -n \
+ osd-*.$(facet_svc mds$n).oi_scrub |
+ awk '/^updated:/ { print $2 }')
+ fi
+
+ if [ $expected -eq 0 -a $actual -ne 0 ]; then
+ error "($error_id) Expected no repaired on mds$n, but" \
+ "got '$actual'"
+ fi
+
+ if [ $expected -ne 0 -a $actual -lt $expected ]; then
+ error "($error_id) Expected '$expected' on mds$n, but" \
+ "got '$actual'"
+ fi
+ done
+}
+
+scrub_check_data() {
+ local error_id=$1
+ local n
+
+ for n in $(seq $MDSCOUNT); do
+ diff -q $LUSTRE/tests/test-framework.sh \
+ $DIR/$tdir/mds$n/test-framework.sh ||
+ error "($error_id) File data check failed"
+ done
+}
+
+scrub_check_data2() {
+ local filename=$1
+ local error_id=$2
+ local n
+
+ for n in $(seq $MDSCOUNT); do
+ diff -q $LUSTRE/tests/$filename \
+ $DIR/$tdir/mds$n/$filename ||
+ error "($error_id) File data check failed"
+ done
+}
+
+scrub_remove_ois() {
+ [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] && return
+
+ local error_id=$1
+ local index=$2
+ local n
+
+ for n in $(seq $MDSCOUNT); do
+ mds_remove_ois mds$n $index ||
+ error "($error_id) Failed to remove OI .$index on mds$n"
+ done
+}
+
+scrub_enable_auto() {
+ do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param -n \
+ osd-*.*.auto_scrub=1
+}
+
+full_scrub_ratio() {
+ [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] && return
+
+ local ratio=$1
+
+ do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param -n \
+ osd-*.*.full_scrub_ratio=$ratio
+}
+
+full_scrub_threshold_rate() {
+ [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] && return
+
+ local rate=$1
+
+ do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param -n \
+ osd-*.*.full_scrub_threshold_rate=$rate
+}
+
+scrub_enable_index_backup() {
+ do_nodes $(comma_list $(all_server_nodes)) $LCTL set_param -n \
+ osd-*.*.index_backup=1
+}