Whamcloud - gitweb
LU-1538 tests: standardize test script init - dne-part-2
[fs/lustre-release.git] / lustre / tests / sanity-scrub.sh
index 6a14220..dae61a3 100644 (file)
@@ -7,16 +7,18 @@
 set -e
 
 ONLY=${ONLY:-"$*"}
+
+LUSTRE=${LUSTRE:-$(dirname $0)/..}
+. $LUSTRE/tests/test-framework.sh
+init_test_env $@
+init_logging
+
 ALWAYS_EXCEPT="$SANITY_SCRUB_EXCEPT"
 
 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
-. $LUSTRE/tests/test-framework.sh
-init_test_env $@
-. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
-init_logging
+build_test_filter
 
 require_dsh_mds || exit 0
 
@@ -27,7 +29,7 @@ if ! check_versions; then
        exit 0
 fi
 
-stopall
+cleanupall
 
 SAVED_MDSSIZE=${MDSSIZE}
 SAVED_OSTSIZE=${OSTSIZE}
@@ -43,14 +45,10 @@ OSTSIZE=200000
 [ $OSTCOUNT -gt 4 ] && OSTCOUNT=4
 
 # build up a clean test environment.
-formatall
-setupall
-
-build_test_filter
+REFORMAT="yes" check_and_setup_lustre
 
 MDT_DEV="${FSNAME}-MDT0000"
 OST_DEV="${FSNAME}-OST0000"
-MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
 
 scrub_start() {
        local error_id=$1
@@ -101,14 +99,16 @@ scrub_prep() {
        echo "preparing... $(date)"
        for n in $(seq $MDSCOUNT); do
                echo "creating $nfiles files on mds$n"
-               test_mkdir -i $((n - 1)) $DIR/$tdir/mds$n ||
+               test_mkdir -i $((n - 1)) -c1 $DIR/$tdir/mds$n ||
                        error "Failed to create directory mds$n"
                cp $LUSTRE/tests/*.sh $DIR/$tdir/mds$n ||
                        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"
@@ -353,6 +353,8 @@ test_0() {
 run_test 0 "Do not auto trigger OI scrub for non-backup/restore case"
 
 test_1a() {
+       [ -n "$FILESET" ] && skip "Not functional for FILESET set"
+
        scrub_prep 0
        echo "start $SINGLEMDS without disabling OI scrub"
        scrub_start_mds 1 "$MOUNT_OPTS_SCRUB"
@@ -372,7 +374,7 @@ test_1a() {
        stop $SINGLEMDS > /dev/null || error "(6) Fail to stop MDS!"
 
        echo "start $SINGLEMDS with disabling OI scrub"
-       start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_NOSCRUB > /dev/null ||
+       start $SINGLEMDS $(mdsdevname 1) $MOUNT_OPTS_NOSCRUB > /dev/null ||
                error "(7) Fail to start MDS!"
 
        local FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }')
@@ -651,6 +653,28 @@ test_4c() {
 }
 run_test 4c "Auto trigger OI scrub if bad OI mapping was found (3)"
 
+test_4d() {
+       [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] && skip "ldiskfs only test"
+
+       check_mount_and_prep
+
+       #define OBD_FAIL_OSD_DUPLICATE_MAP      0x19b
+       do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0x19b
+       for i in {1..100}; do
+               echo $i > $DIR/$tdir/f_$i || error "write f_$i failed"
+       done
+       do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
+
+       for i in {101..200}; do
+               echo $i > $DIR/$tdir/f_$i || error "write f_$i failed"
+       done
+
+       for i in {1..200}; do
+               echo $i | cmp $DIR/$tdir/f_$i - || error "f_$i data corrupt"
+       done
+}
+run_test 4d "FID in LMA mismatch with object FID won't block create"
+
 test_5() {
        formatall > /dev/null
        setupall > /dev/null
@@ -1022,7 +1046,7 @@ test_11() {
        check_mount_and_prep
 
        for n in $(seq $MDSCOUNT); do
-               test_mkdir -i $((n - 1)) $DIR/$tdir/mds$n ||
+               test_mkdir -i $((n - 1)) -c1 $DIR/$tdir/mds$n ||
                        error "(1) Fail to mkdir $DIR/$tdir/mds$n"
 
                createmany -o $DIR/$tdir/mds$n/f $CREATED ||
@@ -1068,7 +1092,7 @@ run_test 11 "OI scrub skips the new created objects only once"
 
 test_12() {
        check_mount_and_prep
-       $SETSTRIPE -c 1 -i 0 $DIR/$tdir
+       $LFS setstripe -c 1 -i 0 $DIR/$tdir
 
        #define OBD_FAIL_OSD_COMPAT_INVALID_ENTRY               0x195
        do_facet ost1 $LCTL set_param fail_loc=0x195
@@ -1106,7 +1130,7 @@ run_test 12 "OI scrub can rebuild invalid /O entries"
 
 test_13() {
        check_mount_and_prep
-       $SETSTRIPE -c 1 -i 0 $DIR/$tdir
+       $LFS setstripe -c 1 -i 0 $DIR/$tdir
 
        #define OBD_FAIL_OSD_COMPAT_NO_ENTRY            0x196
        do_facet ost1 $LCTL set_param fail_loc=0x196
@@ -1139,10 +1163,10 @@ run_test 13 "OI scrub can rebuild missed /O entries"
 
 test_14() {
        [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
-               skip "ldiskfs special test" && return
+               skip "ldiskfs special test"
 
        check_mount_and_prep
-       $SETSTRIPE -c 1 -i 0 $DIR/$tdir
+       $LFS setstripe -c 1 -i 0 $DIR/$tdir
 
        #define OBD_FAIL_OSD_COMPAT_NO_ENTRY            0x196
        do_facet ost1 $LCTL set_param fail_loc=0x196
@@ -1165,13 +1189,19 @@ test_14() {
        mount_client $MOUNT || error "(5) Fail to start client!"
 
        local LF_REPAIRED=$($SHOW_SCRUB_ON_OST |
-                           awk '/^lf_repa[ri]*ed/ { print $2 }')
+                           awk '/^lf_repa[ir]*ed/ { print $2 }')
        [ $LF_REPAIRED -ge 1000 ] ||
                error "(6) Some entry under /lost+found should be repaired"
 
        ls -ail $DIR/$tdir > /dev/null || error "(7) ls should succeed"
+
+       stopall
+
+       echo "run e2fsck again after LFSCK"
+       run_e2fsck $(facet_host ost1) $(ostdevname 1) "-y" ||
+               error "(8) Fail to run e2fsck error"
 }
-run_test 14 "OI scrub can repair objects under lost+found"
+run_test 14 "OI scrub can repair OST objects under lost+found"
 
 test_15() {
        local repaired
@@ -1227,9 +1257,6 @@ test_15() {
 run_test 15 "Dryrun mode OI scrub"
 
 test_16() {
-       [ $(facet_fstype $SINGLEMDS) != "zfs" ] &&
-               skip "only support zfs temporarily" && return
-
        check_mount_and_prep
        scrub_enable_index_backup
 
@@ -1252,7 +1279,8 @@ 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