2001-01-15 05:01:19 +00:00
|
|
|
#! /bin/sh
|
|
|
|
|
# XFS QA Test No. 042
|
|
|
|
|
# $Id: 042,v 1.2 2000/09/27 00:24:22 ajag Exp ajag $
|
|
|
|
|
#
|
2001-02-24 03:53:46 +00:00
|
|
|
# xfs_fsr QA tests
|
|
|
|
|
# create a large fragmented file and check that xfs_fsr doesn't corrupt
|
2001-01-15 05:01:19 +00:00
|
|
|
# it or the other contents of the filesystem
|
|
|
|
|
#
|
|
|
|
|
#-----------------------------------------------------------------------
|
2002-06-04 23:07:56 +00:00
|
|
|
# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
# under the terms of version 2 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.
|
|
|
|
|
#
|
|
|
|
|
# Further, this software is distributed without any warranty that it is
|
|
|
|
|
# free of the rightful claim of any third person regarding infringement
|
|
|
|
|
# or the like. Any license provided herein, whether implied or
|
|
|
|
|
# otherwise, applies only to this software file. Patent licenses, if
|
|
|
|
|
# any, provided herein do not apply to combinations of this program with
|
|
|
|
|
# other software, or any other product whatsoever.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
|
# with this program; if not, write the Free Software Foundation, Inc., 59
|
|
|
|
|
# Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
|
|
|
|
#
|
|
|
|
|
# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
|
|
|
|
# Mountain View, CA 94043, or:
|
|
|
|
|
#
|
|
|
|
|
# http://www.sgi.com
|
|
|
|
|
#
|
|
|
|
|
# For further information regarding this notice, see:
|
|
|
|
|
#
|
|
|
|
|
# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
set +x
|
|
|
|
|
# creator
|
|
|
|
|
owner=ajag@melbourne.sgi.com
|
|
|
|
|
|
|
|
|
|
seq=`basename $0`
|
|
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
|
|
|
|
umount $SCRATCH_MNT
|
|
|
|
|
rm -f $tmp.*
|
|
|
|
|
}
|
|
|
|
|
trap "_cleanup ; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
|
. ./common.rc
|
|
|
|
|
. ./common.filter
|
|
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
|
|
|
|
|
_require_scratch
|
|
|
|
|
|
|
|
|
|
_cull_files()
|
|
|
|
|
{
|
|
|
|
|
perl -e "\$manifest=\"$tmp.manifest\";" -e '
|
|
|
|
|
open MANIFEST, $manifest;
|
|
|
|
|
@in = <MANIFEST>;
|
|
|
|
|
close MANIFEST;
|
|
|
|
|
open MANIFEST, ">$manifest";
|
|
|
|
|
for ($i = 0; $i < @in; $i++) {
|
|
|
|
|
if (($i+1) % 2 == 0) {
|
|
|
|
|
# remove every second file
|
|
|
|
|
chomp($s = $in[$i]);
|
|
|
|
|
if (unlink($s) != 1) {
|
|
|
|
|
print "_cull_files: could not delete \"$s\"\n";
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
print MANIFEST $in[$i];
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-04-04 01:45:38 +00:00
|
|
|
close MANIFEST;
|
|
|
|
|
exit(0);'
|
2001-01-15 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# create a large contiguous file using dd
|
|
|
|
|
# use fill2fs to fill the filesystem up with 4k sized files
|
|
|
|
|
# fill any remaining space using dd
|
|
|
|
|
# delete every second 4k file - remaining free space should be fragmented
|
|
|
|
|
# use fill2 to generate a very large file - run it until it fails producing a truncated file
|
|
|
|
|
# delete the dd-generated file
|
2001-02-24 03:53:46 +00:00
|
|
|
# run xfs_fsr on the filesystem
|
2001-01-15 05:01:19 +00:00
|
|
|
# check checksums for remaining files
|
|
|
|
|
# create 3 minimum sized (16Mb) allocation groups
|
|
|
|
|
# xfs_repair is going to need three to verify the superblock
|
2001-04-04 01:45:38 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
rm -f $seq.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... "
|
2003-05-22 04:16:45 +00:00
|
|
|
_do "_scratch_mkfs_xfs -dsize=48m,agcount=3"
|
|
|
|
|
_do "_scratch_mount"
|
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
|
|
|
|
|
_do "dd if=/dev/zero of=$SCRATCH_MNT/hole$i bs=4096 count=256"
|
|
|
|
|
_do "dd if=/dev/zero of=$SCRATCH_MNT/space$i bs=4096 count=1"
|
2003-05-22 04:16:45 +00:00
|
|
|
_do "xfs_bmap -v $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
|
2001-01-15 05:01:19 +00:00
|
|
|
echo -n "Fill filesystem with 4k files, generate manifest... "
|
2001-04-04 01:45:38 +00:00
|
|
|
fill_options="--verbose --seed=0 --filesize=4096 --stddev=0 --sync=1000000"
|
|
|
|
|
_do "src/fill2fs $fill_options --dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest"
|
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
|
|
|
|
|
_do "umount $SCRATCH_MNT"
|
2003-05-22 04:16:45 +00:00
|
|
|
_do "_scratch_mount"
|
2001-01-15 05:01:19 +00:00
|
|
|
echo -n "Use up any further available space using dd... "
|
|
|
|
|
_do "dd if=/dev/zero of=$SCRATCH_MNT/pad bs=4096"
|
|
|
|
|
echo "done"
|
2001-04-04 01:45:38 +00:00
|
|
|
|
|
|
|
|
# create fragmented file
|
|
|
|
|
_do "Delete every second file" "_cull_files"
|
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
|
|
|
|
|
_do "Run xfs_fsr on filesystem" "xfs_fsr -v $SCRATCH_DEV"
|
2003-05-22 04:16:45 +00:00
|
|
|
_do "xfs_bmap -v $SCRATCH_MNT/fragmented"
|
2001-04-04 01:45:38 +00:00
|
|
|
_do "Check 4k files" "src/fill2fs_check $tmp.manifest"
|
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"
|
|
|
|
|
echo "File is corrupt/missing after fsr. Test failed see $seq.full"
|
|
|
|
|
status=1; exit
|
|
|
|
|
fi
|
|
|
|
|
echo "done"
|
2003-05-22 04:16:45 +00:00
|
|
|
_do "Checking filesystem" "_check_scratch_fs"
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
# 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
|