2010-01-20 10:27:08 +11:00
|
|
|
#! /bin/bash
|
2009-05-28 17:04:15 +02:00
|
|
|
# FS QA Test No. 042
|
|
|
|
|
#
|
|
|
|
|
# xfs_fsr QA tests
|
|
|
|
|
# create a large fragmented file and check that xfs_fsr doesn't corrupt
|
|
|
|
|
# it or the other contents of the filesystem
|
2009-05-12 13:24:15 -05:00
|
|
|
#
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
# Copyright (c) 2000-2002 Silicon Graphics, 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
|
|
|
|
|
#
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
#
|
2001-01-15 05:01:19 +00:00
|
|
|
set +x
|
|
|
|
|
|
|
|
|
|
seq=`basename $0`
|
2013-03-15 12:28:02 +00:00
|
|
|
seqres=$RESULT_DIR/$seq
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount
|
2001-01-15 05:01:19 +00:00
|
|
|
rm -f $tmp.*
|
|
|
|
|
}
|
|
|
|
|
trap "_cleanup ; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
2013-03-15 12:28:04 +00:00
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
# real QA test starts here
|
2004-06-15 07:32:36 +00:00
|
|
|
_supported_fs xfs
|
|
|
|
|
_supported_os IRIX Linux
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
_require_scratch
|
|
|
|
|
|
2009-04-19 21:10:42 -05:00
|
|
|
[ "$XFS_FSR_PROG" = "" ] && _notrun "xfs_fsr not found"
|
|
|
|
|
|
2015-09-21 11:04:59 +10:00
|
|
|
# Test performs several operations to produce a badly fragmented file, then
|
|
|
|
|
# create enough contiguous free space for xfs_fsr to defragment the fragmented
|
|
|
|
|
# file:
|
|
|
|
|
#
|
|
|
|
|
# - create fs with 3 minimum sized (16Mb) allocation groups
|
|
|
|
|
# - create 16x1MB contiguous files which will become large free space extents
|
|
|
|
|
# when deleted
|
|
|
|
|
# - put a small "space" between each of the 16 contiuguous files to ensure we
|
|
|
|
|
# have separated free space extents
|
|
|
|
|
# - fill the remaining free space with a "fill file"
|
|
|
|
|
# - mount/unmount/fill remaining free space with a pad file
|
|
|
|
|
# - punch alternate single block holes in the the "fill file" to create
|
|
|
|
|
# fragmented free space.
|
|
|
|
|
# - use fill2 to generate a very large fragmented file
|
|
|
|
|
# - delete the 16 large contiguous files created initially
|
|
|
|
|
# - run xfs_fsr on the filesystem
|
|
|
|
|
# - check checksums for remaining files
|
2001-04-04 01:45:38 +00:00
|
|
|
|
2013-03-15 12:28:02 +00:00
|
|
|
rm -f $seqres.full
|
2001-04-04 01:45:38 +00:00
|
|
|
_do_die_on_error=message_only
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
echo -n "Make a 48 megabyte filesystem on SCRATCH_DEV and mount... "
|
2006-10-31 16:08:47 +00:00
|
|
|
_scratch_mkfs_xfs -dsize=48m,agcount=3 2>&1 >/dev/null || _fail "mkfs failed"
|
|
|
|
|
_scratch_mount || _fail "mount failed"
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "done"
|
2001-04-04 01:45:38 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
echo -n "Reserve 16 1Mb unfragmented regions... "
|
|
|
|
|
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
|
|
|
|
do
|
2011-02-14 11:22:07 +11:00
|
|
|
_do "$XFS_IO_PROG -f -c \"resvsp 0 1m\" $SCRATCH_MNT/hole$i"
|
|
|
|
|
_do "$XFS_IO_PROG -f -c \"resvsp 0 4k\" $SCRATCH_MNT/space$i"
|
|
|
|
|
_do "xfs_bmap -vp $SCRATCH_MNT/hole$i"
|
2001-01-15 05:01:19 +00:00
|
|
|
done
|
|
|
|
|
echo "done"
|
2001-04-04 01:45:38 +00:00
|
|
|
|
|
|
|
|
# set up filesystem
|
2011-02-14 11:22:07 +11:00
|
|
|
echo -n "Fill filesystem with fill file... "
|
|
|
|
|
for i in `seq 0 1 31`; do
|
2015-09-21 11:04:59 +10:00
|
|
|
_do "$XFS_IO_PROG -f -c \"falloc ${i}m 1m\" $SCRATCH_MNT/fill"
|
2011-02-14 11:22:07 +11:00
|
|
|
done
|
|
|
|
|
_do "xfs_bmap -vp $SCRATCH_MNT/fill"
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "done"
|
2001-04-04 01:45:38 +00:00
|
|
|
# flush the filesystem - make sure there is no space "lost" to pre-allocation
|
2015-12-21 18:07:43 +11:00
|
|
|
_do "_scratch_unmount"
|
2003-05-22 04:16:45 +00:00
|
|
|
_do "_scratch_mount"
|
2015-09-21 11:04:59 +10:00
|
|
|
echo -n "Use up any further available space... "
|
|
|
|
|
_do "$XFS_IO_PROG -f -c \"falloc 0 1m\" $SCRATCH_MNT/pad"
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "done"
|
2001-04-04 01:45:38 +00:00
|
|
|
|
|
|
|
|
# create fragmented file
|
2011-02-14 11:22:07 +11:00
|
|
|
#_do "Delete every second file" "_cull_files"
|
|
|
|
|
echo -n "Punch every second 4k block... "
|
|
|
|
|
for i in `seq 0 8 32768`; do
|
|
|
|
|
# This generates excessive output that significantly slows down the
|
|
|
|
|
# test. It's not necessary for debug, so just bin it.
|
|
|
|
|
$XFS_IO_PROG -f -c "unresvsp ${i}k 4k" $SCRATCH_MNT/fill \
|
|
|
|
|
> /dev/null 2>&1
|
|
|
|
|
done
|
|
|
|
|
_do "xfs_bmap -vp $SCRATCH_MNT/fill"
|
|
|
|
|
_do "sum $SCRATCH_MNT/fill >$tmp.fillsum1"
|
|
|
|
|
echo "done"
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
echo -n "Create one very large file... "
|
|
|
|
|
_do "src/fill2 -d nbytes=16000000,file=$SCRATCH_MNT/fragmented"
|
|
|
|
|
echo "done"
|
2003-05-22 04:16:45 +00:00
|
|
|
_do "xfs_bmap -v $SCRATCH_MNT/fragmented"
|
2001-04-02 05:21:15 +00:00
|
|
|
_do "sum $SCRATCH_MNT/fragmented >$tmp.sum1"
|
2001-04-04 01:45:38 +00:00
|
|
|
_do "Remove other files" "rm -rf $SCRATCH_MNT/{pad,hole*}"
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2001-04-04 01:45:38 +00:00
|
|
|
# defragment
|
2009-05-08 22:03:40 -05:00
|
|
|
_do "Run xfs_fsr on filesystem" "$XFS_FSR_PROG -v $SCRATCH_MNT/fragmented"
|
2003-05-22 04:16:45 +00:00
|
|
|
_do "xfs_bmap -v $SCRATCH_MNT/fragmented"
|
2011-02-14 11:22:07 +11:00
|
|
|
|
|
|
|
|
echo -n "Check fill file... "
|
|
|
|
|
_do "sum $SCRATCH_MNT/fill >$tmp.fillsum2"
|
|
|
|
|
if ! _do "diff $tmp.fillsum1 $tmp.fillsum2"; then
|
|
|
|
|
echo "fail"
|
2013-03-15 12:28:02 +00:00
|
|
|
echo "Fill file is corrupt/missing after fsr. Test failed see $seqres.full"
|
2011-02-14 11:22:07 +11:00
|
|
|
status=1; exit
|
|
|
|
|
fi
|
|
|
|
|
echo "done"
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2001-04-04 01:45:38 +00:00
|
|
|
# check
|
2001-01-15 05:01:19 +00:00
|
|
|
echo -n "Check large file... "
|
2001-04-02 05:21:15 +00:00
|
|
|
_do "sum $SCRATCH_MNT/fragmented >$tmp.sum2"
|
2001-04-04 01:45:38 +00:00
|
|
|
if ! _do "diff $tmp.sum1 $tmp.sum2"; then
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "fail"
|
2013-03-15 12:28:02 +00:00
|
|
|
echo "File is corrupt/missing after fsr. Test failed see $seqres.full"
|
2001-01-15 05:01:19 +00:00
|
|
|
status=1; exit
|
|
|
|
|
fi
|
|
|
|
|
echo "done"
|
|
|
|
|
|
|
|
|
|
# success, all done
|
2001-02-24 03:53:46 +00:00
|
|
|
echo "xfs_fsr tests passed."
|
2001-01-15 05:01:19 +00:00
|
|
|
status=0 ; exit
|