Whamcloud - gitweb
LU-313 tests: re-enable lfsck test to run by default
authorAndreas Dilger <adilger@whamcloud.com>
Tue, 10 Apr 2012 08:53:29 +0000 (16:53 +0800)
committerJohann Lombardi <johann@whamcloud.com>
Mon, 16 Apr 2012 13:19:09 +0000 (09:19 -0400)
Due to bug 13698, the lfsck part of the lfsck.sh test script was
disabled by default. After the fixes in LU-113 were landed, lfsck
should work again. Remove SKIP_LFSCK checks so lfsck.sh actually runs
lfsck instead of silently skipping it unless SKIP_LFSCK=no is set.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Yu Jian <yujian@whamcloud.com>
Change-Id: I430f7398b2d21db0d0755726fdcb6053f25b4b10
Reviewed-on: http://review.whamcloud.com/2497
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Wei Liu <sarah@whamcloud.com>
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
lustre/tests/lfsck.sh
lustre/tests/test-framework.sh

index 865ac85..c82b72f 100644 (file)
@@ -20,8 +20,13 @@ OBJGRP=${OBJGRP:-0} # the OST object group
     { skip "SHARED_DIRECTORY should be specified with a shared directory \
 which can be accessable on all of the nodes" && exit 0; }
 
-which getfattr > /dev/null 2>&1 || { skip "could not find getfattr" && exit 0; }
-which setfattr > /dev/null 2>&1 || { skip "could not find setfattr" && exit 0; }
+which getfattr &>/dev/null || { skip_env "could not find getfattr" && exit 0; }
+which setfattr &>/dev/null || { skip_env "could not find setfattr" && exit 0; }
+
+if [ ! -x $(which $LFSCK_BIN) ]; then
+    log "$($E2FSCK -V)"
+    error "e2fsprogs does not support lfsck"
+fi
 
 MOUNT_2=""
 check_and_setup_lustre
