Whamcloud - gitweb
LU-11716 tests: fix scrub tests
[fs/lustre-release.git] / lustre / tests / sanity-scrub.sh
index 88fd417..ffff7a0 100644 (file)
@@ -27,7 +27,7 @@ if ! check_versions; then
        exit 0
 fi
 
-stopall
+cleanupall
 
 SAVED_MDSSIZE=${MDSSIZE}
 SAVED_OSTSIZE=${OSTSIZE}
@@ -43,8 +43,7 @@ OSTSIZE=200000
 [ $OSTCOUNT -gt 4 ] && OSTCOUNT=4
 
 # build up a clean test environment.
-formatall
-setupall
+REFORMAT="yes" check_and_setup_lustre
 
 build_test_filter
 
@@ -107,8 +106,10 @@ scrub_prep() {
                        error "Failed to copy files to mds$n"
                mkdir -p $DIR/$tdir/mds$n/d_$tfile ||
                        error "mkdir failed on mds$n"
-               createmany -m $DIR/$tdir/mds$n/d_$tfile/f 2 > \
+               touch $DIR/$tdir/mds$n/d_$tfile/f1 > \
                        /dev/null || error "create failed on mds$n"
+               dd if=/dev/zero of=$DIR/$tdir/mds$n/d_$tfile/f2 bs=1M count=1 ||
+                       error "write failed on mds$n"
                if [[ $nfiles -gt 0 ]]; then
                        createmany -m $DIR/$tdir/mds$n/$tfile $nfiles > \
                                /dev/null || error "createmany failed on mds$n"
@@ -331,6 +332,16 @@ full_scrub_threshold_rate() {
                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
+}
+
+scrub_disable_index_backup() {
+       do_nodes $(comma_list $(all_server_nodes)) $LCTL set_param -n \
+               osd-*.*.index_backup=0
+}
+
 test_0() {
        scrub_prep 0
        echo "starting MDTs without disabling OI scrub"
@@ -1216,13 +1227,31 @@ test_15() {
 }
 run_test 15 "Dryrun mode OI scrub"
 
+test_16() {
+       check_mount_and_prep
+       scrub_enable_index_backup
+
+       #define OBD_FAIL_OSD_INDEX_CRASH        0x199
+       do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x199
+       scrub_prep 0
+       do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0
+
+       echo "starting MDTs without disabling OI scrub"
+       scrub_start_mds 1 "$MOUNT_OPTS_SCRUB"
+       mount_client $MOUNT || error "(2) Fail to start client!"
+       scrub_check_data 3
+       scrub_disable_index_backup
+}
+run_test 16 "Initial OI scrub can rebuild crashed index objects"
+
 # restore MDS/OST size
 MDSSIZE=${SAVED_MDSSIZE}
 OSTSIZE=${SAVED_OSTSIZE}
 OSTCOUNT=${SAVED_OSTCOUNT}
 
 # cleanup the system at last
-formatall
+REFORMAT="yes" cleanup_and_setup_lustre
 
 complete $SECONDS
+check_and_cleanup_lustre
 exit_status