3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it would be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 # Functions useful for xfs_repair tests
27 # set values for off/len variables provided by db
28 eval `xfs_db -r -c "$struct" -c stack $SCRATCH_DEV | perl -ne '
29 if (/byte offset (\d+), length (\d+)/) {
30 print "offset=$1\nlength=$2\n"; exit
32 if [ -z "$offset" -o -z "$length" ]; then
33 echo "cannot calculate offset ($offset) or length ($length)"
36 length=`expr $length / 512`
37 src/devzero -v $value -b 1 -n $length -o $offset $SCRATCH_DEV \
38 | perl -npe 's/\d\.\d\dKb/X.XXKb/g'
45 /- agno = / && next; # remove each AG line (variable number)
46 s/(pointer to) (\d+)/\1 INO/;
47 s/(sb root inode value) (\d+)( \(NULLFSINO\))?/\1 INO/;
48 s/(realtime bitmap inode) (\d+)( \(NULLFSINO\))?/\1 INO/;
49 s/(realtime summary inode) (\d+)( \(NULLFSINO\))?/\1 INO/;
50 s/(inconsistent with calculated value) (\d+)/\1 INO/;
51 s/\.+(found)/\1/g; # remove "searching" output
53 s/(bad length -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
54 s/(bad length # -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
55 s/(bad agbno) (\d+)/\1 AGBNO/g;
56 s/(max =) (\d+)/\1 MAX/g;
58 s/(on inode) (\d+)/\1 INO/g;
59 s/(imap claims a free inode) (\d+)/\1 INO/;
60 s/(imap claims in-use inode) (\d+)/\1 INO/;
61 s/(cleared root inode) (\d+)/\1 INO/;
62 s/(resetting inode) (\d+)/\1 INO/;
63 s/(disconnected dir inode) (\d+)/\1 INO/;
65 s/internal log/<TYPEOF> log/g;
66 s/external log on \S+/<TYPEOF> log/g;
67 # realtime subvol - remove this whole line if it appears
68 s/ - generate realtime summary info and bitmap...\n//g;
70 # new xfs repair output filters
72 s/\s+- creating \d+ worker thread\(s\)\n//g;
73 s/\s+- reporting progress in intervals of \d+ minutes\n//g;
74 s/\s+- \d+:\d\d:\d\d:.*\n//g;
75 # 3.1.0 extra accounting output
76 /^agf_/ && next; # remove agf counts
77 /^agi_/ && next; # remove agi counts
78 /^sb_/ && next; # remove sb counts
79 /^agi unlinked/ && next; # remove agi unlinked bucket warning
85 fgrep -v records # lose records in/out lines
88 # do some controlled corrupting & ensure repair recovers us
95 #ensure the filesystem has been dirtied since last repair
98 dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd
100 rm -f $SCRATCH_MNT/sh
103 _zero_position $value "$structure"
104 _scratch_xfs_repair 2>&1 | _filter_repair
106 # some basic sanity checks...
108 _scratch_mount #mount
109 POSIXLY_CORRECT=yes \
110 dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd #open,write
111 POSIXLY_CORRECT=yes \
112 dd if=$SCRATCH_MNT/sh of=/dev/null 2>&1 |_filter_dd #read
113 rm -f $SCRATCH_MNT/sh #unlink
114 umount $SCRATCH_MNT #umount
117 # make sure this script returns success