- do_umount
-else
- # when the OST is also using an OSD this needs to be fixed
- MDTDEVS=`get_mnt_devs osd`
- OSTDEVS=`get_mnt_devs obdfilter`
- OSTCOUNT=`echo $OSTDEVS | wc -w`
-fi # LFSCK_SETUP
-
-# Run e2fsck to get mds and ost info
-# a return status of 1 indicates e2fsck successfuly fixed problems found
-set +e
-
-echo "$E2FSCK -d -v -fn --mdsdb $MDSDB $MDSDEV"
-df > /dev/null # update statfs data on disk
-$E2FSCK -d -v -fn --mdsdb $MDSDB $MDSDEV
-RET=$?
-[ $RET -gt $MAX_ERR ] && echo "$E2FSCK returned $RET" && exit 90 || true
-
-export OSTDB_LIST=""
-i=0
-for OSTDEV in $OSTDEVS; do
- df > /dev/null # update statfs data on disk
- $E2FSCK -d -v -fn --mdsdb $MDSDB --ostdb $OSTDB-$i $OSTDEV
- RET=$?
- [ $RET -gt $MAX_ERR ] && echo "$E2FSCK returned $RET" && exit 100
- OSTDB_LIST="$OSTDB_LIST $OSTDB-$i"
- i=$((i + 1))
-done
-
-#Remount filesystem
-[ "`mount | grep $MOUNT`" ] || $SETUP
-
-# need to turn off shell error detection to get proper error return
-# lfsck will return 1 if the filesystem had errors fixed
-echo "LFSCK TEST 1"
-echo "lfsck -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
-echo y | lfsck -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT
-RET=$?
-[ $RET -eq 0 ] && echo "clean after first check" && exit 0
-echo "LFSCK TEST 1 - finished with rc=$RET"
-[ $RET -gt $MAX_ERR ] && exit 110 || true
-
-# make sure everything gets to the backing store
-sync; sleep 2; sync
-
-echo "LFSCK TEST 2"
-echo "$E2FSCK -d -v -fn --mdsdb $MDSDB $MDSDEV"
-df > /dev/null # update statfs data on disk
-$E2FSCK -d -v -fn --mdsdb $MDSDB $MDSDEV
-RET=$?
-[ $RET -gt $MAX_ERR ] && echo "$E2FSCK returned $RET" && exit 123 || true
-
-i=0
-export OSTDB_LIST=""
-for OSTDEV in $OSTDEVS; do
- df > /dev/null # update statfs data on disk
- $E2FSCK -d -v -fn --mdsdb $MDSDB --ostdb $OSTDB-$i $OSTDEV
- RET=$?
- [ $RET -gt $MAX_ERR ] && echo "$E2FSCK returned $RET" && exit 124
- OSTDB_LIST="$OSTDB_LIST $OSTDB-$i"
- i=$((i + 1))
-done
-
-echo "LFSCK TEST 2"
-echo "lfsck -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
-lfsck -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT
-RET=$?
-echo "LFSCK TEST 2 - finished with rc=$RET"
-[ $RET -ne 0 ] && exit 125 || true
-if [ -z "$WAS_MOUNTED" ]; then
- sh llmountcleanup.sh || exit 120
+# get the server target devices
+get_svr_devs
+
+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
+ create_files $TESTDIR $NUMDIRS $NUMFILES
+
+ # get the objids for files in group $OBJGRP on the OST with index $OSTIDX
+ OST_REMOVE=$(get_objects $OSTIDX $OBJGRP \
+ $(seq -f $TESTDIR/testfile.%g $NUMFILES))
+
+ # 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) || \
+ error "get_ost_dev $OSTNODE $OSTIDX failed"
+
+ # get the file names to be duplicated on the MDS
+ MDS_DUPE=$(get_files dup $TESTDIR $NUMFILES) || error "$MDS_DUPE"
+ # get the file names to be removed from the MDS
+ MDS_REMOVE=$(get_files remove $TESTDIR $NUMFILES) || error "$MDS_REMOVE"
+
+ stopall -f || error "cleanupall failed"
+
+ # remove objects associated with files in group $OBJGRP
+ # on the OST with index $OSTIDX
+ remove_objects $OSTNODE $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 || \
+ error "duplicating files failed"
+ FSCK_MAX_ERR=1 # file system errors corrected
+else # is_empty_fs $MOUNT
+ FSCK_MAX_ERR=4 # file system errors left uncorrected