##/bin/bash
-#
+# SPDX-License-Identifier: GPL-2.0
# 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
-#
# --- initializations ---
rm -f $seqres.full
# Use dump/restore in qa directory (copy them here) for debugging
export PATH="$here:$PATH"
- export __XFSDUMP_PROG="`set_prog_path xfsdump`"
+ export __XFSDUMP_PROG=$(type -P xfsdump)
export XFSDUMP_PROG="$__XFSDUMP_PROG -e"
- export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
- export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
+ export XFSRESTORE_PROG=$(type -P xfsrestore)
+ export XFSINVUTIL_PROG=$(type -P 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"
nobody=4 # define this uid/gid as a number
do_quota_check=true # do quota check if quotas enabled
-# install our cleaner
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
# start inventory from a known base - move it aside for test
for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
if [ -d $dir ]; then
_require_scratch
_scratch_mkfs_xfs >>$seqres.full || _fail "mkfs failed"
- _scratch_mount >>$seqres.full || _fail "mount failed"
+ _scratch_mount >>$seqres.full
}
#
# Cleanup created dirs and files
# Called by trap
#
-_cleanup()
+_cleanup_dump()
{
# Some tests include this before checking _supported_fs xfs
# and the sleeps & checks here get annoying
fi
cd $here
- rm -f $tmp.*
if [ -n "$DEBUGDUMP" ]; then
# save it for inspection
mv $dir.$seq $dir
done
- if [ $status -ne $NOTRUNSTS ]; then
+ if [ -f ${RESULT_DIR}/require_scratch ] && [ $status -ne $NOTRUNSTS ]; then
# Sleep added to stop _check_scratch_fs from complaining that the
# scratch_dev is still busy
sleep 10
{
_saveddir=`pwd`; cd /
_scratch_unmount >>$seqres.full || _fail "unmount failed"
- _scratch_mount >>$seqres.full || _fail "mount failed"
+ _scratch_mount >>$seqres.full
cd $_saveddir
}
status=1
exit
fi
+
+ # Remove fsstress commands that aren't supported on all xfs configs so that
+ # we always execute exactly the same sequence of operations no matter how
+ # the filesystem is configured
+ if $FSSTRESS_PROG | grep -q clonerange; then
+ FSSTRESS_AVOID="-f clonerange=0 $FSSTRESS_AVOID"
+ fi
+ if $FSSTRESS_PROG | grep -q deduperange; then
+ FSSTRESS_AVOID="-f deduperange=0 $FSSTRESS_AVOID"
+ fi
+ if $FSSTRESS_PROG | grep -q copyrange; then
+ FSSTRESS_AVOID="-f copyrange=0 $FSSTRESS_AVOID"
+ fi
+ if $FSSTRESS_PROG | grep -q splice; then
+ FSSTRESS_AVOID="-f splice=0 $FSSTRESS_AVOID"
+ fi
+
echo ""
echo "-----------------------------------------------"
echo "fsstress : $_param"
_mk_fillconfig_perm()
{
- # dir_guid: ugo=rwx,g+s on dir is for IRIX chmod(1)
-
cat <<End-of-File >$tmp.config
# pathname size/dir user group mode
#
file_mix1 10 $nobody $nobody 761
file_mix2 10 $nobody $nobody 642
dir_suid d $nobody $nobody 04777
-dir_guid d $nobody $nobody ugo=rwx,g+s
+dir_guid d $nobody $nobody 02777
dir_sticky d $nobody $nobody 01777
dir_mix1 d $nobody $nobody 761
dir_mix2 d $nobody $nobody 642
-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\]/' \
-e '/skip attribute set/d' \
+ -e '/xfsrestore: NOTE: attempt to reserve [0-9]* bytes for.*Operation not supported/d' \
| perl -ne '
# filter out all the output between the lines "Dump Summary:"
# and "Dump Status:"
echo "Contents of dump ..."
opts="$_restore_debug$restore_args -f $dump_file -t"
echo "xfsrestore $opts" | _dir_filter
- cd $SCRATCH_MNT # for IRIX which needs xfs cwd
+ cd $SCRATCH_MNT
$XFSRESTORE_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter_main |\
_check_quota_file |\
_check_quota_entries |\
print "Found extra:", $0
}
next
+ }
+ $0 ~ "Restore Status: INCOMPLETE" {
+ incomplete = 1
}
{ print }
END {
- if (uquota && !found_uquota) {
+ if (uquota && !found_uquota && !incomplete) {
print "Missing user quota msg:", usermsg
}
- if (gquota && !found_gquota) {
+ if (gquota && !found_gquota && !incomplete) {
print "Missing group quota msg:", groupmsg
}
- if (pquota && !found_pquota) {
+ if (pquota && !found_pquota && !incomplete) {
print "Missing project quota msg:", projectmsg
}
}
# xfsrestore: user quota information written to ...'
# xfsrestore: group quota information written to ...'
# xfsrestore: project quota information written to ...'
-#
-# If on IRIX then look for:
-# xfsrestore: use 'edquota' to restore quotas
-# Else look for:
# xfsrestore: use 'xfs_quota' to restore quotas
#
_check_quota_dumprestore()
{
- if [ "$HOSTOS" == "IRIX" ]; then
_check_quota 'user quota information' \
'group quota information' \
'project quota information' | \
- sed "/xfsrestore:.*use 'edquota' to restore quotas/d"
- else
- _check_quota 'user quota information' \
- 'group quota information' \
- 'project quota information' | \
- sed "/xfsrestore:.*use 'xfs_quota' to restore quotas/d"
- fi
+ sed "/xfsrestore:.*use 'xfs_quota' to restore quotas/d"
}
#
_check_quota 'xfsdump_quotas' 'xfsdump_quotas_group' 'xfsdump_quotas_proj'
}
+_count_dir_files()
+{
+ local dir=$1
+
+ local ndirs=$(find $dir -type d | wc -l)
+ local nents=$(find $dir | wc -l)
+
+ echo "$ndirs directories and $nents entries"
+}
+
+_count_dumpdir_files()
+{
+ _count_dir_files $dump_dir
+}
+
+_count_restoredir_files()
+{
+ _count_dir_files $restore_dir/$dump_sdir
+}
+
# make sure this script returns success
/bin/true