Whamcloud - gitweb
LU-3335 scrub: control OI scrub on OST from user space
[fs/lustre-release.git] / lustre / tests / sanity-scrub.sh
index 9d12686..f8bc0d6 100644 (file)
@@ -26,6 +26,7 @@ SAVED_OSTSIZE=${OSTSIZE}
 MDSSIZE=100000
 OSTSIZE=100000
 
+MOUNT_2=""
 check_and_setup_lustre
 
 [ $(facet_fstype $SINGLEMDS) != ldiskfs ] &&
@@ -41,11 +42,15 @@ check_and_setup_lustre
 build_test_filter
 
 MDT_DEV="${FSNAME}-MDT0000"
+OST_DEV="${FSNAME}-OST0000"
 MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
 START_SCRUB="do_facet $SINGLEMDS $LCTL lfsck_start -M ${MDT_DEV}"
+START_SCRUB_ON_OST="do_facet ost1 $LCTL lfsck_start -M ${OST_DEV}"
 STOP_SCRUB="do_facet $SINGLEMDS $LCTL lfsck_stop -M ${MDT_DEV}"
 SHOW_SCRUB="do_facet $SINGLEMDS \
                $LCTL get_param -n osd-ldiskfs.${MDT_DEV}.oi_scrub"
+SHOW_SCRUB_ON_OST="do_facet ost1 \
+               $LCTL get_param -n osd-ldiskfs.${OST_DEV}.oi_scrub"
 MOUNT_OPTS_SCRUB="-o user_xattr"
 MOUNT_OPTS_NOSCRUB="-o user_xattr,noscrub"
 
@@ -482,7 +487,7 @@ test_7() {
 run_test 7 "System is available during OI scrub scanning"
 
 test_8() {
-       scrub_prep 0
+       scrub_prep 128
        mds_backup_restore || error "(1) Fail to backup/restore!"
 
        echo "start $SINGLEMDS with disabling OI scrub"
@@ -498,7 +503,7 @@ test_8() {
                error "(4) Expect 'inconsistent', but got '$FLAGS'"
 
        #define OBD_FAIL_OSD_SCRUB_DELAY         0x190
-       do_facet $SINGLEMDS $LCTL set_param fail_val=3
+       do_facet $SINGLEMDS $LCTL set_param fail_val=1
        do_facet $SINGLEMDS $LCTL set_param fail_loc=0x190
        $START_SCRUB || error "(5) Fail to start OI scrub!"
 
@@ -639,7 +644,7 @@ test_10a() {
        do_facet $SINGLEMDS \
                $LCTL set_param -n osd-ldiskfs.${MDT_DEV}.auto_scrub 1
        #define OBD_FAIL_OSD_SCRUB_DELAY         0x190
-       do_facet $SINGLEMDS $LCTL set_param fail_val=3
+       do_facet $SINGLEMDS $LCTL set_param fail_val=1
        do_facet $SINGLEMDS $LCTL set_param fail_loc=0x190
        diff -q $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
                error "(6) File diff failed unexpected!"
@@ -684,6 +689,7 @@ test_10a() {
 }
 run_test 10a "non-stopped OI scrub should auto restarts after MDS remount (1)"
 
+# test_10b is obsolete, it will be coverded by related sanity-lfsck tests.
 test_10b() {
        scrub_prep 0
        mds_backup_restore || error "(1) Fail to backup/restore!"
@@ -742,7 +748,7 @@ test_10b() {
        FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }')
        [ -z "$FLAGS" ] || error "(14) Expect empty flags, but got '$FLAGS'"
 }
-run_test 10b "non-stopped OI scrub should auto restarts after MDS remount (2)"
+#run_test 10b "non-stopped OI scrub should auto restarts after MDS remount (2)"
 
 test_11() {
        echo "stopall"
@@ -759,6 +765,9 @@ test_11() {
 
        createmany -o $MOUNT/$tname/f $CREATED || error "(2) Fail to create!"
 
+       cleanup_mount $MOUNT
+       do_facet $SINGLEMDS $LCTL clear
+       start_full_debug_logging
        # reset OI scrub start point by force
        $START_SCRUB -r || error "(3) Fail to start OI scrub!"
        sleep 3
@@ -788,10 +797,85 @@ test_11() {
        [ $SKIPPED -eq 0 ] ||
                error "(8) Expect 0 objects skipped, but got $SKIPPED"
 
+       stop_full_debug_logging
+       restore_mount $MOUNT || error "(9) Fail to start client!"
        rm -rf $MOUNT/$tname > /dev/null
 }
 run_test 11 "OI scrub skips the new created objects only once"
 
+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
+       echo "setupall"
+       setupall > /dev/null
+
+       do_facet ost1 $LCTL set_param fail_loc=0
+       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'"
+
+       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"
+
 # restore MDS/OST size
 MDSSIZE=${SAVED_MDSSIZE}
 OSTSIZE=${SAVED_OSTSIZE}