Files
apfstests/common.repair
T
Dave Chinner fd5fbc5c38 xfsqa: clean up 030 repair output
With the new checks in xfs_repair, it outputs more information
about errors found than previously. This new output can be ignored
for the purposeѕ of this test, so filter it all out. This will
allow the test to run on new and old reapir binaries.

Signed-off-by: Dave Chinner <david@fromorbit.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
2010-05-04 16:01:47 +10:00

119 lines
3.5 KiB
Plaintext

##/bin/bash
#
# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#
# Functions useful for xfs_repair tests
#
_zero_position()
{
value=$1
struct="$2"
# set values for off/len variables provided by db
eval `xfs_db -r -c "$struct" -c stack $SCRATCH_DEV | perl -ne '
if (/byte offset (\d+), length (\d+)/) {
print "offset=$1\nlength=$2\n"; exit
}'`
if [ -z "$offset" -o -z "$length" ]; then
echo "cannot calculate offset ($offset) or length ($length)"
exit
fi
length=`expr $length / 512`
src/devzero -v $value -b 1 -n $length -o $offset $SCRATCH_DEV \
| perl -npe 's/\d\.\d\dKb/X.XXKb/g'
}
_filter_repair()
{
perl -ne '
# for sb
/- agno = / && next; # remove each AG line (variable number)
s/(pointer to) (\d+)/\1 INO/;
s/(sb root inode value) (\d+)( \(NULLFSINO\))?/\1 INO/;
s/(realtime bitmap inode) (\d+)( \(NULLFSINO\))?/\1 INO/;
s/(realtime summary inode) (\d+)( \(NULLFSINO\))?/\1 INO/;
s/(inconsistent with calculated value) (\d+)/\1 INO/;
s/\.+(found)/\1/g; # remove "searching" output
# for agf + agi
s/(bad length -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
s/(bad length # -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
s/(bad agbno) (\d+)/\1 AGBNO/g;
s/(max =) (\d+)/\1 MAX/g;
# for root inos
s/(on inode) (\d+)/\1 INO/g;
s/(imap claims a free inode) (\d+)/\1 INO/;
s/(imap claims in-use inode) (\d+)/\1 INO/;
s/(cleared root inode) (\d+)/\1 INO/;
s/(resetting inode) (\d+)/\1 INO/;
s/(disconnected dir inode) (\d+)/\1 INO/;
# for log
s/internal log/<TYPEOF> log/g;
s/external log on \S+/<TYPEOF> log/g;
# realtime subvol - remove this whole line if it appears
s/ - generate realtime summary info and bitmap...\n//g;
#
# new xfs repair output filters
#
s/\s+- creating \d+ worker thread\(s\)\n//g;
s/\s+- reporting progress in intervals of \d+ minutes\n//g;
s/\s+- \d+:\d\d:\d\d:.*\n//g;
# 3.1.0 extra accounting output
/^agf_/ && next; # remove agf counts
/^agi_/ && next; # remove agi counts
/^sb_/ && next; # remove sb counts
/^agi unlinked/ && next; # remove agi unlinked bucket warning
print;'
}
_filter_dd()
{
fgrep -v records # lose records in/out lines
}
# do some controlled corrupting & ensure repair recovers us
#
_check_repair()
{
value=$1
structure="$2"
#ensure the filesystem has been dirtied since last repair
_scratch_mount
POSIXLY_CORRECT=yes \
dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd
sync
rm -f $SCRATCH_MNT/sh
umount $SCRATCH_MNT
_zero_position $value "$structure"
_scratch_xfs_repair 2>&1 | _filter_repair
# some basic sanity checks...
_check_scratch_fs
_scratch_mount #mount
POSIXLY_CORRECT=yes \
dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd #open,write
POSIXLY_CORRECT=yes \
dd if=$SCRATCH_MNT/sh of=/dev/null 2>&1 |_filter_dd #read
rm -f $SCRATCH_MNT/sh #unlink
umount $SCRATCH_MNT #umount
}
# make sure this script returns success
/bin/true