xfs: refactor _xfs_check calls to the scratch device
[xfstests-dev.git] / tests / xfs / 291
old mode 100644 (file)
new mode 100755 (executable)
index 03c34eb..adef253
@@ -1,30 +1,13 @@
 #! /bin/bash
-# FS QA Test No. 291
-#
-# Test xfs_repair on fragmented multi-block dir2 fs
-#
-#-----------------------------------------------------------------------
+# SPDX-License-Identifier: GPL-2.0
 # Copyright (c) Red Hat, Inc.  All Rights Reserved.
 #
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+# FS QA Test No. 291
 #
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-#-----------------------------------------------------------------------
+# Test xfs_repair on fragmented multi-block dir2 fs
 #
-
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
-seqres=$RESULT_DIR/$seq
-seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
 
 here=`pwd`
@@ -39,16 +22,17 @@ _cleanup()
 }
 
 # get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
 
 _supported_fs xfs
-_supported_os IRIX Linux
+_supported_os Linux
 
 # real QA test starts here
 rm -f $seqres.full
 _require_scratch
-_scratch_mkfs_xfs -n size=16k -d size=128m >> $seqres.full 2>&1
+logblks=$(_scratch_find_xfs_min_logblocks -n size=16k -d size=133m)
+_scratch_mkfs_xfs -n size=16k -l size=${logblks}b -d size=133m >> $seqres.full 2>&1
 _scratch_mount
 
 # First we cause very badly fragmented freespace, then
@@ -56,23 +40,26 @@ _scratch_mount
 # should come out very fragmented as a result
 
 # Step 1: Cause badly fragmented free space
+# 
+# XXX: this needs to be factored to match what generic/204 does to support
+# different inode sizes without ENOSPC
 mkdir $SCRATCH_MNT/fragdir
-for I in `seq 0 27200`; do
+for I in `seq 0 26200`; do
         (echo data > $SCRATCH_MNT/fragdir/f$I) >> $seqres.full 2>&1
 done
 sync
 
-for I in `seq 0 2 27200`; do
+for I in `seq 0 2 26200`; do
         rm -f $SCRATCH_MNT/fragdir/f$I >> $seqres.full 2>&1
 done
 sync
 
 # Soak up any remaining freespace
-xfs_io -f -c "pwrite 0 16m" -c "fsync" $SCRATCH_MNT/space_file.large >> $seqres.full 2>&1
+$XFS_IO_PROG -f -c "pwrite 0 16m" -c "fsync" $SCRATCH_MNT/space_file.large >> $seqres.full 2>&1
 
 # Take a look at freespace for any post-mortem on the test
 _scratch_unmount
-xfs_db -c freesp $SCRATCH_DEV >> $seqres.full 2>&1
+_scratch_xfs_db -r -c freesp  >> $seqres.full 2>&1
 _scratch_mount
 
 # Step 2: Make a bunch of (hopefully fragmented) multiblock
@@ -115,13 +102,16 @@ done
 _scratch_unmount
 # Can xfs_repair and xfs_check cope with this monster?
 _scratch_xfs_repair >> $seqres.full 2>&1 || _fail "xfs_repair failed"
-xfs_check $SCRATCH_DEV >> $seqres.full 2>&1 || _fail "xfs_check failed"
+_scratch_xfs_check >> $seqres.full 2>&1 || _fail "xfs_check failed"
 
 # Yes they can!  Now...
 # Can xfs_metadump cope with this monster?
-xfs_metadump $SCRATCH_DEV $tmp.metadump || _fail "xfs_metadump failed"
+_scratch_metadump $tmp.metadump || _fail "xfs_metadump failed"
 xfs_mdrestore $tmp.metadump $tmp.img || _fail "xfs_mdrestore failed"
-xfs_repair $tmp.img >> $seqres.full 2>&1 || _fail "xfs_repair of metadump failed"
+[ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ] && \
+       rt_repair_opts="-r $SCRATCH_RTDEV"
+$XFS_REPAIR_PROG $rt_repair_opts -f $tmp.img >> $seqres.full 2>&1 || \
+       _fail "xfs_repair of metadump failed"
 
 # Yes it can; success, all done
 status=0