{ 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
# 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"
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
# 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
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}
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=$?
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
}
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