Whamcloud - gitweb
LU-2405 tests: account for inter-op testing sanity/17g
[fs/lustre-release.git] / lustre / tests / lfsck.sh
index 7ade8bc..9e08e0b 100644 (file)
@@ -28,11 +28,6 @@ which can be accessable on all of the nodes" && 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
 
@@ -177,28 +172,29 @@ get_files() {
 
 # Remove objects associated with files.
 remove_objects() {
-    local node=$1
-    shift
-    local ostdev=$1
-    shift
-    local group=$1
-    shift
-    local objids="$@"
-    local tmp
-    local i
-    local rc
-
-    echo "removing objects from $ostdev on $facet: $objids"
-    tmp=$(mktemp $SHARED_DIRECTORY/debugfs.XXXXXXXXXX)
-    for i in $objids; do
-        echo "rm O/$group/d$((i % 32))/$i" >> $tmp
-    done
-
-    do_node $node "$DEBUGFS -w -f $tmp $ostdev"
-    rc=${PIPESTATUS[0]}
-    rm -f $tmp
-
-    return $rc
+       local ostdev=$1
+       shift
+       local group=$1
+       shift
+       local objids="$@"
+       local facet=ost$((OSTIDX + 1))
+       local mntpt=$(facet_mntpt $facet)
+       local opts=$OST_MOUNT_OPTS
+       local i
+       local rc
+
+       echo "removing objects from $ostdev on $facet: $objids"
+       if ! do_facet $facet test -b $ostdev; then
+               opts=$(csa_add "$opts" -o loop)
+       fi
+       mount -t $(facet_fstype $facet) $opts $ostdev $mntpt ||
+               return $?
+       rc=0;
+       for i in $objids; do
+               rm $mntpt/O/$group/d$((i % 32))/$i || { rc=$?; break; }
+       done
+       umount -f $mntpt || return $?
+       return $rc
 }
 
 # Remove files from MDS.
@@ -218,9 +214,9 @@ init_logging
 # get the server target devices
 get_svr_devs
 
+TESTDIR=$DIR/d0.$TESTSUITE
 if is_empty_fs $MOUNT; then
     # create test directory
-    TESTDIR=$DIR/d0.$TESTSUITE
     mkdir -p $TESTDIR || error "mkdir $TESTDIR failed"
 
     # create some dirs and files on the filesystem
@@ -232,7 +228,7 @@ if is_empty_fs $MOUNT; then
 
     # get the node name and target device for the OST with index $OSTIDX
     OSTNODE=$(get_ost_node $OSTIDX) || error "get_ost_node by index $OSTIDX failed"
-    OSTDEV=$(get_ost_dev $OSTNODE $OSTIDX) || \
+    OSTDEV=$(get_ost_dev $OSTNODE $OSTIDX) ||
        error "get_ost_dev $OSTNODE $OSTIDX failed"
 
     # get the file names to be duplicated on the MDS
@@ -244,14 +240,14 @@ if is_empty_fs $MOUNT; then
 
     # remove objects associated with files in group $OBJGRP
     # on the OST with index $OSTIDX
-    remove_objects $OSTNODE $OSTDEV $OBJGRP $OST_REMOVE || \
+    remove_objects $OSTDEV $OBJGRP $OST_REMOVE ||
         error "removing objects failed"
 
     # remove files from MDS
     remove_files $SINGLEMDS $MDTDEV $MDS_REMOVE || error "removing files failed"
 
     # create EAs on files so objects are referenced from different files
-    duplicate_files $SINGLEMDS $MDTDEV $MDS_DUPE || \
+    duplicate_files $SINGLEMDS $MDTDEV $MDS_DUPE ||
         error "duplicating files failed"
     FSCK_MAX_ERR=1   # file system errors corrected
 else # is_empty_fs $MOUNT
@@ -264,8 +260,10 @@ fi
 generate_db
 
 # remount filesystem
+ORIG_REFORMAT=$REFORMAT
 REFORMAT=""
 check_and_setup_lustre
+REFORMAT=$ORIG_REFORMAT
 
 # run lfsck
 rc=0
@@ -287,5 +285,14 @@ else
 fi
 
 complete $SECONDS
+# The test directory contains some files referencing to some object
+# which could cause error when removing the directory.
+RMCNT=0
+while [ -d $TESTDIR ]; do
+       RMCNT=$((RMCNT + 1))
+       rm -fr $TESTDIR || echo "$RMCNT round: rm $TESTDIR failed"
+       [ $RMCNT -ge 10 ] && error "cleanup $TESTDIR failed $RMCNT times"
+       remount_client $MOUNT
+done
 check_and_cleanup_lustre
 exit_status