export FSTYP
# we need common.config
-if ! . ./common.config
+if ! . ./common/config
then
- echo "$iam: failed to source common.config"
+ echo "$iam: failed to source common/config"
exit 1
fi
list=`echo $list | awk -f randomize.awk`
fi
-# we need common.rc
-if ! . ./common.rc
+# we need common/rc
+if ! . ./common/rc
then
- echo "check: failed to source common.rc"
+ echo "check: failed to source common/rc"
exit 1
fi
+++ /dev/null
-##/bin/bash
-#-----------------------------------------------------------------------
-# Copyright (c) 2000-2004 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; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will 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 to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# USA
-#
-# Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
-# Mountain View, CA 94043, USA, or: http://www.sgi.com
-#-----------------------------------------------------------------------
-# common extended attribute and ACL support
-
-# pick three unused user/group ids, store them as $acl[1-3]
-#
-_acl_setup_ids()
-{
- eval `(_cat_passwd; _cat_group) | awk -F: '
- { ids[$3]=1 }
- END {
- j=1
- for(i=1; i<1000000 && j<=3;i++){
- if (! (i in ids)) {
- printf "acl%d=%d;", j, i;
- j++
- }
- }
- }'`
-}
-
-# filter for the acl ids selected above
-#
-_acl_filter_id()
-{
- sed \
- -e "s/u:$acl1/u:id1/" \
- -e "s/u:$acl2/u:id2/" \
- -e "s/u:$acl3/u:id3/" \
- -e "s/g:$acl1/g:id1/" \
- -e "s/g:$acl2/g:id2/" \
- -e "s/g:$acl3/g:id3/" \
- -e "s/ $acl1 / id1 /" \
- -e "s/ $acl2 / id2 /" \
- -e "s/ $acl3 / id3 /"
-}
-
-# filtered ls
-#
-_acl_ls()
-{
- _ls_l -n $* | awk '{ print $1, $3, $4, $NF }' | _acl_filter_id
-}
-
-#
-_acl_list()
-{
- _file1=$1
-
- if [ $HOSTOS = "IRIX" ]; then
- ls -dD $_file1 | _acl_filter_id
- else
- chacl -l $_file1 | _acl_filter_id
- fi
-}
-
-# create an ACL with n ACEs in it
-#
-_create_n_aces()
-{
- let n=$1-4
- acl='u::rwx,g::rwx,o::rwx,m::rwx' # 4 ace acl start
- while [ $n -ne 0 ]; do
- acl="$acl,u:$n:rwx"
- let n=$n-1
- done
- echo $acl
-}
-
-# filter user ace names to user ids
-#
-_filter_aces()
-{
- tmp_file=`mktemp /tmp/ace.XXXXXX`
-
- (_cat_passwd; _cat_group) > $tmp_file
-
- $AWK_PROG -v tmpfile=$tmp_file '
- BEGIN {
- FS=":"
- while ( getline <tmpfile > 0 ) {
- idlist[$1] = $3
- }
- }
- /^user/ { if ($2 in idlist) sub($2, idlist[$2]); print; next}
- /^u/ { if ($2 in idlist) sub($2, idlist[$2]); print; next}
- /^default:user/ { if ($3 in idlist) sub($3, idlist[$3]); print; next}
- {print}
- '
- rm -f $tmp_file
-}
-
-_filter_aces_notypes()
-{
- tr '\[' '\012' | tr ']' '\012' | tr ',' '\012' | _filter_aces|\
- sed -e 's/u:/user:/' -e 's/g:/group:/' -e 's/o:/other:/' -e 's/m:/mask:/'
-}
-
-_require_acls()
-{
- if [ ! -x /bin/chacl -a ! -x /usr/bin/chacl -a ! -x /sbin/chacl ]; then
- _notrun "chacl command not found"
- fi
-
- #
- # Test if chacl is able to list ACLs on the target filesystems. On really
- # old kernels the system calls might not be implemented at all, but the
- # more common case is that the tested filesystem simply doesn't support
- # ACLs.
- #
- touch $TEST_DIR/syscalltest
- chacl -l $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
- cat $TEST_DIR/syscalltest.out >> $RESULT_DIR/$seq.full
-
- if grep -q 'Function not implemented' $TEST_DIR/syscalltest.out; then
- _notrun "kernel does not support ACLs"
- fi
- if grep -q 'Operation not supported' $TEST_DIR/syscalltest.out; then
- _notrun "ACLs not supported by this filesystem type: $FSTYP"
- fi
-
- rm -f $TEST_DIR/syscalltest.out
-}
-
-_list_acl()
-{
- file=$1
-
- ls -dD $file | _acl_filter_id
-}
-
-_require_attrs()
-{
- [ -n $ATTR_PROG ] || _notrun "attr command not found"
- [ -n $GETFATTR_PROG ] || _notrun "getfattr command not found"
- [ -n $SETFATTR_PROG ] || _notrun "setfattr command not found"
-
- #
- # Test if chacl is able to write an attribute on the target filesystems.
- # On really old kernels the system calls might not be implemented at all,
- # but the more common case is that the tested filesystem simply doesn't
- # support attributes. Note that we can't simply list attributes as
- # various security modules generate synthetic attributes not actually
- # stored on disk.
- #
- touch $TEST_DIR/syscalltest
- attr -s "user.xfstests" -V "attr" $TEST_DIR > $TEST_DIR/syscalltest.out 2>&1
- cat $TEST_DIR/syscalltest.out >> $RESULT_DIR/$seq.full
-
- if grep -q 'Function not implemented' $TEST_DIR/syscalltest.out; then
- _notrun "kernel does not support attrs"
- fi
- if grep -q 'Operation not supported' $TEST_DIR/syscalltest.out; then
- _notrun "attrs not supported by this filesystem type: $FSTYP"
- fi
-
- rm -f $TEST_DIR/syscalltest.out
-}
-
-# getfattr -R returns info in readdir order which varies from fs to fs.
-# This sorts the output by filename
-_sort_getfattr_output()
-{
- awk '{a[FNR]=$0}END{n = asort(a); for(i=1; i <= n; i++) print a[i]"\n"}' RS=''
-}
-
-# set maximum total attr space based on fs type
-if [ "$FSTYP" == "xfs" -o "$FSTYP" == "udf" ]; then
- MAX_ATTRS=1000
-else # Assume max ~1 block of attrs
- BLOCK_SIZE=`stat -f $TEST_DIR | grep "Block size" | cut -d " " -f3`
- # user.attribute_XXX="value.XXX" is about 32 bytes; leave some overhead
- let MAX_ATTRS=$BLOCK_SIZE/40
-fi
-
-export MAX_ATTRS
-
-# Set max attr value size based on fs type
-if [ "$FSTYP" == "xfs" -o "$FSTYP" == "udf" -o "$FSTYP" == "btrfs" ]; then
- MAX_ATTRVAL_SIZE=64
-else # Assume max ~1 block of attrs
- BLOCK_SIZE=`stat -f $TEST_DIR | grep "Block size" | cut -d " " -f3`
- # leave a little overhead
- let MAX_ATTRVAL_SIZE=$BLOCK_SIZE-256
-fi
-
-export MAX_ATTRVAL_SIZE
-# make sure this script returns success
-/bin/true
+++ /dev/null
-##/bin/bash
-#
-# Copyright (c) 2000-2003,2006 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
-#
-#
-# setup and check for config parameters, and in particular
-#
-# EMAIL - email of the script runner.
-# TEST_DIR - scratch test directory that is in an already
-# mounted XFS file system, needs to be be world
-# writeable
-# TEST_DEV - device for file system containing TEST_DIR
-#
-# and optionally:
-# SCRATCH_DEV - device you can make a scratch file system on
-# SCRATCH_MNT - mount point for scratch file system
-# SCRATCH_LOGDEV - scratch log device for external log testing
-# SCRATCH_RTDEV - scratch rt dev
-# TEST_LOGDEV - test log device for external log testing
-# TEST_RTDEV - test rt dev
-# TAPE_DEV - the tape device for the xfsdump tests
-# RMT_TAPE_DEV - the remote tape device for the xfsdump tests
-# RMT_IRIXTAPE_DEV- the IRIX remote tape device for the xfsdump tests
-# RMT_TAPE_USER - remote user for tape device
-#
-# - These can be added to $HOST_CONFIG_DIR (witch default to ./config)
-# below or a separate local configuration file can be used (using
-# the HOST_OPTIONS variable).
-# - This script is shared by the stress test system and the auto-qa
-# system
-# - TEST_DEV & TEST_DIR must be assigned.
-# - this script shouldn't make any assertions about filesystem
-# validity or mountedness.
-#
-
-# all tests should use a common language setting to prevent golden
-# output mismatches.
-export LANG=C
-
-# Warning: don't put freeware before /usr/bsd on IRIX coz you'll
-# get the wrong hostname and set your system name to -s :)
-[ -d /usr/bsd ] && PATH=$PATH:/usr/bsd
-[ -d /usr/freeware/bin ] && PATH=$PATH:/usr/freeware/bin
-PATH=".:$PATH"
-
-HOST=`hostname -s`
-HOSTOS=`uname -s`
-[ "$HOSTOS" = "IRIX64" ] && HOSTOS="IRIX"
-
-MODULAR=0 # using XFS as a module or not
-BOOT="/boot" # install target for kernels
-export EXTRA=${EXTRA:=xfs-qa}
-
-# general parameters (mainly for auto-qa)
-SOAK_PROC=3 # -p option to fsstress
-SOAK_STRESS=10000 # -n option to fsstress
-SOAK_PASSES=-1 # count of repetitions of fsstress (while soaking)
-EMAIL=root@localhost # where auto-qa will send its status messages
-export HOST_OPTIONS=${HOST_OPTIONS:=local.config}
-export CHECK_OPTIONS=${CHECK_OPTIONS:="-g auto"}
-export BENCH_PASSES=${BENCH_PASSES:=5}
-export XFS_MKFS_OPTIONS=${XFS_MKFS_OPTIONS:=-bsize=4096}
-export TIME_FACTOR=${TIME_FACTOR:=1}
-export LOAD_FACTOR=${LOAD_FACTOR:=1}
-export DEBUGFS_MNT=${DEBUGFS_MNT:="/sys/kernel/debug"}
-
-export PWD=`pwd`
-#export DEBUG=${DEBUG:=...} # arbitrary CFLAGS really.
-export MALLOCLIB=${MALLOCLIB:=/usr/lib/libefence.a}
-export LOCAL_CONFIGURE_OPTIONS=${LOCAL_CONFIGURE_OPTIONS:=--enable-readline=yes}
-
-# $1 = prog to look for, $2* = default pathnames if not found in $PATH
-set_prog_path()
-{
- p=`which $1 2> /dev/null`
- if [ -n "$p" -a -x "$p" ]; then
- echo $p
- return 0
- fi
- p=$1
-
- shift
- for f; do
- if [ -x $f ]; then
- echo $f
- return 0
- fi
- done
-
- echo ""
- return 1
-}
-
-# Handle mkfs.btrfs which does (or does not) require -f to overwrite
-set_btrfs_mkfs_prog_path_with_opts()
-{
- p=`set_prog_path mkfs.btrfs`
- if [ "$p" != "" ] && grep -q 'force overwrite' $p; then
- echo "$p -f"
- else
- echo $p
- fi
-}
-
-_fatal()
-{
- echo "$*"
- status=1
- exit 1
-}
-
-export MKFS_PROG="`set_prog_path mkfs`"
-[ "$MKFS_PROG" = "" ] && _fatal "mkfs not found"
-
-export MOUNT_PROG="`set_prog_path mount`"
-[ "$MOUNT_PROG" = "" ] && _fatal "mount not found"
-
-export UMOUNT_PROG="`set_prog_path umount`"
-[ "$UMOUNT_PROG" = "" ] && _fatal "umount not found"
-
-export FSSTRESS_PROG="`set_prog_path fsstress $PWD/ltp/fsstress`"
-[ "$FSSTRESS_PROG" = "" ] && _fatal "fsstress not found"
-
-export PERL_PROG="`set_prog_path perl`"
-[ "$PERL_PROG" = "" ] && _fatal "perl not found"
-
-export AWK_PROG="`set_prog_path awk`"
-[ "$AWK_PROG" = "" ] && _fatal "awk not found"
-
-export SED_PROG="`set_prog_path sed`"
-[ "$SED_PROG" = "" ] && _fatal "sed not found"
-
-export BC_PROG="`set_prog_path bc`"
-[ "$BC_PROG" = "" ] && _fatal "bc not found"
-
-export PS_ALL_FLAGS="-ef"
-
-export DF_PROG="`set_prog_path df`"
-[ "$DF_PROG" = "" ] && _fatal "df not found"
-[ "$HOSTOS" = "Linux" ] && export DF_PROG="$DF_PROG -T"
-
-export XFS_LOGPRINT_PROG="`set_prog_path xfs_logprint`"
-export XFS_REPAIR_PROG="`set_prog_path xfs_repair`"
-export XFS_CHECK_PROG="`set_prog_path xfs_check`"
-export XFS_DB_PROG="`set_prog_path xfs_db`"
-export XFS_GROWFS_PROG=`set_prog_path xfs_growfs`
-export XFS_IO_PROG="`set_prog_path xfs_io`"
-export XFS_PARALLEL_REPAIR_PROG="`set_prog_path xfs_prepair`"
-export XFS_PARALLEL_REPAIR64_PROG="`set_prog_path xfs_prepair64`"
-export __XFSDUMP_PROG="`set_prog_path xfsdump`"
-export XFSDUMP_PROG="$__XFSDUMP_PROG -e"
-export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
-export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
-export GETFATTR_PROG="`set_prog_path getfattr`"
-export SETFATTR_PROG="`set_prog_path setfattr`"
-export ATTR_PROG="`set_prog_path attr`"
-export QUOTA_PROG="`set_prog_path quota`"
-export XFS_QUOTA_PROG="`set_prog_path xfs_quota`"
-export KILLALL_PROG="`set_prog_path killall`"
-export INDENT_PROG="`set_prog_path indent`"
-export XFS_COPY_PROG="`set_prog_path xfs_copy`"
-export FSTRIM_PROG="`set_prog_path fstrim`"
-export DUMPE2FS_PROG="`set_prog_path dumpe2fs`"
-export FIO_PROG="`set_prog_path fio`"
-export FILEFRAG_PROG="`set_prog_path filefrag`"
-export E4DEFRAG_PROG="`set_prog_path e4defrag`"
-export LOGGER_PROG="`set_prog_path logger`"
-
-# Generate a comparable xfsprogs version number in the form of
-# major * 10000 + minor * 100 + release
-#
-# $ xfs_db -V
-# xfs_db version 2.9.7
-#
-# so, 2.9.7 = 20907
-_version=`$XFS_DB_PROG -V | $AWK_PROG '
- /version/ {
- if (split($3,ver,".") == 3)
- print (ver[1] * 10000) + (ver[2] * 100) + ver[3];
- }'`
-[ -z "$_version" ] && _fatal "xfsprogs version cannot be found"
-export XFSPROGS_VERSION="$_version"
-
-case "$HOSTOS" in
- IRIX*)
- export MKFS_XFS_PROG="`set_prog_path mkfs_xfs`"
- export MKFS_UDF_PROG="`set_prog_path mkfs_udf`"
- export XFS_FSR_PROG="`set_prog_path /usr/etc/fsr_xfs`"
- export MKFS_NFS_PROG="false"
- ;;
- Linux)
- export MKFS_XFS_PROG="`set_prog_path mkfs.xfs`"
- export MKFS_UDF_PROG="`set_prog_path mkudffs`"
- export MKFS_BTRFS_PROG="`set_btrfs_mkfs_prog_path_with_opts`"
- export BTRFS_UTIL_PROG="`set_prog_path btrfs`"
- export XFS_FSR_PROG="`set_prog_path xfs_fsr`"
- export MKFS_NFS_PROG="false"
- ;;
-esac
-
-known_hosts()
-{
- [ "$HOST_CONFIG_DIR" ] || HOST_CONFIG_DIR=`pwd`/configs
-
- [ -f /etc/xfsqa.config ] && . /etc/xfsqa.config
- [ -f $HOST_CONFIG_DIR/$HOST ] && . $HOST_CONFIG_DIR/$HOST
- [ -f $HOST_CONFIG_DIR/$HOST.config ] && . $HOST_CONFIG_DIR/$HOST.config
-
- # Mandatory Config values.
- MC=""
- [ -z "$EMAIL" ] && MC="$MC EMAIL"
- [ -z "$TEST_DIR" ] && MC="$MC TEST_DIR"
- [ -z "$TEST_DEV" ] && MC="$MC TEST_DEV"
-
- if [ -n "$MC" ]; then
- echo "Warning: need to define parameters for host $HOST"
- echo " or set variables:"
- echo " $MC"
- exit 1
- fi
-}
-
-if [ -f "$HOST_OPTIONS" ]; then
- . "$HOST_OPTIONS"
-else
- known_hosts
-fi
-
-echo $TEST_DEV | grep -q ":" > /dev/null 2>&1
-if [ ! -b "$TEST_DEV" -a "$?" != "0" ]; then
- echo "common.config: Error: \$TEST_DEV ($TEST_DEV) is not a block device or a NFS filesystem"
- exit 1
-fi
-
-if [ ! -d "$TEST_DIR" ]; then
- echo "common.config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
- exit 1
-fi
-
-# a btrfs tester will set only SCRATCH_DEV_POOL, we will put first of its dev
-# to SCRATCH_DEV and rest to SCRATCH_DEV_POOL to maintain the backward compatibility
-if [ ! -z "$SCRATCH_DEV_POOL" ]; then
- if [ ! -z "$SCRATCH_DEV" ]; then
- echo "common.config: Error: \$SCRATCH_DEV should be unset when \$SCRATCH_DEV_POOL is set"
- exit 1
- fi
- SCRATCH_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
- SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | awk '{ ORS=" "; for (i = 2; i <= NF; i++) print $i}'`
-fi
-
-echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
-if [ ! -z "$SCRATCH_DEV" -a ! -b "$SCRATCH_DEV" -a "$?" != "0" ]; then
- echo "common.config: Error: \$SCRATCH_DEV ($SCRATCH_DEV) is not a block device or a NFS filesystem"
- exit 1
-fi
-
-if [ ! -z "$SCRATCH_MNT" -a ! -d "$SCRATCH_MNT" ]; then
- echo "common.config: Error: \$SCRATCH_MNT ($SCRATCH_MNT) is not a directory"
- exit 1
-fi
-
-# make sure this script returns success
-/bin/true
+++ /dev/null
-##/bin/bash
-#
-# Copyright (c) 2009 Eric Sandeen
-# 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 defragmentation tests
-#
-
-_require_defrag()
-{
- case "$FSTYP" in
- xfs)
- DEFRAG_PROG="$XFS_FSR_PROG"
- ;;
- ext4|ext4dev)
- DEFRAG_PROG="$E4DEFRAG_PROG"
- ;;
- btrfs)
- DEFRAG_PROG="$BTRFS_UTIL_PROG filesystem defragment"
- ;;
- *)
- _notrun "defragmentation not supported for fstype \"$FSTYP\""
- ;;
- esac
-
- _require_command $DEFRAG_PROG
- _require_command $FILEFRAG_PROG
-}
-
-_extent_count()
-{
- $FILEFRAG_PROG $1 | awk '{print $2}'
- $FILEFRAG_PROG -v $1 >> $RESULT_DIR/$seq.full 2>&1
-}
-
-# Defrag file, check it, and remove it.
-_defrag()
-{
- echo -n "Before: "
- _extent_count $1
- CSUM_BEFORE=`md5sum $1`
- STAT_BEFORE=`stat -c "a: %x m: %y c: %z" $1`
- $DEFRAG_PROG -v $1 >> $RESULT_DIR/$seq.full 2>&1
- _scratch_remount
- STAT_AFTER=`stat -c "a: %x m: %y c: %z" $1`
- CSUM_AFTER=`md5sum $1`
- echo -n "After: "
- _extent_count $1
- if [ "$CSUM_BEFORE" != "$CSUM_AFTER" ]; then
- _fail "file checksum changed post-defrag ($CSUM_BEFORE/$CSUM_AFTER)"
- fi
- if [ "$STAT_BEFORE" != "$STAT_AFTER" ]; then
- _fail "file timestamps changed post-defrag:\n$STAT_BEFORE\n$STAT_AFTER"
- fi
- rm -f $1
-}
-
+++ /dev/null
-##/bin/bash
-#
-# Copyright (c) 2006 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
-#
-#
-# dmapi functions
-#
-
-# Commands relitive to dmapi qa
-
-DMAPI_QASUITE1_DIR=$here/dmapi/src/suite1/
-DMAPI_QASUITE2_DIR=$here/dmapi/src/suite2/
-DMAPI_COMMON_DIR=$here/dmapi/src/common/
-
-DMAPI_LS_TO_COPY_PATH=$DMAPI_QASUITE2_DIR/bindir/ls_to_copy
-
-_dmapi_scratch_mount () {
- if [ `echo "$MOUNT_OPTIONS" | grep -c dmapi` -gt 0 -o \
- `echo "$MOUNT_OPTIONS" | grep -c dmi` -gt 0 ] ; then
- #already got dmapi options set
- _scratch_mount
- dmapi_mount_result=$?
- else
- _scratch_mount "-o dmapi,mtpt=$SCRATCH_MNT"
- dmapi_mount_result=$?
- fi
-
- if [ $dmapi_mount_result -ne 0 ] ; then
- _notrun "Assuming DMAPI modules are not loaded"
- fi
-}
-
-
+++ /dev/null
-##/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
-#
-
-# --- initializations ---
-rm -f $RESULT_DIR/$seq.full
-
-if [ -n "$DEBUGDUMP" ]; then
- _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 XFSDUMP_PROG="$__XFSDUMP_PROG -e"
- 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
-
-[ "$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
-
-# name those directories
-dump_file=$tmp.dumpfile
-# dump_file=$here/dumpfile #TEMP OVERRIDE DUMP FILE
-dump_sdir=dumpdir
-dump_dir=$SCRATCH_MNT/$dump_sdir
-restore_sdir=restoredir
-restore_dir=$SCRATCH_MNT/$restore_sdir
-multi=3
-dumptape=$TAPE_DEV
-media_label="stress_tape_media"
-session_label="stress_$seq"
-
-nobody=4 # define this uid/gid as a number
-do_quota_check=true # do quota check if quotas enabled
-
-_need_to_be_root
-
-# 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
- [ -d $dir.$seq ] && rm -rf $dir.$seq
- mv $dir $dir.$seq
- fi
-done
-
-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
-#
-_mt()
-{
- op=$1
- if _isrmt; then
- # REMOTE
- _rmtdev=`echo $dumptape | $AWK_PROG -F: '{print $2}'`
-
- if echo $dumptape | grep '@' >/dev/null; then
- _spec=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
- _rmtuser=`echo $_spec | $AWK_PROG -F@ '{print $1}'`
- _rmthost=`echo $_spec | $AWK_PROG -F@ '{print $2}'`
- rsh -n -l $_rmtuser $_rmthost "mt -t $_rmtdev $op"
- else
- _rmthost=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
- rsh -n $_rmthost "mt -t $_rmtdev $op"
- fi
- else
- #LOCAL
- mt -t $dumptape $op
- fi
-}
-
-_check_onl()
-{
- _limit=10
- i=0
- while [ $i -lt $_limit ]; do
- echo "Checking online..." >>$RESULT_DIR/$seq.full
- if _mt status >$tmp.status 2>&1; then
- break;
- else
- sleep 1
- fi
- let i=$i+1
- done
-
-
- if [ $i -eq $_limit ]; then
- echo "ERROR: mt -f $dumptape failed"
- cat $tmp.status
-
- echo "mt -f $dumptape failed" >$seq.notrun
- status=$NOTRUNSTS
- exit
- fi
-
-
- if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
- :
- else
- echo "ERROR: $dumptape is not online"
- cat $tmp.status
-
- echo "dumptape, $dumptape, is not online" >$seq.notrun
- status=$NOTRUNSTS
- exit
- fi
-}
-
-_wait_tape()
-{
- echo "Wait for tape, $dumptape, ..." >>$RESULT_DIR/$seq.full
-
- i=0
- while [ $i -lt 20 ]; do
- echo "Checking status..." >>$RESULT_DIR/$seq.full
- if _mt status 2>&1 | tee -a $RESULT_DIR/$seq.full | egrep -i "onl|ready" >/dev/null; then
- break;
- else
- sleep 1
- fi
- let i=$i+1
- done
-}
-
-#
-# Keep trying so we know we really have rewound
-#
-_rewind()
-{
- echo "Initiate rewind..." >>$RESULT_DIR/$seq.full
- _wait_tape
- _mt rewind >/dev/null
- _wait_tape
-}
-
-#
-# Do a custom erase because:
-# (i) some machines don't support it
-# (ii) some machines take forever to do it
-#
-_erase_soft()
-{
- echo "Erasing tape" | tee -a $RESULT_DIR/$seq.full
- _rewind
- _mt weof 3
- _rewind
-}
-
-_erase_hard()
-{
- echo "Erasing tape" | tee -a $RESULT_DIR/$seq.full
- _mt erase
-}
-
-_isrmt()
-{
- echo $dumptape | grep ':' >/dev/null
-}
-
-#
-# Get tape ready
-#
-_set_variable()
-{
- $have_mtvariable || return
-
- if _isrmt; then
- :
- else
- # LOCAL
- echo "Put scsi tape driver into variable block size mode"
- mt -f $dumptape setblk 0
- fi
-}
-
-_require_tape()
-{
- dumptape=$1
-
- if [ -z "$dumptape" -o "@" == "$dumptape" ]; then
- echo "This test requires a dump tape - none was specified"
- echo "No dump tape specified" >$RESULT_DIR/$seq.notrun
- status=$NOTRUNSTS
- exit
- fi
-
- _check_onl
- _set_variable
-}
-
-_wipe_fs()
-{
- _require_scratch
-
- _scratch_mkfs_xfs >>$RESULT_DIR/$seq.full || _fail "mkfs failed"
- _scratch_mount >>$RESULT_DIR/$seq.full || _fail "mount failed"
-}
-
-#
-# Cleanup created dirs and files
-# Called by trap
-#
-_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.*
-
- if [ -n "$DEBUGDUMP" ]; then
- # save it for inspection
- for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
- [ -d $dir ] || continue
- tar -cvf $RESULT_DIR/$seq.inventory.tar $dir
- ls -nR $dir >$RESULT_DIR/$seq.inventory.ls
- done
- fi
-
- # put inventory dir back
- for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
- [ -d $dir.$seq ] || continue
- rm -rf $dir # get rid of new one
- mv $dir.$seq $dir
- done
-
- if [ $status -ne $NOTRUNSTS ]; then
- # Sleep added to stop _check_scratch_fs from complaining that the
- # scratch_dev is still busy
- sleep 10
-
- _check_scratch_fs
- fi
-}
-
-#
-# ensure that bulkstat data will
-# match with incore data
-# by forcing disk data to be written out
-#
-_stable_fs()
-{
- _saveddir=`pwd`; cd /
- umount $SCRATCH_MNT >>$RESULT_DIR/$seq.full || _fail "unmount failed"
- _scratch_mount >>$RESULT_DIR/$seq.full || _fail "mount failed"
- cd $_saveddir
-}
-
-#
-# Run fsstress to create a mixture of
-# files,dirs,links,symlinks
-#
-# Pinched from test 013.
-#
-_create_dumpdir_stress()
-{
- echo "Creating directory system to dump using fsstress."
-
- _wipe_fs
-
- _param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
- _count=240
- rm -rf $dump_dir
- if ! mkdir $dump_dir; then
- echo " failed to mkdir $dump_dir"
- status=1
- exit
- fi
- echo ""
- echo "-----------------------------------------------"
- echo "fsstress : $_param"
- echo "-----------------------------------------------"
- 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 $RESULT_DIR/$seq.full"
-
- echo "--------------------------------------" >>$RESULT_DIR/$seq.full
- echo "output from fsstress:" >>$RESULT_DIR/$seq.full
- echo "--------------------------------------" >>$RESULT_DIR/$seq.full
- cat $tmp.out >>$RESULT_DIR/$seq.full
- status=1
- fi
-
- _stable_fs
-}
-
-_mk_fillconfig1()
-{
- cat <<End-of-File >$tmp.config
-# pathname size in bytes owner group
-#
-small 10 $nobody $nobody
-big 102400 daemon sys
-sub/small 10 bin bin
-sub/big 102400 $nobody sys
-#
-sub/a 1 $nobody $nobody
-sub/b 2 $nobody $nobody
-sub/c 4 $nobody $nobody
-sub/d 8 $nobody $nobody
-sub/e 16 $nobody $nobody
-sub/f 32 $nobody $nobody
-sub/g 64 $nobody $nobody
-sub/h 128 $nobody $nobody
-sub/i 256 $nobody $nobody
-sub/j 512 $nobody $nobody
-sub/k 1024 $nobody $nobody
-sub/l 2048 $nobody $nobody
-sub/m 4096 $nobody $nobody
-sub/n 8192 $nobody $nobody
-#
-sub/a00 100 $nobody $nobody
-sub/b00 200 $nobody $nobody
-sub/c00 400 $nobody $nobody
-sub/d00 800 $nobody $nobody
-sub/e00 1600 $nobody $nobody
-sub/f00 3200 $nobody $nobody
-sub/g00 6400 $nobody $nobody
-sub/h00 12800 $nobody $nobody
-sub/i00 25600 $nobody $nobody
-sub/j00 51200 $nobody $nobody
-sub/k00 102400 $nobody $nobody
-sub/l00 204800 $nobody $nobody
-sub/m00 409600 $nobody $nobody
-sub/n00 819200 $nobody $nobody
-#
-sub/a000 1000 $nobody $nobody
-sub/e000 16000 $nobody $nobody
-sub/h000 128000 $nobody $nobody
-sub/k000 1024000 $nobody $nobody
-End-of-File
-}
-
-_mk_fillconfig2()
-{
- cat <<End-of-File >$tmp.config
-# pathname size in bytes
-#
-smalll 10 $nobody $nobody
-biggg 102400 $nobody $nobody
-sub/smalll 10 $nobody $nobody
-sub/biggg 102400 $nobody $nobody
-End-of-File
-}
-
-_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_suid 10 $nobody $nobody 04777
-file_guid 10 $nobody $nobody 02777
-file_sticky 10 $nobody $nobody 01777
-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_sticky d $nobody $nobody 01777
-dir_mix1 d $nobody $nobody 761
-dir_mix2 d $nobody $nobody 642
-End-of-File
-}
-
-_mk_fillconfig_ea()
-{
- cat <<End-of-File >$tmp.config
-# pathname size user group perm name value namespace
-#
-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
-dir d $nobody $nobody 777 attr5 dir_text user
-#
-# Add more files so that there are more than the number
-# of streams.
-# There are bugs in dump/restore for # non-dir files < # streams
-# It can be tested in another configuration.
-# It is a pathalogical case.
-#
-sub/a 1 $nobody $nobody
-sub/b 2 $nobody $nobody
-sub/c 4 $nobody $nobody
-sub/d 8 $nobody $nobody
-sub/e 16 $nobody $nobody
-sub/f 32 $nobody $nobody
-sub/g 64 $nobody $nobody
-sub/h 128 $nobody $nobody
-sub/i 256 $nobody $nobody
-sub/j 512 $nobody $nobody
-sub/k 1024 $nobody $nobody
-sub/l 2048 $nobody $nobody
-sub/m 4096 $nobody $nobody
-sub/n 8192 $nobody $nobody
-End-of-File
-}
-
-#
-# extended file attribute flags
-#
-_mk_fillconfig_xattr()
-{
- cat <<End-of-File >$tmp.config
-# pathname size user group perm name
-#
-xflag_realtime 10 $nobody $nobody 777 XFS_XFLAG_REALTIME
-xflag_prealloc 10 $nobody $nobody 777 XFS_XFLAG_PREALLOC
-xflag_immutable 10 $nobody $nobody 777 XFS_XFLAG_IMMUTABLE
-xflag_append 10 $nobody $nobody 777 XFS_XFLAG_APPEND
-xflag_sync 10 $nobody $nobody 777 XFS_XFLAG_SYNC
-xflag_noatime 10 $nobody $nobody 777 XFS_XFLAG_NOATIME
-xflag_nodump 10 $nobody $nobody 777 XFS_XFLAG_NODUMP
-xflag_hasattr 10 $nobody $nobody 777 XFS_XFLAG_HASATTR
-End-of-File
-}
-
-#
-# Create a bunch of directories/files of different sizes
-# filled with data.
-#
-# Pinched from test 001.
-#
-_do_create_dumpdir_fill()
-{
- echo "Creating directory system to dump using src/fill."
-
- mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
- cd $dump_dir
-
- $verbose && echo -n "Setup "
- sed -e '/^#/d' $tmp.config \
- | while read file nbytes owner group perms ea_name ea_value namespace
- do
- if [ $nbytes = "d" ]; then
- # create a directory
- dir=$file
- if [ ! -d $dir ]
- then
- if mkdir $dir
- then
- :
- else
- $verbose && echo
- echo "Error: cannot mkdir \"$dir\""
- exit 1
- fi
- fi
- else
- # create a directory/file
- dir=`dirname $file`
- if [ "$dir" != "." ]
- then
- if [ ! -d $dir ]
- then
- if mkdir $dir
- then
- :
- else
- $verbose && echo
- echo "Error: cannot mkdir \"$dir\""
- exit 1
- fi
- fi
- fi
- rm -f $file
- if $here/src/fill $file $file $nbytes
- then
- :
- else
- $verbose && echo
- echo "Error: cannot create \"$file\""
- exit 1
- fi
- fi
- if [ -n "$owner" -a -n "$group" ]; then
- chown $owner.$group $file
- fi
- if [ -n "$perms" ]; then
- chmod $perms $file
- fi
-
- # extended attributes (EA)
- if [ -n "$ea_name" -a -n "$ea_value" ]; then
- if [ "X$namespace" = "Xroot" ]; then
- attr -R -s $ea_name -V $ea_value $file
- else
- attr -s $ea_name -V $ea_value $file
- fi
- # extended file attribute flags - no value - NOT EAs
- elif [ -n "$ea_name" -a -z "$ea_value" ]; then
- # set the flag
- # TODO XXX
- # use xfs_io to send the ioctl
- :
- fi
- $verbose && echo -n "."
- done
- $verbose && echo
-
- 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
- mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
- _largesize=4294967297
- _largefile=$dump_dir/largefile
- echo "dd a largefile at offset $_largesize"
- POSIXLY_CORRECT=yes \
- dd if=/dev/zero of=$_largefile bs=1 seek=$_largesize count=10 2>&1
- _stable_fs
-}
-
-_create_dumpdir_fill()
-{
- _wipe_fs
- _mk_fillconfig1
- _do_create_dumpdir_fill
- _stable_fs
-}
-
-_create_dumpdir_fill2()
-{
- _wipe_fs
- _mk_fillconfig2
- _do_create_dumpdir_fill
- _stable_fs
-}
-
-_create_dumpdir_fill_perm()
-{
- _wipe_fs
- _mk_fillconfig_perm
- _do_create_dumpdir_fill
- _stable_fs
-}
-
-_create_dumpdir_fill_ea()
-{
- _wipe_fs
- _mk_fillconfig_ea
- _do_create_dumpdir_fill
- _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
-# So we can see if just these get dumped on an incremental
-#
-_append_dumpdir_fill()
-{
- cd $dump_dir
- cat <<End-of-File >$tmp.config
-# pathname
-#
-small
-sub/big
-#
-sub/a
-sub/c
-sub/e
-End-of-File
- sed -e '/^#/d' $tmp.config \
- | while read file
- do
- echo 'Extra text' >>$file
- done
-
- cd $here
- _stable_fs
-}
-
-_do_create_dump_symlinks()
-{
- echo "Creating directory system of symlinks to dump."
-
- mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
- cd $dump_dir
-
- $verbose && echo -n "Setup "
- sed -e '/^#/d' $tmp.config \
- | while read file nbytes owner group owner2 group2 perms perms2
- do
- dir=`dirname $file`
- if [ "$dir" != "." ]
- then
- if [ ! -d $dir ]
- then
- if mkdir $dir
- then
- :
- else
- $verbose && echo
- echo "Error: cannot mkdir \"$dir\""
- exit 1
- fi
- fi
- fi
- rm -f $file
- touch $file
-
- # Do chmod on symlink using umask.
- # This won't do the right thing as it subtracts permissions.
- # However, I don't care, as long as I get some different perms
- # for testing.
- if [ -n "$perms2" ]; then
- omask=`umask`
- umask $perms2
- fi
- ln -s $file $file-link
- if [ -n "$perms2" ]; then
- umask $omask
- fi
-
- if [ -n "$owner" -a -n "$group" ]; then
- chown $owner.$group $file
- fi
- if [ -n "$owner" -a -n "$group" ]; then
- chown -h $owner.$group $file-link
- fi
- if [ -n "$perms" ]; then
- chmod $perms $file
- fi
- $verbose && echo -n "."
- done
- $verbose && echo
-
- cd $here
-}
-
-_mk_symlink_config()
-{
- cat <<End-of-File >$tmp.config
-# path size owner1 group1 owner2 group2 perm1 perm2
-#
-a 0 $nobody $nobody daemon sys 124 421
-b 0 daemon sys bin bin 347 743
-sub/a 0 bin bin $nobody sys 777 777
-sub/b 0 $nobody sys $nobody $nobody 367 763
-End-of-File
-}
-
-_create_dumpdir_symlinks()
-{
- _wipe_fs
- _mk_symlink_config
- _do_create_dump_symlinks
- _stable_fs
-}
-
-#
-# create hardlinks of form $_fname, $_fname_h1 $_fname_h2 ...
-#
-_create_hardlinks()
-{
- _fname=$1
- _numlinks=$2
-
- touch $_fname
- _j=1
- while [ $_j -le $_numlinks ]; do
- _suffix=_h$_j
- _hardlink=$_fname$_suffix
- echo "creating hardlink $_hardlink to $_fname"
- ln $_fname $_hardlink
- let _j=$_j+1
- done
-}
-
-#
-# create a set of hardlinks
-# create hardlinks of form file1, file1_h1 file1_h2 ...
-# create hardlinks of form file2, file2_h1 file2_h2 ...
-# create hardlinks of form file3, file3_h1 file3_h2 ...
-#
-_create_hardset()
-{
- _numsets=$1
- _i=1
- while [ $_i -le $_numsets ]; do
- _create_hardlinks file$_i 5
- let _i=$_i+1
- done
-}
-
-
-_modify_level()
-{
- _level=$1
- echo "mod level $_level" >$dump_dir/file$_level
-}
-
-_create_dumpdir_hardlinks()
-{
- _numsets=$1
- _wipe_fs
- echo "Creating directory system of hardlinks to incrementally dump."
-
- mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
- cd $dump_dir
-
- _create_hardset $_numsets
-
- cd $here
- _stable_fs
-}
-
-#
-# Filter for ls
-# Filter out times and dates on symlinks and char devices.
-# Filter out size on directories because this can differ
-# when transitioning to long inode numbers (ie. 64 bits).
-#
-_ls_filter()
-{
- $AWK_PROG '
- /^l/ { date = $8; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
- /^c/ { date = $9; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
- /^d/ { size = $5; sub(size,"SIZE"); print}
- {print}' \
- | sed -e 's/total [0-9][0-9]*/total TOTAL/'
-}
-
-#
-# Filtering of Irix character hwgraph device names
-# e.g.
-# chardev: /hw/node/xtalk/15/pci/0/scsi_ctlr/0/target/1/lun/0/disk/partition/4/char
-# blkdev: /dev/dsk/dks0d1s4
-#
-_filter_devchar()
-{
- $AWK_PROG '
- /\/hw\/node/ {
- sub(/\/hw.*scsi_ctlr\//,"/dev/dsk/dks") # blah blah /dev/dsk/dks0/target/1/....
- sub(/\/target\//,"d") # blah blah /dev/dsk/dks0d1/lun/0/disk.....
- sub(/\/lun.*partition\//,"s") # blah blah /dev/dsk/dks0d1s4/char
- sub(/\/char/,"") # blah blah /dev/dsk/dks0d1s4
- }
- { print }
- '
-}
-
-
-#
-# Filter out the non-deterministic dump msgs from
-# xfsdump and xfsrestore
-#
-_dump_filter_main()
-{
- _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#$dumptape#TAPE_DEV#" \
- -e "s#$SCRATCH_MNT#SCRATCH_MNT#" \
- -e "s#$dump_file#DUMP_FILE#" \
- -e 's#/var/lib/xfsdump#/var/xfsdump#' \
- -e 's/session id:[ ]*[0-9a-f-]*/session id: ID/' \
- -e '/filesystem id:[ ]*[0-9a-f-]*/d' \
- -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/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 's/\(media file size[ ]*\)[0-9][0-9]*/\1NUM/' \
- -e 's/\(mfile size:[ ]*\)[0-9][0-9]*/\1NUM/' \
- -e '/drive[ ]*[0-9][0-9]*:/d' \
- -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-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\]/' \
- -e '/skip attribute set/d' \
- | perl -ne '
- # filter out all the output between the lines "Dump Summary:"
- # and "Dump Status:"
- if ($_ =~ /(?:Dump|Restore) Summary/) {
- $skip = 1;
- } elsif ($_ =~ /(?:Dump|Restore) Status/) {
- $skip = 0;
- }
- print if (! $skip);' \
- | perl -ne '
- # correct the file count if large scratch devices are being used
- $skip = 0;
- if ($_ =~ /(\S+) directories and (\S+) entries/) {
- $foo = $2;
- if ($ENV{'LARGE_SCRATCH_DEV'} && $foo > 0) {
- $foo -= 1;
- }
- printf("xfsrestore: %u directories and %u entries processed\n",
- $1, $foo);
- $skip = 1;
- }
- print if (! $skip);'
-}
-
-_dump_filter()
-{
- if $do_quota_check
- then
- _dump_filter_main | _check_quota_dumprestore | _check_quota_entries
- else
- _dump_filter_main
- fi
-}
-
-_invutil_filter()
-{
- _dump_filter_main \
- | sed \
- -e 's/UUID[ ]*:[ ][0-9a-f-]*/UUID : ID/' \
- -e 's/TIME OF DUMP[ ]*:.*/TIME OF DUMP : TIME/' \
- -e 's/HOSTNAME:SCRATCH_MNT.*/HOSTNAME:SCRATCH_MNT/' \
- -e 's#inventory/[0-9a-f-]*#inventory/UUID#' \
-
-}
-
-
-_dir_filter()
-{
- sed \
- -e "s#$dump_file#DUMP_FILE#g" \
- -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
- -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
- -e "s#$dumptape#TAPE_DEV#" \
- -e "s#$dump_dir#DUMP_DIR#g" \
- -e "s#$restore_dir#RESTORE_DIR#g" \
- -e "s#$SCRATCH_MNT#SCRATCH_MNT#g" \
- -e "s#$dump_sdir#DUMP_SUBDIR#g" \
- -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
- -e "s#$$#PID#g" \
- -e "/Only in SCRATCH_MNT: .use_space/d" \
-
-}
-
-#
-# Parse xfsdump arguments.
-# Note: requires a space between option letter and argument
-#
-_parse_dump_args()
-{
- OPTIND=0
- dump_args=""
- while [ $# -gt 0 ]
- do
- case $1
- in
- -f)
- [ -z "$2" ] && _fail "missing argument for -f"
- dumptape=$2
- dump_file=$2
- shift
- ;;
- -L)
- [ -z "$2" ] && _fail "missing argument for -L"
- session_label=$2
- shift
- ;;
- --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
- ;;
- -L)
- [ -z "$2" ] && _fail "missing argument for -L"
- session_label=$2
- shift
- ;;
- --multi)
- [ -z "$2" ] && _fail "missing argument for --multi"
- multi=$2
- shift
- ;;
- --check-quota)
- do_quota_check=true
- ;;
- --no-check-quota)
- do_quota_check=false
- ;;
- -K|-R)
- restore_args="$restore_args $1"
- ;;
- *)
- _fail "invalid argument to common.dump function: $1"
- ;;
- esac
- shift
- done
-}
-
-
-#
-# Dump a subdir
-#
-_do_dump_sub()
-{
- _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_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
-}
-
-#
-# Do dump to tape
-#
-_do_dump()
-{
- _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_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
-}
-
-
-#
-# Do full dump with -m
-#
-_do_dump_min()
-{
- _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_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
-}
-
-
-#
-# Do full dump to file
-#
-_do_dump_file()
-{
- _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_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
-}
-
-#
-# Do full dump to multiple files
-#
-_do_dump_multi_file()
-{
- _parse_dump_args $*
-
- multi_args=""
-
- i=0
- while [ $i -lt $multi ]
- do
- multi_args="$multi_args -f $dump_file.$i -M $media_label.$i"
- 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_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
-}
-
-
-_prepare_restore_dir()
-{
- rm -rf $restore_dir
- mkdir $restore_dir || _fail "failed to mkdir $restore_dir"
-}
-
-
-#
-# Get tape ready and restore dir
-#
-_prepare_restore()
-{
- _prepare_restore_dir
-
- echo "Rewinding tape"
- _rewind
-}
-
-#
-# Restore the tape into $restore_dir
-#
-_do_restore()
-{
- _parse_restore_args $*
- _prepare_restore
-
- echo "Restoring from tape..."
- opts="$_restore_debug$restore_args -f $dumptape -L $session_label $restore_dir"
- echo "xfsrestore $opts" | _dir_filter
- $XFSRESTORE_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
-}
-
-#
-# Restore the tape into $restore_dir using -m
-#
-_do_restore_min()
-{
- _parse_restore_args $*
- _prepare_restore
-
- echo "Restoring from tape..."
- onemeg=1048576
- opts="$_restore_debug$restore_args -m -b $onemeg -f $dumptape -L $session_label $restore_dir"
- echo "xfsrestore $opts" | _dir_filter
- $XFSRESTORE_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
-}
-
-#
-# Restore the tape from a dump file
-#
-_do_restore_file()
-{
- _parse_restore_args $*
- _prepare_restore_dir
-
- echo "Restoring from file..."
- opts="$_restore_debug$restore_args -f $dump_file -L $session_label $restore_dir"
- echo "xfsrestore $opts" | _dir_filter
- $XFSRESTORE_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
-}
-
-#
-# Cumulative restore from a file
-# Must call _prepare_restore_dir before the first
-# (and only the first) call to this function.
-#
-_do_restore_file_cum()
-{
- _parse_restore_args $*
-
- echo "Restoring cumumlative from file..."
- opts="$_restore_debug$restore_args -f $dump_file -r $restore_dir"
- echo "xfsrestore $opts" | _dir_filter
- $XFSRESTORE_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
-}
-
-_do_restore_toc()
-{
- _parse_restore_args $*
-
- 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
- $XFSRESTORE_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter_main |\
- _check_quota_file |\
- _check_quota_entries |\
- $AWK_PROG 'NF != 1 { print; next }
- {files = sprintf("%s\n%s", files, $1)}
- END { print files | "sort" } '
- # the above awk code is to alpha sort only the output
- # of files (and not the verbose restore msgs)
- cd $here # put back
-}
-
-#
-# Restore the tape from multiple dump files
-#
-_do_restore_multi_file()
-{
- _parse_restore_args $*
- _prepare_restore_dir
-
- multi_args=""
-
- i=0
- while [ $i -lt $multi ]
- do
- multi_args="$multi_args -f $dump_file.$i"
- let i=$i+1
- done
-
- echo "Restoring from file..."
- opts="$_restore_debug$restore_args $multi_args -L $session_label $restore_dir"
- echo "xfsrestore $opts" | _dir_filter
- $XFSRESTORE_PROG $opts 2>&1 | tee -a $RESULT_DIR/$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_dump_args $1
- _parse_restore_args $2
- _prepare_restore_dir
- echo "xfsdump|xfsrestore ..."
- 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_PROG $dump_opts 2>$tmp.dump.mlog | $XFSRESTORE_PROG $restore_opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
- _dump_filter <$tmp.dump.mlog
-}
-
-#
-# Compare dumped subdirectory with restored dir
-# using ls -nR.
-# Thus no contents are compared but permissions, sizes,
-# owners, etc... are.
-#
-_ls_compare_sub()
-{
- #
- # verify we got back what we dumped
- #
- echo "Comparing listing of dump directory with restore directory"
- ls -nR $dump_dir | tee -a $RESULT_DIR/$seq.full | _ls_filter >$tmp.dump_dir
- ls -nR $restore_dir/$dump_sdir | tee -a $RESULT_DIR/$seq.full | _ls_filter \
- | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
-
- diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
-}
-
-#
-# filter out the date fields
-#
-_ls_nodate_filter()
-{
- $AWK_PROG 'NF == 9 { print $1, $2, $3, $4, $9 }'
-}
-
-#
-# _ls_compare_sub but don't compare dates
-_ls_nodate_compare_sub()
-{
- #
- # verify we got back what we dumped
- #
- echo "Comparing listing of dump directory with restore directory"
- ls -nR $dump_dir | tee -a $RESULT_DIR/$seq.full | _ls_filter | _ls_nodate_filter >$tmp.dump_dir
- ls -nR $restore_dir/$dump_sdir | tee -a $RESULT_DIR/$seq.full | _ls_filter \
- | _ls_nodate_filter | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
-
- diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
-}
-
-#
-# Compare using recursive diff the files of the dumped
-# subdirectory.
-# This one will compare the contents.
-#
-_diff_compare_sub()
-{
- echo "Comparing dump directory with restore directory"
- diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
-}
-
-_get_eas_on_path()
-{
- _path=$1
-
-# Tim - this is the IRIX way...
- # find $_path -exec attr -l {} \; |\
- # awk '{print $9, $2}' |\
- # sed 's/["]//g' |\
- # sort |\
-# and this is now the Linux way...
- echo "User names"
- getfattr --absolute-names -Rh -m user $_path |\
- perl -wn -e '
- if (m/^# file: (\S+)/) { $file = $1 }
- elsif (m/^user\.(\w+)/) { print $file, " ",$1,"\n" }' |\
- sort |\
- while read file ea_name; do
- attr -g $ea_name $file
- done
-
- if [ "$USE_ATTR_SECURE" = yes ]; then
- echo "Security names"
- getfattr --absolute-names -Rh -m security $_path |\
- perl -wn -e '
- if (m/^# file: (\S+)/) { $file = $1 }
- elsif (m/^security\.(\w+)/) { print $file, " ",$1,"\n" }' |\
- sort |\
- while read file ea_name; do
- attr -g $ea_name $file
- done
- fi
-
- echo "Root names"
- getfattr --absolute-names -Rh -m trusted $_path |\
- perl -wn -e '
- if (m/^# file: (\S+)/) { $file = $1 }
- elsif (m/^trusted\.(\w+)/) { print $file, " ",$1,"\n" }' |\
- sort |\
- while read file ea_name; do
- attr -R -g $ea_name $file
- done
-}
-
-#
-# Compare the extended attributes of the files/dirs
-# b/w the dumped and restore dirs.
-#
-#
-# Attribute "attr5" had a 8 byte value for /spare1/dump.5460/dir:
-# Attribute "attr5" had a 8 byte value for /spare1/restore.5460/dump.5460/dir:
-#
-_diff_compare_eas()
-{
- echo "Comparing dump directory with restore directory"
- echo "Looking at the extended attributes (EAs)"
- echo "EAs on dump"
- _get_eas_on_path $dump_dir | tee $RESULT_DIR/$seq.ea1 | _dir_filter
- echo "EAs on restore"
- _get_eas_on_path $restore_dir/$dump_sdir \
- | sed -e "s#$restore_sdir\/##" \
- | tee $RESULT_DIR/$seq.ea2 \
- | _dir_filter
- diff -s $RESULT_DIR/$seq.ea1 $RESULT_DIR/$seq.ea2
-}
-
-
-#
-# Compare using recursive diff the files of the dumped
-# filesystem
-#
-_diff_compare()
-{
- echo "Comparing dump directory with restore directory"
- diff -rs $SCRATCH_MNT $restore_dir | _dir_filter | _check_quota_diff
-}
-
-#
-# Check out the dump inventory
-#
-_dump_inventory()
-{
- $XFSDUMP_PROG $_dump_debug -I | tee -a $RESULT_DIR/$seq.full | _dump_filter_main
-}
-
-#
-# Do the xfsinvutil cmd with debug and filters
-# Need to set variable: "$middate" to the invutil date
-#
-_do_invutil()
-{
- host=`hostname`
- echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$RESULT_DIR/$seq.full
- $XFSINVUTIL_PROG $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
- | tee -a $RESULT_DIR/$seq.full | _invutil_filter
-}
-
-#
-# ensure we can find the user quota msg if user quotas are on
-# ensure we can find the group quota msg if group quotas are on
-#
-_check_quota()
-{
- usermsg=$1
- groupmsg=$2
- projectmsg=$3
- uquota=0
- gquota=0
- pquota=0
- $here/src/feature -U $SCRATCH_DEV && uquota=1
- $here/src/feature -G $SCRATCH_DEV && gquota=1
- $here/src/feature -P $SCRATCH_DEV && pquota=1
-
- $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota \
- -v full=$RESULT_DIR/$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) {
- print "Found extra:", $0
- }
- next
- }
- $0 ~ usermsg {
- print "Found user quota:", $0 >>full
- found_uquota = 1
- if (!uquota) {
- print "Found extra:", $0
- }
- next
- }
- { print }
- END {
- if (uquota && !found_uquota) {
- print "Missing user quota msg:", usermsg
- }
- 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)
-#
-_check_quota_entries()
-{
- uquota=0
- gquota=0
- pquota=0
- $here/src/feature -U $SCRATCH_DEV && uquota=1
- $here/src/feature -G $SCRATCH_DEV && gquota=1
- $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' \
- '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
-}
-
-#
-# 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_proj'
-}
-
-#
-# Look for the quota file in the output
-# Ensure that it is there if it should be
-# Filter it out so that the output is always the same
-# even with no quotas
-#
-_check_quota_file()
-{
- _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group' 'xfsdump_quotas_proj'
-}
-
-
-# make sure this script returns success
-/bin/true
+++ /dev/null
-##/bin/bash
-#
-# Copyright (c) 2007 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
-#
-#
-# Core of filestreams tests.
-#
-
-_check_filestreams_support()
-{
- local irix_timeout_sysvar="xfs_mfstream_timeout"
- local linux_timeout_procvar="/proc/sys/fs/xfs/filestream_centisecs"
- local streams_avail=""
- if [ "$HOSTOS" == "IRIX" ]; then
- # check for the filestreams timeout systune variable in irix
- streams_avail=`systune $irix_timeout_sysvar 2>&1 |
- perl -ne 'if (/'$irix_timeout_sysvar'\s+=\s+\d+/) {print "true"}'`
- else
- # check for the filestreams timeout proc entry in linux
- [ -f $linux_timeout_procvar ] && streams_avail="true"
- fi
-
- if [ "$streams_avail" == "true" ]; then
- return 0
- else
- return 1
- fi
-}
-
-_set_stream_timeout_centisecs()
-{
- local new_timeout_csecs=$1
- local irix_timeout_sysvar="xfs_mfstream_timeout"
- local linux_timeout_procvar="/proc/sys/fs/xfs/filestream_centisecs"
- if [ "$HOSTOS" == "IRIX" ]; then
- echo y | systune -r $irix_timeout_sysvar $new_timeout_csecs >/dev/null
- else
- echo $new_timeout_csecs > $linux_timeout_procvar
- fi
-}
-
-_do_stream()
-{
- local directory_name=$1
- local files=$2
- local file_size=$3
- local bsize=$4
- local iflag=$5
- local dio=$6
- local blocks_in_file=`expr $file_size / $bsize`
-
- mkdir $directory_name
- if [ "$iflag" = "1" -a "$HOSTOS" != "IRIX" ]; then
- $XFS_IO_PROG -x -c "chattr +S" $directory_name \
- || _fail "chattr of filestream flag"
- fi
- cd $directory_name
-
- local dd_cmd=""
- if [ "$HOSTOS" == "IRIX" ]; then
- # for irix use lmdd
- dd_cmd="lmdd"
- [ "$dio" = "1" ] && dd_cmd="$dd_cmd odirect=1"
- else
- # for linux use dd
- dd_cmd="dd"
- [ "$dio" = "1" ] && dd_cmd="$dd_cmd oflag=direct"
- fi
- dd_cmd="$dd_cmd if=/dev/zero bs=${bsize} count=${blocks_in_file}"
-
- local i=1
- while [ $i -le $files ]; do
- $dd_cmd of=frame-${i} 2>&1 | grep -v records | grep -v secs
- i=`expr $i + 1`
- done
-}
-
-_filter_agno()
-{
- # the ag number is in column 4 of xfs_bmap output
- perl -ne '
- $ag = (split /\s+/)[4] ;
- if ($ag =~ /\d+/) {print "$ag "} ;
- '
-}
-
-_get_stream_ags()
-{
- local directory_name=$1
- local stream_ags=`xfs_bmap -vp ${directory_name}/* | _filter_agno`
- echo $stream_ags
-}
-
-_check_for_dupes()
-{
- # check for duplicate numbers between two space seperated vars
- local num_str_one=$1
- local num_str_two=$2
-
- local this_num_one
- local this_num_two
- for this_num_one in $num_str_one; do
- for this_num_two in $num_str_two; do
- if [ "$this_num_one" == "$this_num_two" ]; then
- echo "duplicate AG $this_num_one found" \
- >> $RESULT_DIR/$seq.full
- return 1
- fi
- done
- done
- return 0
-}
-
-_test_streams() {
-
- echo "# testing $* ...."
- local agcount="$1"
- local agsize="$2" # in MB
- local stream_count="$3"
- local stream_files="$4"
- local stream_file_size=`expr $5 \* 1024 \* 1024`
- local use_iflag="$6"
- local use_directio="$7"
- local expected_result="$8" # "fail" if failure is expected
-
- local size=`expr $agsize \* 1024 \* 1024 \* $agcount`
- _scratch_mkfs_xfs -dsize=$size,agcount=$agcount >/dev/null 2>&1 \
- || _fail "mkfs failed"
-
- if [ "$use_iflag" = "0" -o "$HOSTOS" == "IRIX" ]; then
- # mount using filestreams mount option
- _scratch_mount "-o filestreams" \
- || _fail "filestreams mount failed"
- else
- # test will set inode flag
- _scratch_mount || _fail "mount failed"
- fi
-
- cd $SCRATCH_MNT
-
- # start $stream_count streams
- # each stream writes ($stream_files x $stream_file_size)M
- echo "# streaming"
- local stream_pids=""
- local stream_index=1
- while [ $stream_index -le $stream_count ]; do
- _do_stream stream${stream_index}-dir $stream_files \
- $stream_file_size 1048576 $use_iflag $use_directio &
- stream_pids="$stream_pids $!"
- stream_index=`expr $stream_index + 1`
- done
-
- # wait for streams to finish
- # XXX wait here not needed? -dgc
- wait $stream_pids
-
- # sync the buffered streams out in parallel
- # _get_stream_ags does a xfs_bmap which syncs delayed allocations
- echo "# sync AGs..."
- local ag_sync_pids=""
- stream_index=1
- while [ $stream_index -le $stream_count ]; do
- _get_stream_ags stream${stream_index}-dir > /dev/null 2>&1 &
- ag_sync_pids="$ag_sync_pids $!"
- stream_index=`expr $stream_index + 1`
- done
-
- # wait for syncs to finish
- wait $ag_sync_pids
-
- # confirm streams are in seperate AGs
- echo "# checking stream AGs..."
- local this_stream_ags=""
- local ags_seen=""
- local num_streams_with_matching_ags=0
- stream_index=1
- while [ $stream_index -le $stream_count ]; do
- this_stream_ags=`_get_stream_ags stream${stream_index}-dir`
- echo "stream $stream_index AGs: $this_stream_ags" >> $RESULT_DIR/$seq.full
- _check_for_dupes "$ags_seen" "$this_stream_ags"
- if [ $? -ne 0 ]; then
- # this stream is not in seperate AGs to previous streams
- num_streams_with_matching_ags=`expr $num_streams_with_matching_ags + 1`
- fi
- ags_seen="$ags_seen $this_stream_ags"
- stream_index=`expr $stream_index + 1`
- done
-
- _cleanup_streams_umount
- if [ "$expected_result" != "fail" ]; then
- if [ $num_streams_with_matching_ags -eq 0 ]; then
- # all streams in seperate AGs, as expected
- echo "+ passed, streams are in seperate AGs"
- else
- # streams with matching AGs, should be seperate
- _fail "- failed, $num_streams_with_matching_ags streams with matching AGs"
- fi
- else
- # expecting streams to have overlapped
- if [ $num_streams_with_matching_ags -eq 0 ]; then
- # all streams in seperate AGs, should have overlapped
- _fail "- streams are in seperate AGs, expected _matching_"
- else
- # streams with matching AGs, as expected
- echo "+ expected failure, matching AGs"
- fi
- fi
- return 0
-}
-
-_cleanup_streams_umount()
-{
- cd /
- rm -rf ${SCRATCH_MNT}/stream*
- umount $SCRATCH_DEV 2>/dev/null
-}
+++ /dev/null
-##/bin/bash
-#
-# Copyright (c) 2000-2001 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
-#
-#
-# standard filters
-#
-
-# Checks that given_value is in range of correct_value +/- tolerance.
-# Tolerance can be an absolute value or a percentage of the correct value
-# (see examples with tolerances below).
-# Outputs suitable message to stdout if it's not in range.
-#
-# A verbose option, -v, may be used as the LAST argument
-#
-# e.g.
-# foo: 0.0298 = 0.03 +/- 5%
-# _within_tolerance "foo" 0.0298 0.03 5%
-#
-# foo: 0.0298 = 0.03 +/- 0.01
-# _within_tolerance "foo" 0.0298 0.03 0.01
-#
-# foo: 0.0298 = 0.03 -0.01 +0.002
-# _within_tolerance "foo" 0.0298 0.03 0.01 0.002
-#
-# foo: verbose output of 0.0298 = 0.03 +/- 5%
-# _within_tolerance "foo" 0.0298 0.03 5% -v
-_within_tolerance()
-{
- _name=$1
- _given_val=$2
- _correct_val=$3
- _mintol=$4
- _maxtol=$_mintol
- _verbose=0
- _debug=false
-
- # maxtol arg is optional
- # verbose arg is optional
- if [ $# -ge 5 ]
- then
- if [ "$5" = "-v" ]
- then
- _verbose=1
- else
- _maxtol=$5
- fi
- fi
- if [ $# -ge 6 ]
- then
- [ "$6" = "-v" ] && _verbose=1
- fi
-
- # find min with or without %
- _mintolerance=`echo $_mintol | sed -e 's/%//'`
- if [ $_mintol = $_mintolerance ]
- then
- _min=`echo "scale=5; $_correct_val-$_mintolerance" | bc`
- else
- _min=`echo "scale=5; $_correct_val-$_mintolerance*0.01*$_correct_val" | bc`
- fi
-
- # find max with or without %
- _maxtolerance=`echo $_maxtol | sed -e 's/%//'`
- if [ $_maxtol = $_maxtolerance ]
- then
- _max=`echo "scale=5; $_correct_val+$_maxtolerance" | bc`
- else
- _max=`echo "scale=5; $_correct_val+$_maxtolerance*0.01*$_correct_val" | bc`
- fi
-
- $_debug && echo "min = $_min"
- $_debug && echo "max = $_max"
-
- cat <<EOF >$tmp.bc.1
-scale=5;
-if ($_min <= $_given_val) 1;
-if ($_min > $_given_val) 0;
-EOF
-
- cat <<EOF >$tmp.bc.2
-scale=5;
-if ($_given_val <= $_max) 1;
-if ($_given_val > $_max) 0;
-EOF
-
- _above_min=`bc <$tmp.bc.1`
- _below_max=`bc <$tmp.bc.2`
-
- rm -f $tmp.bc.[12]
-
- _in_range=`expr $_above_min \& $_below_max`
-
- # fix up min, max precision for output
- # can vary for 5.3, 6.2
-
- # remove any trailing zeroes from min, max if they have fractional parts
- _min=`echo $_min | sed -e '/\./s/0*$//' -e 's/\.$//'`
- _max=`echo $_max | sed -e '/\./s/0*$//' -e 's/\.$//'`
-
- if [ $_in_range -eq 1 ]
- then
- [ $_verbose -eq 1 ] && echo $_name is in range
- return 0
- else
- [ $_verbose -eq 1 ] && echo $_name has value of $_given_val
- [ $_verbose -eq 1 ] && echo $_name is NOT in range $_min .. $_max
- return 1
- fi
-}
-
-# ctime(3) dates
-#
-_filter_date()
-{
- sed \
- -e 's/[A-Z][a-z][a-z] [A-z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/DATE/'
-}
-
-# prints filtered output on stdout, values (use eval) on stderr
-#
-_filter_mkfs()
-{
- set -
- perl -ne '
- if (/^meta-data=([\w,|\/.-]+)\s+isize=(\d+)\s+agcount=(\d+), agsize=(\d+) blks/) {
- print STDERR "ddev=$1\nisize=$2\nagcount=$3\nagsize=$4\n";
- print STDOUT "meta-data=DDEV isize=XXX agcount=N, agsize=XXX blks\n";
- }
- if (/^\s+=\s+sectsz=(\d+)\s+attr=(\d+)/) {
- print STDERR "sectsz=$1\nattr=$2\n";
- }
- if (/^data\s+=\s+bsize=(\d+)\s+blocks=(\d+), imaxpct=(\d+)/) {
- print STDERR "dbsize=$1\ndblocks=$2\nimaxpct=$3\n";
- print STDOUT "data = bsize=XXX blocks=XXX, imaxpct=PCT\n";
- }
- if (/^\s+=\s+sunit=(\d+)\s+swidth=(\d+) blks/) {
- print STDERR "sunit=$1\nswidth=$2\nunwritten=1\n";
- print STDOUT " = sunit=XXX swidth=XXX, unwritten=X\n";
- }
- if (/^naming\s+=version\s+(\d+)\s+bsize=(\d+)/) {
- print STDERR "dirversion=$1\ndirbsize=$2\n";
- print STDOUT "naming =VERN bsize=XXX\n";
- }
- if (/^log\s+=(internal log|[\w|\/.-]+)\s+bsize=(\d+)\s+blocks=(\d+),\s+version=(\d+)/ ||
- /^log\s+=(internal log|[\w|\/.-]+)\s+bsize=(\d+)\s+blocks=(\d+)/) {
- print STDERR "ldev=\"$1\"\nlbsize=$2\nlblocks=$3\nlversion=$4\n";
- print STDOUT "log =LDEV bsize=XXX blocks=XXX\n";
- }
- if (/^\s+=\s+sectsz=(\d+)\s+sunit=(\d+) blks/) {
- print STDERR "logsectsz=$1\nlogsunit=$2\n\n";
- }
- if (/^realtime\s+=([\w|\/.-]+)\s+extsz=(\d+)\s+blocks=(\d+), rtextents=(\d+)/) {
- print STDERR "rtdev=$1\nrtextsz=$2\nrtblocks=$3\nrtextents=$4\n";
- print STDOUT "realtime =RDEV extsz=XXX blocks=XXX, rtextents=XXX\n";
- }'
-}
-
-
-# prints the bits we care about in growfs
-#
-_filter_growfs()
-{
- perl -ne '
- if (/^data\s+=\s+bsize=(\d+)\s+blocks=(\d+), imaxpct=(\d+)/) {
- print "xfs_growfs --BlockSize=$1 --Blocks=$2\n";
- }
- elsif (/^data/) {
- print;
- }'
-}
-
-_filter_dd()
-{
- $AWK_PROG '
- /records in/ { next }
- /records out/ { next }
- /No space left on device/ { print " !!! disk full (expected)"
- next }
- { print " *** " $0 }
- '
-}
-
-common_line_filter()
-{
- perl -ne 'if (/.*:(.*)/) {
- if ( "$last_line" ne "$1" ) { print "$_"; $first_match=1; }
- elsif ( $first_match==1 ) { print "*\n"; $first_match=0; }
- $last_line="$1";
- }
- else {
- print $_; $last_line=$_;
- }'
-}
-
-_filter_xfs_io()
-{
- sed -e "s/[0-9/.]* [GMKiBbytes]*, [0-9]* ops\; [0-9/:. sec]* ([inf0-9/.]* [EPGMKiBbytes]*\/sec and [inf0-9/.]* ops\/sec)/XXX Bytes, X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/"
-}
-
-_filter_xfs_io_unique()
-{
- common_line_filter | _filter_xfs_io
-}
-
-_filter_test_dir()
-{
- sed -e "s,$TEST_DEV,TEST_DEV,g" -e "s,$TEST_DIR,TEST_DIR,g"
-}
-
-_filter_scratch()
-{
- sed -e "s,$SCRATCH_DEV,SCRATCH_DEV,g" \
- -e "s,$SCRATCH_MNT,SCRATCH_MNT,g" \
- -e "/.use_space/d"
-}
-
-# Turn any device in the scratch pool into SCRATCH_DEV
-_filter_scratch_pool()
-{
- FILTER_STRINGS=`echo $SCRATCH_DEV_POOL | sed -e 's/\s\+/\\\|/g'`
- sed -e "s,$FILTER_STRINGS,SCRATCH_DEV,g"
-}
-
-_filter_spaces()
-{
- sed -e 's/ [ ]*/ /g'
-}
-
-# Account for different "ln" failure messages
-_filter_ln()
-{
- sed -e "s,\(creating symbolic link .*\) to .*: ,\1," \
- -e "s,failed to create,creating,"
-}
-
-# If given an arg, filter *that* UUID string
-# Otherwise look for something that looks like a generic UUID
-_filter_uuid()
-{
- if [ ! -z $1 ]; then
- UUID=$1
- sed -e "s/\(uuid:\) $UUID/\1 <EXACTUUID>/i"
- else
- sed -e "s/\(uuid:\) *[0-9a-f-][0-9a-f-]*/\1 <UUID>/i"
- fi
-}
-
-# Filter out sizes like 6.14MB etc
-_filter_size()
-{
- sed -e "s/[0-9\.]\+\s\?[b|k|m|g|t][b]\?/<SIZE>/ig"
-}
-
-# Convert string read from stdin like 128K to bytes and print it to stdout
-_filter_size_to_bytes()
-{
- read size
- suffix=${size:${#size}-1}
- mul=1
- case $suffix in
- k|K) mul=1024 ;;
- m|M) mul=$((1024*1024)) ;;
- g|G) mul=$((1024*1024*1024)) ;;
- t|T) mul=$((1024*1024*1024*1024)) ;;
- esac
- echo $((${size:0:${#size}-1}*$mul))
-}
-
-# make sure this script returns success
-/bin/true
+++ /dev/null
-# Filters for btrfs command output
-
-. ./common.filter.btrfs
-
-# Some, but not all, commands emit "Btrfs <version>"
-_filter_btrfs_version()
-{
- sed -e "s/^Btrfs.*//g"
-}
-
-_filter_devid()
-{
- sed -e "s/\(devid\s\+\)[0-9]\+/\1 <DEVID>/g"
-}
-
-# If passed a number as first arg, filter that number of devices
-# If passed a UUID as second arg, filter that exact UUID
-_filter_btrfs_filesystem_show()
-{
- if [ ! -z $1 ]; then
- NUMDEVS=$1
- NUM_SUBST="<EXACTNUM>"
- else
- NUMDEVS="[0-9]\+"
- NUM_SUBST="<NUM>"
- fi
-
- UUID=""
- if [ ! -z $2 ]; then
- UUID=$2
- fi
-
- # the uniq collapses all device lines into 1
- _filter_uuid $UUID | _filter_scratch | _filter_scratch_pool | \
- _filter_size | _filter_btrfs_version | _filter_devid | \
- sed -e "s/\(Total devices\) $NUMDEVS/\1 $NUM_SUBST/g" | \
- uniq
-}
-
-# This eliminates all numbers, and shows only unique lines,
-# to accomodate a varying nr. of devices.
-# If given an argument, make sure we saw that many devices
-# in total.
-_filter_btrfs_device_stats()
-{
- if [ ! -z $1 ]; then
- NUMDEVS=$1
- UNIQ_OPT="-c"
- else
- NUMDEVS="thiswillnotmatch"
- UNIQ_OPT=""
- fi
-
- _filter_scratch | _filter_scratch_pool | \
- sed -e "s/[0-9]\+$/<NUM>/g" | sort | uniq $UNIQ_OPT | \
- sed -e "s/$NUMDEVS /<NUMDEVS> /g"
-}
-
-# make sure this script returns success
-/bin/true
+++ /dev/null
-##/bin/bash
-#
-# 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
-#
-#
-# common routines for log testing
-# Created by dxm@sgi.com & tes@sgi.com
-#
-
-fulldir=$RESULT_DIR/$seq.fulldir
-rm -rf $fulldir
-
-_cleanup_logfiles()
-{
- if [ $status -eq 0 ]; then
- # don't keep these files around unless something went wrong
- rm -rf $fulldir
- fi
-}
-
-_full()
-{
- echo "" >>$RESULT_DIR/$seq.full
- echo "*** $* ***" >>$RESULT_DIR/$seq.full
- echo "" >>$RESULT_DIR/$seq.full
-}
-
-_echofull()
-{
- echo "" | tee -a $RESULT_DIR/$seq.full
- echo "*** $* ***" | tee -a $RESULT_DIR/$seq.full
- echo "" | tee -a $RESULT_DIR/$seq.full
-}
-
-# Handle the operations which get split over Log Record
-# boundaries.
-# Oper (379)..... flags: CONTINUE
-# ...
-# Oper (0)....... flags: WAS_CONT END
-#
-# or
-#
-# Oper (379)..... flags: none
-# ...
-# Oper (0)....... flags: none
-#
-_filter_opnum()
-{
- $AWK_PROG '
-BEGIN {
- debug = 0
- }
-/^Oper/ && debug {
- printf "line = %s\n", $0
- }
-/^Oper/ {
- was_cont = 0
- }
-/^Oper/ && /flags: CONTINUE/ {
- # this will be the first op of split region
- $9 = "none" # overwrite CONTINUE flags
- print
- print "Not printing rest"
- was_cont = 1
- next
- }
-/^Oper/ && /flags: WAS_CONT END/ {
- # this will be the last op of split region
- # skip over was-continued op
- # we assume there can be only 1
- was_cont = 1
- next
- }
-(was_cont == 1) {
- # skip over any continued op stuff
- next
- }
- {print}
- '
-}
-
-#
-# Filter out things that can change
-# We have complexities which change when log is sync'ed at different
-# times.
-# Example1: DATA FORK EXTENTS
-# These will not show up if inode is sync'ed sooner
-# /DATA FORK EXTENTS/d;
-# /INODE:/s/flags:0x5/flags:0x1/g;
-# define XFS_ILOG_CORE 0x001 /* log standard inode fields */
-# define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */
-#
-#
-
-_filter_logprint()
-{
- _fix_malloc |\
- sed '
- s/ver:[0-9]/ver:<VERS>/;
- s/version [0-9] format [0-9]/version <VERS> format <FORMAT>/;
- s/data device: 0x[0-9a-f][0-9a-f]*/data device: <DEVICE>/;
- s/log device: 0x[0-9a-f][0-9a-f]*/log device: <DEVICE>/;
- s/log file: \".*\"/log device: <DEVICE>/;
- s/daddr: [0-9][0-9]*/daddr: <DADDR>/;
- s/length: [0-9][0-9]*/length: <LENGTH>/;
- s/length: [0-9][0-9]*/length: <LENGTH>/;
- s/^cycle num overwrites: .*$/cycle num overwrites: <TIDS>/;
- s/tid: [0-9a-f][0-9a-f]*/tid: <TID>/;
- s/tid:0x[0-9a-f][0-9a-f]*/tid:<TID>/;
- s/q:0x[0-9a-f][0-9a-f]*/q:<Q>/;
- s/a:0x[0-9a-f][0-9a-f]*/a:<A>/g;
- s/blkno:0x[0-9a-f][0-9a-f]*/blkno:<BLKNO>/g;
- s/blkno: *[0-9][0-9]* (0x[0-9a-f]*)/blkno: <BLKNO> (<BLKNO>)/g;
- s/blkno: *[0-9][0-9]*/blkno: <BLKNO>/g;
- s/boff: [0-9][0-9]*/boff: <BOFF>/g;
- s/len: *[0-9][0-9]*/len:<LEN>/g;
- /BUF:/s/[ ]*flags:.*$//;
- /zeroed blocks/s/[0-9][0-9]*/<COUNT>/g;
- /cleared blocks/d;
- /log tail/s/[0-9][0-9]*/<COUNT>/g;
- s/atime:[0-9a-fx]* *mtime:[0-9a-fx]* *ctime:[0-9a-fx]*/atime:<TIME> mtime:<TIME> ctime:<TIME>/;
- s/atime 0x[0-9a-f]* mtime 0x[0-9a-f]* ctime 0x[0-9a-f]*/atime <TIME> mtime <TIME> ctime <TIME>/;
- s/block [0-9][0-9]*/block <BLOCK>/;
- s/icount: *[0-9][0-9]* *ifree: *[0-9][0-9]* *fdblks: *[0-9][0-9]* *frext: *[0-9][0-9]*/icount:<COUNT> ifree:<FREE> fdblks:<BLOCKS> frext:<COUNT>/;
- s/sunit: *[0-9][0-9]* *swidth: *[0-9][0-9]*/sunit:<SUNIT> swidth:<SWIDTH>/;
- s/1st: *[0-9][0-9]* *last: *[0-9][0-9]* *cnt: *[0-9][0-9]* *freeblks: *[0-9][0-9]* *longest: *[0-9][0-9]*/1st:<NUM> last:<NUM> cnt:<COUNT> freeblks:<COUNT> longest:<NUM>/;
- s/^uuid: *[0-9a-f-][0-9a-f-]* *format: *.*$/uuid: <UUID> format: <FORMAT>/;
- /flushiter:/d;
- /version:/,/h_size:/d;
- /override tail/s/[0-9][0-9]*/<TAIL_BLK>/;
- /^---*/d;
- /^===*/d;
- /^~~~*/d;
- /extended-header/d;
- /LOG REC AT LSN/d;
- /DATA FORK EXTENTS/d;
- s/BUF: cnt:[1-9][0-9]* total:[1-9][0-9]*.*/BUF: cnt:C total:T/;
- s/INO: cnt:[1-9][0-9]* total:[1-9][0-9]*.*/INO: cnt:C total:T/;
- s/#regs: *[1-9][0-9]*/#regs:R/;
- /INODE:/s/flags:0x5/flags:0x1/g;
- s/Oper ([0-9][0-9]*)/Oper (OPNUM)/;
- /^[ ]*$/d;
- s/ */ /g;
- s/ $//;
- s/newino: 0x[0-9a-f]*$/newino: <INO>/g
- s/newino:0x[0-9a-f]*$/newino:<INO>/g
- s/ino: 0x[0-9a-f]* flags:/ino: <INO> flags:/g
- s/ino:0x[0-9a-f]* flags:/ino:<INO> flags:/g
- s/onlink:[0-9][0-9]*/onlink:<ONLINK>/;
- s/gen:-*[0-9][0-9]*/gen:<GEN>/;
- s/gen 0x[0-9a-f][0-9a-f]*/gen <GEN>/;
- '|\
- awk '
- # collapse BUF DATA group into 1 line
- # for Oper data this can be over separate operations...ughh
- /BUF DATA/ {
- if (!buf_data) { # 1st one
- if (oper) {
- print oper
- oper = 0
- }
- print
- }
- buf_data = 1
- oper = 0 # wont need it now
- next
- }
- /^Oper/ {
- # store it as we dont know if 2nd BUF DATA is to follow
- if (oper) {
- print oper
- }
- oper = $0
- next
- }
- /^TRANS/ && dummy_rec == 1 {
- # start printing again - dummy transaction over
- dummy_rec = 0
- }
- /DUMMY1/ {
- # filter out dummy transactions
- dummy_rec = 1
- next
- }
- {
- if (dummy_rec) {
- next
- }
- buf_data = 0
- if (oper) { # now we can print out oper
- print oper
- oper = 0
- }
- print
- }
- '
-}
-
-_check_log()
-{
- _full "clean_log : xfs_logprint"
- _scratch_xfs_logprint -t | tee -a $RESULT_DIR/$seq.full \
- | head | grep -q "<CLEAN>" || _fail "DIRTY LOG"
-}
-
-_print_logstate()
-{
- _scratch_xfs_logprint -t | tee -a $RESULT_DIR/$seq.full >$tmp.logprint
- if grep -q "<DIRTY>" $tmp.logprint; then
- echo "dirty log"
- fi
- if grep -q "<CLEAN>" $tmp.logprint; then
- echo "clean log"
- fi
-}
-
-_print_operation()
-{
- mkdir $fulldir >/dev/null 2>&1
- mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
- mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
- raw=$fulldir/op.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
- filtered=$fulldir/op.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
-
- echo "### xfs_logprint output ###" | tee $raw >$filtered
- _scratch_xfs_logprint -c 2>&1 \
- | tee -a $raw \
- | _filter_logprint \
- | _filter_opnum \
- >>$filtered
-}
-
-# start at rec#2 "-s 2" so we skip over UMOUNT record which will always
-# be a 512b single header at mkfs time
-# and may not match with the FS mounted at a different LR size
-# => xlog_do_recovery_pass() can not handle the different hdr sizes
-# it assumes them all to be the same between the start..finish
-# NB: On IRIX there is no UMOUNT record and so we could start from -s 0.
-
-_print_transaction_inode()
-{
- _start=$1
- mkdir $fulldir >/dev/null 2>&1
- mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
- mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
- raw=$fulldir/trans_inode.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
- filtered=$fulldir/trans_inode.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
-
- echo "### xfs_logprint -t -i -s START output ###" | tee $raw >$filtered
- _scratch_xfs_logprint -t -i -s $_start 2>&1 \
- | tee -a $raw \
- | _filter_logprint \
- >>$filtered
-}
-
-_print_transaction_buf()
-{
- _start=$1
- mkdir $fulldir >/dev/null 2>&1
- mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
- mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
- raw=$fulldir/trans_buf.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
- filtered=$fulldir/trans_buf.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
-
- echo "### xfs_logprint -t -b -s START output ###" | tee $raw >$filtered
- _scratch_xfs_logprint -t -b -s $_start 2>&1 \
- | tee -a $raw \
- | _filter_logprint \
- >>$filtered
-}
-
-_mkfs_log()
-{
- # create the FS
- # mkfs options to append to log size otion can be specified ($*)
- export MKFS_OPTIONS="-l size=2000b -l lazy-count=1 $*"
- _full "mkfs"
- _scratch_mkfs_xfs >>$RESULT_DIR/$seq.full 2>&1
- if [ $? -ne 0 ] ; then
- _echofull "Cannot mkfs for this test using option specified: $MKFS_OPTIONS"
- return 1
- fi
-
- return 0
-}
-
-
-#
-# mount fs and create some log traffic
-#
-_create_log()
-{
- # mount the FS
- _full "mount"
- _scratch_mount >>$RESULT_DIR/$seq.full 2>&1
- if [ $? -ne 0 ] ; then
- _echofull "mount failed: $MOUNT_OPTIONS"
- return 1
- fi
-
- # generate some log traffic - but not too much - life gets a little
- # more complicated if the log wraps around. This traffic is
- # pretty much arbitary, but could probably be made better than this.
- touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
-
- # unmount the FS
- _full "umount"
- umount $SCRATCH_DEV >>$RESULT_DIR/$seq.full 2>&1
- if [ $? -ne 0 ] ; then
- _echofull "umount failed"
- return 1
- fi
-
- return 0
-}
-
-#
-# mount fs and create some log traffic with sync'ing
-#
-_create_log_sync()
-{
- # mount the FS
- _full " mount"
- _scratch_mount >>$RESULT_DIR/$seq.full 2>&1
- if [ $? -ne 0 ] ; then
- _echofull "mount failed: $MOUNT_OPTIONS"
- return 1
- fi
-
- # generate some log traffic - but not too much
- # add some syncs to get the log flushed to disk
- for file in $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}; do
- touch $file
- sync
- done
-
- # unmount the FS
- _full "umount"
- umount $SCRATCH_DEV >>$RESULT_DIR/$seq.full 2>&1
- if [ $? -ne 0 ] ; then
- _echofull "umount failed"
- return 1
- fi
-}
-
-_cmp_output()
-{
- echo "*** compare logprint: $1 with $2"
- if ! diff $1 $2 >/dev/null; then
- _fail "logprint output $1 differs to $2"
- fi
-}
-
-#
-# Op data of different Log Record sizes will mean that data is
-# split at different points and in op printing it will not
-# try and decode the data which has been split up.
-# So we do a special diff processing to complain of differences
-# if no split is involved.
-#
-# Example diff with forms of:
-# "Left over region from split log item"
-# "Not printing rest of data"
-#
-# 2149c2149
-# < Left over region from split log item
-# ---
-# > BUF DATA
-# 2888c2888,2889
-# < INODE: #regs: 3 Not printing rest of data
-# ---
-# > INODE: #regs: 3 ino: 0x80 flags: 0x5 dsize: 16
-# > blkno: <BLKNO> len:<LEN> boff: <BOFF>
-#
-_process_op_diff()
-{
- $AWK_PROG <$1 '
- BEGIN { num_splits = 1; max_splits = 50 }
- /^[0-9]/ {
-
- # ensure a split happened in previous difference
- if (num_splits < 1 || num_splits > max_splits) {
- print num_splits, " split(s) found prior to diff cmd: ", $0
- num_splits = 1 # shut-up end condition
- exit 1
- }
- num_splits = 0
-
- next
- }
- /Left over region/ || /Not printing rest/ {
- num_splits++
- next
- }
- { next }
- END {
- if (num_splits < 1 || num_splits > max_splits) {
- print num_splits, " split(s) found prior to diff end"
- exit 1
- }
- }
- '
- return $?
-}
-
-_cmp_op_output()
-{
- echo "*** compare logprint: $1 with $2"
-
- diff $1 $2 >$filtered.diff
- if ! _process_op_diff $filtered.diff
- then
- _fail "logprint output $1 differs to $2 considering splits"
- fi
-}
-
-# return xfs log version of device
-# e.g.
-# _log_version /dev/dsk/dks0d1s4
-#
-_log_version()
-{
- _dev=$1
- vers=`xfs_db -c 'sb 0' -c 'p versionnum' -r $_dev | $AWK_PROG '{print $3}'`
- logver=`echo $vers | sed -e 's/0x[0-9a-f]\([0-9a-f]\)[0-9a-f][0-9a-f]/\1/'`
- if [ $logver = 4 -o $logver = 5 -o $logver = 6 -o $logver = 7 -o \
- $logver = c -o $logver = d -o $logver = e -o $logver = f ]; then
- echo 2
- else
- echo 1
- fi
-}
-
-_require_v2log()
-{
- # test out mkfs to see if it supports "-l version=2"
- export MKFS_OPTIONS="-l version=2"
- if ! _scratch_mkfs_xfs >>$RESULT_DIR/$seq.full 2>&1; then
- _notrun "mkfs does not support v2 logs"
- fi
-
- # test out mount to see if it mounts a v2 log fs
- export MOUNT_OPTIONS="-o logbsize=32k"
- if ! _scratch_mount >>$RESULT_DIR/$seq.full 2>&1; then
- _notrun "mount/kernel does not support v2 logs"
- fi
-
- # check after unmount to see if it is clean
- # i.e. it is not a 6.5.25 buggy version checking kernel
- touch $SCRATCH_MNT/file
- umount $SCRATCH_DEV >>$RESULT_DIR/$seq.full 2>&1
- if _scratch_xfs_logprint -t | tee -a $RESULT_DIR/$seq.full \
- | head | grep -q "<DIRTY>"; then
- _notrun "kernel does not support v2 logs"
- fi
-
- # otherwise presume it does support v2 logs...:)
-}
-
-
-# make sure this script returns success
-/bin/true
+++ /dev/null
-##/bin/bash
-#
-# Copyright (c) 2007 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
-#
-#
-# common functions for excersizing hole punches with extent size hints etc.
-
-# source dmap_scratch_mount etc.
-. ./common.dmapi
-
-_spawn_test_file() {
- echo "# spawning test file with $*"
- local blksize=$1
- local file_size=`expr $2 \* $blksize`
- local extent_size_hint=`expr $3 \* $blksize`
- local test_file=$4
- local reserve_space=$5
-
- if [ $extent_size_hint -ne 0 ]; then
- echo "+ setting extent size hint to $extent_size_hint"
- $XFS_IO_PROG -f \
- -c "extsize $extent_size_hint" \
- $test_file
- fi
- # print extent size hint for $test_file
- $XFS_IO_PROG -f \
- -c "extsize" \
- $test_file
-
- if [ "$reserve_space" == "noresv" ]; then
- echo "+ not using resvsp at file creation"
- $XFS_IO_PROG -f \
- -c "truncate $file_size" \
- $test_file
- else
- $XFS_IO_PROG -f \
- -c "truncate $file_size" \
- -c "resvsp 0 $file_size" \
- $test_file
- fi
-}
-
-_do_punch() {
- echo "# punching with $*"
- # punch or bite the ear off $test_file to create a hole
- local blksize=$1
- local punch_offset=`expr $2 \* $blksize`
- local punch_size=`expr $3 \* $blksize`
- local punch_type=$4 # u for unresvsp, d for dm_punch
- local test_file=$5
-
- if [ "$punch_type" == "u" ]; then
- echo "+ hole punch using unresvsp"
- $XFS_IO_PROG -f \
- -c "unresvsp $punch_offset $punch_size" \
- $test_file
- fi
- if [ "$punch_type" == "d" ]; then
- echo "+ hole punch using dmapi punch_hole"
- ${DMAPI_QASUITE1_DIR}cmd/punch_hole -o $punch_offset -l $punch_size \
- ${SCRATCH_MNT}/$test_file
- fi
-}
-
-_do_write() {
- echo "# writing with $*"
- local blksize=$1
- local write_offset=`expr $2 \* $blksize`
- local write_size=`expr $3 \* $blksize`
- local test_file=$4
-
- $XFS_IO_PROG -f \
- -c "pwrite $write_offset $write_size" \
- $test_file >/dev/null
-}
-
-_do_bmap() {
- echo "# showing file state $*"
- local test_file=$1
-
- $XFS_IO_PROG -f \
- -c "bmap -vvp" \
- $test_file
-}
-
-_test_punch() {
- echo "# testing $* ..."
- local blksize=$1
- # all points and sizes below are in terms of filesystem blocks
- local extsize_hint_blks=$2 # extent size hint in FS blocks, 0=do not set
- local file_size_blks=$3 # the file size in blocks
- local punch_points_blks=( $4 ) # array of places to punch holes in the file
- local punch_sizes_blks=( $5 ) # array of size of each punch in blocks
- local punch_types=( $6 ) # array of u=unresvsp or d=dm_punch
- local write_points_blks=( $7 ) # array of places to pwrite in the file
- local write_sizes_blks=( $8 ) # array of size of each write
-
- local punch_write_order=( $9 ) # array of punch/write operation order
- # e.g. "w p w w p" means: do 1st write...
- # then 1st punch, 2nd & 3rd write, 2nd punch
- local resvsp=${10} # if "noresv" then don't resvsp on file create
- local filename=punch_test_file
-
- cd /
- umount $SCRATCH_MNT >/dev/null 2>&1
-
- _scratch_mkfs_xfs -bsize=$blksize >/dev/null 2>&1 \
- || _fail "mkfs failed"
-
- local this_punch_type=""
- local dmap_punch_used=0
- for this_punch_type in "${punch_types[@]}"; do
- [ "$this_punch_type" == "d" ] && dmap_punch_used=1
- done
- if [ $dmap_punch_used -ne 0 ]; then
- # a punch type of dm_punch has been specified, do a dmapi mount
- echo "+ mounting with dmapi enabled"
- _dmapi_scratch_mount
- else
- # only unresvsp punch type is used, just do a normal mount
- _scratch_mount || _fail "mount failed"
- fi
-
- cd $SCRATCH_MNT
-
- # check a size is specified for each punch
- [ ${#punch_points_blks[*]} -eq ${#punch_sizes_blks[*]} ] \
- || _fail "num punch points given does not equal num punch sizes"
-
- # check a type is specified for each punch
- [ ${#punch_points_blks[*]} -eq ${#punch_types[*]} ] \
- || _fail "num punch points given does not equal num punch types"
-
- # check a size is specified for each write
- [ ${#write_points_blks[*]} -eq ${#write_sizes_blks[*]} ] \
- || _fail "num write points given does not equal num write sizes"
-
- # check punch_write_order operations match number of punches + writes
- local total_pw_operations=`expr ${#punch_points_blks[*]} + ${#write_points_blks[*]}`
- [ $total_pw_operations -eq ${#punch_write_order[*]} ] \
- || _fail "punch_write_order ops doesn't match number of punches + writes"
-
- # create the file and setup extent size hint
- _spawn_test_file $blksize $file_size_blks $extsize_hint_blks $filename $resvsp
-
- # do the writes and punches
- local operation=""
- local punch_index=0
- local write_index=0
- for operation in "${punch_write_order[@]}"; do
- if [ "$operation" == "p" ]; then
- _do_punch $blksize ${punch_points_blks[$punch_index]} \
- ${punch_sizes_blks[$punch_index]} ${punch_types[$punch_index]} \
- $filename
- punch_index=`expr $punch_index + 1`
- fi
- if [ "$operation" == "w" ]; then
- _do_write $blksize ${write_points_blks[$write_index]} \
- ${write_sizes_blks[$write_index]} $filename
- write_index=`expr $write_index + 1`
- fi
- sync
- _do_bmap $filename # print out the state of the file
- done
-}
-
-_coalesce_extents()
-{
- awk -F: '
- {
- range = $2;
- type = $3;
-
- split(range, bounds, "[\\[ \\.\\]]");
- low = bounds[3];
- high = bounds[5];
-
- if (type != prev_type) {
- if (prev_type != "")
- printf("%u]:%s\n", low - 1, prev_type);
- printf("%u: [%u..", out_count++, low);
- prev_type = type;
- }
- }
- END {
- if (prev_type != "")
- printf("%u]:%s\n", high, prev_type);
- }'
-}
-
-_filter_fiemap()
-{
- awk --posix '
- $3 ~ /hole/ {
- print $1, $2, $3;
- next;
- }
- $5 ~ /0x[[:xdigit:]]*8[[:xdigit:]]{2}/ {
- print $1, $2, "unwritten";
- next;
- }
- $5 ~ /0x[[:xdigit:]]+/ {
- print $1, $2, "data";
- }' |
- _coalesce_extents
-}
-
-# Filters fiemap output to only print the
-# file offset column and whether or not
-# it is an extent or a hole
-_filter_hole_fiemap()
-{
- awk --posix '
- $3 ~ /hole/ {
- print $1, $2, $3;
- next;
- }
- $5 ~ /0x[[:xdigit:]]+/ {
- print $1, $2, "extent";
- }' |
- _coalesce_extents
-}
-
-
-# Prints the md5 checksum of a given file
-_md5_checksum()
-{
- md5sum $1 | cut -d ' ' -f1
-}
-
-_filter_bmap()
-{
- awk '
- $3 ~ /hole/ {
- print $1, $2, $3;
- next;
- }
- $7 ~ /10000/ {
- print $1, $2, "unwritten";
- next;
- }
- $7 ~ /00000/ {
- print $1, $2, "data"
- }' |
- _coalesce_extents
-}
-
-die_now()
-{
- status=1
- exit
-}
-
-# test the different corner cases for zeroing a range:
-#
-# 1. into a hole
-# 2. into allocated space
-# 3. into unwritten space
-# 4. hole -> data
-# 5. hole -> unwritten
-# 6. data -> hole
-# 7. data -> unwritten
-# 8. unwritten -> hole
-# 9. unwritten -> data
-# 10. hole -> data -> hole
-# 11. data -> hole -> data
-# 12. unwritten -> data -> unwritten
-# 13. data -> unwritten -> data
-# 14. data -> hole @ EOF
-# 15. data -> hole @ 0
-# 16. data -> cache cold ->hole
-# 17. data -> hole in single block file
-#
-# Test file is removed, created and sync'd between tests.
-#
-# Use -k flag to keep the file between tests. This will
-# test the handling of pre-existing holes.
-#
-# Use the -d flag to not sync the file between tests.
-# This will test the handling of delayed extents
-#
-_test_generic_punch()
-{
-
- remove_testfile=1
- sync_cmd="-c fsync"
- OPTIND=1
- while getopts 'dk' OPTION
- do
- case $OPTION in
- k) remove_testfile=
- ;;
- d) sync_cmd=
- ;;
- ?) echo Invalid flag
- exit 1
- ;;
- esac
- done
- shift $(($OPTIND - 1))
-
- alloc_cmd=$1
- punch_cmd=$2
- zero_cmd=$3 #if not testing zero just set to punch
- map_cmd=$4
- filter_cmd=$5
- testfile=$6
- xfs_io_opt=$7 #needs to be -F if not testing xfs
-
- echo " 1. into a hole"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "$zero_cmd 4k 8k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 2. into allocated space"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "pwrite 0 20k" $sync_cmd \
- -c "$zero_cmd 4k 8k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 3. into unwritten space"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "$alloc_cmd 0 20k" \
- -c "$zero_cmd 4k 8k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 4. hole -> data"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "pwrite 8k 8k" $sync_cmd \
- -c "$zero_cmd 4k 8k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 5. hole -> unwritten"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "$alloc_cmd 8k 8k" \
- -c "$zero_cmd 4k 8k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 6. data -> hole"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "pwrite 0 8k" $sync_cmd \
- -c "$zero_cmd 4k 8k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 7. data -> unwritten"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "pwrite 0 8k" $sync_cmd \
- -c "$alloc_cmd 8k 8k" \
- -c "$zero_cmd 4k 8k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 8. unwritten -> hole"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "$alloc_cmd 0 8k" \
- -c "$zero_cmd 4k 8k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 9. unwritten -> data"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "$alloc_cmd 0 8k" \
- -c "pwrite 8k 8k" $sync_cmd \
- -c "$zero_cmd 4k 8k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 10. hole -> data -> hole"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "pwrite 8k 4k" $sync_cmd \
- -c "$zero_cmd 4k 12k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 11. data -> hole -> data"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "$alloc_cmd 0 20k" \
- -c "pwrite 0 8k" \
- -c "pwrite 12k 8k" $sync_cmd \
- -c "$punch_cmd 8k 4k" \
- -c "$zero_cmd 4k 12k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 12. unwritten -> data -> unwritten"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "$alloc_cmd 0 20k" \
- -c "pwrite 8k 4k" $sync_cmd \
- -c "$zero_cmd 4k 12k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 13. data -> unwritten -> data"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "$alloc_cmd 0 20k" \
- -c "pwrite 0k 8k" $sync_cmd \
- -c "pwrite 12k 8k" -c "fsync" \
- -c "$zero_cmd 4k 12k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 14. data -> hole @ EOF"
- rm -f $testfile
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "pwrite 0 20k" $sync_cmd \
- -c "$zero_cmd 12k 8k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 15. data -> hole @ 0"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "pwrite 0 20k" $sync_cmd \
- -c "$zero_cmd 0k 8k" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
- echo " 16. data -> cache cold ->hole"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- rm -f $testfile.2
- else
- cp $testfile $testfile.2
- fi
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "pwrite 8k 12k" -c "fsync" $testfile.2 \
- > /dev/null
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
- -c "pwrite 0 20k" $sync_cmd \
- -c "$zero_cmd 0k 8k" \
- -c "fadvise -d" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- diff $testfile $testfile.2
- [ $? -ne 0 ] && die_now
- rm -f $testfile.2
- _md5_checksum $testfile
-
- echo " 17. data -> hole in single block file"
- if [ "$remove_testfile" ]; then
- rm -f $testfile
- fi
- block_size=`stat -f $TEST_DEV | grep "Block size" | cut -d " " -f3`
- $XFS_IO_PROG $xfs_io_opt -f -c "truncate $block_size" \
- -c "pwrite 0 $block_size" $sync_cmd \
- -c "$zero_cmd 128 128" \
- -c "$map_cmd -v" $testfile | $filter_cmd
- [ $? -ne 0 ] && die_now
- _md5_checksum $testfile
-
-}
+++ /dev/null
-##/bin/bash
-#
-# Copyright (c) 2000-2001,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 quota tests
-#
-
-#
-# checks that the generic quota support in the kernel is enabled
-# and that we have valid quota user tools installed.
-#
-_require_quota()
-{
- [ -n $QUOTA_PROG ] || _notrun "Quota user tools not installed"
-
- case $FSTYP in
- ext2|ext3|ext4|ext4dev|reiserfs)
- if [ ! -d /proc/sys/fs/quota ]; then
- _notrun "Installed kernel does not support quotas"
- fi
- ;;
- gfs2)
- ;;
- xfs)
- if [ ! -f /proc/fs/xfs/xqmstat ]; then
- _notrun "Installed kernel does not support XFS quotas"
- fi
- ;;
- *)
- _notrun "disk quotas not supported by this filesystem type: $FSTYP"
- ;;
- esac
-
- # SELinux adds extra xattrs which can mess up our expected output.
- # So, mount with a context, and they won't be created
- # nfs_t is a "liberal" context so we can use it.
- if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
- export SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:nfs_t:s0"
- fi
-}
-
-#
-# checks that the XFS quota support in the kernel is enabled
-# and that we have valid quota user tools installed.
-#
-_require_xfs_quota()
-{
- src/feature -q $TEST_DEV
- [ $? -ne 0 ] && _notrun "Installed kernel does not support XFS quota"
- [ -n $XFS_QUOTA_PROG ] || _notrun "XFS quota user tools not installed"
-}
-
-#
-# checks that the XFS project quota support in the kernel is enabled.
-#
-_require_prjquota()
-{
- [ -n "$1" ] && _dev="$1" || _dev="$TEST_DEV"
- src/feature -p $_dev
- [ $? -ne 0 ] && _notrun "Installed kernel does not support project quotas"
-}
-
-#
-# checks for user nobody in /etc/passwd and /etc/group.
-#
-_require_nobody()
-{
- _cat_passwd | grep -q '^nobody'
- [ $? -ne 0 ] && _notrun "password file does not contain user nobody."
-
- _cat_group | egrep -q '^no(body|group)'
- [ $? -ne 0 ] && _notrun "group file does not contain nobody/nogroup."
-}
-
-# create a file as a specific user (uid)
-# takes filename, id, type (u/g/p), blocksize, blockcount
-#
-_file_as_id()
-{
- [ $# != 5 ] && _notrun "broken call to _file_as_id in test $seq"
-
- parent=`dirname $1`
- if [ $3 = p ]; then
- echo PARENT: xfs_io -r -c "chproj $2" -c "chattr +P" $parent >>$RESULT_DIR/$seq.full
- $XFS_IO_PROG -r -c "chproj $2" -c "chattr +P" $parent >>$RESULT_DIR/$seq.full 2>&1
- magik='$>' # (irrelevent, above set projid-inherit-on-parent)
- elif [ $3 = u ]; then
- magik='$>' # perlspeak for effective uid
- elif [ $3 = g ]; then
- magik='$)' # perlspeak for effective gid
- else
- _notrun "broken type in call to _file_as_id in test $seq"
- fi
-
- perl <<EOF >>$RESULT_DIR/$seq.full 2>&1
- \$| = 1;
- $magik = $2;
- if ($5 == 0) {
- print "touch $1";
- exec "touch $1";
- } else {
- print "dd if=/dev/zero of=$1 bs=$4 count=$5";
- exec "dd if=/dev/zero of=$1 bs=$4 count=$5";
- }
-EOF
-# for debugging the above euid change, try... [need write in cwd]
-# exec "dd if=/dev/zero of=$1 bs=$4 count=$5 >>$RESULT_DIR/$seq.full 2>&1";
-
- if [ $3 = p ]; then
- echo PARENT: xfs_io -r -c "chproj 0" -c "chattr -P" $parent >>$RESULT_DIR/$seq.full
- $XFS_IO_PROG -r -c "chproj 0" -c "chattr -P" $parent >>$RESULT_DIR/$seq.full 2>&1
- fi
-}
-
-_choose_uid()
-{
- _cat_passwd | grep '^nobody' | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
-}
-
-_choose_gid()
-{
- _cat_group | egrep '^no(body|group)' | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
-}
-
-_choose_prid()
-{
- if [ "X$projid_file" == "X" ]; then
- projid_file=/etc/projid
- fi
- if [ ! -f $projid_file ]; then
- echo 0
- return
- fi
- perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[1],$a[0] }' \
- $projid_file
-}
-
-_qmount()
-{
- umount $SCRATCH_DEV >/dev/null 2>&1
- _scratch_mount || _fail "qmount failed"
- chmod ugo+rwx $SCRATCH_MNT
-}
-
-_qsetup()
-{
- # setup exactly what it is we'll be testing
- enforce=1
- if src/feature -u $SCRATCH_DEV
- then
- type=u ;
- eval `_choose_uid`
- [ ! -f $seq.out ] && ln -s $seq.usrquota $seq.out
- elif src/feature -g $SCRATCH_DEV
- then
- type=g
- eval `_choose_gid`
- [ ! -f $seq.out ] && ln -s $seq.grpquota $seq.out
- elif src/feature -p $SCRATCH_DEV
- then
- type=p
- eval `_choose_prid`
- [ ! -f $seq.out ] && ln -s $seq.prjquota $seq.out
- elif src/feature -U $SCRATCH_DEV
- then
- type=u
- eval `_choose_uid`
- [ ! -f $seq.out ] && ln -s $seq.uqnoenforce $seq.out
- enforce=0
- elif src/feature -G $SCRATCH_DEV
- then
- type=g
- eval `_choose_gid`
- [ ! -f $seq.out ] && ln -s $seq.gqnoenforce $seq.out
- enforce=0
- elif src/feature -P $SCRATCH_DEV
- then
- type=p
- eval `_choose_prid`
- [ ! -f $seq.out ] && ln -s $seq.pqnoenforce $seq.out
- enforce=0
- else
- _notrun "No quota support at mount time"
- fi
-
- echo "Using output from '" `ls -l $seq.out` "'" >>$RESULT_DIR/$seq.full
- echo "and using type=$type id=$id" >>$RESULT_DIR/$seq.full
-}
-
-#
-# Ensures only the given quota mount option is used
-#
-_qmount_option()
-{
- # Replace any user defined quota options
- # with the quota option that we want.
- # Simplest to do this rather than delete existing ones first because
- # of the variety of commas and spaces and multiple -o's
- # that we'd have to cater for. Doesn't matter if we have duplicates.
- # Use "QUOTA" string so that we don't have any substring confusion
- # thanks to "quota" which will match with "uquota" and "gquota" etc.
- export MOUNT_OPTIONS=`echo $MOUNT_OPTIONS \
- | sed -e 's/uquota/QUOTA/g' \
- -e 's/usrquota/QUOTA/g' \
- -e 's/gquota/QUOTA/g' \
- -e 's/grpquota/QUOTA/g' \
- -e 's/pquota/QUOTA/g' \
- -e 's/quota/QUOTA/g' \
- -e 's/uqnoenforce/QUOTA/g' \
- -e 's/gqnoenforce/QUOTA/g' \
- -e 's/pqnoenforce/QUOTA/g' \
- -e 's/qnoenforce/QUOTA/g' \
- -e "s/QUOTA/$1/g"`
-
- # Ensure we have the given quota option - duplicates are fine
- export MOUNT_OPTIONS="$MOUNT_OPTIONS -o $1"
- echo "MOUNT_OPTIONS = $MOUNT_OPTIONS" >>$RESULT_DIR/$seq.full
-}
-
-_check_quota_usage()
-{
- # Sync to get delalloc to disk
- sync
-
- # kill caches to guarantee removal speculative delalloc
- # XXX: really need an ioctl instead of this big hammer
- echo 3 > /proc/sys/vm/drop_caches
-
- VFS_QUOTA=0
- case $FSTYP in
- ext2|ext3|ext4|ext4dev|reiserfs)
- VFS_QUOTA=1
- quotaon -f -u -g $SCRATCH_MNT 2>/dev/null
- ;;
- *)
- ;;
- esac
- repquota -u -n $SCRATCH_MNT | grep -v "^#0" | _filter_scratch |
- sort >$tmp.user.orig
- repquota -g -n $SCRATCH_MNT | grep -v "^#0" | _filter_scratch |
- sort >$tmp.group.orig
- if [ $VFS_QUOTA -eq 1 ]; then
- quotacheck -u -g $SCRATCH_MNT 2>/dev/null
- else
- # use XFS method to force quotacheck
- xfs_quota -x -c "off -ug" $SCRATCH_MNT
- _scratch_unmount
- _scratch_mount "-o usrquota,grpquota"
- fi
- repquota -u -n $SCRATCH_MNT | grep -v "^#0" | _filter_scratch |
- sort >$tmp.user.checked
- repquota -g -n $SCRATCH_MNT | grep -v "^#0" | _filter_scratch |
- sort >$tmp.group.checked
- if [ $VFS_QUOTA -eq 1 ]; then
- quotaon -u -g $SCRATCH_MNT 2>/dev/null
- fi
- {
- echo "Comparing user usage"
- diff $tmp.user.orig $tmp.user.checked
- } && {
- echo "Comparing group usage"
- diff $tmp.group.orig $tmp.group.checked
- }
-}
-
-# make sure this script returns success
-/bin/true
+++ /dev/null
-##/bin/bash
-#-----------------------------------------------------------------------
-# Copyright (c) 2000-2006 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; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will 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 to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# USA
-#
-# Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
-# Mountain View, CA 94043, USA, or: http://www.sgi.com
-#-----------------------------------------------------------------------
-
-BC=$(which bc 2> /dev/null) || BC=
-
-_require_math()
-{
- if [ -z "$BC" ]; then
- _notrun "this test requires 'bc' tool for doing math operations"
- fi
-}
-
-_math()
-{
- [ $# -le 0 ] && return
- if [ "$BC" ]; then
- result=$(LANG=C echo "scale=0; $@" | "$BC" -q 2> /dev/null)
- else
- _notrun "this test requires 'bc' tool for doing math operations"
- fi
- echo "$result"
-}
-
-dd()
-{
- if [ "$HOSTOS" == "Linux" ]
- then
- command dd --help | grep noxfer > /dev/null 2>&1
-
- if [ "$?" -eq 0 ]
- then
- command dd status=noxfer $@
- else
- command dd $@
- fi
- else
- command dd $@
- fi
-}
-
-# ls -l w/ selinux sometimes puts a dot at the end:
-# -rwxrw-r--. id1 id2 file1
-
-_ls_l()
-{
- ls -l $* | sed "s/\(^[-rwxdlbcpsStT]*\)\. /\1 /"
-}
-
-_mount_opts()
-{
- # SELinux adds extra xattrs which can mess up our expected output.
- # So, mount with a context, and they won't be created
- # nfs_t is a "liberal" context so we can use it.
- if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
- SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:nfs_t:s0"
- export SELINUX_MOUNT_OPTIONS
- fi
-
- case $FSTYP in
- xfs)
- export MOUNT_OPTIONS=$XFS_MOUNT_OPTIONS
- ;;
- udf)
- export MOUNT_OPTIONS=$UDF_MOUNT_OPTIONS
- ;;
- nfs)
- export MOUNT_OPTIONS=$NFS_MOUNT_OPTIONS
- ;;
- ext2|ext3|ext4|ext4dev)
- # acls & xattrs aren't turned on by default on ext$FOO
- export MOUNT_OPTIONS="-o acl,user_xattr $EXT_MOUNT_OPTIONS"
- ;;
- reiserfs)
- # acls & xattrs aren't turned on by default on reiserfs
- export MOUNT_OPTIONS="-o acl,user_xattr $REISERFS_MOUNT_OPTIONS"
- ;;
- gfs2)
- # acls aren't turned on by default on gfs2
- export MOUNT_OPTIONS="-o acl $GFS2_MOUNT_OPTIONS"
- ;;
- *)
- ;;
- esac
-}
-
-_mkfs_opts()
-{
- case $FSTYP in
- xfs)
- export MKFS_OPTIONS=$XFS_MKFS_OPTIONS
- ;;
- udf)
- [ ! -z "$udf_fsize" ] && \
- UDF_MKFS_OPTIONS="$UDF_MKFS_OPTIONS -s $udf_fsize"
- export MKFS_OPTIONS=$UDF_MKFS_OPTIONS
- ;;
- nfs)
- export MKFS_OPTIONS=$NFS_MKFS_OPTIONS
- ;;
- reiserfs)
- export MKFS_OPTIONS="$REISERFS_MKFS_OPTIONS -q"
- ;;
- gfs2)
- export MKFS_OPTIONS="$GFS2_MKFS_OPTIONS -O -p lock_nolock"
- ;;
- jfs)
- export MKFS_OPTIONS="$JFS_MKFS_OPTIONS -q"
- ;;
- *)
- ;;
- esac
-}
-
-_fsck_opts()
-{
- case $FSTYP in
- ext2|ext3|ext4|ext4dev)
- export FSCK_OPTIONS="-nf"
- ;;
- reiserfs)
- export FSCK_OPTIONS="--yes"
- ;;
- *)
- export FSCK_OPTIONS="-n"
- ;;
- esac
-}
-
-[ -z "$FSTYP" ] && FSTYP=xfs
-[ -z "$MOUNT_OPTIONS" ] && _mount_opts
-[ -z "$MKFS_OPTIONS" ] && _mkfs_opts
-[ -z "$FSCK_OPTIONS" ] && _fsck_opts
-
-
-# we need common.config
-if [ "$iam" != "check" ]
-then
- if ! . ./common.config
- then
- echo "$iam: failed to source common.config"
- exit 1
- fi
-fi
-
-# check for correct setup
-case "$FSTYP" in
- xfs)
- [ "$XFS_LOGPRINT_PROG" = "" ] && _fatal "xfs_logprint not found"
- [ "$XFS_REPAIR_PROG" = "" ] && _fatal "xfs_repair not found"
- [ "$XFS_CHECK_PROG" = "" ] && _fatal "xfs_check not found"
- [ "$XFS_DB_PROG" = "" ] && _fatal "xfs_db not found"
- [ "$MKFS_XFS_PROG" = "" ] && _fatal "mkfs_xfs not found"
- ;;
- udf)
- [ "$MKFS_UDF_PROG" = "" ] && _fatal "mkfs_udf/mkudffs not found"
- ;;
- btrfs)
- [ "$MKFS_BTRFS_PROG" = "" ] && _fatal "mkfs.btrfs not found"
- ;;
- nfs)
- ;;
-esac
-
-# make sure we have a standard umask
-umask 022
-
-_mount()
-{
- $MOUNT_PROG `_mount_ops_filter $*`
-}
-
-_scratch_options()
-{
- type=$1
- SCRATCH_OPTIONS=""
-
- if [ "$FSTYP" != "xfs" ]; then
- return
- fi
-
- case $type in
- mkfs)
- [ "$HOSTOS" != "IRIX" ] && SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f"
- rt_opt="-r"
- log_opt="-l"
- ;;
- mount)
- rt_opt="-o"
- log_opt="-o"
- ;;
- esac
- [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
- SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${rt_opt}rtdev=$SCRATCH_RTDEV"
- [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
- SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}logdev=$SCRATCH_LOGDEV"
-}
-
-_test_options()
-{
- type=$1
- TEST_OPTIONS=""
-
- if [ "$FSTYP" != "xfs" ]; then
- return
- fi
-
- case $type in
- mkfs)
- rt_opt="-r"
- log_opt="-l"
- ;;
- mount)
- rt_opt="-o"
- log_opt="-o"
- ;;
- esac
- [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
- TEST_OPTIONS="$TEST_OPTIONS ${rt_opt}rtdev=$TEST_RTDEV"
- [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
- TEST_OPTIONS="$TEST_OPTIONS ${log_opt}logdev=$TEST_LOGDEV"
-}
-
-_mount_ops_filter()
-{
- params="$*"
-
- #get mount point to handle dmapi mtpt option correctly
- let last_index=$#-1
- [ $last_index -gt 0 ] && shift $last_index
- FS_ESCAPED=$1
-
- # irix is fussy about how it is fed its mount options
- # - multiple -o's are not allowed
- # - no spaces between comma delimitered options
- # the sed script replaces all -o's (except the first) with a comma
- # not required for linux, but won't hurt
-
- echo $params | sed -e 's/[[:space:]]*-o[[:space:]]*/UnIqUe/1; s/[[:space:]]*-o[[:space:]]*/,/g; s/UnIqUe/ -o /1' \
- | sed -e 's/dmapi/dmi/' \
- | $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$FS_ESCAPED\1\2#; print;"
-
-}
-
-_scratch_mount_options()
-{
- _scratch_options mount
-
- echo $SCRATCH_OPTIONS $MOUNT_OPTIONS $SELINUX_MOUNT_OPTIONS $* $SCRATCH_DEV $SCRATCH_MNT
-}
-
-_scratch_mount()
-{
- _mount -t $FSTYP `_scratch_mount_options $*`
-}
-
-_scratch_unmount()
-{
- $UMOUNT_PROG $SCRATCH_DEV
-}
-
-_scratch_remount()
-{
- _scratch_unmount
- _scratch_mount
-}
-
-_test_mount()
-{
- _test_options mount
- _mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
-}
-
-_scratch_mkfs_options()
-{
- _scratch_options mkfs
- echo $SCRATCH_OPTIONS $MKFS_OPTIONS $* $SCRATCH_DEV
-}
-
-
-_setup_large_xfs_fs()
-{
- fs_size=$1
- local tmp_dir=/tmp/
-
- [ "$LARGE_SCRATCH_DEV" != yes ] && return 0
- [ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0
- [ $SCRATCH_DEV_EMPTY_SPACE -ge $fs_size ] && return 0
-
- # calculate the size of the file we need to allocate.
- # Default free space in the FS is 50GB, but you can specify more via
- # SCRATCH_DEV_EMPTY_SPACE
- file_size=$(($fs_size - 50*1024*1024*1024))
- file_size=$(($file_size - $SCRATCH_DEV_EMPTY_SPACE))
-
- # mount the filesystem, create the file, unmount it
- _scratch_mount 2>&1 >$tmp_dir/mnt.err
- local status=$?
- if [ $status -ne 0 ]; then
- echo "mount failed"
- cat $tmp_dir/mnt.err >&2
- rm -f $tmp_dir/mnt.err
- return $status
- fi
- rm -f $tmp_dir/mnt.err
-
- xfs_io -F -f \
- -c "truncate $file_size" \
- -c "falloc -k 0 $file_size" \
- -c "chattr +d" \
- $SCRATCH_MNT/.use_space 2>&1 > /dev/null
- export NUM_SPACE_FILES=1
- status=$?
- umount $SCRATCH_MNT
- if [ $status -ne 0 ]; then
- echo "large file prealloc failed"
- cat $tmp_dir/mnt.err >&2
- return $status
- fi
- return 0
-}
-
-_scratch_mkfs_xfs()
-{
- # extra mkfs options can be added by tests
- local extra_mkfs_options=$*
-
- local tmp_dir=/tmp/
-
- _scratch_options mkfs
-
- # save mkfs output in case conflict means we need to run again.
- # only the output for the mkfs that applies should be shown
- $MKFS_XFS_PROG $SCRATCH_OPTIONS $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
- 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
- local mkfs_status=$?
-
- # a mkfs failure may be caused by conflicts between
- # $MKFS_OPTIONS and $extra_mkfs_options
-
- if [ $mkfs_status -ne 0 -a ! -z "$extra_mkfs_options" ]; then
- echo "** mkfs failed with extra mkfs options added to \"$MKFS_OPTIONS\" by test $seq **" \
- >>$RESULT_DIR/$seq.full
- echo "** attempting to mkfs using only test $seq options: $extra_mkfs_options **" \
- >>$RESULT_DIR/$seq.full
- # running mkfs again. overwrite previous mkfs output files
- $MKFS_XFS_PROG $SCRATCH_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
- 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
- mkfs_status=$?
- fi
-
- if [ $mkfs_status -eq 0 -a "$LARGE_SCRATCH_DEV" = yes ]; then
- # manually parse the mkfs output to get the fs size in bytes
- local fs_size
- fs_size=`cat $tmp_dir.mkfsstd | perl -ne '
- if (/^data\s+=\s+bsize=(\d+)\s+blocks=(\d+)/) {
- my $size = $1 * $2;
- print STDOUT "$size\n";
- }'`
- _setup_large_xfs_fs $fs_size
- mkfs_status=$?
- fi
-
- # output stored mkfs output
- cat $tmp_dir.mkfserr >&2
- cat $tmp_dir.mkfsstd
- rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
-
- return $mkfs_status
-}
-
-_setup_large_ext4_fs()
-{
- fs_size=$1
- local tmp_dir=/tmp/
-
- [ "$LARGE_SCRATCH_DEV" != yes ] && return 0
- [ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0
- [ $SCRATCH_DEV_EMPTY_SPACE -ge $fs_size ] && return 0
-
- # Default free space in the FS is 50GB, but you can specify more via
- # SCRATCH_DEV_EMPTY_SPACE
- space_to_consume=$(($fs_size - 50*1024*1024*1024 - $SCRATCH_DEV_EMPTY_SPACE))
-
- # mount the filesystem and create 16TB - 4KB files until we consume
- # all the necessary space.
- _scratch_mount 2>&1 >$tmp_dir/mnt.err
- local status=$?
- if [ $status -ne 0 ]; then
- echo "mount failed"
- cat $tmp_dir/mnt.err >&2
- rm -f $tmp_dir/mnt.err
- return $status
- fi
- rm -f $tmp_dir/mnt.err
-
- file_size=$((16*1024*1024*1024*1024 - 4096))
- nfiles=0
- while [ $space_to_consume -gt $file_size ]; do
-
- xfs_io -F -f \
- -c "truncate $file_size" \
- -c "falloc -k 0 $file_size" \
- $SCRATCH_MNT/.use_space.$nfiles 2>&1
- status=$?
- if [ $status -ne 0 ]; then
- break;
- fi
-
- space_to_consume=$(( $space_to_consume - $file_size ))
- nfiles=$(($nfiles + 1))
- done
-
- # consume the remaining space.
- if [ $space_to_consume -gt 0 ]; then
- xfs_io -F -f \
- -c "truncate $space_to_consume" \
- -c "falloc -k 0 $space_to_consume" \
- $SCRATCH_MNT/.use_space.$nfiles 2>&1
- status=$?
- fi
- export NUM_SPACE_FILES=$nfiles
-
- umount $SCRATCH_MNT
- if [ $status -ne 0 ]; then
- echo "large file prealloc failed"
- cat $tmp_dir/mnt.err >&2
- return $status
- fi
- return 0
-}
-_scratch_mkfs_ext4()
-{
- local tmp_dir=/tmp/
-
- /sbin/mkfs -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV \
- 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
- local mkfs_status=$?
-
- if [ $mkfs_status -eq 0 -a "$LARGE_SCRATCH_DEV" = yes ]; then
- # manually parse the mkfs output to get the fs size in bytes
- fs_size=`cat $tmp_dir.mkfsstd | awk ' \
- /^Block size/ { split($2, a, "="); bs = a[2] ; } \
- / inodes, / { blks = $3 } \
- /reserved for the super user/ { resv = $1 } \
- END { fssize = bs * blks - resv; print fssize }'`
-
- _setup_large_ext4_fs $fs_size
- mkfs_status=$?
- fi
-
- # output stored mkfs output
- cat $tmp_dir.mkfserr >&2
- cat $tmp_dir.mkfsstd
- rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
-
- return $mkfs_status
-}
-
-_scratch_mkfs()
-{
- case $FSTYP in
- xfs)
- _scratch_mkfs_xfs $*
- ;;
- nfs*)
- # do nothing for nfs
- ;;
- udf)
- $MKFS_UDF_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
- ;;
- btrfs)
- $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
- ;;
- ext4)
- _scratch_mkfs_ext4 $*
- ;;
- *)
- yes | $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV
- ;;
- esac
-}
-
-# Create fs of certain size on scratch device
-# _scratch_mkfs_sized <size in bytes> [optional blocksize]
-_scratch_mkfs_sized()
-{
- fssize=$1
- blocksize=$2
- [ -z "$blocksize" ] && blocksize=4096
- blocks=`expr $fssize / $blocksize`
-
- if [ "$HOSTOS" == "Linux" ]; then
- devsize=`blockdev --getsize64 $SCRATCH_DEV`
- [ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
- fi
-
- case $FSTYP in
- xfs)
- _scratch_mkfs_xfs -d size=$fssize -b size=$blocksize
- ;;
- ext2|ext3|ext4|ext4dev)
- yes | ${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
- ;;
- btrfs)
- $MKFS_BTRFS_PROG $MKFS_OPTIONS -b $fssize $SCRATCH_DEV
- ;;
- *)
- _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
- ;;
- esac
-}
-
-# Emulate an N-data-disk stripe w/ various stripe units
-# _scratch_mkfs_geom <sunit bytes> <swidth multiplier> [optional blocksize]
-_scratch_mkfs_geom()
-{
- sunit_bytes=$1
- swidth_mult=$2
- blocksize=$3
- [ -z "$blocksize" ] && blocksize=4096
-
- let sunit_blocks=$sunit_bytes/$blocksize
- let swidth_blocks=$sunit_blocks*$swidth_mult
-
- case $FSTYP in
- xfs)
- MKFS_OPTIONS+=" -b size=$blocksize, -d su=$sunit_bytes,sw=$swidth_mult"
- ;;
- ext4|ext4dev)
- MKFS_OPTIONS+=" -b $blocksize -E stride=$sunit_blocks,stripe_width=$swidth_blocks"
- ;;
- *)
- _notrun "can't mkfs $FSTYP with geometry"
- ;;
- esac
- _scratch_mkfs
-}
-
-_scratch_resvblks()
-{
- case $FSTYP in
- xfs)
- xfs_io -x -c "resblks $1" $SCRATCH_MNT
- ;;
- *)
- ;;
- esac
-}
-
-_scratch_xfs_db_options()
-{
- SCRATCH_OPTIONS=""
- [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
- SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
- echo $SCRATCH_OPTIONS $* $SCRATCH_DEV
-}
-
-_scratch_xfs_logprint()
-{
- SCRATCH_OPTIONS=""
- [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
- SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
- $XFS_LOGPRINT_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
-}
-
-_scratch_xfs_check()
-{
- SCRATCH_OPTIONS=""
- [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
- SCRATCH_OPTIONS="-l $SCRATCH_LOGDEV"
- [ "$LARGE_SCRATCH_DEV" = yes ] && \
- SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
- $XFS_CHECK_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
-}
-
-_scratch_xfs_repair()
-{
- SCRATCH_OPTIONS=""
- [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
- SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
- [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
- SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -r$SCRATCH_RTDEV"
- [ "$LARGE_SCRATCH_DEV" = yes ] && SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
- $XFS_REPAIR_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
-}
-
-_get_pids_by_name()
-{
- if [ $# -ne 1 ]
- then
- echo "Usage: _get_pids_by_name process-name" 1>&2
- exit 1
- fi
-
- # Algorithm ... all ps(1) variants have a time of the form MM:SS or
- # HH:MM:SS before the psargs field, use this as the search anchor.
- #
- # Matches with $1 (process-name) occur if the first psarg is $1
- # or ends in /$1 ... the matching uses sed's regular expressions,
- # so passing a regex into $1 will work.
-
- ps $PS_ALL_FLAGS \
- | sed -n \
- -e 's/$/ /' \
- -e 's/[ ][ ]*/ /g' \
- -e 's/^ //' \
- -e 's/^[^ ]* //' \
- -e "/[0-9]:[0-9][0-9] *[^ ]*\/$1 /s/ .*//p" \
- -e "/[0-9]:[0-9][0-9] *$1 /s/ .*//p"
-}
-
-# fix malloc libs output
-#
-_fix_malloc()
-{
- # filter out the Electric Fence notice
- $PERL_PROG -e '
- while (<>) {
- if (defined $o && /^\s+Electric Fence/) {
- chomp($o);
- print "$o";
- undef $o;
- next;
- }
- print $o if (defined $o);
-
- $o=$_;
- }
- print $o if (defined $o);
- '
-}
-
-# check if run as root
-#
-_need_to_be_root()
-{
- id=`id | $SED_PROG -e 's/(.*//' -e 's/.*=//'`
- if [ "$id" -ne 0 ]
- then
- echo "Arrgh ... you need to be root (not uid=$id) to run this test"
- exit 1
- fi
-}
-
-
-#
-# _df_device : get an IRIX style df line for a given device
-#
-# - returns "" if not mounted
-# - returns fs type in field two (ala IRIX)
-# - joins line together if split by fancy df formatting
-# - strips header etc
-#
-
-_df_device()
-{
- if [ $# -ne 1 ]
- then
- echo "Usage: _df_device device" 1>&2
- exit 1
- fi
-
- $DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 '
- match($1,what) && NF==1 {
- v=$1
- getline
- print v, $0
- exit
- }
- match($1,what) {
- print
- exit
- }
- '
-}
-
-#
-# _df_dir : get an IRIX style df line for device where a directory resides
-#
-# - returns fs type in field two (ala IRIX)
-# - joins line together if split by fancy df formatting
-# - strips header etc
-#
-
-_df_dir()
-{
- if [ $# -ne 1 ]
- then
- echo "Usage: _df_dir device" 1>&2
- exit 1
- fi
-
- $DF_PROG $1 2>/dev/null | $AWK_PROG -v what=$1 '
- NR == 2 && NF==1 {
- v=$1
- getline
- print v, $0;
- exit 0
- }
- NR == 2 {
- print;
- exit 0
- }
- {}
- '
- # otherwise, nada
-}
-
-# return percentage used disk space for mounted device
-
-_used()
-{
- if [ $# -ne 1 ]
- then
- echo "Usage: _used device" 1>&2
- exit 1
- fi
-
- _df_device $1 | $AWK_PROG '{ sub("%", "") ; print $6 }'
-}
-
-# return the FS type of a mounted device
-#
-_fs_type()
-{
- if [ $# -ne 1 ]
- then
- echo "Usage: _fs_type device" 1>&2
- exit 1
- fi
-
- #
- # The Linux kernel shows NFSv4 filesystems in df output as
- # filesystem type nfs4, although we mounted it as nfs earlier.
- # Fix the filesystem type up here so that the callers don't
- # have to bother with this quirk.
- #
- _df_device $1 | $AWK_PROG '{ print $2 }' | sed -e 's/nfs4/nfs/'
-}
-
-# return the FS mount options of a mounted device
-#
-# should write a version which just parses the output of mount for IRIX
-# compatibility, but since this isn't used at all, at the moment I'll leave
-# this for now
-#
-_fs_options()
-{
- if [ $# -ne 1 ]
- then
- echo "Usage: _fs_options device" 1>&2
- exit 1
- fi
-
- $AWK_PROG -v dev=$1 '
- match($1,dev) { print $4 }
- ' </proc/mounts
-}
-
-# returns device number if a file is a block device
-#
-_is_block_dev()
-{
- if [ $# -ne 1 ]
- then
- echo "Usage: _is_block_dev dev" 1>&2
- exit 1
- fi
-
- _dev=$1
- if [ -L "${_dev}" ]; then
- _dev=`readlink -f ${_dev}`
- fi
-
- if [ -b "${_dev}" ]; then
- src/lstat64 ${_dev} | $AWK_PROG '/Device type:/ { print $9 }'
- fi
-}
-
-# Do a command, log it to $RESULT_DIR/$seq.full, optionally test return status
-# and die if command fails. If called with one argument _do executes the
-# command, logs it, and returns its exit status. With two arguments _do
-# first prints the message passed in the first argument, and then "done"
-# or "fail" depending on the return status of the command passed in the
-# second argument. If the command fails and the variable _do_die_on_error
-# is set to "always" or the two argument form is used and _do_die_on_error
-# is set to "message_only" _do will print an error message to
-# $RESULT_DIR/$seq.out and exit.
-
-_do()
-{
- if [ $# -eq 1 ]; then
- _cmd=$1
- elif [ $# -eq 2 ]; then
- _note=$1
- _cmd=$2
- echo -n "$_note... "
- else
- echo "Usage: _do [note] cmd" 1>&2
- status=1; exit
- fi
-
- (eval "echo '---' \"$_cmd\"") >>$RESULT_DIR/$seq.full
- (eval "$_cmd") >$tmp._out 2>&1; ret=$?
- cat $tmp._out | _fix_malloc >>$RESULT_DIR/$seq.full
- if [ $# -eq 2 ]; then
- if [ $ret -eq 0 ]; then
- echo "done"
- else
- echo "fail"
- fi
- fi
- if [ $ret -ne 0 ] \
- && [ "$_do_die_on_error" = "always" \
- -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
- then
- [ $# -ne 2 ] && echo
- eval "echo \"$_cmd\" failed \(returned $ret\): see $RESULT_DIR/$seq.full"
- status=1; exit
- fi
-
- return $ret
-}
-
-# bail out, setting up .notrun file
-#
-_notrun()
-{
- echo "$*" > $RESULT_DIR/$seq.notrun
- echo "$seq not run: $*"
- status=0
- exit
-}
-
-# just plain bail out
-#
-_fail()
-{
- echo "$*" | tee -a $RESULT_DIR/$seq.full
- echo "(see $RESULT_DIR/$seq.full for details)"
- status=1
- exit 1
-}
-
-# tests whether $FSTYP is one of the supported filesystems for a test
-#
-_supported_fs()
-{
- for f
- do
- if [ "$f" = "$FSTYP" -o "$f" = "generic" ]
- then
- return
- fi
- done
-
- _notrun "not suitable for this filesystem type: $FSTYP"
-}
-
-# tests whether $FSTYP is one of the supported OSes for a test
-#
-_supported_os()
-{
- for h
- do
- if [ "$h" = "$HOSTOS" ]
- then
- return
- fi
- done
-
- _notrun "not suitable for this OS: $HOSTOS"
-}
-
-# this test needs a scratch partition - check we're ok & unmount it
-#
-_require_scratch()
-{
- case "$FSTYP" in
- nfs*)
- echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
- if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]
- then
- _notrun "this test requires a valid \$SCRATCH_DEV"
- fi
- ;;
- *)
- if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
- then
- _notrun "this test requires a valid \$SCRATCH_DEV"
- fi
- if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
- then
- _notrun "this test requires a valid \$SCRATCH_DEV"
- fi
- if [ ! -d "$SCRATCH_MNT" ]
- then
- _notrun "this test requires a valid \$SCRATCH_MNT"
- fi
- ;;
- esac
-
- # mounted?
- if _mount | grep -q $SCRATCH_DEV
- then
- # if it's mounted, make sure its on $SCRATCH_MNT
- if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
- then
- echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
- exit 1
- fi
- # and then unmount it
- if ! $UMOUNT_PROG $SCRATCH_DEV
- then
- echo "failed to unmount $SCRATCH_DEV"
- exit 1
- fi
- fi
-}
-
-# this test needs a logdev
-#
-_require_logdev()
-{
- [ -z "$SCRATCH_LOGDEV" -o ! -b "$SCRATCH_LOGDEV" ] && \
- _notrun "This test requires a valid \$SCRATCH_LOGDEV"
- [ "$USE_EXTERNAL" != yes ] && \
- _notrun "This test requires USE_EXTERNAL to be enabled"
-
- # ensure its not mounted
- $UMOUNT_PROG $SCRATCH_LOGDEV 2>/dev/null
-}
-
-# this test requires loopback device support
-#
-_require_loop()
-{
- if [ "$HOSTOS" != "Linux" ]
- then
- _notrun "This test requires linux for loopback device support"
- fi
-
- modprobe loop >/dev/null 2>&1
- if grep loop /proc/devices >/dev/null 2>&1
- then
- :
- else
- _notrun "This test requires loopback device support"
- fi
-}
-
-# this test requires ext2 filesystem support
-#
-_require_ext2()
-{
- if [ "$HOSTOS" != "Linux" ]
- then
- _notrun "This test requires linux for ext2 filesystem support"
- fi
-
- modprobe ext2 >/dev/null 2>&1
- if grep ext2 /proc/filesystems >/dev/null 2>&1
- then
- :
- else
- _notrun "This test requires ext2 filesystem support"
- fi
-}
-
-# this test requires that (large) loopback device files are not in use
-#
-_require_no_large_scratch_dev()
-{
- [ "$LARGE_SCRATCH_DEV" = yes ] && \
- _notrun "Large filesystem testing in progress, skipped this test"
-}
-
-# this test requires that a realtime subvolume is in use, and
-# that the kernel supports realtime as well.
-#
-_require_realtime()
-{
- [ "$USE_EXTERNAL" = yes ] || \
- _notrun "External volumes not in use, skipped this test"
- [ "$SCRATCH_RTDEV" = "" ] && \
- _notrun "Realtime device required, skipped this test"
-}
-
-# this test requires that a specified command (executable) exists
-# $1 - command, $2 - name for error message
-#
-_require_command()
-{
- [ -n "$1" ] && _cmd="$1" || _cmd="$2"
- [ -n "$1" -a -x "$1" ] || _notrun "$_cmd utility required, skipped this test"
-}
-
-# this test requires the projid32bit feature to be available in
-# mkfs.xfs
-#
-_require_projid32bit()
-{
- _scratch_mkfs_xfs -f -i projid32bit=0 2>&1 >/dev/null \
- || _notrun "mkfs.xfs doesn't have projid32bit feature"
-}
-
-# this test requires that external log/realtime devices are not in use
-#
-_require_nonexternal()
-{
- [ "$USE_EXTERNAL" = yes ] && \
- _notrun "External device testing in progress, skipped this test"
-}
-
-# this test requires that a (specified) aio-dio executable exists
-# $1 - command (optional)
-#
-_require_aiodio()
-{
- if [ -z "$1" ]
- then
- AIO_TEST=src/aio-dio-regress/aiodio_sparse2
- [ -x $AIO_TEST ] || _notrun "aio-dio utilities required"
- else
- AIO_TEST=src/aio-dio-regress/$1
- [ -x $AIO_TEST ] || _notrun "$AIO_TEST not built"
- fi
-}
-
-# run an aio-dio program
-# $1 - command
-_run_aiodio()
-{
- if [ -z "$1" ]
- then
- echo "usage: _run_aiodio command_name" 2>&1
- status=1; exit 1
- fi
-
- _require_aiodio $1
-
- local testtemp=$TEST_DIR/aio-testfile
- rm -f $testtemp
- $AIO_TEST $testtemp 2>&1
- status=$?
- rm -f $testtemp
-
- return $status
-}
-
-# indicate whether YP/NIS is active or not
-#
-_yp_active()
-{
- local dn
- dn=$(domainname 2>/dev/null)
- test -n "${dn}" -a "${dn}" != "(none)"
- echo $?
-}
-
-# cat the password file
-#
-_cat_passwd()
-{
- [ $(_yp_active) -eq 0 ] && ypcat passwd
- cat /etc/passwd
-}
-
-# cat the group file
-#
-_cat_group()
-{
- [ $(_yp_active) -eq 0 ] && ypcat group
- cat /etc/group
-}
-
-# check for the fsgqa user on the machine
-#
-_require_user()
-{
- qa_user=fsgqa
- _cat_passwd | grep -q $qa_user
- [ "$?" == "0" ] || _notrun "$qa_user user not defined."
- echo /bin/true | su $qa_user
- [ "$?" == "0" ] || _notrun "$qa_user cannot execute commands."
-}
-
-# check for the fsgqa group on the machine
-#
-_require_group()
-{
- qa_group=fsgqa
- _cat_group | grep -q $qa_group
- [ "$?" == "0" ] || _notrun "$qa_group user not defined."
-}
-
-_filter_user_do()
-{
- perl -ne "
-s,.*Permission\sdenied.*,Permission denied,;
-s,.*no\saccess\sto\stty.*,,;
-s,.*no\sjob\scontrol\sin\sthis\sshell.*,,;
-s,^\s*$,,;
- print;"
-}
-
-_user_do()
-{
- if [ "$HOSTOS" == "IRIX" ]
- then
- echo $1 | /bin/bash "su $qa_user 2>&1" | _filter_user_do
- else
- echo $1 | su $qa_user 2>&1 | _filter_user_do
- fi
-}
-
-# check that xfs_io, kernel, and filesystem all support zero
-_require_xfs_io_zero()
-{
- testio=`$XFS_IO_PROG -c "zero help" 2>&1`
- echo $testio | grep -q 'command "zero" not found' && \
- _notrun "zero command not supported"
-}
-
-# check that xfs_io, glibc, kernel, and filesystem all (!) support
-# fallocate
-#
-_require_xfs_io_falloc()
-{
- testfile=$TEST_DIR/$$.falloc
- testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $testfile 2>&1`
- rm -f $testfile 2>&1 > /dev/null
- echo $testio | grep -q "not found" && \
- _notrun "xfs_io fallocate support is missing"
- echo $testio | grep -q "Operation not supported" && \
- _notrun "xfs_io fallocate command failed (old kernel/wrong fs?)"
-}
-
-# check that xfs_io, kernel and filesystem all support fallocate with hole
-# punching
-_require_xfs_io_falloc_punch()
-{
- testfile=$TEST_DIR/$$.falloc
- testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
- -c "fpunch 4k 8k" $testfile 2>&1`
- rm -f $testfile 2>&1 > /dev/null
- echo $testio | grep -q "not found" && \
- _notrun "xfs_io fallocate punch support is missing"
- echo $testio | grep -q "Operation not supported" && \
- _notrun "xfs_io fallocate punch command failed (no fs support?)"
-}
-
-# check that xfs_io, kernel and filesystem support fiemap
-_require_xfs_io_fiemap()
-{
- testfile=$TEST_DIR/$$.fiemap
- testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
- -c "fiemap -v" $testfile 2>&1`
- rm -f $testfile 2>&1 > /dev/null
- echo $testio | grep -q "not found" && \
- _notrun "xfs_io fiemap support is missing"
- echo $testio | grep -q "Operation not supported" && \
- _notrun "xfs_io fiemap command failed (no fs support?)"
-}
-
-# Check that a fs has enough free space (in 1024b blocks)
-#
-_require_fs_space()
-{
- MNT=$1
- BLOCKS=$2 # in units of 1024
- let GB=$BLOCKS/1024/1024
-
- FREE_BLOCKS=`df -klP $MNT | grep -v Filesystem | awk '{print $4}'`
- [ $FREE_BLOCKS -lt $BLOCKS ] && \
- _notrun "This test requires at least ${GB}GB free on $MNT to run"
-}
-
-#
-# Check if the filesystem supports sparse files.
-#
-# Unfortunately there is no better way to do this than a manual black list.
-#
-_require_sparse_files()
-{
- case $FSTYP in
- hfsplus)
- _notrun "Sparse files not supported by this filesystem type: $FSTYP"
- ;;
- *)
- ;;
- esac
-}
-
-_require_debugfs()
-{
- #boot_params always present in debugfs
- [ -d "$DEBUGFS_MNT/boot_params" ] || _notrun "Debugfs not mounted"
-}
-
-_require_fail_make_request()
-{
- [ -f "$DEBUGFS_MNT/fail_make_request/probability" ] \
- || _notrun "$DEBUGFS_MNT/fail_make_request \
- not found. Seems that CONFIG_FAIL_MAKE_REQUEST kernel config option not enabled"
-}
-
-# check that a FS on a device is mounted
-# if so, return mount point
-#
-_is_mounted()
-{
- if [ $# -ne 1 ]
- then
- echo "Usage: _is_mounted device" 1>&2
- exit 1
- fi
-
- device=$1
-
- if _mount | grep "$device " | $AWK_PROG -v pattern="type $FSTYP" '
- pattern { print $3 ; exit 0 }
- END { exit 1 }
- '
- then
- echo "_is_mounted: $device is not a mounted $FSTYP FS"
- exit 1
- fi
-}
-
-# remount a FS to a new mode (ro or rw)
-#
-_remount()
-{
- if [ $# -ne 2 ]
- then
- echo "Usage: _remount device ro/rw" 1>&2
- exit 1
- fi
- device=$1
- mode=$2
-
- if ! mount -o remount,$mode $device
- then
- echo "_remount: failed to remount filesystem on $device as $mode"
- exit 1
- fi
-}
-
-# Run the appropriate repair/check on a filesystem
-#
-# if the filesystem is mounted, it's either remounted ro before being
-# checked or it's unmounted and then remounted
-#
-
-# If set, we remount ro instead of unmounting for fsck
-USE_REMOUNT=0
-
-_umount_or_remount_ro()
-{
- if [ $# -ne 1 ]
- then
- echo "Usage: _umount_or_remount_ro <device>" 1>&2
- exit 1
- fi
-
- device=$1
- mountpoint=`_is_mounted $device`
-
- if [ $USE_REMOUNT -eq 0 ]; then
- $UMOUNT_PROG $device
- else
- _remount $device ro
- fi
- echo "$mountpoint"
-}
-
-_mount_or_remount_rw()
-{
- if [ $# -ne 3 ]
- then
- echo "Usage: _mount_or_remount_rw <opts> <device> <mountpoint>" 1>&2
- exit 1
- fi
- mount_opts=$1
- device=$2
- mountpoint=$3
-
- if [ $USE_REMOUNT -eq 0 ]
- then
- if ! _mount -t $FSTYP $mount_opts $device $mountpoint
- then
- echo "!!! failed to remount $device on $mountpoint"
- return 0 # ok=0
- fi
- else
- _remount $device rw
- fi
-
- return 1 # ok=1
-}
-
-# Check a generic filesystem in no-op mode; this assumes that the
-# underlying fsck program accepts "-n" for a no-op (check-only) run,
-# and that it will still return an errno for corruption in this mode.
-#
-# Filesystems which don't support this will need to define their
-# own check routine.
-#
-_check_generic_filesystem()
-{
- device=$1
-
- # If type is set, we're mounted
- type=`_fs_type $device`
- ok=1
-
- if [ "$type" = "$FSTYP" ]
- then
- # mounted ...
- mountpoint=`_umount_or_remount_ro $device`
- fi
-
- fsck -t $FSTYP $FSCK_OPTIONS $device >$tmp.fsck 2>&1
- if [ $? -ne 0 ]
- then
- echo "_check_generic_filesystem: filesystem on $device is inconsistent (see $RESULT_DIR/$seq.full)"
-
- echo "_check_generic filesystem: filesystem on $device is inconsistent" >>$RESULT_DIR/$seq.full
- echo "*** fsck.$FSTYP output ***" >>$RESULT_DIR/$seq.full
- cat $tmp.fsck >>$RESULT_DIR/$seq.full
- echo "*** end fsck.$FSTYP output" >>$RESULT_DIR/$seq.full
-
- ok=0
- fi
- rm -f $tmp.fsck
-
- if [ $ok -eq 0 ]
- then
- echo "*** mount output ***" >>$RESULT_DIR/$seq.full
- _mount >>$RESULT_DIR/$seq.full
- echo "*** end mount output" >>$RESULT_DIR/$seq.full
- elif [ "$type" = "$FSTYP" ]
- then
- # was mounted ...
- _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
- ok=$?
- fi
-
- if [ $ok -eq 0 ]; then
- status=1
- exit 1
- fi
-
- return 0
-}
-
-# run xfs_check and friends on a FS.
-
-_check_xfs_filesystem()
-{
- if [ $# -ne 3 ]
- then
- echo "Usage: _check_xfs_filesystem device <logdev>|none <rtdev>|none" 1>&2
- exit 1
- fi
-
- extra_mount_options=""
- device=$1
- if [ "$2" != "none" ]; then
- extra_log_options="-l$2"
- extra_mount_options="-ologdev=$2"
- fi
-
- if [ "$3" != "none" ]; then
- extra_rt_options="-r$3"
- extra_mount_options=$extra_mount_options" -ortdev=$3"
- fi
- extra_mount_options=$extra_mount_options" $MOUNT_OPTIONS"
-
- [ "$FSTYP" != xfs ] && return 0
-
- type=`_fs_type $device`
- ok=1
-
- if [ "$type" = "xfs" ]
- then
- # mounted ...
- mountpoint=`_umount_or_remount_ro $device`
- fi
-
- $XFS_LOGPRINT_PROG -t $extra_log_options $device 2>&1 \
- | tee $tmp.logprint | grep -q "<CLEAN>"
- if [ $? -ne 0 -a "$HOSTOS" = "Linux" ]
- then
- echo "_check_xfs_filesystem: filesystem on $device has dirty log (see $RESULT_DIR/$seq.full)"
-
- echo "_check_xfs_filesystem: filesystem on $device has dirty log" >>$RESULT_DIR/$seq.full
- echo "*** xfs_logprint -t output ***" >>$RESULT_DIR/$seq.full
- cat $tmp.logprint >>$RESULT_DIR/$seq.full
- echo "*** end xfs_logprint output" >>$RESULT_DIR/$seq.full
-
- ok=0
- fi
-
- # xfs_check runs out of memory on large files, so even providing the test
- # option (-t) to avoid indexing the free space trees doesn't make it pass on
- # large filesystems. Avoid it.
- if [ "$LARGE_SCRATCH_DEV" != yes ]; then
- $XFS_CHECK_PROG $extra_log_options $device 2>&1 |\
- _fix_malloc >$tmp.fs_check
- fi
- if [ -s $tmp.fs_check ]
- then
- echo "_check_xfs_filesystem: filesystem on $device is inconsistent (c) (see $RESULT_DIR/$seq.full)"
-
- echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$RESULT_DIR/$seq.full
- echo "*** xfs_check output ***" >>$RESULT_DIR/$seq.full
- cat $tmp.fs_check >>$RESULT_DIR/$seq.full
- echo "*** end xfs_check output" >>$RESULT_DIR/$seq.full
-
- ok=0
- fi
-
- $XFS_REPAIR_PROG -n $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
- if [ $? -ne 0 ]
- then
- echo "_check_xfs_filesystem: filesystem on $device is inconsistent (r) (see $RESULT_DIR/$seq.full)"
-
- echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$RESULT_DIR/$seq.full
- echo "*** xfs_repair -n output ***" >>$RESULT_DIR/$seq.full
- cat $tmp.repair | _fix_malloc >>$RESULT_DIR/$seq.full
- echo "*** end xfs_repair output" >>$RESULT_DIR/$seq.full
-
- ok=0
- fi
- rm -f $tmp.fs_check $tmp.logprint $tmp.repair
-
- if [ $ok -eq 0 ]
- then
- echo "*** mount output ***" >>$RESULT_DIR/$seq.full
- _mount >>$RESULT_DIR/$seq.full
- echo "*** end mount output" >>$RESULT_DIR/$seq.full
- elif [ "$type" = "xfs" ]
- then
- _mount_or_remount_rw "$extra_mount_options" $device $mountpoint
- fi
-
- if [ $ok -eq 0 ]; then
- status=1
- exit 1
- fi
-
- return 0
-}
-
-# Filter the knowen errors the UDF Verifier reports.
-_udf_test_known_error_filter()
-{
- egrep -v "PVD 60 Error: Interchange Level: 1, Maximum Interchange Level: 0|FSD 28 Error: Interchange Level: 1, Maximum Interchange Level: 1,|PVD 72 Warning: Volume Set Identifier: \"\*IRIX UDF\",|Warning: [0-9]+ unused blocks NOT marked as unallocated."
-
-}
-
-_check_udf_filesystem()
-{
- [ "$DISABLE_UDF_TEST" == "1" ] && return
-
- if [ $# -ne 1 -a $# -ne 2 ]
- then
- echo "Usage: _check_udf_filesystem device [last_block]" 1>&2
- exit 1
- fi
-
- if [ ! -x $here/src/udf_test ]
- then
- echo "udf_test not installed, please download and build the Philips"
- echo "UDF Verification Software from http://www.extra.research.philips.com/udf/."
- echo "Then copy the udf_test binary to $here/src/."
- echo "If you do not wish to run udf_test then set environment variable DISABLE_UDF_TEST"
- echo "to 1."
- return
- fi
-
- device=$1
- if [ $# -eq 2 ];
- then
- LAST_BLOCK=`expr \( $2 - 1 \)`
- OPT_ARG="-lastvalidblock $LAST_BLOCK"
- fi
-
- rm -f $RESULT_DIR/$seq.checkfs
- sleep 1 # Due to a problem with time stamps in udf_test
- $here/src/udf_test $OPT_ARG $device | tee $RESULT_DIR/$seq.checkfs | egrep "Error|Warning" | \
- _udf_test_known_error_filter | \
- egrep -iv "Error count:.*[0-9]+.*total occurrences:.*[0-9]+|Warning count:.*[0-9]+.*total occurrences:.*[0-9]+" | \
- sed "s/^.*$/Warning UDF Verifier reported errors see $RESULT_DIR/$seq.checkfs./g"
-
-}
-
-_check_xfs_test_fs()
-{
- TEST_LOG="none"
- TEST_RT="none"
- [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
- TEST_LOG="$TEST_LOGDEV"
-
- [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
- TEST_RT="$TEST_RTDEV"
-
- _check_xfs_filesystem $TEST_DEV $TEST_LOG $TEST_RT
-
- # check for ipath consistency
- if $XFS_GROWFS_PROG -n $TEST_DIR | grep -q 'inode-paths=1'; then
- # errors go to stderr
- xfs_check_ipaths $TEST_DIR >/dev/null
- xfs_repair_ipaths -n $TEST_DIR >/dev/null
- fi
-}
-
-_check_btrfs_filesystem()
-{
- device=$1
-
- # If type is set, we're mounted
- type=`_fs_type $device`
- ok=1
-
- if [ "$type" = "$FSTYP" ]
- then
- # mounted ...
- mountpoint=`_umount_or_remount_ro $device`
- fi
-
- btrfsck $device >$tmp.fsck 2>&1
- if [ $? -ne 0 ]
- then
- echo "_check_btrfs_filesystem: filesystem on $device is inconsistent (see $RESULT_DIR/$seq.full)"
-
- echo "_check_btrfs_filesystem: filesystem on $device is inconsistent" >>$RESULT_DIR/$seq.full
- echo "*** fsck.$FSTYP output ***" >>$RESULT_DIR/$seq.full
- cat $tmp.fsck >>$RESULT_DIR/$seq.full
- echo "*** end fsck.$FSTYP output" >>$RESULT_DIR/$seq.full
-
- ok=0
- fi
- rm -f $tmp.fsck
-
- if [ $ok -eq 0 ]
- then
- echo "*** mount output ***" >>$RESULT_DIR/$seq.full
- _mount >>$RESULT_DIR/$seq.full
- echo "*** end mount output" >>$RESULT_DIR/$seq.full
- elif [ "$type" = "$FSTYP" ]
- then
- # was mounted ...
- _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
- ok=$?
- fi
-
- if [ $ok -eq 0 ]; then
- status=1
- exit 1
- fi
-
- return 0
-}
-
-_check_test_fs()
-{
- case $FSTYP in
- xfs)
- _check_xfs_test_fs
- ;;
- nfs)
- # no way to check consistency for nfs
- ;;
- udf)
- # do nothing for now
- ;;
- btrfs)
- _check_btrfs_filesystem $TEST_DEV
- ;;
- *)
- _check_generic_filesystem $TEST_DEV
- ;;
- esac
-}
-
-_check_scratch_fs()
-{
- case $FSTYP in
- xfs)
- SCRATCH_LOG="none"
- SCRATCH_RT="none"
- [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
- SCRATCH_LOG="$SCRATCH_LOGDEV"
-
- [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
- SCRATCH_RT="$SCRATCH_RTDEV"
-
- _check_xfs_filesystem $SCRATCH_DEV $SCRATCH_LOG $SCRATCH_RT
- ;;
- udf)
- _check_udf_filesystem $SCRATCH_DEV $udf_fsize
- ;;
- nfs*)
- # Don't know how to check an NFS filesystem, yet.
- ;;
- btrfs)
- _check_btrfs_filesystem $SCRATCH_DEV
- ;;
- *)
- _check_generic_filesystem $SCRATCH_DEV
- ;;
- esac
-}
-
-_full_fstyp_details()
-{
- [ -z "$FSTYP" ] && FSTYP=xfs
- if [ $FSTYP = xfs ]; then
- if [ -d /proc/fs/xfs ]; then
- if grep -q 'debug 0' /proc/fs/xfs/stat; then
- FSTYP="$FSTYP (non-debug)"
- elif grep -q 'debug 1' /proc/fs/xfs/stat; then
- FSTYP="$FSTYP (debug)"
- fi
- else
- if uname -a | grep -qi 'debug'; then
- FSTYP="$FSTYP (debug)"
- else
- FSTYP="$FSTYP (non-debug)"
- fi
- fi
- fi
- echo $FSTYP
-}
-
-_full_platform_details()
-{
- os=`uname -s`
- host=`hostname -s`
- kernel=`uname -r`
- platform=`uname -m`
- echo "$os/$platform $host $kernel"
-}
-
-_setup_udf_scratchdir()
-{
- [ "$FSTYP" != "udf" ] \
- && _fail "setup_udf_testdir: \$FSTYP is not udf"
- [ -z "$SCRATCH_DEV" -o ! -b "$SCRATCH_DEV" ] \
- && _notrun "this test requires a valid \$SCRATCH_DEV"
- [ -z "$SCRATCH_MNT" ] \
- && _notrun "this test requires a valid \$SCRATCH_MNT"
-
- # mounted?
- if _mount | grep -q $SCRATCH_DEV
- then
- # if it's mounted, make sure its on $TEST_RW_DIR
- if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
- then
- _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
- fi
- $UMOUNT_PROG $SCRATCH_DEV
- fi
-
- _scratch_mkfs
- _scratch_mount
-
- testdir=$SCRATCH_MNT
-}
-
-_setup_nfs_scratchdir()
-{
- [ "$FSTYP" != "nfs" ] \
- && _fail "setup_nfs_testdir: \$FSTYP is not nfs"
- [ -z "$SCRATCH_DEV" ] \
- && _notrun "this test requires a valid host fs for \$SCRATCH_DEV"
- [ -z "$SCRATCH_MNT" ] \
- && _notrun "this test requires a valid \$SCRATCH_MNT"
-
- # mounted?
- if _mount | grep -q $SCRATCH_DEV
- then
- # if it's mounted, make sure its on $SCRATCH_MNT
- if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
- then
- _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
- fi
- $UMOUNT_PROG $SCRATCH_DEV
- fi
-
- _scratch_mkfs
- _scratch_mount
-
- testdir=$SCRATCH_MNT
-}
-
-#
-# Warning for UDF and NFS:
-# this function calls _setup_udf_scratchdir and _setup_udf_scratchdir
-# which actually uses the scratch dir for the test dir.
-#
-# This was done because testdir was intended to be a persistent
-# XFS only partition. This should eventually change, and treat
-# at least local filesystems all the same.
-#
-_setup_testdir()
-{
- case $FSTYP in
- udf)
- _setup_udf_scratchdir
- ;;
- nfs*)
- _setup_nfs_scratchdir
- ;;
- *)
- testdir=$TEST_DIR
- ;;
- esac
-}
-
-_cleanup_testdir()
-{
- case $FSTYP in
- udf)
- # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
- [ -n "$testdir" ] && $UMOUNT_PROG $testdir
- ;;
- nfs*)
- # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
- [ -n "$testdir" ] && $UMOUNT_PROG $testdir
- ;;
- *)
- # do nothing, testdir is $TEST_DIR
- :
- ;;
- esac
-}
-
-_link_out_file()
-{
- if [ -z "$1" -o -z "$2" ]; then
- echo Error must pass src and dst.
- exit
- fi
- rm -f $2
- if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
- ln -s $1.irix $2
- elif [ "`uname`" == "Linux" ]; then
- ln -s $1.linux $2
- else
- echo Error test $seq does not run on the operating system: `uname`
- exit
- fi
-}
-
-_die()
-{
- echo $@
- exit 1
-}
-
-#takes files, randomdata
-_nfiles()
-{
- f=0
- while [ $f -lt $1 ]
- do
- file=f$f
- echo > $file
- if [ $size -gt 0 ]; then
- if [ "$2" == "false" ]; then
- dd if=/dev/zero of=$file bs=1024 count=$size 2>&1 | _filter_dd
- else
- dd if=/dev/urandom of=$file bs=1024 count=$size 2>&1 | _filter_dd
- fi
- fi
- let f=$f+1
- done
-}
-
-# takes dirname, depth, randomdata
-_descend()
-{
- dirname=$1; depth=$2; randomdata=$3
- mkdir $dirname || die "mkdir $dirname failed"
- cd $dirname
-
- _nfiles $files $randomdata # files for this dir and data type
-
- [ $depth -eq 0 ] && return
- let deep=$depth-1 # go 1 down
-
- [ $verbose = true ] && echo "descending, depth from leaves = $deep"
-
- d=0
- while [ $d -lt $dirs ]
- do
- _descend d$d $deep &
- let d=$d+1
- wait
- done
-}
-
-# Populate a filesystem with inodes for performance experiments
-#
-# usage: populate [-v] [-n ndirs] [-f nfiles] [-d depth] [-r root] [-s size] [-x]
-#
-_populate_fs()
-{
- here=`pwd`
- dirs=5 # ndirs in each subdir till leaves
- size=0 # sizeof files in K
- files=100 # num files in _each_ subdir
- depth=2 # depth of tree from root to leaves
- verbose=false
- root=root # path of initial root of directory tree
- randomdata=false # -x data type urandom or zero
-
- OPTIND=1
- while getopts "d:f:n:r:s:v:x" c
- do
- case $c in
- d) depth=$OPTARG;;
- n) dirs=$OPTARG;;
- f) files=$OPTARG;;
- s) size=$OPTARG;;
- v) verbose=true;;
- r) root=$OPTARG;;
- x) randomdata=true;;
- esac
- done
-
- _descend $root $depth $randomdata
- wait
-
- cd $here
-
- [ $verbose = true ] && echo done
-}
-
-# query whether the given file has the given inode flag set
-#
-_test_inode_flag()
-{
- flag=$1
- file=$2
-
- if which $XFS_IO_PROG >/dev/null; then
- if $XFS_IO_PROG -r -c 'lsattr -v' "$file" | grep -q "$flag" ; then
- return 0
- fi
- fi
- return 1
-}
-
-# query the given files extsize allocator hint in bytes (if any)
-#
-_test_inode_extsz()
-{
- file=$1
- blocks=""
-
- if which $XFS_IO_PROG >/dev/null; then
- blocks=`$XFS_IO_PROG -r -c 'stat' "$file" | \
- awk '/^xattr.extsize =/ { print $3 }'`
- fi
- [ -z "$blocks" ] && blocks="0"
- echo $blocks
-}
-
-# scratch_dev_pool should contain the disks pool for the btrfs raid
-_require_scratch_dev_pool()
-{
- local i
- if [ -z "$SCRATCH_DEV_POOL" ]; then
- _notrun "this test requires a valid \$SCRATCH_DEV_POOL"
- fi
-
- # btrfs test case needs 2 or more scratch_dev_pool; other FS not sure
- # so fail it
- case $FSTYP in
- btrfs)
- if [ "`echo $SCRATCH_DEV_POOL|wc -w`" -lt 2 ]; then
- _notrun "btrfs and this test needs 2 or more disks in SCRATCH_DEV_POOL"
- fi
- ;;
- *)
- _notrun "dev_pool is not supported by fstype \"$FSTYP\""
- ;;
- esac
-
- for i in $SCRATCH_DEV_POOL; do
- if [ "`_is_block_dev $i`" = "" ]; then
- _notrun "this test requires valid block disk $i"
- fi
- if [ "`_is_block_dev $i`" = "`_is_block_dev $TEST_DEV`" ]; then
- _notrun "$i is part of TEST_DEV, this test requires unique disks"
- fi
- if _mount | grep -q $i; then
- if ! $UMOUNT_PROG $i; then
- echo "failed to unmount $i - aborting"
- exit 1
- fi
- fi
- # to help better debug when something fails, we remove
- # traces of previous btrfs FS on the dev.
- dd if=/dev/zero of=$i bs=4096 count=100 > /dev/null 2>&1
- done
-}
-
-# We will check if the device is virtual (eg: loop device) since it does not
-# have the delete entry-point. Otherwise SCSI and USB devices are fine.
-_require_deletable_scratch_dev_pool()
-{
- local i
- local x
- for i in $SCRATCH_DEV_POOL; do
- x=`echo $i | cut -d"/" -f 3`
- ls -l /sys/class/block/${x} | grep -q "virtual"
- if [ $? == "0" ]; then
- _notrun "$i is a virtual device which is not deletable"
- fi
- done
-}
-
-# We check for btrfs and (optionally) features of the btrfs command
-_require_btrfs()
-{
- cmd=$1
- _require_command $BTRFS_UTIL_PROG btrfs
- if [ -z "$1" ]; then
- return 1;
- fi
- $BTRFS_UTIL_PROG $cmd --help >/dev/null 2>&1
- [ $? -eq 0 ] || _notrun "$BTRFS_UTIL_PROG too old (must support $cmd)"
-}
-
-# Check that fio is present, and it is able to execute given jobfile
-_require_fio()
-{
- job=$1
-
- _require_command $FIO_PROG
- if [ -z "$1" ]; then
- return 1;
- fi
-
- $FIO_PROG --warnings-fatal --showcmd $job >/dev/null 2>&1
- [ $? -eq 0 ] || _notrun "$FIO_PROG too old"
-}
-
-# Does freeze work on this fs?
-_require_freeze()
-{
- xfs_freeze -f "$TEST_DIR" >/dev/null 2>&1
- result=$?
- xfs_freeze -u "$TEST_DIR" >/dev/null 2>&1
- [ $result -eq 0 ] || _notrun "$FSTYP does not support freezing"
-}
-
-# arg 1 is dev to remove and is output of the below eg.
-# ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
-_devmgt_remove()
-{
- echo 1 > /sys/class/scsi_device/${1}/device/delete || _fail "Remove disk failed"
-}
-
-# arg 1 is dev to add and is output of the below eg.
-# ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
-_devmgt_add()
-{
- local h
- local tdl
- # arg 1 will be in h:t:d:l format now in the h and "t d l" format
- h=`echo ${1} | cut -d":" -f 1`
- tdl=`echo ${1} | cut -d":" -f 2-|sed 's/:/ /g'`
-
- echo ${tdl} > /sys/class/scsi_host/host${h}/scan || _fail "Add disk failed"
-}
-
-_require_fstrim()
-{
- if [ -z "$FSTRIM_PROG" ]; then
- _notrun "This test requires fstrim utility."
- fi
-}
-
-_test_batched_discard()
-{
- if [ $# -ne 1 ]; then
- echo "Usage: _test_batched_discard mnt_point" 1>&2
- exit 1
- fi
- _require_fstrim
- $FSTRIM_PROG ${1} &>/dev/null
-}
-
-_require_dumpe2fs()
-{
- if [ -z "$DUMPE2FS_PROG" ]; then
- _notrun "This test requires dumpe2fs utility."
- fi
-}
-
-_create_loop_device()
-{
- file=$1
- dev=`losetup -f --show $file` || _fail "Cannot assign $file to a loop device"
- echo $dev
-}
-
-_destroy_loop_device()
-{
- dev=$1
- losetup -d $dev || _fail "Cannot destroy loop device $dev"
-}
-
-_scale_fsstress_args()
-{
- args=""
- while [ $# -gt 0 ]; do
- case "$1" in
- -n) args="$args $1 $(($2 * $TIME_FACTOR))"; shift ;;
- -p) args="$args $1 $(($2 * $LOAD_FACTOR))"; shift ;;
- *) args="$args $1" ;;
- esac
- shift
- done
- echo $args
-}
-
-run_check()
-{
- echo "# $@" >> $RESULT_DIR/$seq.full 2>&1
- "$@" >> $RESULT_DIR/$seq.full 2>&1 || _fail "failed: '$@'"
-}
-
-################################################################################
-
-if [ "$iam" != new ]
-then
- # make some further configuration checks here
-
- if [ "$TEST_DEV" = "" ]
- then
- echo "common.rc: Error: \$TEST_DEV is not set"
- exit 1
- fi
-
- # if $TEST_DEV is not mounted, mount it now as XFS
- if [ -z "`_fs_type $TEST_DEV`" ]
- then
- # $TEST_DEV is not mounted
- if ! _test_mount
- then
- echo "common.rc: retrying test device mount with external set"
- [ "$USE_EXTERNAL" != "yes" ] && export USE_EXTERNAL=yes
- if ! _test_mount
- then
- echo "common.rc: could not mount $TEST_DEV on $TEST_DIR"
- exit 1
- fi
- fi
- fi
-
- if [ "`_fs_type $TEST_DEV`" != "$FSTYP" ]
- then
- echo "common.rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED $FSTYP filesystem"
- $DF_PROG $TEST_DEV
- exit 1
- fi
-fi
-
-# make sure this script returns success
-/bin/true
+++ /dev/null
-##/bin/bash
-#
-# 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
-#
-#
-# Functions useful for xfs_repair tests
-#
-
-_zero_position()
-{
- value=$1
- struct="$2"
-
- # set values for off/len variables provided by db
- eval `xfs_db -r -c "$struct" -c stack $SCRATCH_DEV | perl -ne '
- if (/byte offset (\d+), length (\d+)/) {
- print "offset=$1\nlength=$2\n"; exit
- }'`
- if [ -z "$offset" -o -z "$length" ]; then
- echo "cannot calculate offset ($offset) or length ($length)"
- exit
- fi
- length=`expr $length / 512`
- src/devzero -v $value -b 1 -n $length -o $offset $SCRATCH_DEV \
- | perl -npe 's/\d\.\d\dKb/X.XXKb/g'
-}
-
-_filter_repair()
-{
- perl -ne '
-# for sb
-/- agno = / && next; # remove each AG line (variable number)
-s/(pointer to) (\d+)/\1 INO/;
-s/(sb root inode value) (\d+)( \(NULLFSINO\))?/\1 INO/;
-s/(realtime bitmap inode) (\d+)( \(NULLFSINO\))?/\1 INO/;
-s/(realtime summary inode) (\d+)( \(NULLFSINO\))?/\1 INO/;
-s/(inconsistent with calculated value) (\d+)/\1 INO/;
-s/\.+(found)/\1/g; # remove "searching" output
-# for agf + agi
-s/(bad length -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
-s/(bad length # -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
-s/(bad agbno) (\d+)/\1 AGBNO/g;
-s/(max =) (\d+)/\1 MAX/g;
-# for root inos
-s/(on inode) (\d+)/\1 INO/g;
-s/(imap claims a free inode) (\d+)/\1 INO/;
-s/(imap claims in-use inode) (\d+)/\1 INO/;
-s/(cleared root inode) (\d+)/\1 INO/;
-s/(resetting inode) (\d+)/\1 INO/;
-s/(disconnected dir inode) (\d+)/\1 INO/;
-# for log
-s/internal log/<TYPEOF> log/g;
-s/external log on \S+/<TYPEOF> log/g;
-# realtime subvol - remove this whole line if it appears
-s/ - generate realtime summary info and bitmap...\n//g;
-#
-# new xfs repair output filters
-#
-s/\s+- creating \d+ worker thread\(s\)\n//g;
-s/\s+- reporting progress in intervals of \d+ minutes\n//g;
-s/\s+- \d+:\d\d:\d\d:.*\n//g;
-# 3.1.0 extra accounting output
-/^agf_/ && next; # remove agf counts
-/^agi_/ && next; # remove agi counts
-/^sb_/ && next; # remove sb counts
-/^agi unlinked/ && next; # remove agi unlinked bucket warning
-# crc enabled filesystem output
-/XFS_CORRUPTION_ERROR/ && next;
-/^bad uuid/ && next;
- print;'
-}
-
-_filter_dd()
-{
- fgrep -v records # lose records in/out lines
-}
-
-# do some controlled corrupting & ensure repair recovers us
-#
-_check_repair()
-{
- value=$1
- structure="$2"
-
- #ensure the filesystem has been dirtied since last repair
- _scratch_mount
- POSIXLY_CORRECT=yes \
- dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd
- sync
- rm -f $SCRATCH_MNT/sh
- umount $SCRATCH_MNT
-
- _zero_position $value "$structure"
- _scratch_xfs_repair 2>&1 | _filter_repair
-
- # some basic sanity checks...
- _check_scratch_fs
- _scratch_mount #mount
- POSIXLY_CORRECT=yes \
- dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd #open,write
- POSIXLY_CORRECT=yes \
- dd if=$SCRATCH_MNT/sh of=/dev/null 2>&1 |_filter_dd #read
- rm -f $SCRATCH_MNT/sh #unlink
- umount $SCRATCH_MNT #umount
-}
-
-# make sure this script returns success
-/bin/true
+++ /dev/null
-##/bin/bash
-#
-# Copyright (c) 2012 Red Hat, Inc
-# All Rights Reserved.
-#
-# Written by Eric Sandeen <sandeen@redhat.com>
-#
-# 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 tests on unique block devices
-#
-
-_require_scsi_debug()
-{
- # make sure we have the module and it's not already used
- modinfo scsi_debug 2>&1 > /dev/null || _notrun "scsi_debug module not found"
- lsmod | grep -wq scsi_debug && (rmmod scsi_debug || _notrun "scsi_debug module in use")
- # make sure it has the features we need
- # logical/physical sectors plus unmap support all went in together
- modinfo scsi_debug | grep -wq sector_size || _notrun "scsi_debug too old"
-}
-
-# Args: [physical sector size, [logical sector size, [unaligned(0|1), [size in megs]]]]
-_get_scsi_debug_dev()
-{
- # Defaults to phys 512, logical 512, aligned
- physical=${1-512}
- logical=${2-512}
- unaligned=${3-0}
- size=${4-128}
-
- phys_exp=0
- while [ $logical -lt $physical ]; do
- let physical=physical/2
- let phys_exp=phys_exp+1
- done
- opts="sector_size=$logical physblk_exp=$phys_exp lowest_aligned=$unaligned dev_size_mb=$size"
- echo "scsi_debug options $opts" >> $RESULT_DIR/$seq.full
- modprobe scsi_debug $opts
- [ $? -eq 0 ] || _fail "scsi_debug modprobe failed"
- sleep 1
- device=`grep -wl scsi_debug /sys/block/sd*/device/model | awk -F / '{print $4}'`
- echo "/dev/$device"
-}
-
-_put_scsi_debug_dev()
-{
- sleep 1
- lsmod | grep -wq scsi_debug || return
- rmmod scsi_debug || _fail "Could not remove scsi_debug module"
-}
--- /dev/null
+##/bin/bash
+#-----------------------------------------------------------------------
+# Copyright (c) 2000-2004 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will 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 to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+#
+# Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
+# Mountain View, CA 94043, USA, or: http://www.sgi.com
+#-----------------------------------------------------------------------
+# common extended attribute and ACL support
+
+# pick three unused user/group ids, store them as $acl[1-3]
+#
+_acl_setup_ids()
+{
+ eval `(_cat_passwd; _cat_group) | awk -F: '
+ { ids[$3]=1 }
+ END {
+ j=1
+ for(i=1; i<1000000 && j<=3;i++){
+ if (! (i in ids)) {
+ printf "acl%d=%d;", j, i;
+ j++
+ }
+ }
+ }'`
+}
+
+# filter for the acl ids selected above
+#
+_acl_filter_id()
+{
+ sed \
+ -e "s/u:$acl1/u:id1/" \
+ -e "s/u:$acl2/u:id2/" \
+ -e "s/u:$acl3/u:id3/" \
+ -e "s/g:$acl1/g:id1/" \
+ -e "s/g:$acl2/g:id2/" \
+ -e "s/g:$acl3/g:id3/" \
+ -e "s/ $acl1 / id1 /" \
+ -e "s/ $acl2 / id2 /" \
+ -e "s/ $acl3 / id3 /"
+}
+
+# filtered ls
+#
+_acl_ls()
+{
+ _ls_l -n $* | awk '{ print $1, $3, $4, $NF }' | _acl_filter_id
+}
+
+#
+_acl_list()
+{
+ _file1=$1
+
+ if [ $HOSTOS = "IRIX" ]; then
+ ls -dD $_file1 | _acl_filter_id
+ else
+ chacl -l $_file1 | _acl_filter_id
+ fi
+}
+
+# create an ACL with n ACEs in it
+#
+_create_n_aces()
+{
+ let n=$1-4
+ acl='u::rwx,g::rwx,o::rwx,m::rwx' # 4 ace acl start
+ while [ $n -ne 0 ]; do
+ acl="$acl,u:$n:rwx"
+ let n=$n-1
+ done
+ echo $acl
+}
+
+# filter user ace names to user ids
+#
+_filter_aces()
+{
+ tmp_file=`mktemp /tmp/ace.XXXXXX`
+
+ (_cat_passwd; _cat_group) > $tmp_file
+
+ $AWK_PROG -v tmpfile=$tmp_file '
+ BEGIN {
+ FS=":"
+ while ( getline <tmpfile > 0 ) {
+ idlist[$1] = $3
+ }
+ }
+ /^user/ { if ($2 in idlist) sub($2, idlist[$2]); print; next}
+ /^u/ { if ($2 in idlist) sub($2, idlist[$2]); print; next}
+ /^default:user/ { if ($3 in idlist) sub($3, idlist[$3]); print; next}
+ {print}
+ '
+ rm -f $tmp_file
+}
+
+_filter_aces_notypes()
+{
+ tr '\[' '\012' | tr ']' '\012' | tr ',' '\012' | _filter_aces|\
+ sed -e 's/u:/user:/' -e 's/g:/group:/' -e 's/o:/other:/' -e 's/m:/mask:/'
+}
+
+_require_acls()
+{
+ if [ ! -x /bin/chacl -a ! -x /usr/bin/chacl -a ! -x /sbin/chacl ]; then
+ _notrun "chacl command not found"
+ fi
+
+ #
+ # Test if chacl is able to list ACLs on the target filesystems. On really
+ # old kernels the system calls might not be implemented at all, but the
+ # more common case is that the tested filesystem simply doesn't support
+ # ACLs.
+ #
+ touch $TEST_DIR/syscalltest
+ chacl -l $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
+ cat $TEST_DIR/syscalltest.out >> $RESULT_DIR/$seq.full
+
+ if grep -q 'Function not implemented' $TEST_DIR/syscalltest.out; then
+ _notrun "kernel does not support ACLs"
+ fi
+ if grep -q 'Operation not supported' $TEST_DIR/syscalltest.out; then
+ _notrun "ACLs not supported by this filesystem type: $FSTYP"
+ fi
+
+ rm -f $TEST_DIR/syscalltest.out
+}
+
+_list_acl()
+{
+ file=$1
+
+ ls -dD $file | _acl_filter_id
+}
+
+_require_attrs()
+{
+ [ -n $ATTR_PROG ] || _notrun "attr command not found"
+ [ -n $GETFATTR_PROG ] || _notrun "getfattr command not found"
+ [ -n $SETFATTR_PROG ] || _notrun "setfattr command not found"
+
+ #
+ # Test if chacl is able to write an attribute on the target filesystems.
+ # On really old kernels the system calls might not be implemented at all,
+ # but the more common case is that the tested filesystem simply doesn't
+ # support attributes. Note that we can't simply list attributes as
+ # various security modules generate synthetic attributes not actually
+ # stored on disk.
+ #
+ touch $TEST_DIR/syscalltest
+ attr -s "user.xfstests" -V "attr" $TEST_DIR > $TEST_DIR/syscalltest.out 2>&1
+ cat $TEST_DIR/syscalltest.out >> $RESULT_DIR/$seq.full
+
+ if grep -q 'Function not implemented' $TEST_DIR/syscalltest.out; then
+ _notrun "kernel does not support attrs"
+ fi
+ if grep -q 'Operation not supported' $TEST_DIR/syscalltest.out; then
+ _notrun "attrs not supported by this filesystem type: $FSTYP"
+ fi
+
+ rm -f $TEST_DIR/syscalltest.out
+}
+
+# getfattr -R returns info in readdir order which varies from fs to fs.
+# This sorts the output by filename
+_sort_getfattr_output()
+{
+ awk '{a[FNR]=$0}END{n = asort(a); for(i=1; i <= n; i++) print a[i]"\n"}' RS=''
+}
+
+# set maximum total attr space based on fs type
+if [ "$FSTYP" == "xfs" -o "$FSTYP" == "udf" ]; then
+ MAX_ATTRS=1000
+else # Assume max ~1 block of attrs
+ BLOCK_SIZE=`stat -f $TEST_DIR | grep "Block size" | cut -d " " -f3`
+ # user.attribute_XXX="value.XXX" is about 32 bytes; leave some overhead
+ let MAX_ATTRS=$BLOCK_SIZE/40
+fi
+
+export MAX_ATTRS
+
+# Set max attr value size based on fs type
+if [ "$FSTYP" == "xfs" -o "$FSTYP" == "udf" -o "$FSTYP" == "btrfs" ]; then
+ MAX_ATTRVAL_SIZE=64
+else # Assume max ~1 block of attrs
+ BLOCK_SIZE=`stat -f $TEST_DIR | grep "Block size" | cut -d " " -f3`
+ # leave a little overhead
+ let MAX_ATTRVAL_SIZE=$BLOCK_SIZE-256
+fi
+
+export MAX_ATTRVAL_SIZE
+# make sure this script returns success
+/bin/true
--- /dev/null
+##/bin/bash
+#
+# Copyright (c) 2000-2003,2006 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
+#
+#
+# setup and check for config parameters, and in particular
+#
+# EMAIL - email of the script runner.
+# TEST_DIR - scratch test directory that is in an already
+# mounted XFS file system, needs to be be world
+# writeable
+# TEST_DEV - device for file system containing TEST_DIR
+#
+# and optionally:
+# SCRATCH_DEV - device you can make a scratch file system on
+# SCRATCH_MNT - mount point for scratch file system
+# SCRATCH_LOGDEV - scratch log device for external log testing
+# SCRATCH_RTDEV - scratch rt dev
+# TEST_LOGDEV - test log device for external log testing
+# TEST_RTDEV - test rt dev
+# TAPE_DEV - the tape device for the xfsdump tests
+# RMT_TAPE_DEV - the remote tape device for the xfsdump tests
+# RMT_IRIXTAPE_DEV- the IRIX remote tape device for the xfsdump tests
+# RMT_TAPE_USER - remote user for tape device
+#
+# - These can be added to $HOST_CONFIG_DIR (witch default to ./config)
+# below or a separate local configuration file can be used (using
+# the HOST_OPTIONS variable).
+# - This script is shared by the stress test system and the auto-qa
+# system
+# - TEST_DEV & TEST_DIR must be assigned.
+# - this script shouldn't make any assertions about filesystem
+# validity or mountedness.
+#
+
+# all tests should use a common language setting to prevent golden
+# output mismatches.
+export LANG=C
+
+# Warning: don't put freeware before /usr/bsd on IRIX coz you'll
+# get the wrong hostname and set your system name to -s :)
+[ -d /usr/bsd ] && PATH=$PATH:/usr/bsd
+[ -d /usr/freeware/bin ] && PATH=$PATH:/usr/freeware/bin
+PATH=".:$PATH"
+
+HOST=`hostname -s`
+HOSTOS=`uname -s`
+[ "$HOSTOS" = "IRIX64" ] && HOSTOS="IRIX"
+
+MODULAR=0 # using XFS as a module or not
+BOOT="/boot" # install target for kernels
+export EXTRA=${EXTRA:=xfs-qa}
+
+# general parameters (mainly for auto-qa)
+SOAK_PROC=3 # -p option to fsstress
+SOAK_STRESS=10000 # -n option to fsstress
+SOAK_PASSES=-1 # count of repetitions of fsstress (while soaking)
+EMAIL=root@localhost # where auto-qa will send its status messages
+export HOST_OPTIONS=${HOST_OPTIONS:=local.config}
+export CHECK_OPTIONS=${CHECK_OPTIONS:="-g auto"}
+export BENCH_PASSES=${BENCH_PASSES:=5}
+export XFS_MKFS_OPTIONS=${XFS_MKFS_OPTIONS:=-bsize=4096}
+export TIME_FACTOR=${TIME_FACTOR:=1}
+export LOAD_FACTOR=${LOAD_FACTOR:=1}
+export DEBUGFS_MNT=${DEBUGFS_MNT:="/sys/kernel/debug"}
+
+export PWD=`pwd`
+#export DEBUG=${DEBUG:=...} # arbitrary CFLAGS really.
+export MALLOCLIB=${MALLOCLIB:=/usr/lib/libefence.a}
+export LOCAL_CONFIGURE_OPTIONS=${LOCAL_CONFIGURE_OPTIONS:=--enable-readline=yes}
+
+# $1 = prog to look for, $2* = default pathnames if not found in $PATH
+set_prog_path()
+{
+ p=`which $1 2> /dev/null`
+ if [ -n "$p" -a -x "$p" ]; then
+ echo $p
+ return 0
+ fi
+ p=$1
+
+ shift
+ for f; do
+ if [ -x $f ]; then
+ echo $f
+ return 0
+ fi
+ done
+
+ echo ""
+ return 1
+}
+
+# Handle mkfs.btrfs which does (or does not) require -f to overwrite
+set_btrfs_mkfs_prog_path_with_opts()
+{
+ p=`set_prog_path mkfs.btrfs`
+ if [ "$p" != "" ] && grep -q 'force overwrite' $p; then
+ echo "$p -f"
+ else
+ echo $p
+ fi
+}
+
+_fatal()
+{
+ echo "$*"
+ status=1
+ exit 1
+}
+
+export MKFS_PROG="`set_prog_path mkfs`"
+[ "$MKFS_PROG" = "" ] && _fatal "mkfs not found"
+
+export MOUNT_PROG="`set_prog_path mount`"
+[ "$MOUNT_PROG" = "" ] && _fatal "mount not found"
+
+export UMOUNT_PROG="`set_prog_path umount`"
+[ "$UMOUNT_PROG" = "" ] && _fatal "umount not found"
+
+export FSSTRESS_PROG="`set_prog_path fsstress $PWD/ltp/fsstress`"
+[ "$FSSTRESS_PROG" = "" ] && _fatal "fsstress not found"
+
+export PERL_PROG="`set_prog_path perl`"
+[ "$PERL_PROG" = "" ] && _fatal "perl not found"
+
+export AWK_PROG="`set_prog_path awk`"
+[ "$AWK_PROG" = "" ] && _fatal "awk not found"
+
+export SED_PROG="`set_prog_path sed`"
+[ "$SED_PROG" = "" ] && _fatal "sed not found"
+
+export BC_PROG="`set_prog_path bc`"
+[ "$BC_PROG" = "" ] && _fatal "bc not found"
+
+export PS_ALL_FLAGS="-ef"
+
+export DF_PROG="`set_prog_path df`"
+[ "$DF_PROG" = "" ] && _fatal "df not found"
+[ "$HOSTOS" = "Linux" ] && export DF_PROG="$DF_PROG -T"
+
+export XFS_LOGPRINT_PROG="`set_prog_path xfs_logprint`"
+export XFS_REPAIR_PROG="`set_prog_path xfs_repair`"
+export XFS_CHECK_PROG="`set_prog_path xfs_check`"
+export XFS_DB_PROG="`set_prog_path xfs_db`"
+export XFS_GROWFS_PROG=`set_prog_path xfs_growfs`
+export XFS_IO_PROG="`set_prog_path xfs_io`"
+export XFS_PARALLEL_REPAIR_PROG="`set_prog_path xfs_prepair`"
+export XFS_PARALLEL_REPAIR64_PROG="`set_prog_path xfs_prepair64`"
+export __XFSDUMP_PROG="`set_prog_path xfsdump`"
+export XFSDUMP_PROG="$__XFSDUMP_PROG -e"
+export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
+export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
+export GETFATTR_PROG="`set_prog_path getfattr`"
+export SETFATTR_PROG="`set_prog_path setfattr`"
+export ATTR_PROG="`set_prog_path attr`"
+export QUOTA_PROG="`set_prog_path quota`"
+export XFS_QUOTA_PROG="`set_prog_path xfs_quota`"
+export KILLALL_PROG="`set_prog_path killall`"
+export INDENT_PROG="`set_prog_path indent`"
+export XFS_COPY_PROG="`set_prog_path xfs_copy`"
+export FSTRIM_PROG="`set_prog_path fstrim`"
+export DUMPE2FS_PROG="`set_prog_path dumpe2fs`"
+export FIO_PROG="`set_prog_path fio`"
+export FILEFRAG_PROG="`set_prog_path filefrag`"
+export E4DEFRAG_PROG="`set_prog_path e4defrag`"
+export LOGGER_PROG="`set_prog_path logger`"
+
+# Generate a comparable xfsprogs version number in the form of
+# major * 10000 + minor * 100 + release
+#
+# $ xfs_db -V
+# xfs_db version 2.9.7
+#
+# so, 2.9.7 = 20907
+_version=`$XFS_DB_PROG -V | $AWK_PROG '
+ /version/ {
+ if (split($3,ver,".") == 3)
+ print (ver[1] * 10000) + (ver[2] * 100) + ver[3];
+ }'`
+[ -z "$_version" ] && _fatal "xfsprogs version cannot be found"
+export XFSPROGS_VERSION="$_version"
+
+case "$HOSTOS" in
+ IRIX*)
+ export MKFS_XFS_PROG="`set_prog_path mkfs_xfs`"
+ export MKFS_UDF_PROG="`set_prog_path mkfs_udf`"
+ export XFS_FSR_PROG="`set_prog_path /usr/etc/fsr_xfs`"
+ export MKFS_NFS_PROG="false"
+ ;;
+ Linux)
+ export MKFS_XFS_PROG="`set_prog_path mkfs.xfs`"
+ export MKFS_UDF_PROG="`set_prog_path mkudffs`"
+ export MKFS_BTRFS_PROG="`set_btrfs_mkfs_prog_path_with_opts`"
+ export BTRFS_UTIL_PROG="`set_prog_path btrfs`"
+ export XFS_FSR_PROG="`set_prog_path xfs_fsr`"
+ export MKFS_NFS_PROG="false"
+ ;;
+esac
+
+known_hosts()
+{
+ [ "$HOST_CONFIG_DIR" ] || HOST_CONFIG_DIR=`pwd`/configs
+
+ [ -f /etc/xfsqa.config ] && . /etc/xfsqa.config
+ [ -f $HOST_CONFIG_DIR/$HOST ] && . $HOST_CONFIG_DIR/$HOST
+ [ -f $HOST_CONFIG_DIR/$HOST.config ] && . $HOST_CONFIG_DIR/$HOST.config
+
+ # Mandatory Config values.
+ MC=""
+ [ -z "$EMAIL" ] && MC="$MC EMAIL"
+ [ -z "$TEST_DIR" ] && MC="$MC TEST_DIR"
+ [ -z "$TEST_DEV" ] && MC="$MC TEST_DEV"
+
+ if [ -n "$MC" ]; then
+ echo "Warning: need to define parameters for host $HOST"
+ echo " or set variables:"
+ echo " $MC"
+ exit 1
+ fi
+}
+
+if [ -f "$HOST_OPTIONS" ]; then
+ . "$HOST_OPTIONS"
+else
+ known_hosts
+fi
+
+echo $TEST_DEV | grep -q ":" > /dev/null 2>&1
+if [ ! -b "$TEST_DEV" -a "$?" != "0" ]; then
+ echo "common.config: Error: \$TEST_DEV ($TEST_DEV) is not a block device or a NFS filesystem"
+ exit 1
+fi
+
+if [ ! -d "$TEST_DIR" ]; then
+ echo "common.config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
+ exit 1
+fi
+
+# a btrfs tester will set only SCRATCH_DEV_POOL, we will put first of its dev
+# to SCRATCH_DEV and rest to SCRATCH_DEV_POOL to maintain the backward compatibility
+if [ ! -z "$SCRATCH_DEV_POOL" ]; then
+ if [ ! -z "$SCRATCH_DEV" ]; then
+ echo "common.config: Error: \$SCRATCH_DEV should be unset when \$SCRATCH_DEV_POOL is set"
+ exit 1
+ fi
+ SCRATCH_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
+ SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | awk '{ ORS=" "; for (i = 2; i <= NF; i++) print $i}'`
+fi
+
+echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
+if [ ! -z "$SCRATCH_DEV" -a ! -b "$SCRATCH_DEV" -a "$?" != "0" ]; then
+ echo "common.config: Error: \$SCRATCH_DEV ($SCRATCH_DEV) is not a block device or a NFS filesystem"
+ exit 1
+fi
+
+if [ ! -z "$SCRATCH_MNT" -a ! -d "$SCRATCH_MNT" ]; then
+ echo "common.config: Error: \$SCRATCH_MNT ($SCRATCH_MNT) is not a directory"
+ exit 1
+fi
+
+# make sure this script returns success
+/bin/true
--- /dev/null
+##/bin/bash
+#
+# Copyright (c) 2009 Eric Sandeen
+# 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 defragmentation tests
+#
+
+_require_defrag()
+{
+ case "$FSTYP" in
+ xfs)
+ DEFRAG_PROG="$XFS_FSR_PROG"
+ ;;
+ ext4|ext4dev)
+ DEFRAG_PROG="$E4DEFRAG_PROG"
+ ;;
+ btrfs)
+ DEFRAG_PROG="$BTRFS_UTIL_PROG filesystem defragment"
+ ;;
+ *)
+ _notrun "defragmentation not supported for fstype \"$FSTYP\""
+ ;;
+ esac
+
+ _require_command $DEFRAG_PROG
+ _require_command $FILEFRAG_PROG
+}
+
+_extent_count()
+{
+ $FILEFRAG_PROG $1 | awk '{print $2}'
+ $FILEFRAG_PROG -v $1 >> $RESULT_DIR/$seq.full 2>&1
+}
+
+# Defrag file, check it, and remove it.
+_defrag()
+{
+ echo -n "Before: "
+ _extent_count $1
+ CSUM_BEFORE=`md5sum $1`
+ STAT_BEFORE=`stat -c "a: %x m: %y c: %z" $1`
+ $DEFRAG_PROG -v $1 >> $RESULT_DIR/$seq.full 2>&1
+ _scratch_remount
+ STAT_AFTER=`stat -c "a: %x m: %y c: %z" $1`
+ CSUM_AFTER=`md5sum $1`
+ echo -n "After: "
+ _extent_count $1
+ if [ "$CSUM_BEFORE" != "$CSUM_AFTER" ]; then
+ _fail "file checksum changed post-defrag ($CSUM_BEFORE/$CSUM_AFTER)"
+ fi
+ if [ "$STAT_BEFORE" != "$STAT_AFTER" ]; then
+ _fail "file timestamps changed post-defrag:\n$STAT_BEFORE\n$STAT_AFTER"
+ fi
+ rm -f $1
+}
+
--- /dev/null
+##/bin/bash
+#
+# Copyright (c) 2006 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
+#
+#
+# dmapi functions
+#
+
+# Commands relitive to dmapi qa
+
+DMAPI_QASUITE1_DIR=$here/dmapi/src/suite1/
+DMAPI_QASUITE2_DIR=$here/dmapi/src/suite2/
+DMAPI_COMMON_DIR=$here/dmapi/src/common/
+
+DMAPI_LS_TO_COPY_PATH=$DMAPI_QASUITE2_DIR/bindir/ls_to_copy
+
+_dmapi_scratch_mount () {
+ if [ `echo "$MOUNT_OPTIONS" | grep -c dmapi` -gt 0 -o \
+ `echo "$MOUNT_OPTIONS" | grep -c dmi` -gt 0 ] ; then
+ #already got dmapi options set
+ _scratch_mount
+ dmapi_mount_result=$?
+ else
+ _scratch_mount "-o dmapi,mtpt=$SCRATCH_MNT"
+ dmapi_mount_result=$?
+ fi
+
+ if [ $dmapi_mount_result -ne 0 ] ; then
+ _notrun "Assuming DMAPI modules are not loaded"
+ fi
+}
+
+
--- /dev/null
+##/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
+#
+
+# --- initializations ---
+rm -f $RESULT_DIR/$seq.full
+
+if [ -n "$DEBUGDUMP" ]; then
+ _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 XFSDUMP_PROG="$__XFSDUMP_PROG -e"
+ 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
+
+[ "$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
+
+# name those directories
+dump_file=$tmp.dumpfile
+# dump_file=$here/dumpfile #TEMP OVERRIDE DUMP FILE
+dump_sdir=dumpdir
+dump_dir=$SCRATCH_MNT/$dump_sdir
+restore_sdir=restoredir
+restore_dir=$SCRATCH_MNT/$restore_sdir
+multi=3
+dumptape=$TAPE_DEV
+media_label="stress_tape_media"
+session_label="stress_$seq"
+
+nobody=4 # define this uid/gid as a number
+do_quota_check=true # do quota check if quotas enabled
+
+_need_to_be_root
+
+# 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
+ [ -d $dir.$seq ] && rm -rf $dir.$seq
+ mv $dir $dir.$seq
+ fi
+done
+
+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
+#
+_mt()
+{
+ op=$1
+ if _isrmt; then
+ # REMOTE
+ _rmtdev=`echo $dumptape | $AWK_PROG -F: '{print $2}'`
+
+ if echo $dumptape | grep '@' >/dev/null; then
+ _spec=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
+ _rmtuser=`echo $_spec | $AWK_PROG -F@ '{print $1}'`
+ _rmthost=`echo $_spec | $AWK_PROG -F@ '{print $2}'`
+ rsh -n -l $_rmtuser $_rmthost "mt -t $_rmtdev $op"
+ else
+ _rmthost=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
+ rsh -n $_rmthost "mt -t $_rmtdev $op"
+ fi
+ else
+ #LOCAL
+ mt -t $dumptape $op
+ fi
+}
+
+_check_onl()
+{
+ _limit=10
+ i=0
+ while [ $i -lt $_limit ]; do
+ echo "Checking online..." >>$RESULT_DIR/$seq.full
+ if _mt status >$tmp.status 2>&1; then
+ break;
+ else
+ sleep 1
+ fi
+ let i=$i+1
+ done
+
+
+ if [ $i -eq $_limit ]; then
+ echo "ERROR: mt -f $dumptape failed"
+ cat $tmp.status
+
+ echo "mt -f $dumptape failed" >$seq.notrun
+ status=$NOTRUNSTS
+ exit
+ fi
+
+
+ if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
+ :
+ else
+ echo "ERROR: $dumptape is not online"
+ cat $tmp.status
+
+ echo "dumptape, $dumptape, is not online" >$seq.notrun
+ status=$NOTRUNSTS
+ exit
+ fi
+}
+
+_wait_tape()
+{
+ echo "Wait for tape, $dumptape, ..." >>$RESULT_DIR/$seq.full
+
+ i=0
+ while [ $i -lt 20 ]; do
+ echo "Checking status..." >>$RESULT_DIR/$seq.full
+ if _mt status 2>&1 | tee -a $RESULT_DIR/$seq.full | egrep -i "onl|ready" >/dev/null; then
+ break;
+ else
+ sleep 1
+ fi
+ let i=$i+1
+ done
+}
+
+#
+# Keep trying so we know we really have rewound
+#
+_rewind()
+{
+ echo "Initiate rewind..." >>$RESULT_DIR/$seq.full
+ _wait_tape
+ _mt rewind >/dev/null
+ _wait_tape
+}
+
+#
+# Do a custom erase because:
+# (i) some machines don't support it
+# (ii) some machines take forever to do it
+#
+_erase_soft()
+{
+ echo "Erasing tape" | tee -a $RESULT_DIR/$seq.full
+ _rewind
+ _mt weof 3
+ _rewind
+}
+
+_erase_hard()
+{
+ echo "Erasing tape" | tee -a $RESULT_DIR/$seq.full
+ _mt erase
+}
+
+_isrmt()
+{
+ echo $dumptape | grep ':' >/dev/null
+}
+
+#
+# Get tape ready
+#
+_set_variable()
+{
+ $have_mtvariable || return
+
+ if _isrmt; then
+ :
+ else
+ # LOCAL
+ echo "Put scsi tape driver into variable block size mode"
+ mt -f $dumptape setblk 0
+ fi
+}
+
+_require_tape()
+{
+ dumptape=$1
+
+ if [ -z "$dumptape" -o "@" == "$dumptape" ]; then
+ echo "This test requires a dump tape - none was specified"
+ echo "No dump tape specified" >$RESULT_DIR/$seq.notrun
+ status=$NOTRUNSTS
+ exit
+ fi
+
+ _check_onl
+ _set_variable
+}
+
+_wipe_fs()
+{
+ _require_scratch
+
+ _scratch_mkfs_xfs >>$RESULT_DIR/$seq.full || _fail "mkfs failed"
+ _scratch_mount >>$RESULT_DIR/$seq.full || _fail "mount failed"
+}
+
+#
+# Cleanup created dirs and files
+# Called by trap
+#
+_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.*
+
+ if [ -n "$DEBUGDUMP" ]; then
+ # save it for inspection
+ for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
+ [ -d $dir ] || continue
+ tar -cvf $RESULT_DIR/$seq.inventory.tar $dir
+ ls -nR $dir >$RESULT_DIR/$seq.inventory.ls
+ done
+ fi
+
+ # put inventory dir back
+ for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
+ [ -d $dir.$seq ] || continue
+ rm -rf $dir # get rid of new one
+ mv $dir.$seq $dir
+ done
+
+ if [ $status -ne $NOTRUNSTS ]; then
+ # Sleep added to stop _check_scratch_fs from complaining that the
+ # scratch_dev is still busy
+ sleep 10
+
+ _check_scratch_fs
+ fi
+}
+
+#
+# ensure that bulkstat data will
+# match with incore data
+# by forcing disk data to be written out
+#
+_stable_fs()
+{
+ _saveddir=`pwd`; cd /
+ umount $SCRATCH_MNT >>$RESULT_DIR/$seq.full || _fail "unmount failed"
+ _scratch_mount >>$RESULT_DIR/$seq.full || _fail "mount failed"
+ cd $_saveddir
+}
+
+#
+# Run fsstress to create a mixture of
+# files,dirs,links,symlinks
+#
+# Pinched from test 013.
+#
+_create_dumpdir_stress()
+{
+ echo "Creating directory system to dump using fsstress."
+
+ _wipe_fs
+
+ _param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
+ _count=240
+ rm -rf $dump_dir
+ if ! mkdir $dump_dir; then
+ echo " failed to mkdir $dump_dir"
+ status=1
+ exit
+ fi
+ echo ""
+ echo "-----------------------------------------------"
+ echo "fsstress : $_param"
+ echo "-----------------------------------------------"
+ 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 $RESULT_DIR/$seq.full"
+
+ echo "--------------------------------------" >>$RESULT_DIR/$seq.full
+ echo "output from fsstress:" >>$RESULT_DIR/$seq.full
+ echo "--------------------------------------" >>$RESULT_DIR/$seq.full
+ cat $tmp.out >>$RESULT_DIR/$seq.full
+ status=1
+ fi
+
+ _stable_fs
+}
+
+_mk_fillconfig1()
+{
+ cat <<End-of-File >$tmp.config
+# pathname size in bytes owner group
+#
+small 10 $nobody $nobody
+big 102400 daemon sys
+sub/small 10 bin bin
+sub/big 102400 $nobody sys
+#
+sub/a 1 $nobody $nobody
+sub/b 2 $nobody $nobody
+sub/c 4 $nobody $nobody
+sub/d 8 $nobody $nobody
+sub/e 16 $nobody $nobody
+sub/f 32 $nobody $nobody
+sub/g 64 $nobody $nobody
+sub/h 128 $nobody $nobody
+sub/i 256 $nobody $nobody
+sub/j 512 $nobody $nobody
+sub/k 1024 $nobody $nobody
+sub/l 2048 $nobody $nobody
+sub/m 4096 $nobody $nobody
+sub/n 8192 $nobody $nobody
+#
+sub/a00 100 $nobody $nobody
+sub/b00 200 $nobody $nobody
+sub/c00 400 $nobody $nobody
+sub/d00 800 $nobody $nobody
+sub/e00 1600 $nobody $nobody
+sub/f00 3200 $nobody $nobody
+sub/g00 6400 $nobody $nobody
+sub/h00 12800 $nobody $nobody
+sub/i00 25600 $nobody $nobody
+sub/j00 51200 $nobody $nobody
+sub/k00 102400 $nobody $nobody
+sub/l00 204800 $nobody $nobody
+sub/m00 409600 $nobody $nobody
+sub/n00 819200 $nobody $nobody
+#
+sub/a000 1000 $nobody $nobody
+sub/e000 16000 $nobody $nobody
+sub/h000 128000 $nobody $nobody
+sub/k000 1024000 $nobody $nobody
+End-of-File
+}
+
+_mk_fillconfig2()
+{
+ cat <<End-of-File >$tmp.config
+# pathname size in bytes
+#
+smalll 10 $nobody $nobody
+biggg 102400 $nobody $nobody
+sub/smalll 10 $nobody $nobody
+sub/biggg 102400 $nobody $nobody
+End-of-File
+}
+
+_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_suid 10 $nobody $nobody 04777
+file_guid 10 $nobody $nobody 02777
+file_sticky 10 $nobody $nobody 01777
+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_sticky d $nobody $nobody 01777
+dir_mix1 d $nobody $nobody 761
+dir_mix2 d $nobody $nobody 642
+End-of-File
+}
+
+_mk_fillconfig_ea()
+{
+ cat <<End-of-File >$tmp.config
+# pathname size user group perm name value namespace
+#
+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
+dir d $nobody $nobody 777 attr5 dir_text user
+#
+# Add more files so that there are more than the number
+# of streams.
+# There are bugs in dump/restore for # non-dir files < # streams
+# It can be tested in another configuration.
+# It is a pathalogical case.
+#
+sub/a 1 $nobody $nobody
+sub/b 2 $nobody $nobody
+sub/c 4 $nobody $nobody
+sub/d 8 $nobody $nobody
+sub/e 16 $nobody $nobody
+sub/f 32 $nobody $nobody
+sub/g 64 $nobody $nobody
+sub/h 128 $nobody $nobody
+sub/i 256 $nobody $nobody
+sub/j 512 $nobody $nobody
+sub/k 1024 $nobody $nobody
+sub/l 2048 $nobody $nobody
+sub/m 4096 $nobody $nobody
+sub/n 8192 $nobody $nobody
+End-of-File
+}
+
+#
+# extended file attribute flags
+#
+_mk_fillconfig_xattr()
+{
+ cat <<End-of-File >$tmp.config
+# pathname size user group perm name
+#
+xflag_realtime 10 $nobody $nobody 777 XFS_XFLAG_REALTIME
+xflag_prealloc 10 $nobody $nobody 777 XFS_XFLAG_PREALLOC
+xflag_immutable 10 $nobody $nobody 777 XFS_XFLAG_IMMUTABLE
+xflag_append 10 $nobody $nobody 777 XFS_XFLAG_APPEND
+xflag_sync 10 $nobody $nobody 777 XFS_XFLAG_SYNC
+xflag_noatime 10 $nobody $nobody 777 XFS_XFLAG_NOATIME
+xflag_nodump 10 $nobody $nobody 777 XFS_XFLAG_NODUMP
+xflag_hasattr 10 $nobody $nobody 777 XFS_XFLAG_HASATTR
+End-of-File
+}
+
+#
+# Create a bunch of directories/files of different sizes
+# filled with data.
+#
+# Pinched from test 001.
+#
+_do_create_dumpdir_fill()
+{
+ echo "Creating directory system to dump using src/fill."
+
+ mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
+ cd $dump_dir
+
+ $verbose && echo -n "Setup "
+ sed -e '/^#/d' $tmp.config \
+ | while read file nbytes owner group perms ea_name ea_value namespace
+ do
+ if [ $nbytes = "d" ]; then
+ # create a directory
+ dir=$file
+ if [ ! -d $dir ]
+ then
+ if mkdir $dir
+ then
+ :
+ else
+ $verbose && echo
+ echo "Error: cannot mkdir \"$dir\""
+ exit 1
+ fi
+ fi
+ else
+ # create a directory/file
+ dir=`dirname $file`
+ if [ "$dir" != "." ]
+ then
+ if [ ! -d $dir ]
+ then
+ if mkdir $dir
+ then
+ :
+ else
+ $verbose && echo
+ echo "Error: cannot mkdir \"$dir\""
+ exit 1
+ fi
+ fi
+ fi
+ rm -f $file
+ if $here/src/fill $file $file $nbytes
+ then
+ :
+ else
+ $verbose && echo
+ echo "Error: cannot create \"$file\""
+ exit 1
+ fi
+ fi
+ if [ -n "$owner" -a -n "$group" ]; then
+ chown $owner.$group $file
+ fi
+ if [ -n "$perms" ]; then
+ chmod $perms $file
+ fi
+
+ # extended attributes (EA)
+ if [ -n "$ea_name" -a -n "$ea_value" ]; then
+ if [ "X$namespace" = "Xroot" ]; then
+ attr -R -s $ea_name -V $ea_value $file
+ else
+ attr -s $ea_name -V $ea_value $file
+ fi
+ # extended file attribute flags - no value - NOT EAs
+ elif [ -n "$ea_name" -a -z "$ea_value" ]; then
+ # set the flag
+ # TODO XXX
+ # use xfs_io to send the ioctl
+ :
+ fi
+ $verbose && echo -n "."
+ done
+ $verbose && echo
+
+ 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
+ mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
+ _largesize=4294967297
+ _largefile=$dump_dir/largefile
+ echo "dd a largefile at offset $_largesize"
+ POSIXLY_CORRECT=yes \
+ dd if=/dev/zero of=$_largefile bs=1 seek=$_largesize count=10 2>&1
+ _stable_fs
+}
+
+_create_dumpdir_fill()
+{
+ _wipe_fs
+ _mk_fillconfig1
+ _do_create_dumpdir_fill
+ _stable_fs
+}
+
+_create_dumpdir_fill2()
+{
+ _wipe_fs
+ _mk_fillconfig2
+ _do_create_dumpdir_fill
+ _stable_fs
+}
+
+_create_dumpdir_fill_perm()
+{
+ _wipe_fs
+ _mk_fillconfig_perm
+ _do_create_dumpdir_fill
+ _stable_fs
+}
+
+_create_dumpdir_fill_ea()
+{
+ _wipe_fs
+ _mk_fillconfig_ea
+ _do_create_dumpdir_fill
+ _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
+# So we can see if just these get dumped on an incremental
+#
+_append_dumpdir_fill()
+{
+ cd $dump_dir
+ cat <<End-of-File >$tmp.config
+# pathname
+#
+small
+sub/big
+#
+sub/a
+sub/c
+sub/e
+End-of-File
+ sed -e '/^#/d' $tmp.config \
+ | while read file
+ do
+ echo 'Extra text' >>$file
+ done
+
+ cd $here
+ _stable_fs
+}
+
+_do_create_dump_symlinks()
+{
+ echo "Creating directory system of symlinks to dump."
+
+ mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
+ cd $dump_dir
+
+ $verbose && echo -n "Setup "
+ sed -e '/^#/d' $tmp.config \
+ | while read file nbytes owner group owner2 group2 perms perms2
+ do
+ dir=`dirname $file`
+ if [ "$dir" != "." ]
+ then
+ if [ ! -d $dir ]
+ then
+ if mkdir $dir
+ then
+ :
+ else
+ $verbose && echo
+ echo "Error: cannot mkdir \"$dir\""
+ exit 1
+ fi
+ fi
+ fi
+ rm -f $file
+ touch $file
+
+ # Do chmod on symlink using umask.
+ # This won't do the right thing as it subtracts permissions.
+ # However, I don't care, as long as I get some different perms
+ # for testing.
+ if [ -n "$perms2" ]; then
+ omask=`umask`
+ umask $perms2
+ fi
+ ln -s $file $file-link
+ if [ -n "$perms2" ]; then
+ umask $omask
+ fi
+
+ if [ -n "$owner" -a -n "$group" ]; then
+ chown $owner.$group $file
+ fi
+ if [ -n "$owner" -a -n "$group" ]; then
+ chown -h $owner.$group $file-link
+ fi
+ if [ -n "$perms" ]; then
+ chmod $perms $file
+ fi
+ $verbose && echo -n "."
+ done
+ $verbose && echo
+
+ cd $here
+}
+
+_mk_symlink_config()
+{
+ cat <<End-of-File >$tmp.config
+# path size owner1 group1 owner2 group2 perm1 perm2
+#
+a 0 $nobody $nobody daemon sys 124 421
+b 0 daemon sys bin bin 347 743
+sub/a 0 bin bin $nobody sys 777 777
+sub/b 0 $nobody sys $nobody $nobody 367 763
+End-of-File
+}
+
+_create_dumpdir_symlinks()
+{
+ _wipe_fs
+ _mk_symlink_config
+ _do_create_dump_symlinks
+ _stable_fs
+}
+
+#
+# create hardlinks of form $_fname, $_fname_h1 $_fname_h2 ...
+#
+_create_hardlinks()
+{
+ _fname=$1
+ _numlinks=$2
+
+ touch $_fname
+ _j=1
+ while [ $_j -le $_numlinks ]; do
+ _suffix=_h$_j
+ _hardlink=$_fname$_suffix
+ echo "creating hardlink $_hardlink to $_fname"
+ ln $_fname $_hardlink
+ let _j=$_j+1
+ done
+}
+
+#
+# create a set of hardlinks
+# create hardlinks of form file1, file1_h1 file1_h2 ...
+# create hardlinks of form file2, file2_h1 file2_h2 ...
+# create hardlinks of form file3, file3_h1 file3_h2 ...
+#
+_create_hardset()
+{
+ _numsets=$1
+ _i=1
+ while [ $_i -le $_numsets ]; do
+ _create_hardlinks file$_i 5
+ let _i=$_i+1
+ done
+}
+
+
+_modify_level()
+{
+ _level=$1
+ echo "mod level $_level" >$dump_dir/file$_level
+}
+
+_create_dumpdir_hardlinks()
+{
+ _numsets=$1
+ _wipe_fs
+ echo "Creating directory system of hardlinks to incrementally dump."
+
+ mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
+ cd $dump_dir
+
+ _create_hardset $_numsets
+
+ cd $here
+ _stable_fs
+}
+
+#
+# Filter for ls
+# Filter out times and dates on symlinks and char devices.
+# Filter out size on directories because this can differ
+# when transitioning to long inode numbers (ie. 64 bits).
+#
+_ls_filter()
+{
+ $AWK_PROG '
+ /^l/ { date = $8; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
+ /^c/ { date = $9; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
+ /^d/ { size = $5; sub(size,"SIZE"); print}
+ {print}' \
+ | sed -e 's/total [0-9][0-9]*/total TOTAL/'
+}
+
+#
+# Filtering of Irix character hwgraph device names
+# e.g.
+# chardev: /hw/node/xtalk/15/pci/0/scsi_ctlr/0/target/1/lun/0/disk/partition/4/char
+# blkdev: /dev/dsk/dks0d1s4
+#
+_filter_devchar()
+{
+ $AWK_PROG '
+ /\/hw\/node/ {
+ sub(/\/hw.*scsi_ctlr\//,"/dev/dsk/dks") # blah blah /dev/dsk/dks0/target/1/....
+ sub(/\/target\//,"d") # blah blah /dev/dsk/dks0d1/lun/0/disk.....
+ sub(/\/lun.*partition\//,"s") # blah blah /dev/dsk/dks0d1s4/char
+ sub(/\/char/,"") # blah blah /dev/dsk/dks0d1s4
+ }
+ { print }
+ '
+}
+
+
+#
+# Filter out the non-deterministic dump msgs from
+# xfsdump and xfsrestore
+#
+_dump_filter_main()
+{
+ _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#$dumptape#TAPE_DEV#" \
+ -e "s#$SCRATCH_MNT#SCRATCH_MNT#" \
+ -e "s#$dump_file#DUMP_FILE#" \
+ -e 's#/var/lib/xfsdump#/var/xfsdump#' \
+ -e 's/session id:[ ]*[0-9a-f-]*/session id: ID/' \
+ -e '/filesystem id:[ ]*[0-9a-f-]*/d' \
+ -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/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 's/\(media file size[ ]*\)[0-9][0-9]*/\1NUM/' \
+ -e 's/\(mfile size:[ ]*\)[0-9][0-9]*/\1NUM/' \
+ -e '/drive[ ]*[0-9][0-9]*:/d' \
+ -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-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\]/' \
+ -e '/skip attribute set/d' \
+ | perl -ne '
+ # filter out all the output between the lines "Dump Summary:"
+ # and "Dump Status:"
+ if ($_ =~ /(?:Dump|Restore) Summary/) {
+ $skip = 1;
+ } elsif ($_ =~ /(?:Dump|Restore) Status/) {
+ $skip = 0;
+ }
+ print if (! $skip);' \
+ | perl -ne '
+ # correct the file count if large scratch devices are being used
+ $skip = 0;
+ if ($_ =~ /(\S+) directories and (\S+) entries/) {
+ $foo = $2;
+ if ($ENV{'LARGE_SCRATCH_DEV'} && $foo > 0) {
+ $foo -= 1;
+ }
+ printf("xfsrestore: %u directories and %u entries processed\n",
+ $1, $foo);
+ $skip = 1;
+ }
+ print if (! $skip);'
+}
+
+_dump_filter()
+{
+ if $do_quota_check
+ then
+ _dump_filter_main | _check_quota_dumprestore | _check_quota_entries
+ else
+ _dump_filter_main
+ fi
+}
+
+_invutil_filter()
+{
+ _dump_filter_main \
+ | sed \
+ -e 's/UUID[ ]*:[ ][0-9a-f-]*/UUID : ID/' \
+ -e 's/TIME OF DUMP[ ]*:.*/TIME OF DUMP : TIME/' \
+ -e 's/HOSTNAME:SCRATCH_MNT.*/HOSTNAME:SCRATCH_MNT/' \
+ -e 's#inventory/[0-9a-f-]*#inventory/UUID#' \
+
+}
+
+
+_dir_filter()
+{
+ sed \
+ -e "s#$dump_file#DUMP_FILE#g" \
+ -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
+ -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
+ -e "s#$dumptape#TAPE_DEV#" \
+ -e "s#$dump_dir#DUMP_DIR#g" \
+ -e "s#$restore_dir#RESTORE_DIR#g" \
+ -e "s#$SCRATCH_MNT#SCRATCH_MNT#g" \
+ -e "s#$dump_sdir#DUMP_SUBDIR#g" \
+ -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
+ -e "s#$$#PID#g" \
+ -e "/Only in SCRATCH_MNT: .use_space/d" \
+
+}
+
+#
+# Parse xfsdump arguments.
+# Note: requires a space between option letter and argument
+#
+_parse_dump_args()
+{
+ OPTIND=0
+ dump_args=""
+ while [ $# -gt 0 ]
+ do
+ case $1
+ in
+ -f)
+ [ -z "$2" ] && _fail "missing argument for -f"
+ dumptape=$2
+ dump_file=$2
+ shift
+ ;;
+ -L)
+ [ -z "$2" ] && _fail "missing argument for -L"
+ session_label=$2
+ shift
+ ;;
+ --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
+ ;;
+ -L)
+ [ -z "$2" ] && _fail "missing argument for -L"
+ session_label=$2
+ shift
+ ;;
+ --multi)
+ [ -z "$2" ] && _fail "missing argument for --multi"
+ multi=$2
+ shift
+ ;;
+ --check-quota)
+ do_quota_check=true
+ ;;
+ --no-check-quota)
+ do_quota_check=false
+ ;;
+ -K|-R)
+ restore_args="$restore_args $1"
+ ;;
+ *)
+ _fail "invalid argument to common.dump function: $1"
+ ;;
+ esac
+ shift
+ done
+}
+
+
+#
+# Dump a subdir
+#
+_do_dump_sub()
+{
+ _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_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
+}
+
+#
+# Do dump to tape
+#
+_do_dump()
+{
+ _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_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
+}
+
+
+#
+# Do full dump with -m
+#
+_do_dump_min()
+{
+ _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_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
+}
+
+
+#
+# Do full dump to file
+#
+_do_dump_file()
+{
+ _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_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
+}
+
+#
+# Do full dump to multiple files
+#
+_do_dump_multi_file()
+{
+ _parse_dump_args $*
+
+ multi_args=""
+
+ i=0
+ while [ $i -lt $multi ]
+ do
+ multi_args="$multi_args -f $dump_file.$i -M $media_label.$i"
+ 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_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
+}
+
+
+_prepare_restore_dir()
+{
+ rm -rf $restore_dir
+ mkdir $restore_dir || _fail "failed to mkdir $restore_dir"
+}
+
+
+#
+# Get tape ready and restore dir
+#
+_prepare_restore()
+{
+ _prepare_restore_dir
+
+ echo "Rewinding tape"
+ _rewind
+}
+
+#
+# Restore the tape into $restore_dir
+#
+_do_restore()
+{
+ _parse_restore_args $*
+ _prepare_restore
+
+ echo "Restoring from tape..."
+ opts="$_restore_debug$restore_args -f $dumptape -L $session_label $restore_dir"
+ echo "xfsrestore $opts" | _dir_filter
+ $XFSRESTORE_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
+}
+
+#
+# Restore the tape into $restore_dir using -m
+#
+_do_restore_min()
+{
+ _parse_restore_args $*
+ _prepare_restore
+
+ echo "Restoring from tape..."
+ onemeg=1048576
+ opts="$_restore_debug$restore_args -m -b $onemeg -f $dumptape -L $session_label $restore_dir"
+ echo "xfsrestore $opts" | _dir_filter
+ $XFSRESTORE_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
+}
+
+#
+# Restore the tape from a dump file
+#
+_do_restore_file()
+{
+ _parse_restore_args $*
+ _prepare_restore_dir
+
+ echo "Restoring from file..."
+ opts="$_restore_debug$restore_args -f $dump_file -L $session_label $restore_dir"
+ echo "xfsrestore $opts" | _dir_filter
+ $XFSRESTORE_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
+}
+
+#
+# Cumulative restore from a file
+# Must call _prepare_restore_dir before the first
+# (and only the first) call to this function.
+#
+_do_restore_file_cum()
+{
+ _parse_restore_args $*
+
+ echo "Restoring cumumlative from file..."
+ opts="$_restore_debug$restore_args -f $dump_file -r $restore_dir"
+ echo "xfsrestore $opts" | _dir_filter
+ $XFSRESTORE_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
+}
+
+_do_restore_toc()
+{
+ _parse_restore_args $*
+
+ 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
+ $XFSRESTORE_PROG $opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter_main |\
+ _check_quota_file |\
+ _check_quota_entries |\
+ $AWK_PROG 'NF != 1 { print; next }
+ {files = sprintf("%s\n%s", files, $1)}
+ END { print files | "sort" } '
+ # the above awk code is to alpha sort only the output
+ # of files (and not the verbose restore msgs)
+ cd $here # put back
+}
+
+#
+# Restore the tape from multiple dump files
+#
+_do_restore_multi_file()
+{
+ _parse_restore_args $*
+ _prepare_restore_dir
+
+ multi_args=""
+
+ i=0
+ while [ $i -lt $multi ]
+ do
+ multi_args="$multi_args -f $dump_file.$i"
+ let i=$i+1
+ done
+
+ echo "Restoring from file..."
+ opts="$_restore_debug$restore_args $multi_args -L $session_label $restore_dir"
+ echo "xfsrestore $opts" | _dir_filter
+ $XFSRESTORE_PROG $opts 2>&1 | tee -a $RESULT_DIR/$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_dump_args $1
+ _parse_restore_args $2
+ _prepare_restore_dir
+ echo "xfsdump|xfsrestore ..."
+ 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_PROG $dump_opts 2>$tmp.dump.mlog | $XFSRESTORE_PROG $restore_opts 2>&1 | tee -a $RESULT_DIR/$seq.full | _dump_filter
+ _dump_filter <$tmp.dump.mlog
+}
+
+#
+# Compare dumped subdirectory with restored dir
+# using ls -nR.
+# Thus no contents are compared but permissions, sizes,
+# owners, etc... are.
+#
+_ls_compare_sub()
+{
+ #
+ # verify we got back what we dumped
+ #
+ echo "Comparing listing of dump directory with restore directory"
+ ls -nR $dump_dir | tee -a $RESULT_DIR/$seq.full | _ls_filter >$tmp.dump_dir
+ ls -nR $restore_dir/$dump_sdir | tee -a $RESULT_DIR/$seq.full | _ls_filter \
+ | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
+
+ diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
+}
+
+#
+# filter out the date fields
+#
+_ls_nodate_filter()
+{
+ $AWK_PROG 'NF == 9 { print $1, $2, $3, $4, $9 }'
+}
+
+#
+# _ls_compare_sub but don't compare dates
+_ls_nodate_compare_sub()
+{
+ #
+ # verify we got back what we dumped
+ #
+ echo "Comparing listing of dump directory with restore directory"
+ ls -nR $dump_dir | tee -a $RESULT_DIR/$seq.full | _ls_filter | _ls_nodate_filter >$tmp.dump_dir
+ ls -nR $restore_dir/$dump_sdir | tee -a $RESULT_DIR/$seq.full | _ls_filter \
+ | _ls_nodate_filter | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
+
+ diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
+}
+
+#
+# Compare using recursive diff the files of the dumped
+# subdirectory.
+# This one will compare the contents.
+#
+_diff_compare_sub()
+{
+ echo "Comparing dump directory with restore directory"
+ diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
+}
+
+_get_eas_on_path()
+{
+ _path=$1
+
+# Tim - this is the IRIX way...
+ # find $_path -exec attr -l {} \; |\
+ # awk '{print $9, $2}' |\
+ # sed 's/["]//g' |\
+ # sort |\
+# and this is now the Linux way...
+ echo "User names"
+ getfattr --absolute-names -Rh -m user $_path |\
+ perl -wn -e '
+ if (m/^# file: (\S+)/) { $file = $1 }
+ elsif (m/^user\.(\w+)/) { print $file, " ",$1,"\n" }' |\
+ sort |\
+ while read file ea_name; do
+ attr -g $ea_name $file
+ done
+
+ if [ "$USE_ATTR_SECURE" = yes ]; then
+ echo "Security names"
+ getfattr --absolute-names -Rh -m security $_path |\
+ perl -wn -e '
+ if (m/^# file: (\S+)/) { $file = $1 }
+ elsif (m/^security\.(\w+)/) { print $file, " ",$1,"\n" }' |\
+ sort |\
+ while read file ea_name; do
+ attr -g $ea_name $file
+ done
+ fi
+
+ echo "Root names"
+ getfattr --absolute-names -Rh -m trusted $_path |\
+ perl -wn -e '
+ if (m/^# file: (\S+)/) { $file = $1 }
+ elsif (m/^trusted\.(\w+)/) { print $file, " ",$1,"\n" }' |\
+ sort |\
+ while read file ea_name; do
+ attr -R -g $ea_name $file
+ done
+}
+
+#
+# Compare the extended attributes of the files/dirs
+# b/w the dumped and restore dirs.
+#
+#
+# Attribute "attr5" had a 8 byte value for /spare1/dump.5460/dir:
+# Attribute "attr5" had a 8 byte value for /spare1/restore.5460/dump.5460/dir:
+#
+_diff_compare_eas()
+{
+ echo "Comparing dump directory with restore directory"
+ echo "Looking at the extended attributes (EAs)"
+ echo "EAs on dump"
+ _get_eas_on_path $dump_dir | tee $RESULT_DIR/$seq.ea1 | _dir_filter
+ echo "EAs on restore"
+ _get_eas_on_path $restore_dir/$dump_sdir \
+ | sed -e "s#$restore_sdir\/##" \
+ | tee $RESULT_DIR/$seq.ea2 \
+ | _dir_filter
+ diff -s $RESULT_DIR/$seq.ea1 $RESULT_DIR/$seq.ea2
+}
+
+
+#
+# Compare using recursive diff the files of the dumped
+# filesystem
+#
+_diff_compare()
+{
+ echo "Comparing dump directory with restore directory"
+ diff -rs $SCRATCH_MNT $restore_dir | _dir_filter | _check_quota_diff
+}
+
+#
+# Check out the dump inventory
+#
+_dump_inventory()
+{
+ $XFSDUMP_PROG $_dump_debug -I | tee -a $RESULT_DIR/$seq.full | _dump_filter_main
+}
+
+#
+# Do the xfsinvutil cmd with debug and filters
+# Need to set variable: "$middate" to the invutil date
+#
+_do_invutil()
+{
+ host=`hostname`
+ echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$RESULT_DIR/$seq.full
+ $XFSINVUTIL_PROG $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
+ | tee -a $RESULT_DIR/$seq.full | _invutil_filter
+}
+
+#
+# ensure we can find the user quota msg if user quotas are on
+# ensure we can find the group quota msg if group quotas are on
+#
+_check_quota()
+{
+ usermsg=$1
+ groupmsg=$2
+ projectmsg=$3
+ uquota=0
+ gquota=0
+ pquota=0
+ $here/src/feature -U $SCRATCH_DEV && uquota=1
+ $here/src/feature -G $SCRATCH_DEV && gquota=1
+ $here/src/feature -P $SCRATCH_DEV && pquota=1
+
+ $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota \
+ -v full=$RESULT_DIR/$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) {
+ print "Found extra:", $0
+ }
+ next
+ }
+ $0 ~ usermsg {
+ print "Found user quota:", $0 >>full
+ found_uquota = 1
+ if (!uquota) {
+ print "Found extra:", $0
+ }
+ next
+ }
+ { print }
+ END {
+ if (uquota && !found_uquota) {
+ print "Missing user quota msg:", usermsg
+ }
+ 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)
+#
+_check_quota_entries()
+{
+ uquota=0
+ gquota=0
+ pquota=0
+ $here/src/feature -U $SCRATCH_DEV && uquota=1
+ $here/src/feature -G $SCRATCH_DEV && gquota=1
+ $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' \
+ '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
+}
+
+#
+# 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_proj'
+}
+
+#
+# Look for the quota file in the output
+# Ensure that it is there if it should be
+# Filter it out so that the output is always the same
+# even with no quotas
+#
+_check_quota_file()
+{
+ _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group' 'xfsdump_quotas_proj'
+}
+
+
+# make sure this script returns success
+/bin/true
--- /dev/null
+##/bin/bash
+#
+# Copyright (c) 2007 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
+#
+#
+# Core of filestreams tests.
+#
+
+_check_filestreams_support()
+{
+ local irix_timeout_sysvar="xfs_mfstream_timeout"
+ local linux_timeout_procvar="/proc/sys/fs/xfs/filestream_centisecs"
+ local streams_avail=""
+ if [ "$HOSTOS" == "IRIX" ]; then
+ # check for the filestreams timeout systune variable in irix
+ streams_avail=`systune $irix_timeout_sysvar 2>&1 |
+ perl -ne 'if (/'$irix_timeout_sysvar'\s+=\s+\d+/) {print "true"}'`
+ else
+ # check for the filestreams timeout proc entry in linux
+ [ -f $linux_timeout_procvar ] && streams_avail="true"
+ fi
+
+ if [ "$streams_avail" == "true" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+_set_stream_timeout_centisecs()
+{
+ local new_timeout_csecs=$1
+ local irix_timeout_sysvar="xfs_mfstream_timeout"
+ local linux_timeout_procvar="/proc/sys/fs/xfs/filestream_centisecs"
+ if [ "$HOSTOS" == "IRIX" ]; then
+ echo y | systune -r $irix_timeout_sysvar $new_timeout_csecs >/dev/null
+ else
+ echo $new_timeout_csecs > $linux_timeout_procvar
+ fi
+}
+
+_do_stream()
+{
+ local directory_name=$1
+ local files=$2
+ local file_size=$3
+ local bsize=$4
+ local iflag=$5
+ local dio=$6
+ local blocks_in_file=`expr $file_size / $bsize`
+
+ mkdir $directory_name
+ if [ "$iflag" = "1" -a "$HOSTOS" != "IRIX" ]; then
+ $XFS_IO_PROG -x -c "chattr +S" $directory_name \
+ || _fail "chattr of filestream flag"
+ fi
+ cd $directory_name
+
+ local dd_cmd=""
+ if [ "$HOSTOS" == "IRIX" ]; then
+ # for irix use lmdd
+ dd_cmd="lmdd"
+ [ "$dio" = "1" ] && dd_cmd="$dd_cmd odirect=1"
+ else
+ # for linux use dd
+ dd_cmd="dd"
+ [ "$dio" = "1" ] && dd_cmd="$dd_cmd oflag=direct"
+ fi
+ dd_cmd="$dd_cmd if=/dev/zero bs=${bsize} count=${blocks_in_file}"
+
+ local i=1
+ while [ $i -le $files ]; do
+ $dd_cmd of=frame-${i} 2>&1 | grep -v records | grep -v secs
+ i=`expr $i + 1`
+ done
+}
+
+_filter_agno()
+{
+ # the ag number is in column 4 of xfs_bmap output
+ perl -ne '
+ $ag = (split /\s+/)[4] ;
+ if ($ag =~ /\d+/) {print "$ag "} ;
+ '
+}
+
+_get_stream_ags()
+{
+ local directory_name=$1
+ local stream_ags=`xfs_bmap -vp ${directory_name}/* | _filter_agno`
+ echo $stream_ags
+}
+
+_check_for_dupes()
+{
+ # check for duplicate numbers between two space seperated vars
+ local num_str_one=$1
+ local num_str_two=$2
+
+ local this_num_one
+ local this_num_two
+ for this_num_one in $num_str_one; do
+ for this_num_two in $num_str_two; do
+ if [ "$this_num_one" == "$this_num_two" ]; then
+ echo "duplicate AG $this_num_one found" \
+ >> $RESULT_DIR/$seq.full
+ return 1
+ fi
+ done
+ done
+ return 0
+}
+
+_test_streams() {
+
+ echo "# testing $* ...."
+ local agcount="$1"
+ local agsize="$2" # in MB
+ local stream_count="$3"
+ local stream_files="$4"
+ local stream_file_size=`expr $5 \* 1024 \* 1024`
+ local use_iflag="$6"
+ local use_directio="$7"
+ local expected_result="$8" # "fail" if failure is expected
+
+ local size=`expr $agsize \* 1024 \* 1024 \* $agcount`
+ _scratch_mkfs_xfs -dsize=$size,agcount=$agcount >/dev/null 2>&1 \
+ || _fail "mkfs failed"
+
+ if [ "$use_iflag" = "0" -o "$HOSTOS" == "IRIX" ]; then
+ # mount using filestreams mount option
+ _scratch_mount "-o filestreams" \
+ || _fail "filestreams mount failed"
+ else
+ # test will set inode flag
+ _scratch_mount || _fail "mount failed"
+ fi
+
+ cd $SCRATCH_MNT
+
+ # start $stream_count streams
+ # each stream writes ($stream_files x $stream_file_size)M
+ echo "# streaming"
+ local stream_pids=""
+ local stream_index=1
+ while [ $stream_index -le $stream_count ]; do
+ _do_stream stream${stream_index}-dir $stream_files \
+ $stream_file_size 1048576 $use_iflag $use_directio &
+ stream_pids="$stream_pids $!"
+ stream_index=`expr $stream_index + 1`
+ done
+
+ # wait for streams to finish
+ # XXX wait here not needed? -dgc
+ wait $stream_pids
+
+ # sync the buffered streams out in parallel
+ # _get_stream_ags does a xfs_bmap which syncs delayed allocations
+ echo "# sync AGs..."
+ local ag_sync_pids=""
+ stream_index=1
+ while [ $stream_index -le $stream_count ]; do
+ _get_stream_ags stream${stream_index}-dir > /dev/null 2>&1 &
+ ag_sync_pids="$ag_sync_pids $!"
+ stream_index=`expr $stream_index + 1`
+ done
+
+ # wait for syncs to finish
+ wait $ag_sync_pids
+
+ # confirm streams are in seperate AGs
+ echo "# checking stream AGs..."
+ local this_stream_ags=""
+ local ags_seen=""
+ local num_streams_with_matching_ags=0
+ stream_index=1
+ while [ $stream_index -le $stream_count ]; do
+ this_stream_ags=`_get_stream_ags stream${stream_index}-dir`
+ echo "stream $stream_index AGs: $this_stream_ags" >> $RESULT_DIR/$seq.full
+ _check_for_dupes "$ags_seen" "$this_stream_ags"
+ if [ $? -ne 0 ]; then
+ # this stream is not in seperate AGs to previous streams
+ num_streams_with_matching_ags=`expr $num_streams_with_matching_ags + 1`
+ fi
+ ags_seen="$ags_seen $this_stream_ags"
+ stream_index=`expr $stream_index + 1`
+ done
+
+ _cleanup_streams_umount
+ if [ "$expected_result" != "fail" ]; then
+ if [ $num_streams_with_matching_ags -eq 0 ]; then
+ # all streams in seperate AGs, as expected
+ echo "+ passed, streams are in seperate AGs"
+ else
+ # streams with matching AGs, should be seperate
+ _fail "- failed, $num_streams_with_matching_ags streams with matching AGs"
+ fi
+ else
+ # expecting streams to have overlapped
+ if [ $num_streams_with_matching_ags -eq 0 ]; then
+ # all streams in seperate AGs, should have overlapped
+ _fail "- streams are in seperate AGs, expected _matching_"
+ else
+ # streams with matching AGs, as expected
+ echo "+ expected failure, matching AGs"
+ fi
+ fi
+ return 0
+}
+
+_cleanup_streams_umount()
+{
+ cd /
+ rm -rf ${SCRATCH_MNT}/stream*
+ umount $SCRATCH_DEV 2>/dev/null
+}
--- /dev/null
+##/bin/bash
+#
+# Copyright (c) 2000-2001 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
+#
+#
+# standard filters
+#
+
+# Checks that given_value is in range of correct_value +/- tolerance.
+# Tolerance can be an absolute value or a percentage of the correct value
+# (see examples with tolerances below).
+# Outputs suitable message to stdout if it's not in range.
+#
+# A verbose option, -v, may be used as the LAST argument
+#
+# e.g.
+# foo: 0.0298 = 0.03 +/- 5%
+# _within_tolerance "foo" 0.0298 0.03 5%
+#
+# foo: 0.0298 = 0.03 +/- 0.01
+# _within_tolerance "foo" 0.0298 0.03 0.01
+#
+# foo: 0.0298 = 0.03 -0.01 +0.002
+# _within_tolerance "foo" 0.0298 0.03 0.01 0.002
+#
+# foo: verbose output of 0.0298 = 0.03 +/- 5%
+# _within_tolerance "foo" 0.0298 0.03 5% -v
+_within_tolerance()
+{
+ _name=$1
+ _given_val=$2
+ _correct_val=$3
+ _mintol=$4
+ _maxtol=$_mintol
+ _verbose=0
+ _debug=false
+
+ # maxtol arg is optional
+ # verbose arg is optional
+ if [ $# -ge 5 ]
+ then
+ if [ "$5" = "-v" ]
+ then
+ _verbose=1
+ else
+ _maxtol=$5
+ fi
+ fi
+ if [ $# -ge 6 ]
+ then
+ [ "$6" = "-v" ] && _verbose=1
+ fi
+
+ # find min with or without %
+ _mintolerance=`echo $_mintol | sed -e 's/%//'`
+ if [ $_mintol = $_mintolerance ]
+ then
+ _min=`echo "scale=5; $_correct_val-$_mintolerance" | bc`
+ else
+ _min=`echo "scale=5; $_correct_val-$_mintolerance*0.01*$_correct_val" | bc`
+ fi
+
+ # find max with or without %
+ _maxtolerance=`echo $_maxtol | sed -e 's/%//'`
+ if [ $_maxtol = $_maxtolerance ]
+ then
+ _max=`echo "scale=5; $_correct_val+$_maxtolerance" | bc`
+ else
+ _max=`echo "scale=5; $_correct_val+$_maxtolerance*0.01*$_correct_val" | bc`
+ fi
+
+ $_debug && echo "min = $_min"
+ $_debug && echo "max = $_max"
+
+ cat <<EOF >$tmp.bc.1
+scale=5;
+if ($_min <= $_given_val) 1;
+if ($_min > $_given_val) 0;
+EOF
+
+ cat <<EOF >$tmp.bc.2
+scale=5;
+if ($_given_val <= $_max) 1;
+if ($_given_val > $_max) 0;
+EOF
+
+ _above_min=`bc <$tmp.bc.1`
+ _below_max=`bc <$tmp.bc.2`
+
+ rm -f $tmp.bc.[12]
+
+ _in_range=`expr $_above_min \& $_below_max`
+
+ # fix up min, max precision for output
+ # can vary for 5.3, 6.2
+
+ # remove any trailing zeroes from min, max if they have fractional parts
+ _min=`echo $_min | sed -e '/\./s/0*$//' -e 's/\.$//'`
+ _max=`echo $_max | sed -e '/\./s/0*$//' -e 's/\.$//'`
+
+ if [ $_in_range -eq 1 ]
+ then
+ [ $_verbose -eq 1 ] && echo $_name is in range
+ return 0
+ else
+ [ $_verbose -eq 1 ] && echo $_name has value of $_given_val
+ [ $_verbose -eq 1 ] && echo $_name is NOT in range $_min .. $_max
+ return 1
+ fi
+}
+
+# ctime(3) dates
+#
+_filter_date()
+{
+ sed \
+ -e 's/[A-Z][a-z][a-z] [A-z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/DATE/'
+}
+
+# prints filtered output on stdout, values (use eval) on stderr
+#
+_filter_mkfs()
+{
+ set -
+ perl -ne '
+ if (/^meta-data=([\w,|\/.-]+)\s+isize=(\d+)\s+agcount=(\d+), agsize=(\d+) blks/) {
+ print STDERR "ddev=$1\nisize=$2\nagcount=$3\nagsize=$4\n";
+ print STDOUT "meta-data=DDEV isize=XXX agcount=N, agsize=XXX blks\n";
+ }
+ if (/^\s+=\s+sectsz=(\d+)\s+attr=(\d+)/) {
+ print STDERR "sectsz=$1\nattr=$2\n";
+ }
+ if (/^data\s+=\s+bsize=(\d+)\s+blocks=(\d+), imaxpct=(\d+)/) {
+ print STDERR "dbsize=$1\ndblocks=$2\nimaxpct=$3\n";
+ print STDOUT "data = bsize=XXX blocks=XXX, imaxpct=PCT\n";
+ }
+ if (/^\s+=\s+sunit=(\d+)\s+swidth=(\d+) blks/) {
+ print STDERR "sunit=$1\nswidth=$2\nunwritten=1\n";
+ print STDOUT " = sunit=XXX swidth=XXX, unwritten=X\n";
+ }
+ if (/^naming\s+=version\s+(\d+)\s+bsize=(\d+)/) {
+ print STDERR "dirversion=$1\ndirbsize=$2\n";
+ print STDOUT "naming =VERN bsize=XXX\n";
+ }
+ if (/^log\s+=(internal log|[\w|\/.-]+)\s+bsize=(\d+)\s+blocks=(\d+),\s+version=(\d+)/ ||
+ /^log\s+=(internal log|[\w|\/.-]+)\s+bsize=(\d+)\s+blocks=(\d+)/) {
+ print STDERR "ldev=\"$1\"\nlbsize=$2\nlblocks=$3\nlversion=$4\n";
+ print STDOUT "log =LDEV bsize=XXX blocks=XXX\n";
+ }
+ if (/^\s+=\s+sectsz=(\d+)\s+sunit=(\d+) blks/) {
+ print STDERR "logsectsz=$1\nlogsunit=$2\n\n";
+ }
+ if (/^realtime\s+=([\w|\/.-]+)\s+extsz=(\d+)\s+blocks=(\d+), rtextents=(\d+)/) {
+ print STDERR "rtdev=$1\nrtextsz=$2\nrtblocks=$3\nrtextents=$4\n";
+ print STDOUT "realtime =RDEV extsz=XXX blocks=XXX, rtextents=XXX\n";
+ }'
+}
+
+
+# prints the bits we care about in growfs
+#
+_filter_growfs()
+{
+ perl -ne '
+ if (/^data\s+=\s+bsize=(\d+)\s+blocks=(\d+), imaxpct=(\d+)/) {
+ print "xfs_growfs --BlockSize=$1 --Blocks=$2\n";
+ }
+ elsif (/^data/) {
+ print;
+ }'
+}
+
+_filter_dd()
+{
+ $AWK_PROG '
+ /records in/ { next }
+ /records out/ { next }
+ /No space left on device/ { print " !!! disk full (expected)"
+ next }
+ { print " *** " $0 }
+ '
+}
+
+common_line_filter()
+{
+ perl -ne 'if (/.*:(.*)/) {
+ if ( "$last_line" ne "$1" ) { print "$_"; $first_match=1; }
+ elsif ( $first_match==1 ) { print "*\n"; $first_match=0; }
+ $last_line="$1";
+ }
+ else {
+ print $_; $last_line=$_;
+ }'
+}
+
+_filter_xfs_io()
+{
+ sed -e "s/[0-9/.]* [GMKiBbytes]*, [0-9]* ops\; [0-9/:. sec]* ([inf0-9/.]* [EPGMKiBbytes]*\/sec and [inf0-9/.]* ops\/sec)/XXX Bytes, X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/"
+}
+
+_filter_xfs_io_unique()
+{
+ common_line_filter | _filter_xfs_io
+}
+
+_filter_test_dir()
+{
+ sed -e "s,$TEST_DEV,TEST_DEV,g" -e "s,$TEST_DIR,TEST_DIR,g"
+}
+
+_filter_scratch()
+{
+ sed -e "s,$SCRATCH_DEV,SCRATCH_DEV,g" \
+ -e "s,$SCRATCH_MNT,SCRATCH_MNT,g" \
+ -e "/.use_space/d"
+}
+
+# Turn any device in the scratch pool into SCRATCH_DEV
+_filter_scratch_pool()
+{
+ FILTER_STRINGS=`echo $SCRATCH_DEV_POOL | sed -e 's/\s\+/\\\|/g'`
+ sed -e "s,$FILTER_STRINGS,SCRATCH_DEV,g"
+}
+
+_filter_spaces()
+{
+ sed -e 's/ [ ]*/ /g'
+}
+
+# Account for different "ln" failure messages
+_filter_ln()
+{
+ sed -e "s,\(creating symbolic link .*\) to .*: ,\1," \
+ -e "s,failed to create,creating,"
+}
+
+# If given an arg, filter *that* UUID string
+# Otherwise look for something that looks like a generic UUID
+_filter_uuid()
+{
+ if [ ! -z $1 ]; then
+ UUID=$1
+ sed -e "s/\(uuid:\) $UUID/\1 <EXACTUUID>/i"
+ else
+ sed -e "s/\(uuid:\) *[0-9a-f-][0-9a-f-]*/\1 <UUID>/i"
+ fi
+}
+
+# Filter out sizes like 6.14MB etc
+_filter_size()
+{
+ sed -e "s/[0-9\.]\+\s\?[b|k|m|g|t][b]\?/<SIZE>/ig"
+}
+
+# Convert string read from stdin like 128K to bytes and print it to stdout
+_filter_size_to_bytes()
+{
+ read size
+ suffix=${size:${#size}-1}
+ mul=1
+ case $suffix in
+ k|K) mul=1024 ;;
+ m|M) mul=$((1024*1024)) ;;
+ g|G) mul=$((1024*1024*1024)) ;;
+ t|T) mul=$((1024*1024*1024*1024)) ;;
+ esac
+ echo $((${size:0:${#size}-1}*$mul))
+}
+
+# make sure this script returns success
+/bin/true
--- /dev/null
+# Filters for btrfs command output
+
+. ./common.filter.btrfs
+
+# Some, but not all, commands emit "Btrfs <version>"
+_filter_btrfs_version()
+{
+ sed -e "s/^Btrfs.*//g"
+}
+
+_filter_devid()
+{
+ sed -e "s/\(devid\s\+\)[0-9]\+/\1 <DEVID>/g"
+}
+
+# If passed a number as first arg, filter that number of devices
+# If passed a UUID as second arg, filter that exact UUID
+_filter_btrfs_filesystem_show()
+{
+ if [ ! -z $1 ]; then
+ NUMDEVS=$1
+ NUM_SUBST="<EXACTNUM>"
+ else
+ NUMDEVS="[0-9]\+"
+ NUM_SUBST="<NUM>"
+ fi
+
+ UUID=""
+ if [ ! -z $2 ]; then
+ UUID=$2
+ fi
+
+ # the uniq collapses all device lines into 1
+ _filter_uuid $UUID | _filter_scratch | _filter_scratch_pool | \
+ _filter_size | _filter_btrfs_version | _filter_devid | \
+ sed -e "s/\(Total devices\) $NUMDEVS/\1 $NUM_SUBST/g" | \
+ uniq
+}
+
+# This eliminates all numbers, and shows only unique lines,
+# to accomodate a varying nr. of devices.
+# If given an argument, make sure we saw that many devices
+# in total.
+_filter_btrfs_device_stats()
+{
+ if [ ! -z $1 ]; then
+ NUMDEVS=$1
+ UNIQ_OPT="-c"
+ else
+ NUMDEVS="thiswillnotmatch"
+ UNIQ_OPT=""
+ fi
+
+ _filter_scratch | _filter_scratch_pool | \
+ sed -e "s/[0-9]\+$/<NUM>/g" | sort | uniq $UNIQ_OPT | \
+ sed -e "s/$NUMDEVS /<NUMDEVS> /g"
+}
+
+# make sure this script returns success
+/bin/true
--- /dev/null
+##/bin/bash
+#
+# 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
+#
+#
+# common routines for log testing
+# Created by dxm@sgi.com & tes@sgi.com
+#
+
+fulldir=$RESULT_DIR/$seq.fulldir
+rm -rf $fulldir
+
+_cleanup_logfiles()
+{
+ if [ $status -eq 0 ]; then
+ # don't keep these files around unless something went wrong
+ rm -rf $fulldir
+ fi
+}
+
+_full()
+{
+ echo "" >>$RESULT_DIR/$seq.full
+ echo "*** $* ***" >>$RESULT_DIR/$seq.full
+ echo "" >>$RESULT_DIR/$seq.full
+}
+
+_echofull()
+{
+ echo "" | tee -a $RESULT_DIR/$seq.full
+ echo "*** $* ***" | tee -a $RESULT_DIR/$seq.full
+ echo "" | tee -a $RESULT_DIR/$seq.full
+}
+
+# Handle the operations which get split over Log Record
+# boundaries.
+# Oper (379)..... flags: CONTINUE
+# ...
+# Oper (0)....... flags: WAS_CONT END
+#
+# or
+#
+# Oper (379)..... flags: none
+# ...
+# Oper (0)....... flags: none
+#
+_filter_opnum()
+{
+ $AWK_PROG '
+BEGIN {
+ debug = 0
+ }
+/^Oper/ && debug {
+ printf "line = %s\n", $0
+ }
+/^Oper/ {
+ was_cont = 0
+ }
+/^Oper/ && /flags: CONTINUE/ {
+ # this will be the first op of split region
+ $9 = "none" # overwrite CONTINUE flags
+ print
+ print "Not printing rest"
+ was_cont = 1
+ next
+ }
+/^Oper/ && /flags: WAS_CONT END/ {
+ # this will be the last op of split region
+ # skip over was-continued op
+ # we assume there can be only 1
+ was_cont = 1
+ next
+ }
+(was_cont == 1) {
+ # skip over any continued op stuff
+ next
+ }
+ {print}
+ '
+}
+
+#
+# Filter out things that can change
+# We have complexities which change when log is sync'ed at different
+# times.
+# Example1: DATA FORK EXTENTS
+# These will not show up if inode is sync'ed sooner
+# /DATA FORK EXTENTS/d;
+# /INODE:/s/flags:0x5/flags:0x1/g;
+# define XFS_ILOG_CORE 0x001 /* log standard inode fields */
+# define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */
+#
+#
+
+_filter_logprint()
+{
+ _fix_malloc |\
+ sed '
+ s/ver:[0-9]/ver:<VERS>/;
+ s/version [0-9] format [0-9]/version <VERS> format <FORMAT>/;
+ s/data device: 0x[0-9a-f][0-9a-f]*/data device: <DEVICE>/;
+ s/log device: 0x[0-9a-f][0-9a-f]*/log device: <DEVICE>/;
+ s/log file: \".*\"/log device: <DEVICE>/;
+ s/daddr: [0-9][0-9]*/daddr: <DADDR>/;
+ s/length: [0-9][0-9]*/length: <LENGTH>/;
+ s/length: [0-9][0-9]*/length: <LENGTH>/;
+ s/^cycle num overwrites: .*$/cycle num overwrites: <TIDS>/;
+ s/tid: [0-9a-f][0-9a-f]*/tid: <TID>/;
+ s/tid:0x[0-9a-f][0-9a-f]*/tid:<TID>/;
+ s/q:0x[0-9a-f][0-9a-f]*/q:<Q>/;
+ s/a:0x[0-9a-f][0-9a-f]*/a:<A>/g;
+ s/blkno:0x[0-9a-f][0-9a-f]*/blkno:<BLKNO>/g;
+ s/blkno: *[0-9][0-9]* (0x[0-9a-f]*)/blkno: <BLKNO> (<BLKNO>)/g;
+ s/blkno: *[0-9][0-9]*/blkno: <BLKNO>/g;
+ s/boff: [0-9][0-9]*/boff: <BOFF>/g;
+ s/len: *[0-9][0-9]*/len:<LEN>/g;
+ /BUF:/s/[ ]*flags:.*$//;
+ /zeroed blocks/s/[0-9][0-9]*/<COUNT>/g;
+ /cleared blocks/d;
+ /log tail/s/[0-9][0-9]*/<COUNT>/g;
+ s/atime:[0-9a-fx]* *mtime:[0-9a-fx]* *ctime:[0-9a-fx]*/atime:<TIME> mtime:<TIME> ctime:<TIME>/;
+ s/atime 0x[0-9a-f]* mtime 0x[0-9a-f]* ctime 0x[0-9a-f]*/atime <TIME> mtime <TIME> ctime <TIME>/;
+ s/block [0-9][0-9]*/block <BLOCK>/;
+ s/icount: *[0-9][0-9]* *ifree: *[0-9][0-9]* *fdblks: *[0-9][0-9]* *frext: *[0-9][0-9]*/icount:<COUNT> ifree:<FREE> fdblks:<BLOCKS> frext:<COUNT>/;
+ s/sunit: *[0-9][0-9]* *swidth: *[0-9][0-9]*/sunit:<SUNIT> swidth:<SWIDTH>/;
+ s/1st: *[0-9][0-9]* *last: *[0-9][0-9]* *cnt: *[0-9][0-9]* *freeblks: *[0-9][0-9]* *longest: *[0-9][0-9]*/1st:<NUM> last:<NUM> cnt:<COUNT> freeblks:<COUNT> longest:<NUM>/;
+ s/^uuid: *[0-9a-f-][0-9a-f-]* *format: *.*$/uuid: <UUID> format: <FORMAT>/;
+ /flushiter:/d;
+ /version:/,/h_size:/d;
+ /override tail/s/[0-9][0-9]*/<TAIL_BLK>/;
+ /^---*/d;
+ /^===*/d;
+ /^~~~*/d;
+ /extended-header/d;
+ /LOG REC AT LSN/d;
+ /DATA FORK EXTENTS/d;
+ s/BUF: cnt:[1-9][0-9]* total:[1-9][0-9]*.*/BUF: cnt:C total:T/;
+ s/INO: cnt:[1-9][0-9]* total:[1-9][0-9]*.*/INO: cnt:C total:T/;
+ s/#regs: *[1-9][0-9]*/#regs:R/;
+ /INODE:/s/flags:0x5/flags:0x1/g;
+ s/Oper ([0-9][0-9]*)/Oper (OPNUM)/;
+ /^[ ]*$/d;
+ s/ */ /g;
+ s/ $//;
+ s/newino: 0x[0-9a-f]*$/newino: <INO>/g
+ s/newino:0x[0-9a-f]*$/newino:<INO>/g
+ s/ino: 0x[0-9a-f]* flags:/ino: <INO> flags:/g
+ s/ino:0x[0-9a-f]* flags:/ino:<INO> flags:/g
+ s/onlink:[0-9][0-9]*/onlink:<ONLINK>/;
+ s/gen:-*[0-9][0-9]*/gen:<GEN>/;
+ s/gen 0x[0-9a-f][0-9a-f]*/gen <GEN>/;
+ '|\
+ awk '
+ # collapse BUF DATA group into 1 line
+ # for Oper data this can be over separate operations...ughh
+ /BUF DATA/ {
+ if (!buf_data) { # 1st one
+ if (oper) {
+ print oper
+ oper = 0
+ }
+ print
+ }
+ buf_data = 1
+ oper = 0 # wont need it now
+ next
+ }
+ /^Oper/ {
+ # store it as we dont know if 2nd BUF DATA is to follow
+ if (oper) {
+ print oper
+ }
+ oper = $0
+ next
+ }
+ /^TRANS/ && dummy_rec == 1 {
+ # start printing again - dummy transaction over
+ dummy_rec = 0
+ }
+ /DUMMY1/ {
+ # filter out dummy transactions
+ dummy_rec = 1
+ next
+ }
+ {
+ if (dummy_rec) {
+ next
+ }
+ buf_data = 0
+ if (oper) { # now we can print out oper
+ print oper
+ oper = 0
+ }
+ print
+ }
+ '
+}
+
+_check_log()
+{
+ _full "clean_log : xfs_logprint"
+ _scratch_xfs_logprint -t | tee -a $RESULT_DIR/$seq.full \
+ | head | grep -q "<CLEAN>" || _fail "DIRTY LOG"
+}
+
+_print_logstate()
+{
+ _scratch_xfs_logprint -t | tee -a $RESULT_DIR/$seq.full >$tmp.logprint
+ if grep -q "<DIRTY>" $tmp.logprint; then
+ echo "dirty log"
+ fi
+ if grep -q "<CLEAN>" $tmp.logprint; then
+ echo "clean log"
+ fi
+}
+
+_print_operation()
+{
+ mkdir $fulldir >/dev/null 2>&1
+ mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
+ mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
+ raw=$fulldir/op.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
+ filtered=$fulldir/op.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
+
+ echo "### xfs_logprint output ###" | tee $raw >$filtered
+ _scratch_xfs_logprint -c 2>&1 \
+ | tee -a $raw \
+ | _filter_logprint \
+ | _filter_opnum \
+ >>$filtered
+}
+
+# start at rec#2 "-s 2" so we skip over UMOUNT record which will always
+# be a 512b single header at mkfs time
+# and may not match with the FS mounted at a different LR size
+# => xlog_do_recovery_pass() can not handle the different hdr sizes
+# it assumes them all to be the same between the start..finish
+# NB: On IRIX there is no UMOUNT record and so we could start from -s 0.
+
+_print_transaction_inode()
+{
+ _start=$1
+ mkdir $fulldir >/dev/null 2>&1
+ mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
+ mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
+ raw=$fulldir/trans_inode.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
+ filtered=$fulldir/trans_inode.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
+
+ echo "### xfs_logprint -t -i -s START output ###" | tee $raw >$filtered
+ _scratch_xfs_logprint -t -i -s $_start 2>&1 \
+ | tee -a $raw \
+ | _filter_logprint \
+ >>$filtered
+}
+
+_print_transaction_buf()
+{
+ _start=$1
+ mkdir $fulldir >/dev/null 2>&1
+ mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
+ mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
+ raw=$fulldir/trans_buf.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
+ filtered=$fulldir/trans_buf.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
+
+ echo "### xfs_logprint -t -b -s START output ###" | tee $raw >$filtered
+ _scratch_xfs_logprint -t -b -s $_start 2>&1 \
+ | tee -a $raw \
+ | _filter_logprint \
+ >>$filtered
+}
+
+_mkfs_log()
+{
+ # create the FS
+ # mkfs options to append to log size otion can be specified ($*)
+ export MKFS_OPTIONS="-l size=2000b -l lazy-count=1 $*"
+ _full "mkfs"
+ _scratch_mkfs_xfs >>$RESULT_DIR/$seq.full 2>&1
+ if [ $? -ne 0 ] ; then
+ _echofull "Cannot mkfs for this test using option specified: $MKFS_OPTIONS"
+ return 1
+ fi
+
+ return 0
+}
+
+
+#
+# mount fs and create some log traffic
+#
+_create_log()
+{
+ # mount the FS
+ _full "mount"
+ _scratch_mount >>$RESULT_DIR/$seq.full 2>&1
+ if [ $? -ne 0 ] ; then
+ _echofull "mount failed: $MOUNT_OPTIONS"
+ return 1
+ fi
+
+ # generate some log traffic - but not too much - life gets a little
+ # more complicated if the log wraps around. This traffic is
+ # pretty much arbitary, but could probably be made better than this.
+ touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
+
+ # unmount the FS
+ _full "umount"
+ umount $SCRATCH_DEV >>$RESULT_DIR/$seq.full 2>&1
+ if [ $? -ne 0 ] ; then
+ _echofull "umount failed"
+ return 1
+ fi
+
+ return 0
+}
+
+#
+# mount fs and create some log traffic with sync'ing
+#
+_create_log_sync()
+{
+ # mount the FS
+ _full " mount"
+ _scratch_mount >>$RESULT_DIR/$seq.full 2>&1
+ if [ $? -ne 0 ] ; then
+ _echofull "mount failed: $MOUNT_OPTIONS"
+ return 1
+ fi
+
+ # generate some log traffic - but not too much
+ # add some syncs to get the log flushed to disk
+ for file in $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}; do
+ touch $file
+ sync
+ done
+
+ # unmount the FS
+ _full "umount"
+ umount $SCRATCH_DEV >>$RESULT_DIR/$seq.full 2>&1
+ if [ $? -ne 0 ] ; then
+ _echofull "umount failed"
+ return 1
+ fi
+}
+
+_cmp_output()
+{
+ echo "*** compare logprint: $1 with $2"
+ if ! diff $1 $2 >/dev/null; then
+ _fail "logprint output $1 differs to $2"
+ fi
+}
+
+#
+# Op data of different Log Record sizes will mean that data is
+# split at different points and in op printing it will not
+# try and decode the data which has been split up.
+# So we do a special diff processing to complain of differences
+# if no split is involved.
+#
+# Example diff with forms of:
+# "Left over region from split log item"
+# "Not printing rest of data"
+#
+# 2149c2149
+# < Left over region from split log item
+# ---
+# > BUF DATA
+# 2888c2888,2889
+# < INODE: #regs: 3 Not printing rest of data
+# ---
+# > INODE: #regs: 3 ino: 0x80 flags: 0x5 dsize: 16
+# > blkno: <BLKNO> len:<LEN> boff: <BOFF>
+#
+_process_op_diff()
+{
+ $AWK_PROG <$1 '
+ BEGIN { num_splits = 1; max_splits = 50 }
+ /^[0-9]/ {
+
+ # ensure a split happened in previous difference
+ if (num_splits < 1 || num_splits > max_splits) {
+ print num_splits, " split(s) found prior to diff cmd: ", $0
+ num_splits = 1 # shut-up end condition
+ exit 1
+ }
+ num_splits = 0
+
+ next
+ }
+ /Left over region/ || /Not printing rest/ {
+ num_splits++
+ next
+ }
+ { next }
+ END {
+ if (num_splits < 1 || num_splits > max_splits) {
+ print num_splits, " split(s) found prior to diff end"
+ exit 1
+ }
+ }
+ '
+ return $?
+}
+
+_cmp_op_output()
+{
+ echo "*** compare logprint: $1 with $2"
+
+ diff $1 $2 >$filtered.diff
+ if ! _process_op_diff $filtered.diff
+ then
+ _fail "logprint output $1 differs to $2 considering splits"
+ fi
+}
+
+# return xfs log version of device
+# e.g.
+# _log_version /dev/dsk/dks0d1s4
+#
+_log_version()
+{
+ _dev=$1
+ vers=`xfs_db -c 'sb 0' -c 'p versionnum' -r $_dev | $AWK_PROG '{print $3}'`
+ logver=`echo $vers | sed -e 's/0x[0-9a-f]\([0-9a-f]\)[0-9a-f][0-9a-f]/\1/'`
+ if [ $logver = 4 -o $logver = 5 -o $logver = 6 -o $logver = 7 -o \
+ $logver = c -o $logver = d -o $logver = e -o $logver = f ]; then
+ echo 2
+ else
+ echo 1
+ fi
+}
+
+_require_v2log()
+{
+ # test out mkfs to see if it supports "-l version=2"
+ export MKFS_OPTIONS="-l version=2"
+ if ! _scratch_mkfs_xfs >>$RESULT_DIR/$seq.full 2>&1; then
+ _notrun "mkfs does not support v2 logs"
+ fi
+
+ # test out mount to see if it mounts a v2 log fs
+ export MOUNT_OPTIONS="-o logbsize=32k"
+ if ! _scratch_mount >>$RESULT_DIR/$seq.full 2>&1; then
+ _notrun "mount/kernel does not support v2 logs"
+ fi
+
+ # check after unmount to see if it is clean
+ # i.e. it is not a 6.5.25 buggy version checking kernel
+ touch $SCRATCH_MNT/file
+ umount $SCRATCH_DEV >>$RESULT_DIR/$seq.full 2>&1
+ if _scratch_xfs_logprint -t | tee -a $RESULT_DIR/$seq.full \
+ | head | grep -q "<DIRTY>"; then
+ _notrun "kernel does not support v2 logs"
+ fi
+
+ # otherwise presume it does support v2 logs...:)
+}
+
+
+# make sure this script returns success
+/bin/true
--- /dev/null
+##/bin/bash
+#
+# Copyright (c) 2007 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
+#
+#
+# common functions for excersizing hole punches with extent size hints etc.
+
+# source dmap_scratch_mount etc.
+. ./common/dmapi
+
+_spawn_test_file() {
+ echo "# spawning test file with $*"
+ local blksize=$1
+ local file_size=`expr $2 \* $blksize`
+ local extent_size_hint=`expr $3 \* $blksize`
+ local test_file=$4
+ local reserve_space=$5
+
+ if [ $extent_size_hint -ne 0 ]; then
+ echo "+ setting extent size hint to $extent_size_hint"
+ $XFS_IO_PROG -f \
+ -c "extsize $extent_size_hint" \
+ $test_file
+ fi
+ # print extent size hint for $test_file
+ $XFS_IO_PROG -f \
+ -c "extsize" \
+ $test_file
+
+ if [ "$reserve_space" == "noresv" ]; then
+ echo "+ not using resvsp at file creation"
+ $XFS_IO_PROG -f \
+ -c "truncate $file_size" \
+ $test_file
+ else
+ $XFS_IO_PROG -f \
+ -c "truncate $file_size" \
+ -c "resvsp 0 $file_size" \
+ $test_file
+ fi
+}
+
+_do_punch() {
+ echo "# punching with $*"
+ # punch or bite the ear off $test_file to create a hole
+ local blksize=$1
+ local punch_offset=`expr $2 \* $blksize`
+ local punch_size=`expr $3 \* $blksize`
+ local punch_type=$4 # u for unresvsp, d for dm_punch
+ local test_file=$5
+
+ if [ "$punch_type" == "u" ]; then
+ echo "+ hole punch using unresvsp"
+ $XFS_IO_PROG -f \
+ -c "unresvsp $punch_offset $punch_size" \
+ $test_file
+ fi
+ if [ "$punch_type" == "d" ]; then
+ echo "+ hole punch using dmapi punch_hole"
+ ${DMAPI_QASUITE1_DIR}cmd/punch_hole -o $punch_offset -l $punch_size \
+ ${SCRATCH_MNT}/$test_file
+ fi
+}
+
+_do_write() {
+ echo "# writing with $*"
+ local blksize=$1
+ local write_offset=`expr $2 \* $blksize`
+ local write_size=`expr $3 \* $blksize`
+ local test_file=$4
+
+ $XFS_IO_PROG -f \
+ -c "pwrite $write_offset $write_size" \
+ $test_file >/dev/null
+}
+
+_do_bmap() {
+ echo "# showing file state $*"
+ local test_file=$1
+
+ $XFS_IO_PROG -f \
+ -c "bmap -vvp" \
+ $test_file
+}
+
+_test_punch() {
+ echo "# testing $* ..."
+ local blksize=$1
+ # all points and sizes below are in terms of filesystem blocks
+ local extsize_hint_blks=$2 # extent size hint in FS blocks, 0=do not set
+ local file_size_blks=$3 # the file size in blocks
+ local punch_points_blks=( $4 ) # array of places to punch holes in the file
+ local punch_sizes_blks=( $5 ) # array of size of each punch in blocks
+ local punch_types=( $6 ) # array of u=unresvsp or d=dm_punch
+ local write_points_blks=( $7 ) # array of places to pwrite in the file
+ local write_sizes_blks=( $8 ) # array of size of each write
+
+ local punch_write_order=( $9 ) # array of punch/write operation order
+ # e.g. "w p w w p" means: do 1st write...
+ # then 1st punch, 2nd & 3rd write, 2nd punch
+ local resvsp=${10} # if "noresv" then don't resvsp on file create
+ local filename=punch_test_file
+
+ cd /
+ umount $SCRATCH_MNT >/dev/null 2>&1
+
+ _scratch_mkfs_xfs -bsize=$blksize >/dev/null 2>&1 \
+ || _fail "mkfs failed"
+
+ local this_punch_type=""
+ local dmap_punch_used=0
+ for this_punch_type in "${punch_types[@]}"; do
+ [ "$this_punch_type" == "d" ] && dmap_punch_used=1
+ done
+ if [ $dmap_punch_used -ne 0 ]; then
+ # a punch type of dm_punch has been specified, do a dmapi mount
+ echo "+ mounting with dmapi enabled"
+ _dmapi_scratch_mount
+ else
+ # only unresvsp punch type is used, just do a normal mount
+ _scratch_mount || _fail "mount failed"
+ fi
+
+ cd $SCRATCH_MNT
+
+ # check a size is specified for each punch
+ [ ${#punch_points_blks[*]} -eq ${#punch_sizes_blks[*]} ] \
+ || _fail "num punch points given does not equal num punch sizes"
+
+ # check a type is specified for each punch
+ [ ${#punch_points_blks[*]} -eq ${#punch_types[*]} ] \
+ || _fail "num punch points given does not equal num punch types"
+
+ # check a size is specified for each write
+ [ ${#write_points_blks[*]} -eq ${#write_sizes_blks[*]} ] \
+ || _fail "num write points given does not equal num write sizes"
+
+ # check punch_write_order operations match number of punches + writes
+ local total_pw_operations=`expr ${#punch_points_blks[*]} + ${#write_points_blks[*]}`
+ [ $total_pw_operations -eq ${#punch_write_order[*]} ] \
+ || _fail "punch_write_order ops doesn't match number of punches + writes"
+
+ # create the file and setup extent size hint
+ _spawn_test_file $blksize $file_size_blks $extsize_hint_blks $filename $resvsp
+
+ # do the writes and punches
+ local operation=""
+ local punch_index=0
+ local write_index=0
+ for operation in "${punch_write_order[@]}"; do
+ if [ "$operation" == "p" ]; then
+ _do_punch $blksize ${punch_points_blks[$punch_index]} \
+ ${punch_sizes_blks[$punch_index]} ${punch_types[$punch_index]} \
+ $filename
+ punch_index=`expr $punch_index + 1`
+ fi
+ if [ "$operation" == "w" ]; then
+ _do_write $blksize ${write_points_blks[$write_index]} \
+ ${write_sizes_blks[$write_index]} $filename
+ write_index=`expr $write_index + 1`
+ fi
+ sync
+ _do_bmap $filename # print out the state of the file
+ done
+}
+
+_coalesce_extents()
+{
+ awk -F: '
+ {
+ range = $2;
+ type = $3;
+
+ split(range, bounds, "[\\[ \\.\\]]");
+ low = bounds[3];
+ high = bounds[5];
+
+ if (type != prev_type) {
+ if (prev_type != "")
+ printf("%u]:%s\n", low - 1, prev_type);
+ printf("%u: [%u..", out_count++, low);
+ prev_type = type;
+ }
+ }
+ END {
+ if (prev_type != "")
+ printf("%u]:%s\n", high, prev_type);
+ }'
+}
+
+_filter_fiemap()
+{
+ awk --posix '
+ $3 ~ /hole/ {
+ print $1, $2, $3;
+ next;
+ }
+ $5 ~ /0x[[:xdigit:]]*8[[:xdigit:]]{2}/ {
+ print $1, $2, "unwritten";
+ next;
+ }
+ $5 ~ /0x[[:xdigit:]]+/ {
+ print $1, $2, "data";
+ }' |
+ _coalesce_extents
+}
+
+# Filters fiemap output to only print the
+# file offset column and whether or not
+# it is an extent or a hole
+_filter_hole_fiemap()
+{
+ awk --posix '
+ $3 ~ /hole/ {
+ print $1, $2, $3;
+ next;
+ }
+ $5 ~ /0x[[:xdigit:]]+/ {
+ print $1, $2, "extent";
+ }' |
+ _coalesce_extents
+}
+
+
+# Prints the md5 checksum of a given file
+_md5_checksum()
+{
+ md5sum $1 | cut -d ' ' -f1
+}
+
+_filter_bmap()
+{
+ awk '
+ $3 ~ /hole/ {
+ print $1, $2, $3;
+ next;
+ }
+ $7 ~ /10000/ {
+ print $1, $2, "unwritten";
+ next;
+ }
+ $7 ~ /00000/ {
+ print $1, $2, "data"
+ }' |
+ _coalesce_extents
+}
+
+die_now()
+{
+ status=1
+ exit
+}
+
+# test the different corner cases for zeroing a range:
+#
+# 1. into a hole
+# 2. into allocated space
+# 3. into unwritten space
+# 4. hole -> data
+# 5. hole -> unwritten
+# 6. data -> hole
+# 7. data -> unwritten
+# 8. unwritten -> hole
+# 9. unwritten -> data
+# 10. hole -> data -> hole
+# 11. data -> hole -> data
+# 12. unwritten -> data -> unwritten
+# 13. data -> unwritten -> data
+# 14. data -> hole @ EOF
+# 15. data -> hole @ 0
+# 16. data -> cache cold ->hole
+# 17. data -> hole in single block file
+#
+# Test file is removed, created and sync'd between tests.
+#
+# Use -k flag to keep the file between tests. This will
+# test the handling of pre-existing holes.
+#
+# Use the -d flag to not sync the file between tests.
+# This will test the handling of delayed extents
+#
+_test_generic_punch()
+{
+
+ remove_testfile=1
+ sync_cmd="-c fsync"
+ OPTIND=1
+ while getopts 'dk' OPTION
+ do
+ case $OPTION in
+ k) remove_testfile=
+ ;;
+ d) sync_cmd=
+ ;;
+ ?) echo Invalid flag
+ exit 1
+ ;;
+ esac
+ done
+ shift $(($OPTIND - 1))
+
+ alloc_cmd=$1
+ punch_cmd=$2
+ zero_cmd=$3 #if not testing zero just set to punch
+ map_cmd=$4
+ filter_cmd=$5
+ testfile=$6
+ xfs_io_opt=$7 #needs to be -F if not testing xfs
+
+ echo " 1. into a hole"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "$zero_cmd 4k 8k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 2. into allocated space"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "pwrite 0 20k" $sync_cmd \
+ -c "$zero_cmd 4k 8k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 3. into unwritten space"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "$alloc_cmd 0 20k" \
+ -c "$zero_cmd 4k 8k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 4. hole -> data"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "pwrite 8k 8k" $sync_cmd \
+ -c "$zero_cmd 4k 8k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 5. hole -> unwritten"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "$alloc_cmd 8k 8k" \
+ -c "$zero_cmd 4k 8k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 6. data -> hole"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "pwrite 0 8k" $sync_cmd \
+ -c "$zero_cmd 4k 8k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 7. data -> unwritten"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "pwrite 0 8k" $sync_cmd \
+ -c "$alloc_cmd 8k 8k" \
+ -c "$zero_cmd 4k 8k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 8. unwritten -> hole"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "$alloc_cmd 0 8k" \
+ -c "$zero_cmd 4k 8k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 9. unwritten -> data"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "$alloc_cmd 0 8k" \
+ -c "pwrite 8k 8k" $sync_cmd \
+ -c "$zero_cmd 4k 8k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 10. hole -> data -> hole"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "pwrite 8k 4k" $sync_cmd \
+ -c "$zero_cmd 4k 12k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 11. data -> hole -> data"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "$alloc_cmd 0 20k" \
+ -c "pwrite 0 8k" \
+ -c "pwrite 12k 8k" $sync_cmd \
+ -c "$punch_cmd 8k 4k" \
+ -c "$zero_cmd 4k 12k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 12. unwritten -> data -> unwritten"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "$alloc_cmd 0 20k" \
+ -c "pwrite 8k 4k" $sync_cmd \
+ -c "$zero_cmd 4k 12k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 13. data -> unwritten -> data"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "$alloc_cmd 0 20k" \
+ -c "pwrite 0k 8k" $sync_cmd \
+ -c "pwrite 12k 8k" -c "fsync" \
+ -c "$zero_cmd 4k 12k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 14. data -> hole @ EOF"
+ rm -f $testfile
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "pwrite 0 20k" $sync_cmd \
+ -c "$zero_cmd 12k 8k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 15. data -> hole @ 0"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "pwrite 0 20k" $sync_cmd \
+ -c "$zero_cmd 0k 8k" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+ echo " 16. data -> cache cold ->hole"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ rm -f $testfile.2
+ else
+ cp $testfile $testfile.2
+ fi
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "pwrite 8k 12k" -c "fsync" $testfile.2 \
+ > /dev/null
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate 20k" \
+ -c "pwrite 0 20k" $sync_cmd \
+ -c "$zero_cmd 0k 8k" \
+ -c "fadvise -d" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ diff $testfile $testfile.2
+ [ $? -ne 0 ] && die_now
+ rm -f $testfile.2
+ _md5_checksum $testfile
+
+ echo " 17. data -> hole in single block file"
+ if [ "$remove_testfile" ]; then
+ rm -f $testfile
+ fi
+ block_size=`stat -f $TEST_DEV | grep "Block size" | cut -d " " -f3`
+ $XFS_IO_PROG $xfs_io_opt -f -c "truncate $block_size" \
+ -c "pwrite 0 $block_size" $sync_cmd \
+ -c "$zero_cmd 128 128" \
+ -c "$map_cmd -v" $testfile | $filter_cmd
+ [ $? -ne 0 ] && die_now
+ _md5_checksum $testfile
+
+}
--- /dev/null
+##/bin/bash
+#
+# Copyright (c) 2000-2001,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 quota tests
+#
+
+#
+# checks that the generic quota support in the kernel is enabled
+# and that we have valid quota user tools installed.
+#
+_require_quota()
+{
+ [ -n $QUOTA_PROG ] || _notrun "Quota user tools not installed"
+
+ case $FSTYP in
+ ext2|ext3|ext4|ext4dev|reiserfs)
+ if [ ! -d /proc/sys/fs/quota ]; then
+ _notrun "Installed kernel does not support quotas"
+ fi
+ ;;
+ gfs2)
+ ;;
+ xfs)
+ if [ ! -f /proc/fs/xfs/xqmstat ]; then
+ _notrun "Installed kernel does not support XFS quotas"
+ fi
+ ;;
+ *)
+ _notrun "disk quotas not supported by this filesystem type: $FSTYP"
+ ;;
+ esac
+
+ # SELinux adds extra xattrs which can mess up our expected output.
+ # So, mount with a context, and they won't be created
+ # nfs_t is a "liberal" context so we can use it.
+ if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
+ export SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:nfs_t:s0"
+ fi
+}
+
+#
+# checks that the XFS quota support in the kernel is enabled
+# and that we have valid quota user tools installed.
+#
+_require_xfs_quota()
+{
+ src/feature -q $TEST_DEV
+ [ $? -ne 0 ] && _notrun "Installed kernel does not support XFS quota"
+ [ -n $XFS_QUOTA_PROG ] || _notrun "XFS quota user tools not installed"
+}
+
+#
+# checks that the XFS project quota support in the kernel is enabled.
+#
+_require_prjquota()
+{
+ [ -n "$1" ] && _dev="$1" || _dev="$TEST_DEV"
+ src/feature -p $_dev
+ [ $? -ne 0 ] && _notrun "Installed kernel does not support project quotas"
+}
+
+#
+# checks for user nobody in /etc/passwd and /etc/group.
+#
+_require_nobody()
+{
+ _cat_passwd | grep -q '^nobody'
+ [ $? -ne 0 ] && _notrun "password file does not contain user nobody."
+
+ _cat_group | egrep -q '^no(body|group)'
+ [ $? -ne 0 ] && _notrun "group file does not contain nobody/nogroup."
+}
+
+# create a file as a specific user (uid)
+# takes filename, id, type (u/g/p), blocksize, blockcount
+#
+_file_as_id()
+{
+ [ $# != 5 ] && _notrun "broken call to _file_as_id in test $seq"
+
+ parent=`dirname $1`
+ if [ $3 = p ]; then
+ echo PARENT: xfs_io -r -c "chproj $2" -c "chattr +P" $parent >>$RESULT_DIR/$seq.full
+ $XFS_IO_PROG -r -c "chproj $2" -c "chattr +P" $parent >>$RESULT_DIR/$seq.full 2>&1
+ magik='$>' # (irrelevent, above set projid-inherit-on-parent)
+ elif [ $3 = u ]; then
+ magik='$>' # perlspeak for effective uid
+ elif [ $3 = g ]; then
+ magik='$)' # perlspeak for effective gid
+ else
+ _notrun "broken type in call to _file_as_id in test $seq"
+ fi
+
+ perl <<EOF >>$RESULT_DIR/$seq.full 2>&1
+ \$| = 1;
+ $magik = $2;
+ if ($5 == 0) {
+ print "touch $1";
+ exec "touch $1";
+ } else {
+ print "dd if=/dev/zero of=$1 bs=$4 count=$5";
+ exec "dd if=/dev/zero of=$1 bs=$4 count=$5";
+ }
+EOF
+# for debugging the above euid change, try... [need write in cwd]
+# exec "dd if=/dev/zero of=$1 bs=$4 count=$5 >>$RESULT_DIR/$seq.full 2>&1";
+
+ if [ $3 = p ]; then
+ echo PARENT: xfs_io -r -c "chproj 0" -c "chattr -P" $parent >>$RESULT_DIR/$seq.full
+ $XFS_IO_PROG -r -c "chproj 0" -c "chattr -P" $parent >>$RESULT_DIR/$seq.full 2>&1
+ fi
+}
+
+_choose_uid()
+{
+ _cat_passwd | grep '^nobody' | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
+}
+
+_choose_gid()
+{
+ _cat_group | egrep '^no(body|group)' | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
+}
+
+_choose_prid()
+{
+ if [ "X$projid_file" == "X" ]; then
+ projid_file=/etc/projid
+ fi
+ if [ ! -f $projid_file ]; then
+ echo 0
+ return
+ fi
+ perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[1],$a[0] }' \
+ $projid_file
+}
+
+_qmount()
+{
+ umount $SCRATCH_DEV >/dev/null 2>&1
+ _scratch_mount || _fail "qmount failed"
+ chmod ugo+rwx $SCRATCH_MNT
+}
+
+_qsetup()
+{
+ # setup exactly what it is we'll be testing
+ enforce=1
+ if src/feature -u $SCRATCH_DEV
+ then
+ type=u ;
+ eval `_choose_uid`
+ [ ! -f $seq.out ] && ln -s $seq.usrquota $seq.out
+ elif src/feature -g $SCRATCH_DEV
+ then
+ type=g
+ eval `_choose_gid`
+ [ ! -f $seq.out ] && ln -s $seq.grpquota $seq.out
+ elif src/feature -p $SCRATCH_DEV
+ then
+ type=p
+ eval `_choose_prid`
+ [ ! -f $seq.out ] && ln -s $seq.prjquota $seq.out
+ elif src/feature -U $SCRATCH_DEV
+ then
+ type=u
+ eval `_choose_uid`
+ [ ! -f $seq.out ] && ln -s $seq.uqnoenforce $seq.out
+ enforce=0
+ elif src/feature -G $SCRATCH_DEV
+ then
+ type=g
+ eval `_choose_gid`
+ [ ! -f $seq.out ] && ln -s $seq.gqnoenforce $seq.out
+ enforce=0
+ elif src/feature -P $SCRATCH_DEV
+ then
+ type=p
+ eval `_choose_prid`
+ [ ! -f $seq.out ] && ln -s $seq.pqnoenforce $seq.out
+ enforce=0
+ else
+ _notrun "No quota support at mount time"
+ fi
+
+ echo "Using output from '" `ls -l $seq.out` "'" >>$RESULT_DIR/$seq.full
+ echo "and using type=$type id=$id" >>$RESULT_DIR/$seq.full
+}
+
+#
+# Ensures only the given quota mount option is used
+#
+_qmount_option()
+{
+ # Replace any user defined quota options
+ # with the quota option that we want.
+ # Simplest to do this rather than delete existing ones first because
+ # of the variety of commas and spaces and multiple -o's
+ # that we'd have to cater for. Doesn't matter if we have duplicates.
+ # Use "QUOTA" string so that we don't have any substring confusion
+ # thanks to "quota" which will match with "uquota" and "gquota" etc.
+ export MOUNT_OPTIONS=`echo $MOUNT_OPTIONS \
+ | sed -e 's/uquota/QUOTA/g' \
+ -e 's/usrquota/QUOTA/g' \
+ -e 's/gquota/QUOTA/g' \
+ -e 's/grpquota/QUOTA/g' \
+ -e 's/pquota/QUOTA/g' \
+ -e 's/quota/QUOTA/g' \
+ -e 's/uqnoenforce/QUOTA/g' \
+ -e 's/gqnoenforce/QUOTA/g' \
+ -e 's/pqnoenforce/QUOTA/g' \
+ -e 's/qnoenforce/QUOTA/g' \
+ -e "s/QUOTA/$1/g"`
+
+ # Ensure we have the given quota option - duplicates are fine
+ export MOUNT_OPTIONS="$MOUNT_OPTIONS -o $1"
+ echo "MOUNT_OPTIONS = $MOUNT_OPTIONS" >>$RESULT_DIR/$seq.full
+}
+
+_check_quota_usage()
+{
+ # Sync to get delalloc to disk
+ sync
+
+ # kill caches to guarantee removal speculative delalloc
+ # XXX: really need an ioctl instead of this big hammer
+ echo 3 > /proc/sys/vm/drop_caches
+
+ VFS_QUOTA=0
+ case $FSTYP in
+ ext2|ext3|ext4|ext4dev|reiserfs)
+ VFS_QUOTA=1
+ quotaon -f -u -g $SCRATCH_MNT 2>/dev/null
+ ;;
+ *)
+ ;;
+ esac
+ repquota -u -n $SCRATCH_MNT | grep -v "^#0" | _filter_scratch |
+ sort >$tmp.user.orig
+ repquota -g -n $SCRATCH_MNT | grep -v "^#0" | _filter_scratch |
+ sort >$tmp.group.orig
+ if [ $VFS_QUOTA -eq 1 ]; then
+ quotacheck -u -g $SCRATCH_MNT 2>/dev/null
+ else
+ # use XFS method to force quotacheck
+ xfs_quota -x -c "off -ug" $SCRATCH_MNT
+ _scratch_unmount
+ _scratch_mount "-o usrquota,grpquota"
+ fi
+ repquota -u -n $SCRATCH_MNT | grep -v "^#0" | _filter_scratch |
+ sort >$tmp.user.checked
+ repquota -g -n $SCRATCH_MNT | grep -v "^#0" | _filter_scratch |
+ sort >$tmp.group.checked
+ if [ $VFS_QUOTA -eq 1 ]; then
+ quotaon -u -g $SCRATCH_MNT 2>/dev/null
+ fi
+ {
+ echo "Comparing user usage"
+ diff $tmp.user.orig $tmp.user.checked
+ } && {
+ echo "Comparing group usage"
+ diff $tmp.group.orig $tmp.group.checked
+ }
+}
+
+# make sure this script returns success
+/bin/true
--- /dev/null
+##/bin/bash
+#-----------------------------------------------------------------------
+# Copyright (c) 2000-2006 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will 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 to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+#
+# Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
+# Mountain View, CA 94043, USA, or: http://www.sgi.com
+#-----------------------------------------------------------------------
+
+BC=$(which bc 2> /dev/null) || BC=
+
+_require_math()
+{
+ if [ -z "$BC" ]; then
+ _notrun "this test requires 'bc' tool for doing math operations"
+ fi
+}
+
+_math()
+{
+ [ $# -le 0 ] && return
+ if [ "$BC" ]; then
+ result=$(LANG=C echo "scale=0; $@" | "$BC" -q 2> /dev/null)
+ else
+ _notrun "this test requires 'bc' tool for doing math operations"
+ fi
+ echo "$result"
+}
+
+dd()
+{
+ if [ "$HOSTOS" == "Linux" ]
+ then
+ command dd --help | grep noxfer > /dev/null 2>&1
+
+ if [ "$?" -eq 0 ]
+ then
+ command dd status=noxfer $@
+ else
+ command dd $@
+ fi
+ else
+ command dd $@
+ fi
+}
+
+# ls -l w/ selinux sometimes puts a dot at the end:
+# -rwxrw-r--. id1 id2 file1
+
+_ls_l()
+{
+ ls -l $* | sed "s/\(^[-rwxdlbcpsStT]*\)\. /\1 /"
+}
+
+_mount_opts()
+{
+ # SELinux adds extra xattrs which can mess up our expected output.
+ # So, mount with a context, and they won't be created
+ # nfs_t is a "liberal" context so we can use it.
+ if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
+ SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:nfs_t:s0"
+ export SELINUX_MOUNT_OPTIONS
+ fi
+
+ case $FSTYP in
+ xfs)
+ export MOUNT_OPTIONS=$XFS_MOUNT_OPTIONS
+ ;;
+ udf)
+ export MOUNT_OPTIONS=$UDF_MOUNT_OPTIONS
+ ;;
+ nfs)
+ export MOUNT_OPTIONS=$NFS_MOUNT_OPTIONS
+ ;;
+ ext2|ext3|ext4|ext4dev)
+ # acls & xattrs aren't turned on by default on ext$FOO
+ export MOUNT_OPTIONS="-o acl,user_xattr $EXT_MOUNT_OPTIONS"
+ ;;
+ reiserfs)
+ # acls & xattrs aren't turned on by default on reiserfs
+ export MOUNT_OPTIONS="-o acl,user_xattr $REISERFS_MOUNT_OPTIONS"
+ ;;
+ gfs2)
+ # acls aren't turned on by default on gfs2
+ export MOUNT_OPTIONS="-o acl $GFS2_MOUNT_OPTIONS"
+ ;;
+ *)
+ ;;
+ esac
+}
+
+_mkfs_opts()
+{
+ case $FSTYP in
+ xfs)
+ export MKFS_OPTIONS=$XFS_MKFS_OPTIONS
+ ;;
+ udf)
+ [ ! -z "$udf_fsize" ] && \
+ UDF_MKFS_OPTIONS="$UDF_MKFS_OPTIONS -s $udf_fsize"
+ export MKFS_OPTIONS=$UDF_MKFS_OPTIONS
+ ;;
+ nfs)
+ export MKFS_OPTIONS=$NFS_MKFS_OPTIONS
+ ;;
+ reiserfs)
+ export MKFS_OPTIONS="$REISERFS_MKFS_OPTIONS -q"
+ ;;
+ gfs2)
+ export MKFS_OPTIONS="$GFS2_MKFS_OPTIONS -O -p lock_nolock"
+ ;;
+ jfs)
+ export MKFS_OPTIONS="$JFS_MKFS_OPTIONS -q"
+ ;;
+ *)
+ ;;
+ esac
+}
+
+_fsck_opts()
+{
+ case $FSTYP in
+ ext2|ext3|ext4|ext4dev)
+ export FSCK_OPTIONS="-nf"
+ ;;
+ reiserfs)
+ export FSCK_OPTIONS="--yes"
+ ;;
+ *)
+ export FSCK_OPTIONS="-n"
+ ;;
+ esac
+}
+
+[ -z "$FSTYP" ] && FSTYP=xfs
+[ -z "$MOUNT_OPTIONS" ] && _mount_opts
+[ -z "$MKFS_OPTIONS" ] && _mkfs_opts
+[ -z "$FSCK_OPTIONS" ] && _fsck_opts
+
+
+# we need common.config
+if [ "$iam" != "check" ]
+then
+ if ! . ./common/config
+ then
+ echo "$iam: failed to source common.config"
+ exit 1
+ fi
+fi
+
+# check for correct setup
+case "$FSTYP" in
+ xfs)
+ [ "$XFS_LOGPRINT_PROG" = "" ] && _fatal "xfs_logprint not found"
+ [ "$XFS_REPAIR_PROG" = "" ] && _fatal "xfs_repair not found"
+ [ "$XFS_CHECK_PROG" = "" ] && _fatal "xfs_check not found"
+ [ "$XFS_DB_PROG" = "" ] && _fatal "xfs_db not found"
+ [ "$MKFS_XFS_PROG" = "" ] && _fatal "mkfs_xfs not found"
+ ;;
+ udf)
+ [ "$MKFS_UDF_PROG" = "" ] && _fatal "mkfs_udf/mkudffs not found"
+ ;;
+ btrfs)
+ [ "$MKFS_BTRFS_PROG" = "" ] && _fatal "mkfs.btrfs not found"
+ ;;
+ nfs)
+ ;;
+esac
+
+# make sure we have a standard umask
+umask 022
+
+_mount()
+{
+ $MOUNT_PROG `_mount_ops_filter $*`
+}
+
+_scratch_options()
+{
+ type=$1
+ SCRATCH_OPTIONS=""
+
+ if [ "$FSTYP" != "xfs" ]; then
+ return
+ fi
+
+ case $type in
+ mkfs)
+ [ "$HOSTOS" != "IRIX" ] && SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f"
+ rt_opt="-r"
+ log_opt="-l"
+ ;;
+ mount)
+ rt_opt="-o"
+ log_opt="-o"
+ ;;
+ esac
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
+ SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${rt_opt}rtdev=$SCRATCH_RTDEV"
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+ SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}logdev=$SCRATCH_LOGDEV"
+}
+
+_test_options()
+{
+ type=$1
+ TEST_OPTIONS=""
+
+ if [ "$FSTYP" != "xfs" ]; then
+ return
+ fi
+
+ case $type in
+ mkfs)
+ rt_opt="-r"
+ log_opt="-l"
+ ;;
+ mount)
+ rt_opt="-o"
+ log_opt="-o"
+ ;;
+ esac
+ [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
+ TEST_OPTIONS="$TEST_OPTIONS ${rt_opt}rtdev=$TEST_RTDEV"
+ [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
+ TEST_OPTIONS="$TEST_OPTIONS ${log_opt}logdev=$TEST_LOGDEV"
+}
+
+_mount_ops_filter()
+{
+ params="$*"
+
+ #get mount point to handle dmapi mtpt option correctly
+ let last_index=$#-1
+ [ $last_index -gt 0 ] && shift $last_index
+ FS_ESCAPED=$1
+
+ # irix is fussy about how it is fed its mount options
+ # - multiple -o's are not allowed
+ # - no spaces between comma delimitered options
+ # the sed script replaces all -o's (except the first) with a comma
+ # not required for linux, but won't hurt
+
+ echo $params | sed -e 's/[[:space:]]*-o[[:space:]]*/UnIqUe/1; s/[[:space:]]*-o[[:space:]]*/,/g; s/UnIqUe/ -o /1' \
+ | sed -e 's/dmapi/dmi/' \
+ | $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$FS_ESCAPED\1\2#; print;"
+
+}
+
+_scratch_mount_options()
+{
+ _scratch_options mount
+
+ echo $SCRATCH_OPTIONS $MOUNT_OPTIONS $SELINUX_MOUNT_OPTIONS $* $SCRATCH_DEV $SCRATCH_MNT
+}
+
+_scratch_mount()
+{
+ _mount -t $FSTYP `_scratch_mount_options $*`
+}
+
+_scratch_unmount()
+{
+ $UMOUNT_PROG $SCRATCH_DEV
+}
+
+_scratch_remount()
+{
+ _scratch_unmount
+ _scratch_mount
+}
+
+_test_mount()
+{
+ _test_options mount
+ _mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
+}
+
+_scratch_mkfs_options()
+{
+ _scratch_options mkfs
+ echo $SCRATCH_OPTIONS $MKFS_OPTIONS $* $SCRATCH_DEV
+}
+
+
+_setup_large_xfs_fs()
+{
+ fs_size=$1
+ local tmp_dir=/tmp/
+
+ [ "$LARGE_SCRATCH_DEV" != yes ] && return 0
+ [ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0
+ [ $SCRATCH_DEV_EMPTY_SPACE -ge $fs_size ] && return 0
+
+ # calculate the size of the file we need to allocate.
+ # Default free space in the FS is 50GB, but you can specify more via
+ # SCRATCH_DEV_EMPTY_SPACE
+ file_size=$(($fs_size - 50*1024*1024*1024))
+ file_size=$(($file_size - $SCRATCH_DEV_EMPTY_SPACE))
+
+ # mount the filesystem, create the file, unmount it
+ _scratch_mount 2>&1 >$tmp_dir/mnt.err
+ local status=$?
+ if [ $status -ne 0 ]; then
+ echo "mount failed"
+ cat $tmp_dir/mnt.err >&2
+ rm -f $tmp_dir/mnt.err
+ return $status
+ fi
+ rm -f $tmp_dir/mnt.err
+
+ xfs_io -F -f \
+ -c "truncate $file_size" \
+ -c "falloc -k 0 $file_size" \
+ -c "chattr +d" \
+ $SCRATCH_MNT/.use_space 2>&1 > /dev/null
+ export NUM_SPACE_FILES=1
+ status=$?
+ umount $SCRATCH_MNT
+ if [ $status -ne 0 ]; then
+ echo "large file prealloc failed"
+ cat $tmp_dir/mnt.err >&2
+ return $status
+ fi
+ return 0
+}
+
+_scratch_mkfs_xfs()
+{
+ # extra mkfs options can be added by tests
+ local extra_mkfs_options=$*
+
+ local tmp_dir=/tmp/
+
+ _scratch_options mkfs
+
+ # save mkfs output in case conflict means we need to run again.
+ # only the output for the mkfs that applies should be shown
+ $MKFS_XFS_PROG $SCRATCH_OPTIONS $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
+ 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
+ local mkfs_status=$?
+
+ # a mkfs failure may be caused by conflicts between
+ # $MKFS_OPTIONS and $extra_mkfs_options
+
+ if [ $mkfs_status -ne 0 -a ! -z "$extra_mkfs_options" ]; then
+ echo "** mkfs failed with extra mkfs options added to \"$MKFS_OPTIONS\" by test $seq **" \
+ >>$RESULT_DIR/$seq.full
+ echo "** attempting to mkfs using only test $seq options: $extra_mkfs_options **" \
+ >>$RESULT_DIR/$seq.full
+ # running mkfs again. overwrite previous mkfs output files
+ $MKFS_XFS_PROG $SCRATCH_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
+ 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
+ mkfs_status=$?
+ fi
+
+ if [ $mkfs_status -eq 0 -a "$LARGE_SCRATCH_DEV" = yes ]; then
+ # manually parse the mkfs output to get the fs size in bytes
+ local fs_size
+ fs_size=`cat $tmp_dir.mkfsstd | perl -ne '
+ if (/^data\s+=\s+bsize=(\d+)\s+blocks=(\d+)/) {
+ my $size = $1 * $2;
+ print STDOUT "$size\n";
+ }'`
+ _setup_large_xfs_fs $fs_size
+ mkfs_status=$?
+ fi
+
+ # output stored mkfs output
+ cat $tmp_dir.mkfserr >&2
+ cat $tmp_dir.mkfsstd
+ rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
+
+ return $mkfs_status
+}
+
+_setup_large_ext4_fs()
+{
+ fs_size=$1
+ local tmp_dir=/tmp/
+
+ [ "$LARGE_SCRATCH_DEV" != yes ] && return 0
+ [ -z "$SCRATCH_DEV_EMPTY_SPACE" ] && SCRATCH_DEV_EMPTY_SPACE=0
+ [ $SCRATCH_DEV_EMPTY_SPACE -ge $fs_size ] && return 0
+
+ # Default free space in the FS is 50GB, but you can specify more via
+ # SCRATCH_DEV_EMPTY_SPACE
+ space_to_consume=$(($fs_size - 50*1024*1024*1024 - $SCRATCH_DEV_EMPTY_SPACE))
+
+ # mount the filesystem and create 16TB - 4KB files until we consume
+ # all the necessary space.
+ _scratch_mount 2>&1 >$tmp_dir/mnt.err
+ local status=$?
+ if [ $status -ne 0 ]; then
+ echo "mount failed"
+ cat $tmp_dir/mnt.err >&2
+ rm -f $tmp_dir/mnt.err
+ return $status
+ fi
+ rm -f $tmp_dir/mnt.err
+
+ file_size=$((16*1024*1024*1024*1024 - 4096))
+ nfiles=0
+ while [ $space_to_consume -gt $file_size ]; do
+
+ xfs_io -F -f \
+ -c "truncate $file_size" \
+ -c "falloc -k 0 $file_size" \
+ $SCRATCH_MNT/.use_space.$nfiles 2>&1
+ status=$?
+ if [ $status -ne 0 ]; then
+ break;
+ fi
+
+ space_to_consume=$(( $space_to_consume - $file_size ))
+ nfiles=$(($nfiles + 1))
+ done
+
+ # consume the remaining space.
+ if [ $space_to_consume -gt 0 ]; then
+ xfs_io -F -f \
+ -c "truncate $space_to_consume" \
+ -c "falloc -k 0 $space_to_consume" \
+ $SCRATCH_MNT/.use_space.$nfiles 2>&1
+ status=$?
+ fi
+ export NUM_SPACE_FILES=$nfiles
+
+ umount $SCRATCH_MNT
+ if [ $status -ne 0 ]; then
+ echo "large file prealloc failed"
+ cat $tmp_dir/mnt.err >&2
+ return $status
+ fi
+ return 0
+}
+_scratch_mkfs_ext4()
+{
+ local tmp_dir=/tmp/
+
+ /sbin/mkfs -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV \
+ 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
+ local mkfs_status=$?
+
+ if [ $mkfs_status -eq 0 -a "$LARGE_SCRATCH_DEV" = yes ]; then
+ # manually parse the mkfs output to get the fs size in bytes
+ fs_size=`cat $tmp_dir.mkfsstd | awk ' \
+ /^Block size/ { split($2, a, "="); bs = a[2] ; } \
+ / inodes, / { blks = $3 } \
+ /reserved for the super user/ { resv = $1 } \
+ END { fssize = bs * blks - resv; print fssize }'`
+
+ _setup_large_ext4_fs $fs_size
+ mkfs_status=$?
+ fi
+
+ # output stored mkfs output
+ cat $tmp_dir.mkfserr >&2
+ cat $tmp_dir.mkfsstd
+ rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
+
+ return $mkfs_status
+}
+
+_scratch_mkfs()
+{
+ case $FSTYP in
+ xfs)
+ _scratch_mkfs_xfs $*
+ ;;
+ nfs*)
+ # do nothing for nfs
+ ;;
+ udf)
+ $MKFS_UDF_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
+ ;;
+ btrfs)
+ $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
+ ;;
+ ext4)
+ _scratch_mkfs_ext4 $*
+ ;;
+ *)
+ yes | $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV
+ ;;
+ esac
+}
+
+# Create fs of certain size on scratch device
+# _scratch_mkfs_sized <size in bytes> [optional blocksize]
+_scratch_mkfs_sized()
+{
+ fssize=$1
+ blocksize=$2
+ [ -z "$blocksize" ] && blocksize=4096
+ blocks=`expr $fssize / $blocksize`
+
+ if [ "$HOSTOS" == "Linux" ]; then
+ devsize=`blockdev --getsize64 $SCRATCH_DEV`
+ [ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
+ fi
+
+ case $FSTYP in
+ xfs)
+ _scratch_mkfs_xfs -d size=$fssize -b size=$blocksize
+ ;;
+ ext2|ext3|ext4|ext4dev)
+ yes | ${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+ ;;
+ btrfs)
+ $MKFS_BTRFS_PROG $MKFS_OPTIONS -b $fssize $SCRATCH_DEV
+ ;;
+ *)
+ _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
+ ;;
+ esac
+}
+
+# Emulate an N-data-disk stripe w/ various stripe units
+# _scratch_mkfs_geom <sunit bytes> <swidth multiplier> [optional blocksize]
+_scratch_mkfs_geom()
+{
+ sunit_bytes=$1
+ swidth_mult=$2
+ blocksize=$3
+ [ -z "$blocksize" ] && blocksize=4096
+
+ let sunit_blocks=$sunit_bytes/$blocksize
+ let swidth_blocks=$sunit_blocks*$swidth_mult
+
+ case $FSTYP in
+ xfs)
+ MKFS_OPTIONS+=" -b size=$blocksize, -d su=$sunit_bytes,sw=$swidth_mult"
+ ;;
+ ext4|ext4dev)
+ MKFS_OPTIONS+=" -b $blocksize -E stride=$sunit_blocks,stripe_width=$swidth_blocks"
+ ;;
+ *)
+ _notrun "can't mkfs $FSTYP with geometry"
+ ;;
+ esac
+ _scratch_mkfs
+}
+
+_scratch_resvblks()
+{
+ case $FSTYP in
+ xfs)
+ xfs_io -x -c "resblks $1" $SCRATCH_MNT
+ ;;
+ *)
+ ;;
+ esac
+}
+
+_scratch_xfs_db_options()
+{
+ SCRATCH_OPTIONS=""
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+ SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
+ echo $SCRATCH_OPTIONS $* $SCRATCH_DEV
+}
+
+_scratch_xfs_logprint()
+{
+ SCRATCH_OPTIONS=""
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+ SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
+ $XFS_LOGPRINT_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
+}
+
+_scratch_xfs_check()
+{
+ SCRATCH_OPTIONS=""
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+ SCRATCH_OPTIONS="-l $SCRATCH_LOGDEV"
+ [ "$LARGE_SCRATCH_DEV" = yes ] && \
+ SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
+ $XFS_CHECK_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
+}
+
+_scratch_xfs_repair()
+{
+ SCRATCH_OPTIONS=""
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+ SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
+ SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -r$SCRATCH_RTDEV"
+ [ "$LARGE_SCRATCH_DEV" = yes ] && SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
+ $XFS_REPAIR_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
+}
+
+_get_pids_by_name()
+{
+ if [ $# -ne 1 ]
+ then
+ echo "Usage: _get_pids_by_name process-name" 1>&2
+ exit 1
+ fi
+
+ # Algorithm ... all ps(1) variants have a time of the form MM:SS or
+ # HH:MM:SS before the psargs field, use this as the search anchor.
+ #
+ # Matches with $1 (process-name) occur if the first psarg is $1
+ # or ends in /$1 ... the matching uses sed's regular expressions,
+ # so passing a regex into $1 will work.
+
+ ps $PS_ALL_FLAGS \
+ | sed -n \
+ -e 's/$/ /' \
+ -e 's/[ ][ ]*/ /g' \
+ -e 's/^ //' \
+ -e 's/^[^ ]* //' \
+ -e "/[0-9]:[0-9][0-9] *[^ ]*\/$1 /s/ .*//p" \
+ -e "/[0-9]:[0-9][0-9] *$1 /s/ .*//p"
+}
+
+# fix malloc libs output
+#
+_fix_malloc()
+{
+ # filter out the Electric Fence notice
+ $PERL_PROG -e '
+ while (<>) {
+ if (defined $o && /^\s+Electric Fence/) {
+ chomp($o);
+ print "$o";
+ undef $o;
+ next;
+ }
+ print $o if (defined $o);
+
+ $o=$_;
+ }
+ print $o if (defined $o);
+ '
+}
+
+# check if run as root
+#
+_need_to_be_root()
+{
+ id=`id | $SED_PROG -e 's/(.*//' -e 's/.*=//'`
+ if [ "$id" -ne 0 ]
+ then
+ echo "Arrgh ... you need to be root (not uid=$id) to run this test"
+ exit 1
+ fi
+}
+
+
+#
+# _df_device : get an IRIX style df line for a given device
+#
+# - returns "" if not mounted
+# - returns fs type in field two (ala IRIX)
+# - joins line together if split by fancy df formatting
+# - strips header etc
+#
+
+_df_device()
+{
+ if [ $# -ne 1 ]
+ then
+ echo "Usage: _df_device device" 1>&2
+ exit 1
+ fi
+
+ $DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 '
+ match($1,what) && NF==1 {
+ v=$1
+ getline
+ print v, $0
+ exit
+ }
+ match($1,what) {
+ print
+ exit
+ }
+ '
+}
+
+#
+# _df_dir : get an IRIX style df line for device where a directory resides
+#
+# - returns fs type in field two (ala IRIX)
+# - joins line together if split by fancy df formatting
+# - strips header etc
+#
+
+_df_dir()
+{
+ if [ $# -ne 1 ]
+ then
+ echo "Usage: _df_dir device" 1>&2
+ exit 1
+ fi
+
+ $DF_PROG $1 2>/dev/null | $AWK_PROG -v what=$1 '
+ NR == 2 && NF==1 {
+ v=$1
+ getline
+ print v, $0;
+ exit 0
+ }
+ NR == 2 {
+ print;
+ exit 0
+ }
+ {}
+ '
+ # otherwise, nada
+}
+
+# return percentage used disk space for mounted device
+
+_used()
+{
+ if [ $# -ne 1 ]
+ then
+ echo "Usage: _used device" 1>&2
+ exit 1
+ fi
+
+ _df_device $1 | $AWK_PROG '{ sub("%", "") ; print $6 }'
+}
+
+# return the FS type of a mounted device
+#
+_fs_type()
+{
+ if [ $# -ne 1 ]
+ then
+ echo "Usage: _fs_type device" 1>&2
+ exit 1
+ fi
+
+ #
+ # The Linux kernel shows NFSv4 filesystems in df output as
+ # filesystem type nfs4, although we mounted it as nfs earlier.
+ # Fix the filesystem type up here so that the callers don't
+ # have to bother with this quirk.
+ #
+ _df_device $1 | $AWK_PROG '{ print $2 }' | sed -e 's/nfs4/nfs/'
+}
+
+# return the FS mount options of a mounted device
+#
+# should write a version which just parses the output of mount for IRIX
+# compatibility, but since this isn't used at all, at the moment I'll leave
+# this for now
+#
+_fs_options()
+{
+ if [ $# -ne 1 ]
+ then
+ echo "Usage: _fs_options device" 1>&2
+ exit 1
+ fi
+
+ $AWK_PROG -v dev=$1 '
+ match($1,dev) { print $4 }
+ ' </proc/mounts
+}
+
+# returns device number if a file is a block device
+#
+_is_block_dev()
+{
+ if [ $# -ne 1 ]
+ then
+ echo "Usage: _is_block_dev dev" 1>&2
+ exit 1
+ fi
+
+ _dev=$1
+ if [ -L "${_dev}" ]; then
+ _dev=`readlink -f ${_dev}`
+ fi
+
+ if [ -b "${_dev}" ]; then
+ src/lstat64 ${_dev} | $AWK_PROG '/Device type:/ { print $9 }'
+ fi
+}
+
+# Do a command, log it to $RESULT_DIR/$seq.full, optionally test return status
+# and die if command fails. If called with one argument _do executes the
+# command, logs it, and returns its exit status. With two arguments _do
+# first prints the message passed in the first argument, and then "done"
+# or "fail" depending on the return status of the command passed in the
+# second argument. If the command fails and the variable _do_die_on_error
+# is set to "always" or the two argument form is used and _do_die_on_error
+# is set to "message_only" _do will print an error message to
+# $RESULT_DIR/$seq.out and exit.
+
+_do()
+{
+ if [ $# -eq 1 ]; then
+ _cmd=$1
+ elif [ $# -eq 2 ]; then
+ _note=$1
+ _cmd=$2
+ echo -n "$_note... "
+ else
+ echo "Usage: _do [note] cmd" 1>&2
+ status=1; exit
+ fi
+
+ (eval "echo '---' \"$_cmd\"") >>$RESULT_DIR/$seq.full
+ (eval "$_cmd") >$tmp._out 2>&1; ret=$?
+ cat $tmp._out | _fix_malloc >>$RESULT_DIR/$seq.full
+ if [ $# -eq 2 ]; then
+ if [ $ret -eq 0 ]; then
+ echo "done"
+ else
+ echo "fail"
+ fi
+ fi
+ if [ $ret -ne 0 ] \
+ && [ "$_do_die_on_error" = "always" \
+ -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
+ then
+ [ $# -ne 2 ] && echo
+ eval "echo \"$_cmd\" failed \(returned $ret\): see $RESULT_DIR/$seq.full"
+ status=1; exit
+ fi
+
+ return $ret
+}
+
+# bail out, setting up .notrun file
+#
+_notrun()
+{
+ echo "$*" > $RESULT_DIR/$seq.notrun
+ echo "$seq not run: $*"
+ status=0
+ exit
+}
+
+# just plain bail out
+#
+_fail()
+{
+ echo "$*" | tee -a $RESULT_DIR/$seq.full
+ echo "(see $RESULT_DIR/$seq.full for details)"
+ status=1
+ exit 1
+}
+
+# tests whether $FSTYP is one of the supported filesystems for a test
+#
+_supported_fs()
+{
+ for f
+ do
+ if [ "$f" = "$FSTYP" -o "$f" = "generic" ]
+ then
+ return
+ fi
+ done
+
+ _notrun "not suitable for this filesystem type: $FSTYP"
+}
+
+# tests whether $FSTYP is one of the supported OSes for a test
+#
+_supported_os()
+{
+ for h
+ do
+ if [ "$h" = "$HOSTOS" ]
+ then
+ return
+ fi
+ done
+
+ _notrun "not suitable for this OS: $HOSTOS"
+}
+
+# this test needs a scratch partition - check we're ok & unmount it
+#
+_require_scratch()
+{
+ case "$FSTYP" in
+ nfs*)
+ echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
+ if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]
+ then
+ _notrun "this test requires a valid \$SCRATCH_DEV"
+ fi
+ ;;
+ *)
+ if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
+ then
+ _notrun "this test requires a valid \$SCRATCH_DEV"
+ fi
+ if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
+ then
+ _notrun "this test requires a valid \$SCRATCH_DEV"
+ fi
+ if [ ! -d "$SCRATCH_MNT" ]
+ then
+ _notrun "this test requires a valid \$SCRATCH_MNT"
+ fi
+ ;;
+ esac
+
+ # mounted?
+ if _mount | grep -q $SCRATCH_DEV
+ then
+ # if it's mounted, make sure its on $SCRATCH_MNT
+ if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
+ then
+ echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
+ exit 1
+ fi
+ # and then unmount it
+ if ! $UMOUNT_PROG $SCRATCH_DEV
+ then
+ echo "failed to unmount $SCRATCH_DEV"
+ exit 1
+ fi
+ fi
+}
+
+# this test needs a logdev
+#
+_require_logdev()
+{
+ [ -z "$SCRATCH_LOGDEV" -o ! -b "$SCRATCH_LOGDEV" ] && \
+ _notrun "This test requires a valid \$SCRATCH_LOGDEV"
+ [ "$USE_EXTERNAL" != yes ] && \
+ _notrun "This test requires USE_EXTERNAL to be enabled"
+
+ # ensure its not mounted
+ $UMOUNT_PROG $SCRATCH_LOGDEV 2>/dev/null
+}
+
+# this test requires loopback device support
+#
+_require_loop()
+{
+ if [ "$HOSTOS" != "Linux" ]
+ then
+ _notrun "This test requires linux for loopback device support"
+ fi
+
+ modprobe loop >/dev/null 2>&1
+ if grep loop /proc/devices >/dev/null 2>&1
+ then
+ :
+ else
+ _notrun "This test requires loopback device support"
+ fi
+}
+
+# this test requires ext2 filesystem support
+#
+_require_ext2()
+{
+ if [ "$HOSTOS" != "Linux" ]
+ then
+ _notrun "This test requires linux for ext2 filesystem support"
+ fi
+
+ modprobe ext2 >/dev/null 2>&1
+ if grep ext2 /proc/filesystems >/dev/null 2>&1
+ then
+ :
+ else
+ _notrun "This test requires ext2 filesystem support"
+ fi
+}
+
+# this test requires that (large) loopback device files are not in use
+#
+_require_no_large_scratch_dev()
+{
+ [ "$LARGE_SCRATCH_DEV" = yes ] && \
+ _notrun "Large filesystem testing in progress, skipped this test"
+}
+
+# this test requires that a realtime subvolume is in use, and
+# that the kernel supports realtime as well.
+#
+_require_realtime()
+{
+ [ "$USE_EXTERNAL" = yes ] || \
+ _notrun "External volumes not in use, skipped this test"
+ [ "$SCRATCH_RTDEV" = "" ] && \
+ _notrun "Realtime device required, skipped this test"
+}
+
+# this test requires that a specified command (executable) exists
+# $1 - command, $2 - name for error message
+#
+_require_command()
+{
+ [ -n "$1" ] && _cmd="$1" || _cmd="$2"
+ [ -n "$1" -a -x "$1" ] || _notrun "$_cmd utility required, skipped this test"
+}
+
+# this test requires the projid32bit feature to be available in
+# mkfs.xfs
+#
+_require_projid32bit()
+{
+ _scratch_mkfs_xfs -f -i projid32bit=0 2>&1 >/dev/null \
+ || _notrun "mkfs.xfs doesn't have projid32bit feature"
+}
+
+# this test requires that external log/realtime devices are not in use
+#
+_require_nonexternal()
+{
+ [ "$USE_EXTERNAL" = yes ] && \
+ _notrun "External device testing in progress, skipped this test"
+}
+
+# this test requires that a (specified) aio-dio executable exists
+# $1 - command (optional)
+#
+_require_aiodio()
+{
+ if [ -z "$1" ]
+ then
+ AIO_TEST=src/aio-dio-regress/aiodio_sparse2
+ [ -x $AIO_TEST ] || _notrun "aio-dio utilities required"
+ else
+ AIO_TEST=src/aio-dio-regress/$1
+ [ -x $AIO_TEST ] || _notrun "$AIO_TEST not built"
+ fi
+}
+
+# run an aio-dio program
+# $1 - command
+_run_aiodio()
+{
+ if [ -z "$1" ]
+ then
+ echo "usage: _run_aiodio command_name" 2>&1
+ status=1; exit 1
+ fi
+
+ _require_aiodio $1
+
+ local testtemp=$TEST_DIR/aio-testfile
+ rm -f $testtemp
+ $AIO_TEST $testtemp 2>&1
+ status=$?
+ rm -f $testtemp
+
+ return $status
+}
+
+# indicate whether YP/NIS is active or not
+#
+_yp_active()
+{
+ local dn
+ dn=$(domainname 2>/dev/null)
+ test -n "${dn}" -a "${dn}" != "(none)"
+ echo $?
+}
+
+# cat the password file
+#
+_cat_passwd()
+{
+ [ $(_yp_active) -eq 0 ] && ypcat passwd
+ cat /etc/passwd
+}
+
+# cat the group file
+#
+_cat_group()
+{
+ [ $(_yp_active) -eq 0 ] && ypcat group
+ cat /etc/group
+}
+
+# check for the fsgqa user on the machine
+#
+_require_user()
+{
+ qa_user=fsgqa
+ _cat_passwd | grep -q $qa_user
+ [ "$?" == "0" ] || _notrun "$qa_user user not defined."
+ echo /bin/true | su $qa_user
+ [ "$?" == "0" ] || _notrun "$qa_user cannot execute commands."
+}
+
+# check for the fsgqa group on the machine
+#
+_require_group()
+{
+ qa_group=fsgqa
+ _cat_group | grep -q $qa_group
+ [ "$?" == "0" ] || _notrun "$qa_group user not defined."
+}
+
+_filter_user_do()
+{
+ perl -ne "
+s,.*Permission\sdenied.*,Permission denied,;
+s,.*no\saccess\sto\stty.*,,;
+s,.*no\sjob\scontrol\sin\sthis\sshell.*,,;
+s,^\s*$,,;
+ print;"
+}
+
+_user_do()
+{
+ if [ "$HOSTOS" == "IRIX" ]
+ then
+ echo $1 | /bin/bash "su $qa_user 2>&1" | _filter_user_do
+ else
+ echo $1 | su $qa_user 2>&1 | _filter_user_do
+ fi
+}
+
+# check that xfs_io, kernel, and filesystem all support zero
+_require_xfs_io_zero()
+{
+ testio=`$XFS_IO_PROG -c "zero help" 2>&1`
+ echo $testio | grep -q 'command "zero" not found' && \
+ _notrun "zero command not supported"
+}
+
+# check that xfs_io, glibc, kernel, and filesystem all (!) support
+# fallocate
+#
+_require_xfs_io_falloc()
+{
+ testfile=$TEST_DIR/$$.falloc
+ testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $testfile 2>&1`
+ rm -f $testfile 2>&1 > /dev/null
+ echo $testio | grep -q "not found" && \
+ _notrun "xfs_io fallocate support is missing"
+ echo $testio | grep -q "Operation not supported" && \
+ _notrun "xfs_io fallocate command failed (old kernel/wrong fs?)"
+}
+
+# check that xfs_io, kernel and filesystem all support fallocate with hole
+# punching
+_require_xfs_io_falloc_punch()
+{
+ testfile=$TEST_DIR/$$.falloc
+ testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
+ -c "fpunch 4k 8k" $testfile 2>&1`
+ rm -f $testfile 2>&1 > /dev/null
+ echo $testio | grep -q "not found" && \
+ _notrun "xfs_io fallocate punch support is missing"
+ echo $testio | grep -q "Operation not supported" && \
+ _notrun "xfs_io fallocate punch command failed (no fs support?)"
+}
+
+# check that xfs_io, kernel and filesystem support fiemap
+_require_xfs_io_fiemap()
+{
+ testfile=$TEST_DIR/$$.fiemap
+ testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
+ -c "fiemap -v" $testfile 2>&1`
+ rm -f $testfile 2>&1 > /dev/null
+ echo $testio | grep -q "not found" && \
+ _notrun "xfs_io fiemap support is missing"
+ echo $testio | grep -q "Operation not supported" && \
+ _notrun "xfs_io fiemap command failed (no fs support?)"
+}
+
+# Check that a fs has enough free space (in 1024b blocks)
+#
+_require_fs_space()
+{
+ MNT=$1
+ BLOCKS=$2 # in units of 1024
+ let GB=$BLOCKS/1024/1024
+
+ FREE_BLOCKS=`df -klP $MNT | grep -v Filesystem | awk '{print $4}'`
+ [ $FREE_BLOCKS -lt $BLOCKS ] && \
+ _notrun "This test requires at least ${GB}GB free on $MNT to run"
+}
+
+#
+# Check if the filesystem supports sparse files.
+#
+# Unfortunately there is no better way to do this than a manual black list.
+#
+_require_sparse_files()
+{
+ case $FSTYP in
+ hfsplus)
+ _notrun "Sparse files not supported by this filesystem type: $FSTYP"
+ ;;
+ *)
+ ;;
+ esac
+}
+
+_require_debugfs()
+{
+ #boot_params always present in debugfs
+ [ -d "$DEBUGFS_MNT/boot_params" ] || _notrun "Debugfs not mounted"
+}
+
+_require_fail_make_request()
+{
+ [ -f "$DEBUGFS_MNT/fail_make_request/probability" ] \
+ || _notrun "$DEBUGFS_MNT/fail_make_request \
+ not found. Seems that CONFIG_FAIL_MAKE_REQUEST kernel config option not enabled"
+}
+
+# check that a FS on a device is mounted
+# if so, return mount point
+#
+_is_mounted()
+{
+ if [ $# -ne 1 ]
+ then
+ echo "Usage: _is_mounted device" 1>&2
+ exit 1
+ fi
+
+ device=$1
+
+ if _mount | grep "$device " | $AWK_PROG -v pattern="type $FSTYP" '
+ pattern { print $3 ; exit 0 }
+ END { exit 1 }
+ '
+ then
+ echo "_is_mounted: $device is not a mounted $FSTYP FS"
+ exit 1
+ fi
+}
+
+# remount a FS to a new mode (ro or rw)
+#
+_remount()
+{
+ if [ $# -ne 2 ]
+ then
+ echo "Usage: _remount device ro/rw" 1>&2
+ exit 1
+ fi
+ device=$1
+ mode=$2
+
+ if ! mount -o remount,$mode $device
+ then
+ echo "_remount: failed to remount filesystem on $device as $mode"
+ exit 1
+ fi
+}
+
+# Run the appropriate repair/check on a filesystem
+#
+# if the filesystem is mounted, it's either remounted ro before being
+# checked or it's unmounted and then remounted
+#
+
+# If set, we remount ro instead of unmounting for fsck
+USE_REMOUNT=0
+
+_umount_or_remount_ro()
+{
+ if [ $# -ne 1 ]
+ then
+ echo "Usage: _umount_or_remount_ro <device>" 1>&2
+ exit 1
+ fi
+
+ device=$1
+ mountpoint=`_is_mounted $device`
+
+ if [ $USE_REMOUNT -eq 0 ]; then
+ $UMOUNT_PROG $device
+ else
+ _remount $device ro
+ fi
+ echo "$mountpoint"
+}
+
+_mount_or_remount_rw()
+{
+ if [ $# -ne 3 ]
+ then
+ echo "Usage: _mount_or_remount_rw <opts> <device> <mountpoint>" 1>&2
+ exit 1
+ fi
+ mount_opts=$1
+ device=$2
+ mountpoint=$3
+
+ if [ $USE_REMOUNT -eq 0 ]
+ then
+ if ! _mount -t $FSTYP $mount_opts $device $mountpoint
+ then
+ echo "!!! failed to remount $device on $mountpoint"
+ return 0 # ok=0
+ fi
+ else
+ _remount $device rw
+ fi
+
+ return 1 # ok=1
+}
+
+# Check a generic filesystem in no-op mode; this assumes that the
+# underlying fsck program accepts "-n" for a no-op (check-only) run,
+# and that it will still return an errno for corruption in this mode.
+#
+# Filesystems which don't support this will need to define their
+# own check routine.
+#
+_check_generic_filesystem()
+{
+ device=$1
+
+ # If type is set, we're mounted
+ type=`_fs_type $device`
+ ok=1
+
+ if [ "$type" = "$FSTYP" ]
+ then
+ # mounted ...
+ mountpoint=`_umount_or_remount_ro $device`
+ fi
+
+ fsck -t $FSTYP $FSCK_OPTIONS $device >$tmp.fsck 2>&1
+ if [ $? -ne 0 ]
+ then
+ echo "_check_generic_filesystem: filesystem on $device is inconsistent (see $RESULT_DIR/$seq.full)"
+
+ echo "_check_generic filesystem: filesystem on $device is inconsistent" >>$RESULT_DIR/$seq.full
+ echo "*** fsck.$FSTYP output ***" >>$RESULT_DIR/$seq.full
+ cat $tmp.fsck >>$RESULT_DIR/$seq.full
+ echo "*** end fsck.$FSTYP output" >>$RESULT_DIR/$seq.full
+
+ ok=0
+ fi
+ rm -f $tmp.fsck
+
+ if [ $ok -eq 0 ]
+ then
+ echo "*** mount output ***" >>$RESULT_DIR/$seq.full
+ _mount >>$RESULT_DIR/$seq.full
+ echo "*** end mount output" >>$RESULT_DIR/$seq.full
+ elif [ "$type" = "$FSTYP" ]
+ then
+ # was mounted ...
+ _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
+ ok=$?
+ fi
+
+ if [ $ok -eq 0 ]; then
+ status=1
+ exit 1
+ fi
+
+ return 0
+}
+
+# run xfs_check and friends on a FS.
+
+_check_xfs_filesystem()
+{
+ if [ $# -ne 3 ]
+ then
+ echo "Usage: _check_xfs_filesystem device <logdev>|none <rtdev>|none" 1>&2
+ exit 1
+ fi
+
+ extra_mount_options=""
+ device=$1
+ if [ "$2" != "none" ]; then
+ extra_log_options="-l$2"
+ extra_mount_options="-ologdev=$2"
+ fi
+
+ if [ "$3" != "none" ]; then
+ extra_rt_options="-r$3"
+ extra_mount_options=$extra_mount_options" -ortdev=$3"
+ fi
+ extra_mount_options=$extra_mount_options" $MOUNT_OPTIONS"
+
+ [ "$FSTYP" != xfs ] && return 0
+
+ type=`_fs_type $device`
+ ok=1
+
+ if [ "$type" = "xfs" ]
+ then
+ # mounted ...
+ mountpoint=`_umount_or_remount_ro $device`
+ fi
+
+ $XFS_LOGPRINT_PROG -t $extra_log_options $device 2>&1 \
+ | tee $tmp.logprint | grep -q "<CLEAN>"
+ if [ $? -ne 0 -a "$HOSTOS" = "Linux" ]
+ then
+ echo "_check_xfs_filesystem: filesystem on $device has dirty log (see $RESULT_DIR/$seq.full)"
+
+ echo "_check_xfs_filesystem: filesystem on $device has dirty log" >>$RESULT_DIR/$seq.full
+ echo "*** xfs_logprint -t output ***" >>$RESULT_DIR/$seq.full
+ cat $tmp.logprint >>$RESULT_DIR/$seq.full
+ echo "*** end xfs_logprint output" >>$RESULT_DIR/$seq.full
+
+ ok=0
+ fi
+
+ # xfs_check runs out of memory on large files, so even providing the test
+ # option (-t) to avoid indexing the free space trees doesn't make it pass on
+ # large filesystems. Avoid it.
+ if [ "$LARGE_SCRATCH_DEV" != yes ]; then
+ $XFS_CHECK_PROG $extra_log_options $device 2>&1 |\
+ _fix_malloc >$tmp.fs_check
+ fi
+ if [ -s $tmp.fs_check ]
+ then
+ echo "_check_xfs_filesystem: filesystem on $device is inconsistent (c) (see $RESULT_DIR/$seq.full)"
+
+ echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$RESULT_DIR/$seq.full
+ echo "*** xfs_check output ***" >>$RESULT_DIR/$seq.full
+ cat $tmp.fs_check >>$RESULT_DIR/$seq.full
+ echo "*** end xfs_check output" >>$RESULT_DIR/$seq.full
+
+ ok=0
+ fi
+
+ $XFS_REPAIR_PROG -n $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
+ if [ $? -ne 0 ]
+ then
+ echo "_check_xfs_filesystem: filesystem on $device is inconsistent (r) (see $RESULT_DIR/$seq.full)"
+
+ echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$RESULT_DIR/$seq.full
+ echo "*** xfs_repair -n output ***" >>$RESULT_DIR/$seq.full
+ cat $tmp.repair | _fix_malloc >>$RESULT_DIR/$seq.full
+ echo "*** end xfs_repair output" >>$RESULT_DIR/$seq.full
+
+ ok=0
+ fi
+ rm -f $tmp.fs_check $tmp.logprint $tmp.repair
+
+ if [ $ok -eq 0 ]
+ then
+ echo "*** mount output ***" >>$RESULT_DIR/$seq.full
+ _mount >>$RESULT_DIR/$seq.full
+ echo "*** end mount output" >>$RESULT_DIR/$seq.full
+ elif [ "$type" = "xfs" ]
+ then
+ _mount_or_remount_rw "$extra_mount_options" $device $mountpoint
+ fi
+
+ if [ $ok -eq 0 ]; then
+ status=1
+ exit 1
+ fi
+
+ return 0
+}
+
+# Filter the knowen errors the UDF Verifier reports.
+_udf_test_known_error_filter()
+{
+ egrep -v "PVD 60 Error: Interchange Level: 1, Maximum Interchange Level: 0|FSD 28 Error: Interchange Level: 1, Maximum Interchange Level: 1,|PVD 72 Warning: Volume Set Identifier: \"\*IRIX UDF\",|Warning: [0-9]+ unused blocks NOT marked as unallocated."
+
+}
+
+_check_udf_filesystem()
+{
+ [ "$DISABLE_UDF_TEST" == "1" ] && return
+
+ if [ $# -ne 1 -a $# -ne 2 ]
+ then
+ echo "Usage: _check_udf_filesystem device [last_block]" 1>&2
+ exit 1
+ fi
+
+ if [ ! -x $here/src/udf_test ]
+ then
+ echo "udf_test not installed, please download and build the Philips"
+ echo "UDF Verification Software from http://www.extra.research.philips.com/udf/."
+ echo "Then copy the udf_test binary to $here/src/."
+ echo "If you do not wish to run udf_test then set environment variable DISABLE_UDF_TEST"
+ echo "to 1."
+ return
+ fi
+
+ device=$1
+ if [ $# -eq 2 ];
+ then
+ LAST_BLOCK=`expr \( $2 - 1 \)`
+ OPT_ARG="-lastvalidblock $LAST_BLOCK"
+ fi
+
+ rm -f $RESULT_DIR/$seq.checkfs
+ sleep 1 # Due to a problem with time stamps in udf_test
+ $here/src/udf_test $OPT_ARG $device | tee $RESULT_DIR/$seq.checkfs | egrep "Error|Warning" | \
+ _udf_test_known_error_filter | \
+ egrep -iv "Error count:.*[0-9]+.*total occurrences:.*[0-9]+|Warning count:.*[0-9]+.*total occurrences:.*[0-9]+" | \
+ sed "s/^.*$/Warning UDF Verifier reported errors see $RESULT_DIR/$seq.checkfs./g"
+
+}
+
+_check_xfs_test_fs()
+{
+ TEST_LOG="none"
+ TEST_RT="none"
+ [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
+ TEST_LOG="$TEST_LOGDEV"
+
+ [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
+ TEST_RT="$TEST_RTDEV"
+
+ _check_xfs_filesystem $TEST_DEV $TEST_LOG $TEST_RT
+
+ # check for ipath consistency
+ if $XFS_GROWFS_PROG -n $TEST_DIR | grep -q 'inode-paths=1'; then
+ # errors go to stderr
+ xfs_check_ipaths $TEST_DIR >/dev/null
+ xfs_repair_ipaths -n $TEST_DIR >/dev/null
+ fi
+}
+
+_check_btrfs_filesystem()
+{
+ device=$1
+
+ # If type is set, we're mounted
+ type=`_fs_type $device`
+ ok=1
+
+ if [ "$type" = "$FSTYP" ]
+ then
+ # mounted ...
+ mountpoint=`_umount_or_remount_ro $device`
+ fi
+
+ btrfsck $device >$tmp.fsck 2>&1
+ if [ $? -ne 0 ]
+ then
+ echo "_check_btrfs_filesystem: filesystem on $device is inconsistent (see $RESULT_DIR/$seq.full)"
+
+ echo "_check_btrfs_filesystem: filesystem on $device is inconsistent" >>$RESULT_DIR/$seq.full
+ echo "*** fsck.$FSTYP output ***" >>$RESULT_DIR/$seq.full
+ cat $tmp.fsck >>$RESULT_DIR/$seq.full
+ echo "*** end fsck.$FSTYP output" >>$RESULT_DIR/$seq.full
+
+ ok=0
+ fi
+ rm -f $tmp.fsck
+
+ if [ $ok -eq 0 ]
+ then
+ echo "*** mount output ***" >>$RESULT_DIR/$seq.full
+ _mount >>$RESULT_DIR/$seq.full
+ echo "*** end mount output" >>$RESULT_DIR/$seq.full
+ elif [ "$type" = "$FSTYP" ]
+ then
+ # was mounted ...
+ _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
+ ok=$?
+ fi
+
+ if [ $ok -eq 0 ]; then
+ status=1
+ exit 1
+ fi
+
+ return 0
+}
+
+_check_test_fs()
+{
+ case $FSTYP in
+ xfs)
+ _check_xfs_test_fs
+ ;;
+ nfs)
+ # no way to check consistency for nfs
+ ;;
+ udf)
+ # do nothing for now
+ ;;
+ btrfs)
+ _check_btrfs_filesystem $TEST_DEV
+ ;;
+ *)
+ _check_generic_filesystem $TEST_DEV
+ ;;
+ esac
+}
+
+_check_scratch_fs()
+{
+ case $FSTYP in
+ xfs)
+ SCRATCH_LOG="none"
+ SCRATCH_RT="none"
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+ SCRATCH_LOG="$SCRATCH_LOGDEV"
+
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
+ SCRATCH_RT="$SCRATCH_RTDEV"
+
+ _check_xfs_filesystem $SCRATCH_DEV $SCRATCH_LOG $SCRATCH_RT
+ ;;
+ udf)
+ _check_udf_filesystem $SCRATCH_DEV $udf_fsize
+ ;;
+ nfs*)
+ # Don't know how to check an NFS filesystem, yet.
+ ;;
+ btrfs)
+ _check_btrfs_filesystem $SCRATCH_DEV
+ ;;
+ *)
+ _check_generic_filesystem $SCRATCH_DEV
+ ;;
+ esac
+}
+
+_full_fstyp_details()
+{
+ [ -z "$FSTYP" ] && FSTYP=xfs
+ if [ $FSTYP = xfs ]; then
+ if [ -d /proc/fs/xfs ]; then
+ if grep -q 'debug 0' /proc/fs/xfs/stat; then
+ FSTYP="$FSTYP (non-debug)"
+ elif grep -q 'debug 1' /proc/fs/xfs/stat; then
+ FSTYP="$FSTYP (debug)"
+ fi
+ else
+ if uname -a | grep -qi 'debug'; then
+ FSTYP="$FSTYP (debug)"
+ else
+ FSTYP="$FSTYP (non-debug)"
+ fi
+ fi
+ fi
+ echo $FSTYP
+}
+
+_full_platform_details()
+{
+ os=`uname -s`
+ host=`hostname -s`
+ kernel=`uname -r`
+ platform=`uname -m`
+ echo "$os/$platform $host $kernel"
+}
+
+_setup_udf_scratchdir()
+{
+ [ "$FSTYP" != "udf" ] \
+ && _fail "setup_udf_testdir: \$FSTYP is not udf"
+ [ -z "$SCRATCH_DEV" -o ! -b "$SCRATCH_DEV" ] \
+ && _notrun "this test requires a valid \$SCRATCH_DEV"
+ [ -z "$SCRATCH_MNT" ] \
+ && _notrun "this test requires a valid \$SCRATCH_MNT"
+
+ # mounted?
+ if _mount | grep -q $SCRATCH_DEV
+ then
+ # if it's mounted, make sure its on $TEST_RW_DIR
+ if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
+ then
+ _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
+ fi
+ $UMOUNT_PROG $SCRATCH_DEV
+ fi
+
+ _scratch_mkfs
+ _scratch_mount
+
+ testdir=$SCRATCH_MNT
+}
+
+_setup_nfs_scratchdir()
+{
+ [ "$FSTYP" != "nfs" ] \
+ && _fail "setup_nfs_testdir: \$FSTYP is not nfs"
+ [ -z "$SCRATCH_DEV" ] \
+ && _notrun "this test requires a valid host fs for \$SCRATCH_DEV"
+ [ -z "$SCRATCH_MNT" ] \
+ && _notrun "this test requires a valid \$SCRATCH_MNT"
+
+ # mounted?
+ if _mount | grep -q $SCRATCH_DEV
+ then
+ # if it's mounted, make sure its on $SCRATCH_MNT
+ if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
+ then
+ _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
+ fi
+ $UMOUNT_PROG $SCRATCH_DEV
+ fi
+
+ _scratch_mkfs
+ _scratch_mount
+
+ testdir=$SCRATCH_MNT
+}
+
+#
+# Warning for UDF and NFS:
+# this function calls _setup_udf_scratchdir and _setup_udf_scratchdir
+# which actually uses the scratch dir for the test dir.
+#
+# This was done because testdir was intended to be a persistent
+# XFS only partition. This should eventually change, and treat
+# at least local filesystems all the same.
+#
+_setup_testdir()
+{
+ case $FSTYP in
+ udf)
+ _setup_udf_scratchdir
+ ;;
+ nfs*)
+ _setup_nfs_scratchdir
+ ;;
+ *)
+ testdir=$TEST_DIR
+ ;;
+ esac
+}
+
+_cleanup_testdir()
+{
+ case $FSTYP in
+ udf)
+ # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
+ [ -n "$testdir" ] && $UMOUNT_PROG $testdir
+ ;;
+ nfs*)
+ # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
+ [ -n "$testdir" ] && $UMOUNT_PROG $testdir
+ ;;
+ *)
+ # do nothing, testdir is $TEST_DIR
+ :
+ ;;
+ esac
+}
+
+_link_out_file()
+{
+ if [ -z "$1" -o -z "$2" ]; then
+ echo Error must pass src and dst.
+ exit
+ fi
+ rm -f $2
+ if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
+ ln -s $1.irix $2
+ elif [ "`uname`" == "Linux" ]; then
+ ln -s $1.linux $2
+ else
+ echo Error test $seq does not run on the operating system: `uname`
+ exit
+ fi
+}
+
+_die()
+{
+ echo $@
+ exit 1
+}
+
+#takes files, randomdata
+_nfiles()
+{
+ f=0
+ while [ $f -lt $1 ]
+ do
+ file=f$f
+ echo > $file
+ if [ $size -gt 0 ]; then
+ if [ "$2" == "false" ]; then
+ dd if=/dev/zero of=$file bs=1024 count=$size 2>&1 | _filter_dd
+ else
+ dd if=/dev/urandom of=$file bs=1024 count=$size 2>&1 | _filter_dd
+ fi
+ fi
+ let f=$f+1
+ done
+}
+
+# takes dirname, depth, randomdata
+_descend()
+{
+ dirname=$1; depth=$2; randomdata=$3
+ mkdir $dirname || die "mkdir $dirname failed"
+ cd $dirname
+
+ _nfiles $files $randomdata # files for this dir and data type
+
+ [ $depth -eq 0 ] && return
+ let deep=$depth-1 # go 1 down
+
+ [ $verbose = true ] && echo "descending, depth from leaves = $deep"
+
+ d=0
+ while [ $d -lt $dirs ]
+ do
+ _descend d$d $deep &
+ let d=$d+1
+ wait
+ done
+}
+
+# Populate a filesystem with inodes for performance experiments
+#
+# usage: populate [-v] [-n ndirs] [-f nfiles] [-d depth] [-r root] [-s size] [-x]
+#
+_populate_fs()
+{
+ here=`pwd`
+ dirs=5 # ndirs in each subdir till leaves
+ size=0 # sizeof files in K
+ files=100 # num files in _each_ subdir
+ depth=2 # depth of tree from root to leaves
+ verbose=false
+ root=root # path of initial root of directory tree
+ randomdata=false # -x data type urandom or zero
+
+ OPTIND=1
+ while getopts "d:f:n:r:s:v:x" c
+ do
+ case $c in
+ d) depth=$OPTARG;;
+ n) dirs=$OPTARG;;
+ f) files=$OPTARG;;
+ s) size=$OPTARG;;
+ v) verbose=true;;
+ r) root=$OPTARG;;
+ x) randomdata=true;;
+ esac
+ done
+
+ _descend $root $depth $randomdata
+ wait
+
+ cd $here
+
+ [ $verbose = true ] && echo done
+}
+
+# query whether the given file has the given inode flag set
+#
+_test_inode_flag()
+{
+ flag=$1
+ file=$2
+
+ if which $XFS_IO_PROG >/dev/null; then
+ if $XFS_IO_PROG -r -c 'lsattr -v' "$file" | grep -q "$flag" ; then
+ return 0
+ fi
+ fi
+ return 1
+}
+
+# query the given files extsize allocator hint in bytes (if any)
+#
+_test_inode_extsz()
+{
+ file=$1
+ blocks=""
+
+ if which $XFS_IO_PROG >/dev/null; then
+ blocks=`$XFS_IO_PROG -r -c 'stat' "$file" | \
+ awk '/^xattr.extsize =/ { print $3 }'`
+ fi
+ [ -z "$blocks" ] && blocks="0"
+ echo $blocks
+}
+
+# scratch_dev_pool should contain the disks pool for the btrfs raid
+_require_scratch_dev_pool()
+{
+ local i
+ if [ -z "$SCRATCH_DEV_POOL" ]; then
+ _notrun "this test requires a valid \$SCRATCH_DEV_POOL"
+ fi
+
+ # btrfs test case needs 2 or more scratch_dev_pool; other FS not sure
+ # so fail it
+ case $FSTYP in
+ btrfs)
+ if [ "`echo $SCRATCH_DEV_POOL|wc -w`" -lt 2 ]; then
+ _notrun "btrfs and this test needs 2 or more disks in SCRATCH_DEV_POOL"
+ fi
+ ;;
+ *)
+ _notrun "dev_pool is not supported by fstype \"$FSTYP\""
+ ;;
+ esac
+
+ for i in $SCRATCH_DEV_POOL; do
+ if [ "`_is_block_dev $i`" = "" ]; then
+ _notrun "this test requires valid block disk $i"
+ fi
+ if [ "`_is_block_dev $i`" = "`_is_block_dev $TEST_DEV`" ]; then
+ _notrun "$i is part of TEST_DEV, this test requires unique disks"
+ fi
+ if _mount | grep -q $i; then
+ if ! $UMOUNT_PROG $i; then
+ echo "failed to unmount $i - aborting"
+ exit 1
+ fi
+ fi
+ # to help better debug when something fails, we remove
+ # traces of previous btrfs FS on the dev.
+ dd if=/dev/zero of=$i bs=4096 count=100 > /dev/null 2>&1
+ done
+}
+
+# We will check if the device is virtual (eg: loop device) since it does not
+# have the delete entry-point. Otherwise SCSI and USB devices are fine.
+_require_deletable_scratch_dev_pool()
+{
+ local i
+ local x
+ for i in $SCRATCH_DEV_POOL; do
+ x=`echo $i | cut -d"/" -f 3`
+ ls -l /sys/class/block/${x} | grep -q "virtual"
+ if [ $? == "0" ]; then
+ _notrun "$i is a virtual device which is not deletable"
+ fi
+ done
+}
+
+# We check for btrfs and (optionally) features of the btrfs command
+_require_btrfs()
+{
+ cmd=$1
+ _require_command $BTRFS_UTIL_PROG btrfs
+ if [ -z "$1" ]; then
+ return 1;
+ fi
+ $BTRFS_UTIL_PROG $cmd --help >/dev/null 2>&1
+ [ $? -eq 0 ] || _notrun "$BTRFS_UTIL_PROG too old (must support $cmd)"
+}
+
+# Check that fio is present, and it is able to execute given jobfile
+_require_fio()
+{
+ job=$1
+
+ _require_command $FIO_PROG
+ if [ -z "$1" ]; then
+ return 1;
+ fi
+
+ $FIO_PROG --warnings-fatal --showcmd $job >/dev/null 2>&1
+ [ $? -eq 0 ] || _notrun "$FIO_PROG too old"
+}
+
+# Does freeze work on this fs?
+_require_freeze()
+{
+ xfs_freeze -f "$TEST_DIR" >/dev/null 2>&1
+ result=$?
+ xfs_freeze -u "$TEST_DIR" >/dev/null 2>&1
+ [ $result -eq 0 ] || _notrun "$FSTYP does not support freezing"
+}
+
+# arg 1 is dev to remove and is output of the below eg.
+# ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
+_devmgt_remove()
+{
+ echo 1 > /sys/class/scsi_device/${1}/device/delete || _fail "Remove disk failed"
+}
+
+# arg 1 is dev to add and is output of the below eg.
+# ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
+_devmgt_add()
+{
+ local h
+ local tdl
+ # arg 1 will be in h:t:d:l format now in the h and "t d l" format
+ h=`echo ${1} | cut -d":" -f 1`
+ tdl=`echo ${1} | cut -d":" -f 2-|sed 's/:/ /g'`
+
+ echo ${tdl} > /sys/class/scsi_host/host${h}/scan || _fail "Add disk failed"
+}
+
+_require_fstrim()
+{
+ if [ -z "$FSTRIM_PROG" ]; then
+ _notrun "This test requires fstrim utility."
+ fi
+}
+
+_test_batched_discard()
+{
+ if [ $# -ne 1 ]; then
+ echo "Usage: _test_batched_discard mnt_point" 1>&2
+ exit 1
+ fi
+ _require_fstrim
+ $FSTRIM_PROG ${1} &>/dev/null
+}
+
+_require_dumpe2fs()
+{
+ if [ -z "$DUMPE2FS_PROG" ]; then
+ _notrun "This test requires dumpe2fs utility."
+ fi
+}
+
+_create_loop_device()
+{
+ file=$1
+ dev=`losetup -f --show $file` || _fail "Cannot assign $file to a loop device"
+ echo $dev
+}
+
+_destroy_loop_device()
+{
+ dev=$1
+ losetup -d $dev || _fail "Cannot destroy loop device $dev"
+}
+
+_scale_fsstress_args()
+{
+ args=""
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ -n) args="$args $1 $(($2 * $TIME_FACTOR))"; shift ;;
+ -p) args="$args $1 $(($2 * $LOAD_FACTOR))"; shift ;;
+ *) args="$args $1" ;;
+ esac
+ shift
+ done
+ echo $args
+}
+
+run_check()
+{
+ echo "# $@" >> $RESULT_DIR/$seq.full 2>&1
+ "$@" >> $RESULT_DIR/$seq.full 2>&1 || _fail "failed: '$@'"
+}
+
+################################################################################
+
+if [ "$iam" != new ]
+then
+ # make some further configuration checks here
+
+ if [ "$TEST_DEV" = "" ]
+ then
+ echo "common.rc: Error: \$TEST_DEV is not set"
+ exit 1
+ fi
+
+ # if $TEST_DEV is not mounted, mount it now as XFS
+ if [ -z "`_fs_type $TEST_DEV`" ]
+ then
+ # $TEST_DEV is not mounted
+ if ! _test_mount
+ then
+ echo "common.rc: retrying test device mount with external set"
+ [ "$USE_EXTERNAL" != "yes" ] && export USE_EXTERNAL=yes
+ if ! _test_mount
+ then
+ echo "common.rc: could not mount $TEST_DEV on $TEST_DIR"
+ exit 1
+ fi
+ fi
+ fi
+
+ if [ "`_fs_type $TEST_DEV`" != "$FSTYP" ]
+ then
+ echo "common.rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED $FSTYP filesystem"
+ $DF_PROG $TEST_DEV
+ exit 1
+ fi
+fi
+
+# make sure this script returns success
+/bin/true
--- /dev/null
+##/bin/bash
+#
+# 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
+#
+#
+# Functions useful for xfs_repair tests
+#
+
+_zero_position()
+{
+ value=$1
+ struct="$2"
+
+ # set values for off/len variables provided by db
+ eval `xfs_db -r -c "$struct" -c stack $SCRATCH_DEV | perl -ne '
+ if (/byte offset (\d+), length (\d+)/) {
+ print "offset=$1\nlength=$2\n"; exit
+ }'`
+ if [ -z "$offset" -o -z "$length" ]; then
+ echo "cannot calculate offset ($offset) or length ($length)"
+ exit
+ fi
+ length=`expr $length / 512`
+ src/devzero -v $value -b 1 -n $length -o $offset $SCRATCH_DEV \
+ | perl -npe 's/\d\.\d\dKb/X.XXKb/g'
+}
+
+_filter_repair()
+{
+ perl -ne '
+# for sb
+/- agno = / && next; # remove each AG line (variable number)
+s/(pointer to) (\d+)/\1 INO/;
+s/(sb root inode value) (\d+)( \(NULLFSINO\))?/\1 INO/;
+s/(realtime bitmap inode) (\d+)( \(NULLFSINO\))?/\1 INO/;
+s/(realtime summary inode) (\d+)( \(NULLFSINO\))?/\1 INO/;
+s/(inconsistent with calculated value) (\d+)/\1 INO/;
+s/\.+(found)/\1/g; # remove "searching" output
+# for agf + agi
+s/(bad length -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
+s/(bad length # -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
+s/(bad agbno) (\d+)/\1 AGBNO/g;
+s/(max =) (\d+)/\1 MAX/g;
+# for root inos
+s/(on inode) (\d+)/\1 INO/g;
+s/(imap claims a free inode) (\d+)/\1 INO/;
+s/(imap claims in-use inode) (\d+)/\1 INO/;
+s/(cleared root inode) (\d+)/\1 INO/;
+s/(resetting inode) (\d+)/\1 INO/;
+s/(disconnected dir inode) (\d+)/\1 INO/;
+# for log
+s/internal log/<TYPEOF> log/g;
+s/external log on \S+/<TYPEOF> log/g;
+# realtime subvol - remove this whole line if it appears
+s/ - generate realtime summary info and bitmap...\n//g;
+#
+# new xfs repair output filters
+#
+s/\s+- creating \d+ worker thread\(s\)\n//g;
+s/\s+- reporting progress in intervals of \d+ minutes\n//g;
+s/\s+- \d+:\d\d:\d\d:.*\n//g;
+# 3.1.0 extra accounting output
+/^agf_/ && next; # remove agf counts
+/^agi_/ && next; # remove agi counts
+/^sb_/ && next; # remove sb counts
+/^agi unlinked/ && next; # remove agi unlinked bucket warning
+# crc enabled filesystem output
+/XFS_CORRUPTION_ERROR/ && next;
+/^bad uuid/ && next;
+ print;'
+}
+
+_filter_dd()
+{
+ fgrep -v records # lose records in/out lines
+}
+
+# do some controlled corrupting & ensure repair recovers us
+#
+_check_repair()
+{
+ value=$1
+ structure="$2"
+
+ #ensure the filesystem has been dirtied since last repair
+ _scratch_mount
+ POSIXLY_CORRECT=yes \
+ dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd
+ sync
+ rm -f $SCRATCH_MNT/sh
+ umount $SCRATCH_MNT
+
+ _zero_position $value "$structure"
+ _scratch_xfs_repair 2>&1 | _filter_repair
+
+ # some basic sanity checks...
+ _check_scratch_fs
+ _scratch_mount #mount
+ POSIXLY_CORRECT=yes \
+ dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd #open,write
+ POSIXLY_CORRECT=yes \
+ dd if=$SCRATCH_MNT/sh of=/dev/null 2>&1 |_filter_dd #read
+ rm -f $SCRATCH_MNT/sh #unlink
+ umount $SCRATCH_MNT #umount
+}
+
+# make sure this script returns success
+/bin/true
--- /dev/null
+##/bin/bash
+#
+# Copyright (c) 2012 Red Hat, Inc
+# All Rights Reserved.
+#
+# Written by Eric Sandeen <sandeen@redhat.com>
+#
+# 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 tests on unique block devices
+#
+
+_require_scsi_debug()
+{
+ # make sure we have the module and it's not already used
+ modinfo scsi_debug 2>&1 > /dev/null || _notrun "scsi_debug module not found"
+ lsmod | grep -wq scsi_debug && (rmmod scsi_debug || _notrun "scsi_debug module in use")
+ # make sure it has the features we need
+ # logical/physical sectors plus unmap support all went in together
+ modinfo scsi_debug | grep -wq sector_size || _notrun "scsi_debug too old"
+}
+
+# Args: [physical sector size, [logical sector size, [unaligned(0|1), [size in megs]]]]
+_get_scsi_debug_dev()
+{
+ # Defaults to phys 512, logical 512, aligned
+ physical=${1-512}
+ logical=${2-512}
+ unaligned=${3-0}
+ size=${4-128}
+
+ phys_exp=0
+ while [ $logical -lt $physical ]; do
+ let physical=physical/2
+ let phys_exp=phys_exp+1
+ done
+ opts="sector_size=$logical physblk_exp=$phys_exp lowest_aligned=$unaligned dev_size_mb=$size"
+ echo "scsi_debug options $opts" >> $RESULT_DIR/$seq.full
+ modprobe scsi_debug $opts
+ [ $? -eq 0 ] || _fail "scsi_debug modprobe failed"
+ sleep 1
+ device=`grep -wl scsi_debug /sys/block/sd*/device/model | awk -F / '{print $4}'`
+ echo "/dev/$device"
+}
+
+_put_scsi_debug_dev()
+{
+ sleep 1
+ lsmod | grep -wq scsi_debug || return
+ rmmod scsi_debug || _fail "Could not remove scsi_debug module"
+}
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs btrfs
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_need_to_be_root
_supported_fs btrfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_need_to_be_root
_supported_fs btrfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_need_to_be_root
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.defrag
+. ./common/rc
+. ./common/filter
+. ./common/defrag
# real QA test starts here
_supported_fs btrfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./btrfs.filter
+. ./common/rc
+. ./common/filter.btrfs
# real QA test starts here
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs ext4
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.defrag
+. ./common/rc
+. ./common/filter
+. ./common/defrag
# real QA test starts here
_supported_os Linux
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.defrag
+. ./common/rc
+. ./common/filter
+. ./common/defrag
# real QA test starts here
_supported_os Linux
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.defrag
+. ./common/rc
+. ./common/filter
+. ./common/defrag
# real QA test starts here
_supported_os Linux
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.defrag
+. ./common/rc
+. ./common/filter
+. ./common/defrag
# real QA test starts here
_supported_os Linux
echo "QA output created by $seq"
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
tmp=/tmp/$$
here=`pwd`
echo "QA output created by $seq"
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
tmp=/tmp/$$
here=`pwd`
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
[ -x $here/src/dbtest ] || _notrun "dbtest was not built for this platform"
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_do_test()
{
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_supported_fs generic
_supported_os IRIX Linux
status=1 # success is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_cleanup()
{
trap "_cleanup; rm -f $tmp.* $testfile; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
_cleanup()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
# real QA test starts here
_supported_fs generic
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
_cleanup()
{
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "rm -rf $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_do_test()
{
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_do_test()
{
trap "_cleanup; rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "_cleanup; rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
_supported_fs generic
_supported_os Linux
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_filter()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
addentries()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
_cleanup()
{
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# link correct .out file
# This is done bacause udf and xfs print attrs in different orders.
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
runas=$here/src/runas
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_cleanup()
{
_supported_fs generic
_supported_os IRIX Linux
-# Use _populate_fs() in common.rc to create a directory structure.
+# Use _populate_fs() in common/rc to create a directory structure.
TEMP_DIR=/tmp
[ "$FSTYP" == "xfs" ] && TEMP_DIR=$TEST_DIR
TAR_FILE=temp.tar
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
# Modify as appropriate.
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_do_test()
{
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_do_test()
{
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
# real QA test starts here
_supported_fs generic
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
FSX_FILE_SIZE=262144
FSX_ARGS="-q -l $FSX_FILE_SIZE -o 65536 -S 191110531 -N 100000"
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
echo_and_run()
{
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_supported_fs generic
_supported_os Linux
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
# generic, but xfs_io's fallocate must work
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
# generic, but xfs_io's fallocate must work
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
# real QA test starts here
_supported_fs generic
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
+. ./common/rc
# real QA test starts here
_supported_fs generic
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
+. ./common/rc
_supported_fs generic
_supported_os Linux IRIX
trap "_cleanup; exit \$status" 0 1 2 3 15 25
# get standard environment, filters and checks
-. ./common.rc
+. ./common/rc
# real QA test starts here
# generic, but xfs_io's fallocate must work
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
# real QA test starts here
_supported_fs generic
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
FSX_FILE_SIZE=64000000
FSX_ARGS="-q -l $FSX_FILE_SIZE -o 65536 -N 20000"
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
_filter_num()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
FSX_FILE_SIZE=64000000
FSX_ARGS="-q -l $FSX_FILE_SIZE -o 65536 -S 191110531 -N 100000"
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
test_setting()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
# real QA test starts here
_supported_fs generic
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
+. ./common/rc
# real QA test starts here
_supported_fs generic
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
_cleanup()
{
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_supported_fs generic
_supported_os Linux
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_supported_fs generic
_supported_os Linux
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_supported_fs generic
_supported_os Linux
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
mypid=$$
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.punch
+. ./common/rc
+. ./common/filter
+. ./common/punch
# real QA test starts here
_supported_fs generic
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.punch
+. ./common/rc
+. ./common/filter
+. ./common/punch
# real QA test starts here
_supported_fs generic
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
+. ./common/rc
# real QA test starts here
_supported_fs generic
mypid=$$
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# Disable all sync operations to get higher load
FSSTRESS_AVOID="$FSSTRESS_AVOID -ffsync=0 -fsync=0 -ffdatasync=0"
_workout()
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
# Disable all sync operations to get higher load
FSSTRESS_AVOID="$FSSTRESS_AVOID -ffsync=0 -fsync=0 -ffdatasync=0"
_scratch_unmount
}
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
threads=50
count=2
_scratch_unmount
}
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
_scratch_unmount
}
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
_require_scratch
_require_quota
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_supported_fs generic
_supported_os Linux
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs generic
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
rm -f $seqres.full
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs btrfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
_cleanup()
{
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.defrag
+. ./common/rc
+. ./common/filter
+. ./common/defrag
# real QA test starts here
_supported_fs xfs ext4 btrfs
}
# Get standard environment, filters and checks.
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# Prerequisites for the test run.
_supported_fs ext4 xfs btrfs gfs2
[ $FSTYP = "ext4" ] && write_opt_list="$write_opt_list oflag=direct"
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_workout()
{
echo "Switch data journalling mode. Silence is golden."
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
-. common.config
-. common.rc
+. common/config
+. common/rc
_supported_fs ext4 xfs
_supported_os Linux
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_supported_fs ext3 ext4 xfs btrfs reiserfs
_supported_os Linux
_need_to_be_root
_require_scratch
_require_fail_make_request
-# TODO: Function are common enough to be moved to common.blkdev
+# TODO: Function are common enough to be moved to common/blkdev
SCRATCH_REAL_DEV=`readlink -f $SCRATCH_DEV`
SCRATCH_BDEV=`basename $SCRATCH_REAL_DEV`
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_db_filter()
{
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs udf
_cleanup_testdir
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs udf
echo "QA output created by $seq"
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
tmp=/tmp/$$
here=`pwd`
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_do_test()
{
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_do_test()
{
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.log
+. ./common/rc
+. ./common/filter
+. ./common/log
_cleanup()
{
seqfull="$seqres.full"
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_cleanup()
{
tmp=/tmp/$$
status=0 # success is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
_cleanup()
{
status=0 # success is the default!
trap "rm -rf $tmp.*; exit \$status" 0 1 2 3 15
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# link correct .out file
_link_out_file $seq.out $seqfull.out
trap "rm -rf $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# link correct .out file
_link_out_file $seq.out $seqfull.out
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_filter_logprint()
{
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.repair
+. ./common/rc
+. ./common/filter
+. ./common/repair
# link correct .out file
_link_out_file $seq.out $seqfull.out
rm -f $seqres.full
# get standard environment, filters and checks
-. ./common.rc
-. ./common.repair
-. ./common.filter
+. ./common/rc
+. ./common/repair
+. ./common/filter
# link correct .out file
_link_out_file $seq.out $seqfull.out
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.repair
+. ./common/rc
+. ./common/filter
+. ./common/repair
# link correct .out file
_link_out_file $seq.out $seqfull.out
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# link correct .out file
_link_out_file $seq.out $seqfull.out
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# link correct .out file
_link_out_file $seq.out $seqfull.out
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# link correct .out file
_link_out_file $seq.out $seqfull.out
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
[ -z "$KWORKAREA" ] && \
_notrun "Can't run srcdiff without KWORKAREA set"
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# link correct .out file
_link_out_file $seq.out $seqfull.out
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_get_existing_uuid()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_cleanup()
{
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
_cleanup()
{
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
_cleanup()
{
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
_cleanup()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# link correct .out file
_link_out_file $seq.out $seqfull.out
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_notrun "Place holder for IRIX test 057"
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_notrun "Place holder for IRIX test 058"
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dump
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/dump
+. ./common/attr
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dump
+. ./common/rc
+. ./common/filter
+. ./common/dump
_ls_size_filter()
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dump
+. ./common/rc
+. ./common/filter
+. ./common/dump
#
# list recursively the directory
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dump
+. ./common/rc
+. ./common/filter
+. ./common/dump
_cleanup()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
# real QA test starts here
_supported_fs xfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
bitsperlong=`src/feature -w`
# link correct .out file
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# don't put fs images in /tmp
imgs=$TEST_DIR/$$
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# loop devices are available in Linux only
_supported_fs xfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_cleanup()
{
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.log
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/log
+. ./common/quota
# real QA test starts here
_supported_fs xfs
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.log
+. ./common/rc
+. ./common/filter
+. ./common/log
_cleanup()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_filter_resv()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.log
+. ./common/rc
+. ./common/filter
+. ./common/log
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.log
+. ./common/rc
+. ./common/filter
+. ./common/log
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.log
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/log
+. ./common/quota
_do_meta()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.log
+. ./common/rc
+. ./common/filter
+. ./common/log
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.log
+. ./common/rc
+. ./common/filter
+. ./common/log
#
# filter out counts which will vary
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_create_scratch()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_create_scratch()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
_supported_fs xfs
_supported_os Linux #IRIX
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
filter_xfs_quota()
{
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
_supported_fs xfs
_supported_os IRIX
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
_supported_fs xfs
_supported_os IRIX
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.log
+. ./common/rc
+. ./common/filter
+. ./common/log
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment
-. ./common.rc
+. ./common/rc
# real QA test starts here
_supported_fs xfs
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
_cleanup()
{
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.repair
+. ./common/rc
+. ./common/filter
+. ./common/repair
[ -z "$XFS_PARALLEL_REPAIR64_PROG" ] && _notrun "parallel repair binary xfs_prepair64 is not installed"
rm -f $seqres.full
# get standard environment, filters and checks
-. ./common.rc
-. ./common.repair
-. ./common.filter
+. ./common/rc
+. ./common/repair
+. ./common/filter
[ -z "$XFS_PARALLEL_REPAIR_PROG" ] && _notrun "parallel repair binary xfs_prepair is not installed"
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# assumes 1st, 3rd and 5th blocks are single written blocks,
# the others are unwritten.
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.filestreams
+. ./common/rc
+. ./common/filter
+. ./common/filestreams
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.filestreams
+. ./common/rc
+. ./common/filter
+. ./common/filestreams
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.filestreams
+. ./common/rc
+. ./common/filter
+. ./common/filestreams
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.filestreams
+. ./common/rc
+. ./common/filter
+. ./common/filestreams
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.filestreams
+. ./common/rc
+. ./common/filter
+. ./common/filestreams
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
-. ./common.punch
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
+. ./common/punch
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
-. ./common.punch
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
+. ./common/punch
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.repair
+. ./common/rc
+. ./common/filter
+. ./common/repair
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.log
+. ./common/rc
+. ./common/filter
+. ./common/log
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dmapi
+. ./common/rc
+. ./common/filter
+. ./common/dmapi
# real QA test starts here
_supported_fs xfs
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.attr
+. ./common/rc
+. ./common/filter
+. ./common/attr
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
rm -f $seqres.full
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# only xfs supported due to use of xfs_bmap
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
# real QA test starts here
_supported_fs xfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.repair
+. ./common/rc
+. ./common/filter
+. ./common/repair
# real QA test starts here
_supported_fs xfs
rm -f $seqres.full
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
status=1 # failure is the default!
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
# real QA test starts here
_supported_fs xfs
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
+. ./common/rc
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.punch
+. ./common/rc
+. ./common/filter
+. ./common/punch
# real QA test starts here
_supported_fs xfs
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
_cleanup()
{
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.punch
+. ./common/rc
+. ./common/filter
+. ./common/punch
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_require_scratch
trap "_cleanup ; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
+. ./common/rc
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
echo "Silence is golden."
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.quota
+. ./common/rc
+. ./common/filter
+. ./common/quota
echo "Silence is golden."
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
-. ./common.attr
+. ./common/rc
+. ./common/dump
+. ./common/attr
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
-. ./common.attr
+. ./common/rc
+. ./common/dump
+. ./common/attr
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.scsi_debug
+. ./common/rc
+. ./common/filter
+. ./common/scsi_debug
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.dump
+. ./common/rc
+. ./common/dump
# real QA test starts here
_supported_fs xfs
rm -f $seqres.full
# get standard environment, filters and checks
-. ./common.rc
-. ./common.quota
+. ./common/rc
+. ./common/quota
_cleanup()
{
trap "exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
_supported_fs xfs
_supported_os IRIX Linux
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-. ./common.dump
+. ./common/rc
+. ./common/filter
+. ./common/dump
# real QA test starts here
}
# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
+. ./common/rc
+. ./common/filter
# real QA test starts here
_supported_fs xfs