2010-01-20 10:27:08 +11:00
|
|
|
#! /bin/bash
|
2009-05-28 17:04:15 +02:00
|
|
|
# FS QA Test No. 030
|
|
|
|
|
#
|
|
|
|
|
# exercise xfs_repair repairing broken filesystems
|
2009-05-12 13:24:15 -05:00
|
|
|
#
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
# 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
|
|
|
|
|
#
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
#
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2013-03-15 12:28:03 +00:00
|
|
|
seqfull=$0
|
2001-01-15 05:01:19 +00:00
|
|
|
seq=`basename $0`
|
2013-03-15 12:28:02 +00:00
|
|
|
seqres=$RESULT_DIR/$seq
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
2001-04-23 07:37:39 +00:00
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
2004-06-15 07:32:36 +00:00
|
|
|
cd /
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount 2>/dev/null
|
2001-04-23 07:37:39 +00:00
|
|
|
rm -f $tmp.*
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
2013-03-15 12:28:04 +00:00
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
|
|
|
|
. ./common/repair
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
# nuke the superblock, AGI, AGF, AGFL; then try repair the damage
|
2008-03-19 03:18:01 +00:00
|
|
|
#
|
2001-01-15 05:01:19 +00:00
|
|
|
_check_ag()
|
|
|
|
|
{
|
|
|
|
|
for structure in 'sb 0' 'agf 0' 'agi 0' 'agfl 0'
|
|
|
|
|
do
|
|
|
|
|
echo "Corrupting $structure - setting bits to $1"
|
2016-04-05 11:48:16 +10:00
|
|
|
_check_repair $1 "$structure" | uniq |
|
2014-05-13 15:26:59 +10:00
|
|
|
sed -e '/^error following ag 0 unlinked list$/d' \
|
2016-03-23 17:37:32 +11:00
|
|
|
-e '/^bad agbno AGBNO for finobt/d' \
|
|
|
|
|
-e '/^bad agbno AGBNO for rmapbt/d' \
|
|
|
|
|
-e '/^bad agbno AGBNO for refcntbt/d' \
|
2017-01-28 09:38:25 -08:00
|
|
|
-e '/^Missing reverse-mapping record.*/d' \
|
2017-11-01 14:47:36 -07:00
|
|
|
-e '/^unknown block state, ag AGNO, block.*/d'
|
2001-01-15 05:01:19 +00:00
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# real QA test starts here
|
2004-06-15 07:32:36 +00:00
|
|
|
_supported_fs xfs
|
2017-07-20 21:22:05 -07:00
|
|
|
_supported_os Linux
|
2004-06-15 07:32:36 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
_require_scratch
|
2013-03-15 11:53:21 +00:00
|
|
|
_require_no_large_scratch_dev
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2008-03-19 03:18:01 +00:00
|
|
|
DSIZE="-dsize=100m,agcount=6"
|
2002-05-06 07:44:22 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
# first we need to ensure there are no bogus secondary
|
|
|
|
|
# superblocks between the primary and first secondary
|
|
|
|
|
# superblock (hanging around from earlier tests)...
|
2005-12-09 02:52:22 +00:00
|
|
|
#
|
2002-05-06 07:44:22 +00:00
|
|
|
|
2003-05-22 04:16:45 +00:00
|
|
|
_scratch_mkfs_xfs $DSIZE >/dev/null 2>&1
|
2001-01-15 05:01:19 +00:00
|
|
|
if [ $? -ne 0 ] # probably don't have a big enough scratch
|
|
|
|
|
then
|
2001-04-23 07:37:39 +00:00
|
|
|
_notrun "SCRATCH_DEV too small, results would be non-deterministic"
|
2001-01-15 05:01:19 +00:00
|
|
|
else
|
2003-05-22 04:16:45 +00:00
|
|
|
_scratch_mount
|
2001-04-23 07:37:39 +00:00
|
|
|
src/feature -U $SCRATCH_DEV && \
|
2005-12-09 02:52:22 +00:00
|
|
|
_notrun "UQuota are enabled, test needs controlled sb recovery"
|
2001-04-23 07:37:39 +00:00
|
|
|
src/feature -G $SCRATCH_DEV && \
|
2005-12-09 02:52:22 +00:00
|
|
|
_notrun "GQuota are enabled, test needs controlled sb recovery"
|
2005-06-03 15:10:36 +00:00
|
|
|
src/feature -P $SCRATCH_DEV && \
|
2005-12-09 02:52:22 +00:00
|
|
|
_notrun "PQuota are enabled, test needs controlled sb recovery"
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount
|
2001-01-15 05:01:19 +00:00
|
|
|
fi
|
2001-04-23 07:37:39 +00:00
|
|
|
clear=""
|
|
|
|
|
eval `xfs_db -r -c "sb 1" -c stack $SCRATCH_DEV | perl -ne '
|
|
|
|
|
if (/byte offset (\d+), length (\d+)/) {
|
|
|
|
|
print "clear=", $1 / 512, "\n"; exit
|
|
|
|
|
}'`
|
|
|
|
|
[ -z "$clear" ] && echo "Cannot calculate length to clear"
|
|
|
|
|
src/devzero -v -1 -n "$clear" $SCRATCH_DEV >/dev/null
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
# now kick off the real repair test...
|
2005-12-09 02:52:22 +00:00
|
|
|
#
|
2003-05-22 04:16:45 +00:00
|
|
|
_scratch_mkfs_xfs $DSIZE | _filter_mkfs 2>$tmp.mkfs
|
2004-06-15 07:32:36 +00:00
|
|
|
. $tmp.mkfs
|
2001-01-15 05:01:19 +00:00
|
|
|
_check_ag 0
|
|
|
|
|
_check_ag -1
|
|
|
|
|
|
|
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|