-#/bin/sh
+##/bin/bash
#
# Copyright (c) 2000-2002,2005 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 xfsdump/xfsrestore tests
#
rm -f $here/$seq.full
if [ -n "$DEBUGDUMP" ]; then
- _dump_debug=-v4
- _restore_debug=-v4
- _invutil_debug=-d
+ _dump_debug=-v4
+ _restore_debug=-v4
+ _invutil_debug=-d
+
+ # Use dump/restore in qa directory (copy them here) for debugging
+ export PATH="$here:$PATH"
+ export XFSDUMP_PROG="`set_prog_path xfsdump`"
+ export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
+ export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
+ [ -x $here/xfsdump ] && echo "Using xfstests' xfsdump for debug"
+ [ -x $here/xfsrestore ] && echo "Using xfstests' xfsrestore for debug"
+ [ -x $here/xfsinvutil ] && echo "Using xfstests' xfsinvutil for debug"
fi
-# Use dump/restore in qa directory for debugging
-PATH="$here:$PATH"
-export PATH
-#which xfsdump
-#which xfsrestore
-#which xfsinvutil
+[ "$XFSDUMP_PROG" = "" ] && _notrun "xfsdump not found"
+[ "$XFSRESTORE_PROG" = "" ] && _notrun "xfsrestore not found"
+[ "$XFSINVUTIL_PROG" = "" ] && _notrun "xfsinvutil not found"
# status returned for not run tests
NOTRUNSTS=2
have_mtvariable=false
[ `uname` = "Linux" ] && have_mtvariable=true
+
+_require_multi_stream()
+{
+ $XFSDUMP_PROG -JF -f /dev/null -f /dev/null 2> /dev/null |
+ grep -q "too many -f arguments" &&
+ _notrun "xfsdump multi-stream support required"
+}
+
+_require_legacy_v2_format()
+{
+ $XFSDUMP_PROG 2>&1 |
+ grep -q "generate format 2 dump" ||
+ _notrun "xfsdump -K option required"
+
+ $XFSRESTORE_PROG 2>&1 |
+ grep -q "force use of format 2 generation" ||
+ _notrun "xfsrestore -K option required"
+}
+
#
# do a remote/local mt
#
else
sleep 1
fi
- i=`expr $i + 1`
+ let i=$i+1
done
else
sleep 1
fi
- i=`expr $i + 1`
+ let i=$i+1
done
}
{
dumptape=$1
- if [ -z "$dumptape" ]; then
+ if [ -z "$dumptape" -o "@" == "$dumptape" ]; then
echo "This test requires a dump tape - none was specified"
echo "No dump tape specified" >$seq.notrun
status=$NOTRUNSTS
#
_cleanup()
{
+ # Some tests include this before checking _supported_fs xfs
+ # and the sleeps & checks here get annoying
+ if [ "$FSTYP" != "xfs" ]; then
+ return
+ fi
+
cd $here
rm -f $tmp.*
_wipe_fs
_param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
- _count=200
+ _count=240
rm -rf $dump_dir
if ! mkdir $dump_dir; then
echo " failed to mkdir $dump_dir"
then
echo " fsstress (count=$_count) returned $? - see $here/$seq.full"
- echo "--------------------------------------" >>$here/$here/$seq.full
- echo "output from fsstress:" >>$here/$here/$seq.full
- echo "--------------------------------------" >>$here/$here/$seq.full
- cat $tmp.out >>$here/$here/$seq.full
+ echo "--------------------------------------" >>$here/$seq.full
+ echo "output from fsstress:" >>$here/$seq.full
+ echo "--------------------------------------" >>$here/$seq.full
+ cat $tmp.out >>$here/$seq.full
status=1
fi
cd $here
}
+_mk_fillconfig_multi()
+{
+ _mk_fillconfig1
+ cat <<End-of-File >>$tmp.config
+# pathname size in bytes
+#
+large000 8874368 $nobody $nobody
+large111 2582912 $nobody $nobody
+large222 7825792 $nobody $nobody
+End-of-File
+}
+
_create_dumpdir_largefile()
{
_wipe_fs
_stable_fs
}
+#
+# Create enough files, and a few large enough files, so that
+# some files are likely to be split across streams.
+#
+_create_dumpdir_fill_multi()
+{
+ _wipe_fs
+ _mk_fillconfig_multi
+ _do_create_dumpdir_fill
+ _stable_fs
+}
#
# Append a subset of the fill'ed files
_hardlink=$_fname$_suffix
echo "creating hardlink $_hardlink to $_fname"
ln $_fname $_hardlink
- _j=`expr $_j + 1`
+ let _j=$_j+1
done
}
_i=1
while [ $_i -le $_numsets ]; do
_create_hardlinks file$_i 5
- _i=`expr $_i + 1`
+ let _i=$_i+1
done
}
{
_filter_devchar |\
sed \
+ -e "s#$XFSDUMP_PROG#xfsdump#" \
+ -e "s#$XFSRESTORE_PROG#xfsrestore#" \
+ -e "s#$XFSINVUTIL_PROG#xfsinvutil#" \
-e "s/`hostname`/HOSTNAME/" \
-e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
-e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
-e 's/time:[ ].*/time: TIME/' \
-e 's/date:[ ].*/date: DATE/' \
-e 's/dump begun .*/dump begun DATE/' \
+ -e 's/previously begun .*/previously begun DATE/' \
-e 's/[0-9][0-9]* seconds/SECS seconds/' \
-e 's/restore.[0-9][0-9]*/restore.PID/' \
- -e 's/ino [0-9][0-9]*/ino INO/' \
+ -e 's/ino [0-9][0-9]*/ino INO/g' \
+ -e '/stream [0-9]:/s/offset [0-9][0-9]*/offset NUM/g' \
-e '/: dump size/s/[0-9][0-9]*/NUM/' \
-e '/dump size:/s/[0-9][0-9]*/NUM/' \
-e '/dump size per stream:/s/[0-9][0-9]*/NUM/' \
-e '/\/dev\/tty/d' \
-e '/inventory session uuid/d' \
-e '/ - Running single-threaded/d' \
+ -e '/Mount point match/d' \
-e '/^.*I\/O metrics: .*$/d' \
-e 's/1048576/BLOCKSZ/' \
-e 's/2097152/BLOCKSZ/' \
-e 's/(pid[ ]*[1-9][0-9]*)/\(pid PID\)/' \
- -e '/version 3\.0/d' \
+ -e '/version [3-9]\.[0-9]/d' \
-e 's/\/hw\/module.*$/SCRATCH_DEV/' \
+ -e 's/xfsdump: ino map phase 1: .*/xfsdump: ino map <PHASES>/' \
+ -e '/xfsdump: ino map phase [2]/,1d' \
+ -e '/xfsdump: ino map phase [3]/,1d' \
+ -e '/xfsdump: ino map phase [4]/,1d' \
+ -e '/xfsdump: ino map phase [5]/,1d' \
-e 's/id:[[:space:]]*[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/ID: ID/' \
-e 's/\[y\/n\][- ]----------------------*/\[y\/n\]/' \
| perl -ne '
_dir_filter()
{
sed \
- -e "s#$dump_file#DUMP_FILE#" \
+ -e "s#$dump_file#DUMP_FILE#g" \
-e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
-e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
-e "s#$dumptape#TAPE_DEV#" \
}
#
+# Parse xfsdump arguments.
# Note: requires a space between option letter and argument
#
-_parse_args()
+_parse_dump_args()
{
OPTIND=0
dump_args=""
-f)
[ -z "$2" ] && _fail "missing argument for -f"
dumptape=$2
+ dump_file=$2
shift
;;
-L)
session_label=$2
shift
;;
- -o)
- dump_args="$dump_args -o"
+ --multi)
+ [ -z "$2" ] && _fail "missing argument for --multi"
+ multi=$2
+ shift
+ ;;
+ --check-quota)
+ do_quota_check=true
+ ;;
+ --no-check-quota)
+ do_quota_check=false
+ ;;
+ -o|-D|-F|-K)
+ dump_args="$dump_args $1"
+ ;;
+ -l|-d)
+ [ -z "$2" ] && _fail "missing argument for $1"
+ dump_args="$dump_args $1$2"
+ shift
+ ;;
+ *)
+ _fail "invalid argument to common.dump function: $1"
+ ;;
+ esac
+ shift
+ done
+}
+
+#
+# Parse xfsrestore arguments.
+# Note: requires a space between option letter and argument
+#
+_parse_restore_args()
+{
+ OPTIND=0
+ restore_args=""
+ while [ $# -gt 0 ]
+ do
+ case $1
+ in
+ -f)
+ [ -z "$2" ] && _fail "missing argument for -f"
+ dumptape=$2
+ dump_file=$2
+ shift
;;
- -F)
- dump_args="$dump_args -F"
+ -L)
+ [ -z "$2" ] && _fail "missing argument for -L"
+ session_label=$2
+ shift
;;
--multi)
+ [ -z "$2" ] && _fail "missing argument for --multi"
multi=$2
shift
;;
- -q)
+ --check-quota)
do_quota_check=true
;;
- -Q)
+ --no-check-quota)
do_quota_check=false
;;
- -l)
- [ -z "$2" ] && _fail "missing argument for -l"
- dump_args="$dump_args -l$2"
- shift
+ -K|-R)
+ restore_args="$restore_args $1"
;;
*)
_fail "invalid argument to common.dump function: $1"
#
_do_dump_sub()
{
- _parse_args $*
+ _parse_dump_args $*
echo "Dumping to tape..."
opts="$_dump_debug$dump_args -s $dump_sdir -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
echo "xfsdump $opts" | _dir_filter
- xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+ $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
#
#
_do_dump()
{
- _parse_args $*
+ _parse_dump_args $*
echo "Dumping to tape..."
opts="$_dump_debug$dump_args -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
echo "xfsdump $opts" | _dir_filter
- xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+ $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
#
_do_dump_min()
{
- _parse_args $*
+ _parse_dump_args $*
echo "Dumping to tape..."
onemeg=1048576
opts="$_dump_debug$dump_args -m -b $onemeg -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
echo "xfsdump $opts" | _dir_filter
- xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+ $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
#
_do_dump_file()
{
- _parse_args $*
+ _parse_dump_args $*
echo "Dumping to file..."
opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
echo "xfsdump $opts" | _dir_filter
- xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+ $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
#
#
_do_dump_multi_file()
{
- _parse_args "$@"
+ _parse_dump_args $*
multi_args=""
while [ $i -lt $multi ]
do
multi_args="$multi_args -f $dump_file.$i -M $media_label.$i"
- i=`expr $i + 1`
+ let i=$i+1
done
echo "Dumping to files..."
opts="$_dump_debug$dump_args $multi_args -L $session_label $SCRATCH_MNT"
echo "xfsdump $opts" | _dir_filter
- xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+ $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
#
_do_restore()
{
- _parse_args $*
+ _parse_restore_args $*
_prepare_restore
-
echo "Restoring from tape..."
- opts="$_restore_debug -f $dumptape -L $session_label $restore_dir"
+ opts="$_restore_debug$restore_args -f $dumptape -L $session_label $restore_dir"
echo "xfsrestore $opts" | _dir_filter
- xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+ $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
#
#
_do_restore_min()
{
- _parse_args $*
+ _parse_restore_args $*
_prepare_restore
echo "Restoring from tape..."
onemeg=1048576
- opts="$_restore_debug -m -b $onemeg -f $dumptape -L $session_label $restore_dir"
+ opts="$_restore_debug$restore_args -m -b $onemeg -f $dumptape -L $session_label $restore_dir"
echo "xfsrestore $opts" | _dir_filter
- xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+ $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
#
#
_do_restore_file()
{
- _parse_args $*
+ _parse_restore_args $*
_prepare_restore_dir
echo "Restoring from file..."
- opts="$_restore_debug -f $dump_file -L $session_label $restore_dir"
+ opts="$_restore_debug$restore_args -f $dump_file -L $session_label $restore_dir"
echo "xfsrestore $opts" | _dir_filter
- xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+ $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
#
# Cumulative restore from a file
-# Need to specify the dump level e.g. "-l 0"
+# Must call _prepare_restore_dir before the first
+# (and only the first) call to this function.
#
_do_restore_file_cum()
{
- _parse_args $*
- if echo $dump_args | grep '\-l0' >/dev/null; then
- _prepare_restore_dir
- fi
+ _parse_restore_args $*
echo "Restoring cumumlative from file..."
- opts="$_restore_debug -f $dump_file -r $restore_dir"
+ opts="$_restore_debug$restore_args -f $dump_file -r $restore_dir"
echo "xfsrestore $opts" | _dir_filter
- xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+ $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
_do_restore_toc()
{
+ _parse_restore_args $*
+
echo "Contents of dump ..."
- opts="$_restore_debug -f $dump_file -t"
+ opts="$_restore_debug$restore_args -f $dump_file -t"
echo "xfsrestore $opts" | _dir_filter
cd $SCRATCH_MNT # for IRIX which needs xfs cwd
- xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter_main |\
+ $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter_main |\
_check_quota_file |\
_check_quota_entries |\
$AWK_PROG 'NF != 1 { print; next }
#
_do_restore_multi_file()
{
- _parse_args "$@"
+ _parse_restore_args $*
_prepare_restore_dir
multi_args=""
while [ $i -lt $multi ]
do
multi_args="$multi_args -f $dump_file.$i"
- i=`expr $i + 1`
+ let i=$i+1
done
echo "Restoring from file..."
- opts="$_restore_debug $multi_args -L $session_label $restore_dir"
+ opts="$_restore_debug$restore_args $multi_args -L $session_label $restore_dir"
echo "xfsrestore $opts" | _dir_filter
- xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+ $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
#
# Do xfsdump piped into xfsrestore - xfsdump | xfsrestore
+# Pass dump options in $1 and restore options in $2, if required. e.g.:
+# _do_dump_restore "-o -F" "-R"
+# _do_dump_restore "" "-R"
#
# Use -s as we want to dump and restore to the same xfs partition
#
_do_dump_restore()
{
- _parse_args $*
+ _parse_dump_args $1
+ _parse_restore_args $2
_prepare_restore_dir
echo "xfsdump|xfsrestore ..."
- restore_opts="$_restore_debug - $restore_dir"
+ restore_opts="$_restore_debug$restore_args - $restore_dir"
dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter
- xfsdump $dump_opts 2>$tmp.dump.mlog | xfsrestore $restore_opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+ $XFSDUMP_PROG $dump_opts 2>$tmp.dump.mlog | $XFSRESTORE_PROG $restore_opts 2>&1 | tee -a $here/$seq.full | _dump_filter
_dump_filter <$tmp.dump.mlog
}
#
_dump_inventory()
{
- xfsdump $_dump_debug -I | tee -a $here/$seq.full | _dump_filter_main
+ $XFSDUMP_PROG $_dump_debug -I | tee -a $here/$seq.full | _dump_filter_main
}
#
{
host=`hostname`
echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$here/$seq.full
- xfsinvutil $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
+ $XFSINVUTIL_PROG $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
| tee -a $here/$seq.full | _invutil_filter
}