@@ -205,7 +210,7 @@ duplicate_files() {
 # get the server target devices
 get_svr_devs
 
-if [ "$SKIP_LFSCK" = "no" ] && is_empty_fs $MOUNT; then
+if is_empty_fs $MOUNT; then
     # create test directory
     TESTDIR=$DIR/d0.$TESTSUITE
     mkdir -p $TESTDIR || error "mkdir $TESTDIR failed"
@@ -241,7 +246,7 @@ if [ "$SKIP_LFSCK" = "no" ] && is_empty_fs $MOUNT; then
     duplicate_files mds $MDSDEV $MDS_DUPE || \
         error "duplicating files failed"
     FSCK_MAX_ERR=1   # file system errors corrected
-else # $SKIP_LFSCK = yes || !is_empty_fs $MOUNT
+else # is_empty_fs $MOUNT
     FSCK_MAX_ERR=4   # file system errors left uncorrected
 fi
 
@@ -249,35 +254,30 @@ fi
 # lfsck will return 1 if the filesystem had errors fixed
 # run e2fsck to generate databases used for lfsck
 generate_db
-if [ "$SKIP_LFSCK" != "no" ]; then
-    echo "skip lfsck"
+
+# remount filesystem
+REFORMAT=""
+check_and_setup_lustre
+
+# run lfsck
+rc=0
+run_lfsck || rc=$?
+if [ $rc -eq 0 ]; then
+    echo "clean after the first check"
 else
-    # remount filesystem
-    REFORMAT=""
-    check_and_setup_lustre
+    # run e2fsck again to generate databases used for lfsck
+    generate_db
 
-    # run lfsck
+    # run lfsck again
     rc=0
     run_lfsck || rc=$?
     if [ $rc -eq 0 ]; then
-       echo "clean after the first check"
+        echo "clean after the second check"
     else
-        # run e2fsck again to generate databases used for lfsck
-       generate_db
-
-        # run lfsck again
-       rc=0
-       run_lfsck || rc=$?
-       if [ $rc -eq 0 ]; then
-           echo "clean after the second check"
-       else
-           error "lfsck test 2 - finished with rc=$rc"
-       fi
+        error "lfsck test 2 - finished with rc=$rc"
     fi
 fi
 
-LFSCK_ALWAYS=no
-
 complete $(basename $0) $SECONDS
 check_and_cleanup_lustre
 exit_status
index 725a6bb..d152a89 100644 (file)
@@ -119,21 +119,12 @@ init_test_env() {
     export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
     export E2FSCK=${E2FSCK:-e2fsck}
     export LFSCK_BIN=${LFSCK_BIN:-lfsck}
-    export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check filesystem after each test suit
-    export SKIP_LFSCK=${SKIP_LFSCK:-"yes"} # bug 13698, change to "no" when fixed
-    export SHARED_DIRECTORY=${SHARED_DIRECTORY:-"/tmp"}
-    export FSCK_MAX_ERR=4   # File system errors left uncorrected
-    if [ "$SKIP_LFSCK" == "no" ]; then
-       if [ ! -x `which $LFSCK_BIN` ]; then
-           log "$($E2FSCK -V)"
-           error_exit "$E2FSCK does not support lfsck"
-       fi
 
-       export MDSDB=${MDSDB:-$SHARED_DIRECTORY/mdsdb}
-       export OSTDB=${OSTDB:-$SHARED_DIRECTORY/ostdb}
-       export MDSDB_OPT="--mdsdb $MDSDB"
-       export OSTDB_OPT="--ostdb $OSTDB-\$ostidx"
-    fi
+    export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check fs after each test suite
+    export FSCK_MAX_ERR=4   # File system errors left uncorrected
+    export SHARED_DIRECTORY=${SHARED_DIRECTORY:-"/tmp"}
+    export MDSDB=${MDSDB:-$SHARED_DIRECTORY/mdsdb}
+    export OSTDB=${OSTDB:-$SHARED_DIRECTORY/ostdb}
     declare -a OSTDEVS
 
     #[ -d /r ] && export ROOT=${ROOT:-/r}
@@ -2228,11 +2219,10 @@ get_svr_devs() {
 run_e2fsck() {
     local node=$1
     local target_dev=$2
-    local ostidx=$3
-    local ostdb_opt=$4
+    local extra_opts=$3
 
-    df > /dev/null     # update statfs data on disk
-    local cmd="$E2FSCK -d -v -f -n $MDSDB_OPT $ostdb_opt $target_dev"
+    df > /dev/null    # update statfs data on disk
+    local cmd="$E2FSCK -d -v -t -t -f -n $extra_opts $target_dev"
     echo $cmd
     local rc=0
     do_node $node $cmd || rc=$?
@@ -2259,15 +2249,14 @@ generate_db() {
         error_exit "$SHARED_DIRECTORY is not a shared directory"
     rm $tmp_file
 
-    run_e2fsck $(facet_host mds) $MDSDEV
+    run_e2fsck $(facet_host mds) $MDSDEV "--mdsdb $MDSDB"
 
     i=0
     ostidx=0
     OSTDB_LIST=""
     for node in $(osts_nodes); do
         for dev in ${OSTDEVS[i]}; do
-           local ostdb_opt=`eval echo $OSTDB_OPT`
-            run_e2fsck $node $dev $ostidx "$ostdb_opt"
+            run_e2fsck $node $dev "--mdsdb $MDSDB --ostdb $OSTDB-$ostidx"
             OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
             ostidx=$((ostidx + 1))
         done
@@ -2289,14 +2278,10 @@ run_lfsck() {
 }
 
 check_and_cleanup_lustre() {
-    if [ "$LFSCK_ALWAYS" = "yes" ]; then
+    if [ "$LFSCK_ALWAYS" = "yes" -a "$TESTSUITE" != "lfsck" ]; then
         get_svr_devs
         generate_db
-        if [ "$SKIP_LFSCK" == "no" ]; then
-           run_lfsck
-       else
-           echo "skip lfsck"
-        fi
+        run_lfsck
     fi
 
     if is_mounted $MOUNT; then