xfstests: convert tests to use new results directory
[xfstests-dev.git] / tests / xfs / 148
1 #! /bin/bash
2 # FS QA Test No. 148
3 #
4 # Exercise xfs parallel repair on broken filesystems
5 # This is a clone of test 030 useing xfs_prepair64 instead of xfs_repair
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35
36 _cleanup()
37 {
38         cd /
39         umount $SCRATCH_DEV 2>/dev/null
40         rm -f $tmp.*
41 }
42
43 trap "_cleanup; exit \$status" 0 1 2 3 15
44
45 # get standard environment, filters and checks
46 . ./common.rc
47 . ./common.filter
48 . ./common.repair
49
50 [ -z "$XFS_PARALLEL_REPAIR64_PROG" ] && _notrun "parallel repair binary xfs_prepair64 is not installed"
51
52 # force use of parallel repair
53 export XFS_REPAIR_PROG=$XFS_PARALLEL_REPAIR64_PROG
54
55 # nuke the superblock, AGI, AGF, AGFL; then try repair the damage
56
57 _check_ag()
58 {
59         for structure in 'sb 0' 'agf 0' 'agi 0' 'agfl 0'
60         do
61                 echo "Corrupting $structure - setting bits to $1"
62                 _check_repair $1 "$structure"
63         done
64 }
65
66 # real QA test starts here
67 _supported_fs xfs
68 _supported_os IRIX Linux
69
70 _require_scratch
71 _require_no_large_scratch_dev
72
73 DSIZE="-dsize=100m"
74
75 # first we need to ensure there are no bogus secondary
76 # superblocks between the primary and first secondary
77 # superblock (hanging around from earlier tests)...
78 #
79
80 _scratch_mkfs_xfs $DSIZE >/dev/null 2>&1
81 if [ $? -ne 0 ]         # probably don't have a big enough scratch
82 then
83         _notrun "SCRATCH_DEV too small, results would be non-deterministic"
84 else
85         _scratch_mount
86         src/feature -U $SCRATCH_DEV && \
87                 _notrun "UQuota are enabled, test needs controlled sb recovery"
88         src/feature -G $SCRATCH_DEV && \
89                 _notrun "GQuota are enabled, test needs controlled sb recovery"
90         src/feature -P $SCRATCH_DEV && \
91                 _notrun "PQuota are enabled, test needs controlled sb recovery"
92         umount $SCRATCH_DEV
93 fi
94 clear=""
95 eval `xfs_db -r -c "sb 1" -c stack $SCRATCH_DEV | $PERL_PROG -ne '
96         if (/byte offset (\d+), length (\d+)/) {
97                 print "clear=", $1 / 512, "\n"; exit
98         }'`
99 [ -z "$clear" ] && echo "Cannot calculate length to clear"
100 src/devzero -v -1 -n "$clear" $SCRATCH_DEV >/dev/null
101
102 # now kick off the real prepair test...
103 #
104 _scratch_mkfs_xfs $DSIZE | _filter_mkfs 2>$tmp.mkfs
105 . $tmp.mkfs
106 _check_ag 0
107 _check_ag -1
108
109
110 # success, all done
111 status=0
112 exit