#/bin/sh
-
#
-# Functions useful for xfsdump/xfsrestore tests
+# Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. All Rights Reserved.
#
-# 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 version 2 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.
-#
-# Further, this software is distributed without any warranty that it is
-# free of the rightful claim of any third person regarding infringement
-# or the like. Any license provided herein, whether implied or
-# otherwise, applies only to this software file. Patent licenses, if
-# any, provided herein do not apply to combinations of this program with
-# other software, or any other product whatsoever.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston MA 02111-1307, USA.
-#
-# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
-# Mountain View, CA 94043, or:
-#
-# http://www.sgi.com
-#
-# For further information regarding this notice, see:
-#
-# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+# Functions useful for xfsdump/xfsrestore tests
#
# --- initializations ---
_restore_debug=-v4
_invutil_debug=-d
fi
-
+
# Use dump/restore in qa directory for debugging
PATH="$here:$PATH"
export PATH
_mt()
{
op=$1
- if _isrmt; then
+ if _isrmt; then
# REMOTE
_rmtdev=`echo $dumptape | $AWK_PROG -F: '{print $2}'`
{
_limit=10
i=0
- while [ $i -lt $_limit ]; do
+ while [ $i -lt $_limit ]; do
echo "Checking online..." >>$here/$seq.full
if _mt status >$tmp.status 2>&1; then
- break;
+ break;
else
- sleep 2
+ sleep 1
fi
i=`expr $i + 1`
done
echo "ERROR: mt -f $dumptape failed"
cat $tmp.status
- echo "mt -f $dumptape failed" >$seq.notrun
+ echo "mt -f $dumptape failed" >$seq.notrun
status=$NOTRUNSTS
exit
- fi
+ fi
if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
echo "ERROR: $dumptape is not online"
cat $tmp.status
- echo "dumptape, $dumptape, is not online" >$seq.notrun
+ echo "dumptape, $dumptape, is not online" >$seq.notrun
status=$NOTRUNSTS
exit
fi
echo "Wait for tape, $dumptape, ..." >>$here/$seq.full
i=0
- while [ $i -lt 20 ]; do
+ while [ $i -lt 20 ]; do
echo "Checking status..." >>$here/$seq.full
if _mt status 2>&1 | tee -a $here/$seq.full | egrep -i "onl|ready" >/dev/null; then
- break;
+ break;
else
- sleep 2
+ sleep 1
fi
i=`expr $i + 1`
done
}
#
-# Do a custom erase because:
+# Do a custom erase because:
# (i) some machines don't support it
# (ii) some machines take forever to do it
#
# LOCAL
echo "Put scsi tape driver into variable block size mode"
mt -f $dumptape setblk 0
- fi
+ fi
}
_require_tape()
{
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
+ echo "No dump tape specified" >$seq.notrun
status=$NOTRUNSTS
exit
fi
_scratch_mount >>$here/$seq.full || _fail "mount failed"
}
-#
+#
# Cleanup created dirs and files
# Called by trap
#
}
#
-# Run fsstress to create a mixture of
+# Run fsstress to create a mixture of
# files,dirs,links,symlinks
#
# Pinched from test 013.
if ! $here/ltp/fsstress $_param -s 1 $FSSTRESS_AVOID -n $_count -d $dump_dir >$tmp.out 2>&1
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
cat <<End-of-File >$tmp.config
# pathname size user group perm name value namespace
#
-smalll 10 $nobody $nobody 777 attr1 some_text user
+smalll 10 $nobody $nobody 777 attr1 some_text user
biggg 102400 $nobody $nobody 777 attr2 some_text2 root
sub/smalll 10 $nobody $nobody 777 attr3 some_text3 user
sub/biggg 102400 $nobody $nobody 777 attr4 some_text4 root
_mk_fillconfig_xattr()
{
cat <<End-of-File >$tmp.config
-# pathname size user group perm name
+# pathname size user group perm name
#
xflag_realtime 10 $nobody $nobody 777 XFS_XFLAG_REALTIME
xflag_prealloc 10 $nobody $nobody 777 XFS_XFLAG_PREALLOC
do
if [ $nbytes = "d" ]; then
# create a directory
- dir=$file
+ dir=$file
if [ ! -d $dir ]
then
if mkdir $dir
POSIXLY_CORRECT=yes \
dd if=/dev/zero of=$_largefile bs=1 seek=$_largesize count=10 2>&1
_stable_fs
-}
+}
_create_dumpdir_fill()
{
_mk_fillconfig1
_do_create_dumpdir_fill
_stable_fs
-}
+}
_create_dumpdir_fill2()
{
_mk_fillconfig2
_do_create_dumpdir_fill
_stable_fs
-}
+}
_create_dumpdir_fill_perm()
{
_mk_fillconfig_perm
_do_create_dumpdir_fill
_stable_fs
-}
+}
_create_dumpdir_fill_ea()
{
_mk_fillconfig_ea
_do_create_dumpdir_fill
_stable_fs
-}
+}
#
cat <<End-of-File >$tmp.config
# pathname
#
-small
-sub/big
+small
+sub/big
#
sub/a
sub/c
fi
ln -s $file $file-link
if [ -n "$perms2" ]; then
- umask $omask
+ umask $omask
fi
if [ -n "$owner" -a -n "$group" ]; then
_mk_symlink_config()
{
cat <<End-of-File >$tmp.config
-# path size owner1 group1 owner2 group2 perm1 perm2
+# path size owner1 group1 owner2 group2 perm1 perm2
#
a 0 $nobody $nobody daemon sys 124 421
b 0 daemon sys bin bin 347 743
_mk_symlink_config
_do_create_dump_symlinks
_stable_fs
-}
+}
#
# create hardlinks of form $_fname, $_fname_h1 $_fname_h2 ...
#
_create_hardlinks()
{
- _fname=$1
+ _fname=$1
_numlinks=$2
touch $_fname
}
{ print }
'
-}
+}
-#
+#
# Filter out the non-deterministic dump msgs from
# xfsdump and xfsrestore
#
-e 's/(pid[ ]*[1-9][0-9]*)/\(pid PID\)/' \
-e '/version 3\.0/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 '
}
#
-# Note: requires a space between option letter and argument
+# Note: requires a space between option letter and argument
#
_parse_args()
{
in
-f)
[ -z "$2" ] && _fail "missing argument for -f"
- dumptape=$2
+ dumptape=$2
shift
;;
-L)
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
+ echo "xfsdump $opts" | _dir_filter
xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
echo "Dumping to tape..."
opts="$_dump_debug$dump_args -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
- echo "xfsdump $opts" | _dir_filter
+ echo "xfsdump $opts" | _dir_filter
xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
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
+ echo "xfsdump $opts" | _dir_filter
xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
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
+ echo "xfsdump $opts" | _dir_filter
xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
echo "Dumping to files..."
opts="$_dump_debug$dump_args $multi_args -L $session_label $SCRATCH_MNT"
- echo "xfsdump $opts" | _dir_filter
+ echo "xfsdump $opts" | _dir_filter
xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
echo "Restoring from tape..."
opts="$_restore_debug -f $dumptape -L $session_label $restore_dir"
- echo "xfsrestore $opts" | _dir_filter
+ echo "xfsrestore $opts" | _dir_filter
xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
echo "Restoring from tape..."
onemeg=1048576
opts="$_restore_debug -m -b $onemeg -f $dumptape -L $session_label $restore_dir"
- echo "xfsrestore $opts" | _dir_filter
+ echo "xfsrestore $opts" | _dir_filter
xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
echo "Restoring from file..."
opts="$_restore_debug -f $dump_file -L $session_label $restore_dir"
- echo "xfsrestore $opts" | _dir_filter
+ echo "xfsrestore $opts" | _dir_filter
xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
echo "Restoring cumumlative from file..."
opts="$_restore_debug -f $dump_file -r $restore_dir"
- echo "xfsrestore $opts" | _dir_filter
+ echo "xfsrestore $opts" | _dir_filter
xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
echo "Restoring from file..."
opts="$_restore_debug $multi_args -L $session_label $restore_dir"
- echo "xfsrestore $opts" | _dir_filter
+ echo "xfsrestore $opts" | _dir_filter
xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
}
echo "xfsdump|xfsrestore ..."
restore_opts="$_restore_debug - $restore_dir"
dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
- echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter
+ 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
_dump_filter <$tmp.dump.mlog
}
| sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
-
}
#
#
# Do the xfsinvutil cmd with debug and filters
-# Need to set variable: "$middate" to the invutil date
+# Need to set variable: "$middate" to the invutil date
#
_do_invutil()
{
{
usermsg=$1
groupmsg=$2
+ projectmsg=$3
uquota=0
- gquota=0
+ gquota=0
+ pquota=0
$here/src/feature -U $SCRATCH_DEV && uquota=1
$here/src/feature -G $SCRATCH_DEV && gquota=1
-
- $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v full=$here/$seq.full \
- -v usermsg="$usermsg" -v groupmsg="$groupmsg" '
+ $here/src/feature -P $SCRATCH_DEV && pquota=1
+
+ $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota \
+ -v full=$here/$seq.full -v usermsg="$usermsg" \
+ -v groupmsg="$groupmsg" -v projectmsg="$projectmsg" '
+ $0 ~ projectmsg {
+ print "Found project quota:", $0 >>full
+ found_pquota = 1
+ if (!pquota) {
+ print "Found extra:", $0
+ }
+ next
+ }
$0 ~ groupmsg {
print "Found group quota:", $0 >>full
found_gquota = 1
if (gquota && !found_gquota) {
print "Missing group quota msg:", groupmsg
}
+ if (pquota && !found_pquota) {
+ print "Missing project quota msg:", projectmsg
+ }
}
'
}
#
-# xfsrestore: 3 directories and 40 entries processed
-# $5 = 40
-# num entries needs to be reduced by num quota file(s)
+# xfsrestore: 3 directories and 40 entries processed
+# $5 = 40
+# num entries needs to be reduced by num quota file(s)
#
_check_quota_entries()
{
uquota=0
- gquota=0
+ gquota=0
+ pquota=0
$here/src/feature -U $SCRATCH_DEV && uquota=1
$here/src/feature -G $SCRATCH_DEV && gquota=1
- $AWK_PROG -v uquota=$uquota -v gquota=$gquota '
- /entries processed/ {
+ $here/src/feature -P $SCRATCH_DEV && pquota=1
+ $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota '
+ /entries processed/ {
if (uquota) $5--
if (gquota) $5--
+ if (pquota) $5--
}
{print}'
}
# Look for:
# xfsdump: saving user quota information for: SCRATCH_MNT
# xfsdump: saving group quota information for: SCRATCH_MNT
+# xfsdump: saving project quota information for: SCRATCH_MNT
# 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' |\
+ 'group quota information' \
+ 'project quota information' | \
sed "/xfsrestore:.*use 'edquota' to restore quotas/d"
else
_check_quota 'user quota information' \
- 'group quota information'
+ 'group quota information' \
+ 'project quota information' | \
+ sed "/xfsrestore:.*use 'xfs_quota' to restore quotas/d"
fi
}
# Look for:
# Only in RESTORE_DIR: xfsdump_quotas
# Only in RESTORE_DIR: xfsdump_quotas_group
+# Only in RESTORE_DIR: xfsdump_quotas_project
#
_check_quota_diff()
{
_check_quota 'Only in RESTORE_DIR: xfsdump_quotas' \
- 'Only in RESTORE_DIR: xfsdump_quotas_group'
+ 'Only in RESTORE_DIR: xfsdump_quotas_group' \
+ 'Only in RESTORE_DIR: xfsdump_quotas_proj'
}
#
#
_check_quota_file()
{
- _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group'
+ _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group' 'xfsdump_quotas_proj'
}