5 # create a large fragmented file and check that xfs_fsr doesn't corrupt
6 # it or the other contents of the filesystem
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or modify it
12 # under the terms of version 2 of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 # Further, this software is distributed without any warranty that it is
20 # free of the rightful claim of any third person regarding infringement
21 # or the like. Any license provided herein, whether implied or
22 # otherwise, applies only to this software file. Patent licenses, if
23 # any, provided herein do not apply to combinations of this program with
24 # other software, or any other product whatsoever.
26 # You should have received a copy of the GNU General Public License along
27 # with this program; if not, write the Free Software Foundation, Inc., 59
28 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
30 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
31 # Mountain View, CA 94043, or:
35 # For further information regarding this notice, see:
37 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
38 #-----------------------------------------------------------------------
45 echo "QA output created by $seq"
49 status=1 # failure is the default!
56 trap "_cleanup ; exit \$status" 0 1 2 3 15
58 # get standard environment, filters and checks
62 # real QA test starts here
68 perl -e "\$manifest=\"$tmp.manifest\";" -e '
69 open MANIFEST, $manifest;
72 open MANIFEST, ">$manifest";
73 for ($i = 0; $i < @in; $i++) {
74 if (($i+1) % 2 == 0) {
75 # remove every second file
77 if (unlink($s) != 1) {
78 print "_cull_files: could not delete \"$s\"\n";
83 print MANIFEST $in[$i];
90 # create a large contiguous file using dd
91 # use fill2fs to fill the filesystem up with 4k sized files
92 # fill any remaining space using dd
93 # delete every second 4k file - remaining free space should be fragmented
94 # use fill2 to generate a very large file - run it until it fails producing a truncated file
95 # delete the dd-generated file
96 # run xfs_fsr on the filesystem
97 # check checksums for remaining files
98 # create 3 minimum sized (16Mb) allocation groups
99 # xfs_repair is going to need three to verify the superblock
102 _do_die_on_error=message_only
104 echo -n "Make a 48 megabyte filesystem on SCRATCH_DEV and mount... "
105 _do "_scratch_mkfs_xfs -dsize=48m,agcount=3"
109 echo -n "Reserve 16 1Mb unfragmented regions... "
110 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
112 _do "dd if=/dev/zero of=$SCRATCH_MNT/hole$i bs=4096 count=256"
113 _do "dd if=/dev/zero of=$SCRATCH_MNT/space$i bs=4096 count=1"
114 _do "xfs_bmap -v $SCRATCH_MNT/hole$i"
119 echo -n "Fill filesystem with 4k files, generate manifest... "
120 fill_options="--verbose --seed=0 --filesize=4096 --stddev=0 --sync=1000000"
121 _do "src/fill2fs $fill_options --dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest"
123 # flush the filesystem - make sure there is no space "lost" to pre-allocation
124 _do "umount $SCRATCH_MNT"
126 echo -n "Use up any further available space using dd... "
127 _do "dd if=/dev/zero of=$SCRATCH_MNT/pad bs=4096"
130 # create fragmented file
131 _do "Delete every second file" "_cull_files"
132 echo -n "Create one very large file... "
133 _do "src/fill2 -d nbytes=16000000,file=$SCRATCH_MNT/fragmented"
135 _do "xfs_bmap -v $SCRATCH_MNT/fragmented"
136 _do "sum $SCRATCH_MNT/fragmented >$tmp.sum1"
137 _do "Remove other files" "rm -rf $SCRATCH_MNT/{pad,hole*}"
140 _do "Run xfs_fsr on filesystem" "xfs_fsr -v $SCRATCH_DEV"
141 _do "xfs_bmap -v $SCRATCH_MNT/fragmented"
142 _do "Check 4k files" "src/fill2fs_check $tmp.manifest"
145 echo -n "Check large file... "
146 _do "sum $SCRATCH_MNT/fragmented >$tmp.sum2"
147 if ! _do "diff $tmp.sum1 $tmp.sum2"; then
149 echo "File is corrupt/missing after fsr. Test failed see $seq.full"
153 _do "Checking filesystem" "_check_scratch_fs"
156 echo "xfs_fsr tests passed."