xfstests: move generic tests out of top level dir
[xfstests-dev.git] / 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 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32
33 _cleanup()
34 {
35         cd /
36         umount $SCRATCH_DEV 2>/dev/null
37         rm -f $tmp.*
38 }
39
40 trap "_cleanup; exit \$status" 0 1 2 3 15
41
42 # get standard environment, filters and checks
43 . ./common.rc
44 . ./common.filter
45 . ./common.repair
46
47 [ -z "$XFS_PARALLEL_REPAIR64_PROG" ] && _notrun "parallel repair binary xfs_prepair64 is not installed"
48
49 # force use of parallel repair
50 export XFS_REPAIR_PROG=$XFS_PARALLEL_REPAIR64_PROG
51
52 # nuke the superblock, AGI, AGF, AGFL; then try repair the damage
53
54 _check_ag()
55 {
56         for structure in 'sb 0' 'agf 0' 'agi 0' 'agfl 0'
57         do
58                 echo "Corrupting $structure - setting bits to $1"
59                 _check_repair $1 "$structure"
60         done
61 }
62
63 # real QA test starts here
64 _supported_fs xfs
65 _supported_os IRIX Linux
66
67 _require_scratch
68 _require_no_large_scratch_dev
69
70 DSIZE="-dsize=100m"
71
72 # first we need to ensure there are no bogus secondary
73 # superblocks between the primary and first secondary
74 # superblock (hanging around from earlier tests)...
75 #
76
77 _scratch_mkfs_xfs $DSIZE >/dev/null 2>&1
78 if [ $? -ne 0 ]         # probably don't have a big enough scratch
79 then
80         _notrun "SCRATCH_DEV too small, results would be non-deterministic"
81 else
82         _scratch_mount
83         src/feature -U $SCRATCH_DEV && \
84                 _notrun "UQuota are enabled, test needs controlled sb recovery"
85         src/feature -G $SCRATCH_DEV && \
86                 _notrun "GQuota are enabled, test needs controlled sb recovery"
87         src/feature -P $SCRATCH_DEV && \
88                 _notrun "PQuota are enabled, test needs controlled sb recovery"
89         umount $SCRATCH_DEV
90 fi
91 clear=""
92 eval `xfs_db -r -c "sb 1" -c stack $SCRATCH_DEV | $PERL_PROG -ne '
93         if (/byte offset (\d+), length (\d+)/) {
94                 print "clear=", $1 / 512, "\n"; exit
95         }'`
96 [ -z "$clear" ] && echo "Cannot calculate length to clear"
97 src/devzero -v -1 -n "$clear" $SCRATCH_DEV >/dev/null
98
99 # now kick off the real prepair test...
100 #
101 _scratch_mkfs_xfs $DSIZE | _filter_mkfs 2>$tmp.mkfs
102 . $tmp.mkfs
103 _check_ag 0
104 _check_ag -1
105
106
107 # success, all done
108 status=0
109 exit