2001-01-15 05:01:19 +00:00
|
|
|
#! /bin/sh
|
2004-06-15 07:32:36 +00:00
|
|
|
# FS QA Test No. 031
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
|
|
|
|
# exercise xfs_repair - ensure repeated use doesn't corrupt
|
|
|
|
|
#
|
|
|
|
|
#-----------------------------------------------------------------------
|
2002-06-04 23:07:56 +00:00
|
|
|
# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
|
2001-01-15 05:01:19 +00:00
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# creator
|
|
|
|
|
owner=nathans@sgi.com
|
|
|
|
|
|
|
|
|
|
seq=`basename $0`
|
|
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
|
|
|
|
|
rm -f $seq.full
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
|
. ./common.rc
|
|
|
|
|
. ./common.filter
|
|
|
|
|
|
2004-06-15 07:32:36 +00:00
|
|
|
# link correct .out file
|
|
|
|
|
_link_out_file $seq.out
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
_check_repair()
|
|
|
|
|
{
|
2003-05-22 04:16:45 +00:00
|
|
|
_scratch_xfs_repair >$tmp.0 2>&1
|
2001-01-15 05:01:19 +00:00
|
|
|
for i in 1 2 3 4
|
|
|
|
|
do
|
|
|
|
|
echo "Repairing, iteration $i" | tee -a $seq.full
|
2003-05-22 04:16:45 +00:00
|
|
|
_scratch_xfs_repair 2>&1 | tee -a $seq.full >$tmp.$i
|
2002-05-10 05:56:02 +00:00
|
|
|
diff $tmp.0 $tmp.$i >> $seq.full
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "ERROR: repair round $i differs (see $seq.full)"
|
|
|
|
|
break
|
|
|
|
|
fi
|
2001-01-15 05:01:19 +00:00
|
|
|
# echo all interesting stuff...
|
|
|
|
|
perl -ne '
|
|
|
|
|
s/(rebuilding directory inode) (\d+)/\1 INO/g;
|
2003-05-22 04:16:45 +00:00
|
|
|
s/internal log/<TYPEOF> log/g;
|
|
|
|
|
s/external log on \S+/<TYPEOF> log/g;
|
2001-01-15 05:01:19 +00:00
|
|
|
/^\S+/ && print;
|
|
|
|
|
' $tmp.$i
|
|
|
|
|
done
|
|
|
|
|
echo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# prototype file to create various directory forms
|
|
|
|
|
_create_proto()
|
|
|
|
|
{
|
|
|
|
|
total=$1
|
|
|
|
|
count=0
|
|
|
|
|
|
2003-06-01 21:40:24 +00:00
|
|
|
# take inode size into account for non-shortform directories...
|
|
|
|
|
[ $total -gt 0 ] && total=`expr $total \* $isize / 512`
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
cat >$tmp.proto <<EOF
|
|
|
|
|
DUMMY1
|
|
|
|
|
0 0
|
|
|
|
|
: root directory
|
|
|
|
|
d--777 3 1
|
|
|
|
|
lost+found d--755 3 1
|
|
|
|
|
$
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
while [ $count -lt $total ]
|
|
|
|
|
do
|
|
|
|
|
count=`expr $count + 1`
|
|
|
|
|
cat >>$tmp.proto <<EOF
|
|
|
|
|
${count}_of_${total}_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---755 3 1 /bin/true
|
|
|
|
|
EOF
|
|
|
|
|
done
|
|
|
|
|
echo '$' >>$tmp.proto
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# real QA test starts here
|
2004-06-15 07:32:36 +00:00
|
|
|
_supported_fs xfs
|
|
|
|
|
_supported_os IRIX Linux
|
|
|
|
|
|
2003-08-29 06:04:54 +00:00
|
|
|
_require_nobigloopfs
|
2001-01-15 05:01:19 +00:00
|
|
|
_require_scratch
|
|
|
|
|
|
|
|
|
|
# sanity test - default + one root directory entry
|
2003-06-01 21:40:24 +00:00
|
|
|
# Note: must do this proto/mkfs now for later inode size calcs
|
2001-01-15 05:01:19 +00:00
|
|
|
_create_proto 0
|
2006-05-22 03:51:26 +00:00
|
|
|
echo "=== one entry (shortform)"
|
|
|
|
|
_scratch_mkfs_xfs -p $tmp.proto >$tmp.mkfs0 2>&1
|
2003-06-01 21:40:24 +00:00
|
|
|
_filter_mkfs <$tmp.mkfs0 >/dev/null 2>$tmp.mkfs
|
2004-06-15 07:32:36 +00:00
|
|
|
. $tmp.mkfs
|
2001-01-15 05:01:19 +00:00
|
|
|
_check_repair
|
|
|
|
|
|
|
|
|
|
# block-form root directory & repeat
|
|
|
|
|
_create_proto 20
|
2006-05-22 03:51:26 +00:00
|
|
|
echo "=== twenty entries (block form)"
|
|
|
|
|
_scratch_mkfs_xfs -p $tmp.proto | _filter_mkfs >/dev/null 2>&1
|
2001-01-15 05:01:19 +00:00
|
|
|
_check_repair
|
|
|
|
|
|
|
|
|
|
# leaf-form root directory & repeat
|
|
|
|
|
_create_proto 1000
|
2006-05-22 03:51:26 +00:00
|
|
|
echo "=== thousand entries (leaf form)"
|
|
|
|
|
_scratch_mkfs_xfs -p $tmp.proto | _filter_mkfs >/dev/null 2>&1
|
2001-01-15 05:01:19 +00:00
|
|
|
_check_repair
|
|
|
|
|
|
|
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|