2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
7 # exercise xfs_repair repairing broken filesystems
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
21 _scratch_unmount 2>/dev/null
25 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # get standard environment, filters and checks
33 # nuke the superblock, AGI, AGF, AGFL; then try repair the damage
37 for structure in 'sb 0' 'agf 0' 'agi 0' 'agfl 0'
39 echo "Corrupting $structure - setting bits to $1"
40 _check_repair $1 "$structure" | uniq |
41 sed -e '/^error following ag 0 unlinked list$/d' \
42 -e '/^bad agbno AGBNO for finobt/d' \
43 -e '/^bad agbno AGBNO for rmapbt/d' \
44 -e '/^bad agbno AGBNO for refcntbt/d' \
45 -e '/^agf has bad CRC/d' \
46 -e '/^agi has bad CRC/d' \
47 -e '/^bad inobt block count/d' \
48 -e '/^bad finobt block count/d' \
49 -e '/^Missing reverse-mapping record.*/d' \
50 -e '/^bad levels LEVELS for [a-z]* root.*/d' \
51 -e '/^unknown block state, ag AGNO, block.*/d'
55 # real QA test starts here
59 _require_no_large_scratch_dev
61 DSIZE="-dsize=100m,agcount=6"
63 # first we need to ensure there are no bogus secondary
64 # superblocks between the primary and first secondary
65 # superblock (hanging around from earlier tests)...
68 _scratch_mkfs_xfs $DSIZE >/dev/null 2>&1
69 if [ $? -ne 0 ] # probably don't have a big enough scratch
71 _notrun "SCRATCH_DEV too small, results would be non-deterministic"
73 _qmount_option noquota
75 $here/src/feature -U $SCRATCH_DEV && \
76 _notrun "UQuota are enabled, test needs controlled sb recovery"
77 $here/src/feature -G $SCRATCH_DEV && \
78 _notrun "GQuota are enabled, test needs controlled sb recovery"
79 $here/src/feature -P $SCRATCH_DEV && \
80 _notrun "PQuota are enabled, test needs controlled sb recovery"
84 eval `_scratch_xfs_db -r -c "sb 1" -c stack | perl -ne '
85 if (/byte offset (\d+), length (\d+)/) {
86 print "clear=", $1 / 512, "\n"; exit
88 [ -z "$clear" ] && echo "Cannot calculate length to clear"
89 $here/src/devzero -v -1 -n "$clear" $SCRATCH_DEV >/dev/null
91 # now kick off the real repair test...
93 _scratch_mkfs_xfs $DSIZE | _filter_mkfs 2>$tmp.mkfs