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-2002 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];
91 # create a large contiguous file using dd
92 # use fill2fs to fill the filesystem up with 4k sized files
93 # fill any remaining space using dd
94 # delete every second 4k file - remaining free space should be fragmented
95 # use fill2 to generate a very large file - run it until it fails producing a truncated file
96 # delete the dd-generated file
97 # run xfs_fsr on the filesystem
98 # check checksums for remaining files
99 # create 3 minimum sized (16Mb) allocation groups
100 # xfs_repair is going to need three to verify the superblock
103 bmap_cmd="xfs_bmap -v"
104 mnt_cmd="mount -t xfs $SCRATCH_DEV $SCRATCH_MNT"
105 _do_die_on_error=message_only
107 echo -n "Make a 48 megabyte filesystem on SCRATCH_DEV and mount... "
108 _do "mkfs_xfs -dsize=48m,agcount=3 $SCRATCH_DEV"
112 echo -n "Reserve 16 1Mb unfragmented regions... "
113 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
115 _do "dd if=/dev/zero of=$SCRATCH_MNT/hole$i bs=4096 count=256"
116 _do "dd if=/dev/zero of=$SCRATCH_MNT/space$i bs=4096 count=1"
117 _do "$bmap_cmd $SCRATCH_MNT/hole$i"
122 echo -n "Fill filesystem with 4k files, generate manifest... "
123 fill_options="--verbose --seed=0 --filesize=4096 --stddev=0 --sync=1000000"
124 _do "src/fill2fs $fill_options --dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest"
126 # flush the filesystem - make sure there is no space "lost" to pre-allocation
127 _do "umount $SCRATCH_MNT"
129 echo -n "Use up any further available space using dd... "
130 _do "dd if=/dev/zero of=$SCRATCH_MNT/pad bs=4096"
133 # create fragmented file
134 _do "Delete every second file" "_cull_files"
135 echo -n "Create one very large file... "
136 _do "src/fill2 -d nbytes=16000000,file=$SCRATCH_MNT/fragmented"
138 _do "$bmap_cmd $SCRATCH_MNT/fragmented"
139 _do "sum $SCRATCH_MNT/fragmented >$tmp.sum1"
140 _do "Remove other files" "rm -rf $SCRATCH_MNT/{pad,hole*}"
143 _do "Run xfs_fsr on filesystem" "xfs_fsr -v $SCRATCH_DEV"
144 _do "$bmap_cmd $SCRATCH_MNT/fragmented"
145 _do "Check 4k files" "src/fill2fs_check $tmp.manifest"
148 echo -n "Check large file... "
149 _do "sum $SCRATCH_MNT/fragmented >$tmp.sum2"
150 if ! _do "diff $tmp.sum1 $tmp.sum2"; then
152 echo "File is corrupt/missing after fsr. Test failed see $seq.full"
156 _do "Checking filesystem" "_check_fs $SCRATCH_DEV"
159 echo "xfs_fsr tests passed."