4 # exercise xfs_repair repairing broken filesystems
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 echo "QA output created by $seq"
30 status=1 # failure is the default!
35 umount $SCRATCH_DEV 2>/dev/null
39 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
46 # link correct .out file
47 _link_out_file $seq.out
49 # nuke the superblock, AGI, AGF, AGFL; then try repair the damage
53 for structure in 'sb 0' 'agf 0' 'agi 0' 'agfl 0'
55 echo "Corrupting $structure - setting bits to $1"
56 _check_repair $1 "$structure" |
57 sed -e '/^error following ag 0 unlinked list$/d'
61 # real QA test starts here
63 _supported_os IRIX Linux
66 _require_no_large_scratch_dev
68 DSIZE="-dsize=100m,agcount=6"
70 # first we need to ensure there are no bogus secondary
71 # superblocks between the primary and first secondary
72 # superblock (hanging around from earlier tests)...
75 _scratch_mkfs_xfs $DSIZE >/dev/null 2>&1
76 if [ $? -ne 0 ] # probably don't have a big enough scratch
78 _notrun "SCRATCH_DEV too small, results would be non-deterministic"
81 src/feature -U $SCRATCH_DEV && \
82 _notrun "UQuota are enabled, test needs controlled sb recovery"
83 src/feature -G $SCRATCH_DEV && \
84 _notrun "GQuota are enabled, test needs controlled sb recovery"
85 src/feature -P $SCRATCH_DEV && \
86 _notrun "PQuota are enabled, test needs controlled sb recovery"
90 eval `xfs_db -r -c "sb 1" -c stack $SCRATCH_DEV | perl -ne '
91 if (/byte offset (\d+), length (\d+)/) {
92 print "clear=", $1 / 512, "\n"; exit
94 [ -z "$clear" ] && echo "Cannot calculate length to clear"
95 src/devzero -v -1 -n "$clear" $SCRATCH_DEV >/dev/null
97 # now kick off the real repair test...
99 _scratch_mkfs_xfs $DSIZE | _filter_mkfs 2>$tmp.mkfs