3 # $Id: 042,v 1.2 2000/09/27 00:24:22 ajag Exp ajag $
6 # create a large fragmented file and check that xfs_fsr doesn't corrupt
7 # it or the other contents of the filesystem
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or modify it
13 # under the terms of version 2 of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 # Further, this software is distributed without any warranty that it is
21 # free of the rightful claim of any third person regarding infringement
22 # or the like. Any license provided herein, whether implied or
23 # otherwise, applies only to this software file. Patent licenses, if
24 # any, provided herein do not apply to combinations of this program with
25 # other software, or any other product whatsoever.
27 # You should have received a copy of the GNU General Public License along
28 # with this program; if not, write the Free Software Foundation, Inc., 59
29 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
31 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
32 # Mountain View, CA 94043, or:
36 # For further information regarding this notice, see:
38 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
39 #-----------------------------------------------------------------------
43 owner=ajag@melbourne.sgi.com
46 echo "QA output created by $seq"
50 status=1 # failure is the default!
57 trap "_cleanup ; exit \$status" 0 1 2 3 15
59 # get standard environment, filters and checks
63 # real QA test starts here
69 perl -e "\$manifest=\"$tmp.manifest\";" -e '
70 open MANIFEST, $manifest;
73 open MANIFEST, ">$manifest";
74 for ($i = 0; $i < @in; $i++) {
75 if (($i+1) % 2 == 0) {
76 # remove every second file
78 if (unlink($s) != 1) {
79 print "_cull_files: could not delete \"$s\"\n";
84 print MANIFEST $in[$i];
92 if [ $# -ne 1 ]; then echo "Usage: _do \"cmd\"" 1>&2 ; exit 1; fi
93 echo "*** $1" >>$seq.full
94 eval "$1 2>&1 | _fix_malloc >>$seq.full"
98 # create a large contiguous file using dd
99 # use fill2fs to fill the filesystem up with 4k sized files
100 # fill any remaining space using dd
101 # delete every second 4k file - remaining free space should be fragmented
102 # use fill2 to generate a very large file - run it until it fails producing a truncated file
103 # delete the dd-generated file
104 # run xfs_fsr on the filesystem
105 # check checksums for remaining files
107 # create 3 minimum sized (16Mb) allocation groups
108 # xfs_repair is going to need three to verify the superblock
110 echo -n "Make a 48 megabyte filesystem on SCRATCH_DEV and mount... "
111 _do "mkfs -t xfs -d size=48m,agcount=3 -l internal -f $SCRATCH_DEV"
112 _do "mount -t xfs $SCRATCH_DEV $SCRATCH_MNT"
114 echo -n "Reserve 16 1Mb unfragmented regions... "
115 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
117 _do "dd if=/dev/zero of=$SCRATCH_MNT/hole$i bs=4096 count=256"
118 _do "dd if=/dev/zero of=$SCRATCH_MNT/space$i bs=4096 count=1"
119 _do "xfs_bmap $SCRATCH_MNT/hole$i"
122 echo -n "Fill filesystem with 4k files, generate manifest... "
123 _do "(src/fill2fs --verbose --dir=$SCRATCH_MNT/fill --seed=0 --filesize=4096 --stddev=0 --list=$tmp.manifest)"
125 echo -n "Use up any further available space using dd... "
126 _do "dd if=/dev/zero of=$SCRATCH_MNT/pad bs=4096"
128 echo -n "Delete every second file... "
129 if ! _do "_cull_files"; then
131 echo "Could not cull files. Test failed see $seq.full"
135 echo -n "Create one very large file... "
136 _do "src/fill2 -d nbytes=16000000,file=$SCRATCH_MNT/fragmented"
138 _do "xfs_bmap $SCRATCH_MNT/fragmented"
139 _do "(sum $SCRATCH_MNT/fragmented >$tmp.sum1)"
140 echo -n "Remove other files... "
141 _do "rm -rf $SCRATCH_MNT/{pad,hole*}"
145 _do "umount $SCRATCH_MNT"
146 _do "mount -t xfs $SCRATCH_DEV $SCRATCH_MNT"
148 echo -n "Run xfs_fsr on filesystem... "
149 _do "xfs_fsr -v $SCRATCH_DEV"
151 _do "xfs_bmap $SCRATCH_MNT/fragmented"
153 echo -n "Check 4k files... "
154 if ! _do "src/fill2fs_check $tmp.manifest"; then
156 echo "4k file is corrupt/missing after fsr. Test failed see $seq.full"
160 echo -n "Check large file... "
161 _do "(sum $SCRATCH_MNT/fragmented >$tmp.sum2)"
162 if ! diff $tmp.sum1 $tmp.sum2; then
164 echo "File is corrupt/missing after fsr. Test failed see $seq.full"
169 echo -n "Checking filesystem... "
170 _check_fs $SCRATCH_DEV
173 echo "xfs_fsr tests passed."