Files
apfstests/tests/xfs/291
T
Dave Chinner 180adeb433 xfs/291: fix spurious ENOSPC errors
xfs/291 tries to fill the filesystem almost full, so if the log size
changes with mkfs defaults then it's free space calculations are not
longer valid and so it throws lots of ENOSPC errors during a run.
This is not fatal for this test, but it does increase the runtime of
it and fill the 291.full file with unnecessary errors.

The number of frag files it creates is also too many for a 512 byte
inode filesystem (by about 900) so reduce the number of inodes
initially created so the test works ofr 512 byte inodes. With 512
byte inodes, the free space histogram looks like this after the frag
phase:

   from      to extents  blocks    pct
      1       1   10730   10730 100.00

And for 256 byte inodes:

   from      to extents  blocks    pct
      1       1   12388   12388 100.00

So these changes do not affect the intended operation of the test.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-02-04 11:52:17 +11:00

131 lines
3.7 KiB
Bash
Executable File

#! /bin/bash
# FS QA Test No. 291
#
# Test xfs_repair on fragmented multi-block dir2 fs
#
#-----------------------------------------------------------------------
# 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.
#
# 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
#-----------------------------------------------------------------------
#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
_supported_fs xfs
_supported_os IRIX Linux
# real QA test starts here
rm -f $seqres.full
_require_scratch
_scratch_mkfs_xfs -n size=16k -l size=5m -d size=128m >> $seqres.full 2>&1
_scratch_mount
# First we cause very badly fragmented freespace, then
# make some multiblock directories in the filesystem, which
# 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 26200`; do
(echo data > $SCRATCH_MNT/fragdir/f$I) >> $seqres.full 2>&1
done
sync
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
# Take a look at freespace for any post-mortem on the test
_scratch_unmount
xfs_db -r -c freesp $SCRATCH_DEV >> $seqres.full 2>&1
_scratch_mount
# Step 2: Make a bunch of (hopefully fragmented) multiblock
# dir2 directories
# - FMT_LOCAL
mkdir $SCRATCH_MNT/S_IFDIR.FMT_LOCAL
touch $SCRATCH_MNT/S_IFDIR.FMT_LOCAL/localdirfile
# - FMT_EXTENTS
mkdir $SCRATCH_MNT/S_IFDIR.FMT_EXTENTS
for I in `seq 1 100`; do
touch $SCRATCH_MNT/S_IFDIR.FMT_EXTENTS/extent_dir_file_$I
done
# With a few missing
for I in `seq 10 2 20` 100; do
rm -f $SCRATCH_MNT/S_IFDIR.FMT_EXTENTS/extent_dir_file_$I
done
# - FMT_BTREE
mkdir $SCRATCH_MNT/S_IFDIR.FMT_BTREE
for I in `seq 1 1000`; do
touch $SCRATCH_MNT/S_IFDIR.FMT_BTREE/btree_dir_file_$I
done
# With a few missing
for I in `seq 10 2 20` 1000; do
rm -f $SCRATCH_MNT/S_IFDIR.FMT_BTREE/btree_dir_file_$I
done
# Dave's special hack - grow freespace tree
mkdir $SCRATCH_MNT/S_IFDIR.FMT_BTREE2
for I in `seq 1 5000`; do
touch $SCRATCH_MNT/S_IFDIR.FMT_BTREE2/btree2_dir_file_$I
done
# Remove every other (odds)
for I in `seq 1 2 5000`; do
rm -f $SCRATCH_MNT/S_IFDIR.FMT_BTREE2/btree2_dir_file_$I
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"
# Yes they can! Now...
# Can xfs_metadump cope with this monster?
_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"
# Yes it can; success, all done
status=0
exit