2010-01-20 10:27:08 +11:00
|
|
|
##/bin/bash
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
2006-07-07 16:00:24 +00:00
|
|
|
# Copyright (c) 2000-2003,2006 Silicon Graphics, Inc. All Rights Reserved.
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
2009-06-05 15:41:14 -05:00
|
|
|
# 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
|
|
|
|
|
#
|
|
|
|
|
#
|
2001-01-15 05:01:19 +00:00
|
|
|
# setup and check for config parameters, and in particular
|
|
|
|
|
#
|
2008-01-03 05:15:27 +00:00
|
|
|
# EMAIL - email of the script runner.
|
2007-04-20 03:59:08 +00:00
|
|
|
# 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
|
2005-06-27 14:57:49 +00:00
|
|
|
#
|
2001-01-15 05:01:19 +00:00
|
|
|
# and optionally:
|
2009-06-20 19:14:14 +02:00
|
|
|
# SCRATCH_DEV - device you can make a scratch file system on
|
|
|
|
|
# SCRATCH_MNT - mount point for scratch file system
|
2007-04-20 03:59:08 +00:00
|
|
|
# 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
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
2008-03-14 03:18:10 +00:00
|
|
|
# - These can be added to $HOST_CONFIG_DIR (witch default to ./config)
|
|
|
|
|
# below or a separate local configuration file can be used (using
|
2008-01-03 05:15:27 +00:00
|
|
|
# the HOST_OPTIONS variable).
|
2001-01-15 05:01:19 +00:00
|
|
|
# - This script is shared by the stress test system and the auto-qa
|
2013-03-15 12:27:46 +00:00
|
|
|
# system
|
2001-01-15 05:01:19 +00:00
|
|
|
# - TEST_DEV & TEST_DIR must be assigned.
|
|
|
|
|
# - this script shouldn't make any assertions about filesystem
|
|
|
|
|
# validity or mountedness.
|
|
|
|
|
#
|
|
|
|
|
|
2008-04-28 06:25:22 +00:00
|
|
|
# all tests should use a common language setting to prevent golden
|
|
|
|
|
# output mismatches.
|
|
|
|
|
export LANG=C
|
2013-09-19 16:20:37 +00:00
|
|
|
export LC_ALL=C
|
2008-04-28 06:25:22 +00:00
|
|
|
|
2004-06-15 07:32:36 +00:00
|
|
|
# Warning: don't put freeware before /usr/bsd on IRIX coz you'll
|
2007-04-20 03:59:08 +00:00
|
|
|
# get the wrong hostname and set your system name to -s :)
|
2004-06-15 07:32:36 +00:00
|
|
|
[ -d /usr/bsd ] && PATH=$PATH:/usr/bsd
|
|
|
|
|
[ -d /usr/freeware/bin ] && PATH=$PATH:/usr/freeware/bin
|
|
|
|
|
PATH=".:$PATH"
|
|
|
|
|
|
2013-07-11 10:37:57 +00:00
|
|
|
export HOST=`hostname -s`
|
|
|
|
|
export HOSTOS=`uname -s`
|
|
|
|
|
[ "$HOSTOS" = "IRIX64" ] && export HOSTOS="IRIX"
|
2004-06-15 07:32:36 +00:00
|
|
|
|
2013-07-11 10:37:57 +00:00
|
|
|
export MODULAR=0 # using XFS as a module or not
|
|
|
|
|
export BOOT="/boot" # install target for kernels
|
2003-09-22 06:57:28 +00:00
|
|
|
export EXTRA=${EXTRA:=xfs-qa}
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2002-09-18 03:28:20 +00:00
|
|
|
# general parameters (mainly for auto-qa)
|
2013-07-11 10:37:57 +00:00
|
|
|
export SOAK_PROC=3 # -p option to fsstress
|
|
|
|
|
export SOAK_STRESS=10000 # -n option to fsstress
|
|
|
|
|
export SOAK_PASSES=-1 # count of repetitions of fsstress (while soaking)
|
|
|
|
|
export EMAIL=root@localhost # where auto-qa will send its status messages
|
2003-08-25 01:18:54 +00:00
|
|
|
export HOST_OPTIONS=${HOST_OPTIONS:=local.config}
|
2003-05-14 23:34:32 +00:00
|
|
|
export CHECK_OPTIONS=${CHECK_OPTIONS:="-g auto"}
|
2002-11-28 08:37:02 +00:00
|
|
|
export BENCH_PASSES=${BENCH_PASSES:=5}
|
2004-06-15 07:32:36 +00:00
|
|
|
export XFS_MKFS_OPTIONS=${XFS_MKFS_OPTIONS:=-bsize=4096}
|
2013-02-20 10:42:07 +00:00
|
|
|
export TIME_FACTOR=${TIME_FACTOR:=1}
|
|
|
|
|
export LOAD_FACTOR=${LOAD_FACTOR:=1}
|
2013-02-20 10:42:15 +00:00
|
|
|
export DEBUGFS_MNT=${DEBUGFS_MNT:="/sys/kernel/debug"}
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2005-12-09 02:52:22 +00:00
|
|
|
export PWD=`pwd`
|
2003-07-07 06:36:46 +00:00
|
|
|
#export DEBUG=${DEBUG:=...} # arbitrary CFLAGS really.
|
2003-05-13 07:06:18 +00:00
|
|
|
export MALLOCLIB=${MALLOCLIB:=/usr/lib/libefence.a}
|
|
|
|
|
export LOCAL_CONFIGURE_OPTIONS=${LOCAL_CONFIGURE_OPTIONS:=--enable-readline=yes}
|
|
|
|
|
|
2014-04-04 17:18:15 +11:00
|
|
|
export RECREATE_TEST_DEV=false
|
|
|
|
|
|
2004-06-15 07:32:36 +00:00
|
|
|
# $1 = prog to look for, $2* = default pathnames if not found in $PATH
|
|
|
|
|
set_prog_path()
|
|
|
|
|
{
|
|
|
|
|
p=`which $1 2> /dev/null`
|
2007-04-20 03:59:08 +00:00
|
|
|
if [ -n "$p" -a -x "$p" ]; then
|
|
|
|
|
echo $p
|
|
|
|
|
return 0
|
2004-06-15 07:32:36 +00:00
|
|
|
fi
|
|
|
|
|
p=$1
|
2008-03-14 03:18:10 +00:00
|
|
|
|
2004-06-15 07:32:36 +00:00
|
|
|
shift
|
2007-04-20 03:59:08 +00:00
|
|
|
for f; do
|
|
|
|
|
if [ -x $f ]; then
|
|
|
|
|
echo $f
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
2004-06-15 07:32:36 +00:00
|
|
|
done
|
2008-03-14 03:18:10 +00:00
|
|
|
|
2004-06-15 07:32:36 +00:00
|
|
|
echo ""
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-26 20:42:38 +00:00
|
|
|
# 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`
|
2013-03-05 22:41:54 +00:00
|
|
|
if [ "$p" != "" ] && grep -q 'force overwrite' $p; then
|
2013-02-26 20:42:38 +00:00
|
|
|
echo "$p -f"
|
|
|
|
|
else
|
|
|
|
|
echo $p
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-15 07:32:36 +00:00
|
|
|
_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"
|
|
|
|
|
|
2014-05-13 15:28:37 +10:00
|
|
|
export FSSTRESS_PROG="./ltp/fsstress"
|
2014-10-14 22:59:38 +11:00
|
|
|
[ ! -x $FSSTRESS_PROG ] && _fatal "fsstress not found or executable"
|
2005-12-09 02:52:22 +00:00
|
|
|
|
2004-06-15 07:32:36 +00:00
|
|
|
export PERL_PROG="`set_prog_path perl`"
|
|
|
|
|
[ "$PERL_PROG" = "" ] && _fatal "perl not found"
|
|
|
|
|
|
2005-12-09 02:52:22 +00:00
|
|
|
export AWK_PROG="`set_prog_path awk`"
|
|
|
|
|
[ "$AWK_PROG" = "" ] && _fatal "awk not found"
|
|
|
|
|
|
2004-06-15 07:32:36 +00:00
|
|
|
export SED_PROG="`set_prog_path sed`"
|
|
|
|
|
[ "$SED_PROG" = "" ] && _fatal "sed not found"
|
|
|
|
|
|
2008-03-26 03:28:24 +00:00
|
|
|
export BC_PROG="`set_prog_path bc`"
|
|
|
|
|
[ "$BC_PROG" = "" ] && _fatal "bc not found"
|
|
|
|
|
|
2004-06-15 07:32:36 +00:00
|
|
|
export PS_ALL_FLAGS="-ef"
|
|
|
|
|
|
|
|
|
|
export DF_PROG="`set_prog_path df`"
|
|
|
|
|
[ "$DF_PROG" = "" ] && _fatal "df not found"
|
2013-10-29 09:25:24 +00:00
|
|
|
[ "$HOSTOS" = "Linux" ] && export DF_PROG="$DF_PROG -T -P"
|
2004-06-15 07:32:36 +00:00
|
|
|
|
|
|
|
|
export XFS_LOGPRINT_PROG="`set_prog_path xfs_logprint`"
|
|
|
|
|
export XFS_REPAIR_PROG="`set_prog_path xfs_repair`"
|
|
|
|
|
export XFS_DB_PROG="`set_prog_path xfs_db`"
|
2005-06-02 15:09:19 +00:00
|
|
|
export XFS_GROWFS_PROG=`set_prog_path xfs_growfs`
|
|
|
|
|
export XFS_IO_PROG="`set_prog_path xfs_io`"
|
2006-12-20 05:11:03 +00:00
|
|
|
export XFS_PARALLEL_REPAIR_PROG="`set_prog_path xfs_prepair`"
|
|
|
|
|
export XFS_PARALLEL_REPAIR64_PROG="`set_prog_path xfs_prepair64`"
|
2013-03-15 11:53:29 +00:00
|
|
|
export __XFSDUMP_PROG="`set_prog_path xfsdump`"
|
2014-11-10 13:05:22 +11:00
|
|
|
if [ -n "$__XFSDUMP_PROG" ]; then
|
|
|
|
|
export XFSDUMP_PROG="$__XFSDUMP_PROG -e"
|
|
|
|
|
else
|
|
|
|
|
export XFSDUMP_PROG=""
|
|
|
|
|
fi
|
2008-03-26 03:28:24 +00:00
|
|
|
export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
|
|
|
|
|
export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
|
2010-09-09 19:02:17 +02:00
|
|
|
export GETFATTR_PROG="`set_prog_path getfattr`"
|
|
|
|
|
export SETFATTR_PROG="`set_prog_path setfattr`"
|
2014-08-13 11:20:52 +10:00
|
|
|
export CHACL_PROG="`set_prog_path chacl`"
|
2010-09-09 19:02:17 +02:00
|
|
|
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`"
|
2012-10-09 13:24:10 +00:00
|
|
|
export FSTRIM_PROG="`set_prog_path fstrim`"
|
2013-02-03 10:19:56 +00:00
|
|
|
export DUMPE2FS_PROG="`set_prog_path dumpe2fs`"
|
2013-02-20 10:42:06 +00:00
|
|
|
export FIO_PROG="`set_prog_path fio`"
|
2013-03-01 14:17:13 +00:00
|
|
|
export FILEFRAG_PROG="`set_prog_path filefrag`"
|
|
|
|
|
export E4DEFRAG_PROG="`set_prog_path e4defrag`"
|
2013-03-11 23:36:52 +00:00
|
|
|
export LOGGER_PROG="`set_prog_path logger`"
|
2013-05-01 08:47:51 +00:00
|
|
|
export DBENCH_PROG="`set_prog_path dbench`"
|
2013-04-26 19:13:59 +00:00
|
|
|
export DMSETUP_PROG="`set_prog_path dmsetup`"
|
2013-10-21 15:53:16 +00:00
|
|
|
export WIPEFS_PROG="`set_prog_path wipefs`"
|
2014-12-12 10:56:26 +11:00
|
|
|
export DUMP_PROG="`set_prog_path dump`"
|
|
|
|
|
export RESTORE_PROG="`set_prog_path restore`"
|
2015-04-02 09:41:15 +11:00
|
|
|
export LVM_PROG="`set_prog_path lvm`"
|
2015-08-04 14:10:49 +10:00
|
|
|
export CHATTR_PROG="`set_prog_path chattr`"
|
2004-06-15 07:32:36 +00:00
|
|
|
|
2015-08-04 14:10:48 +10:00
|
|
|
# use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
|
|
|
|
|
# newer systems have udevadm command but older systems like RHEL5 don't.
|
|
|
|
|
# But if neither one is available, just set it to "sleep 1" to wait for lv to
|
|
|
|
|
# be settled
|
|
|
|
|
UDEV_SETTLE_PROG="`set_prog_path udevadm`"
|
|
|
|
|
if [ "$UDEV_SETTLE_PROG" == "" ]; then
|
|
|
|
|
# try udevsettle command
|
|
|
|
|
UDEV_SETTLE_PROG="`set_prog_path udevsettle`"
|
|
|
|
|
else
|
|
|
|
|
# udevadm is available, add 'settle' as subcommand
|
|
|
|
|
UDEV_SETTLE_PROG="$UDEV_SETTLE_PROG settle"
|
|
|
|
|
fi
|
|
|
|
|
# neither command is available, use sleep 1
|
|
|
|
|
if [ "$UDEV_SETTLE_PROG" == "" ]; then
|
|
|
|
|
UDEV_SETTLE_PROG="sleep 1"
|
|
|
|
|
fi
|
|
|
|
|
export UDEV_SETTLE_PROG
|
|
|
|
|
|
2008-03-14 03:18:10 +00:00
|
|
|
# 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"
|
|
|
|
|
|
2004-06-15 07:32:36 +00:00
|
|
|
case "$HOSTOS" in
|
|
|
|
|
IRIX*)
|
2007-04-20 03:59:08 +00:00
|
|
|
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"
|
2014-09-08 22:26:52 +10:00
|
|
|
export MKFS_CIFS_PROG="false"
|
2007-04-20 03:59:08 +00:00
|
|
|
;;
|
2004-06-15 07:32:36 +00:00
|
|
|
Linux)
|
2007-04-20 03:59:08 +00:00
|
|
|
export MKFS_XFS_PROG="`set_prog_path mkfs.xfs`"
|
2014-09-29 12:46:43 +10:00
|
|
|
export MKFS_EXT4_PROG="`set_prog_path mkfs.ext4`"
|
2007-04-20 03:59:08 +00:00
|
|
|
export MKFS_UDF_PROG="`set_prog_path mkudffs`"
|
2013-02-26 20:42:38 +00:00
|
|
|
export MKFS_BTRFS_PROG="`set_btrfs_mkfs_prog_path_with_opts`"
|
2014-12-24 14:56:26 +11:00
|
|
|
export MKFS_F2FS_PROG="`set_prog_path mkfs.f2fs`"
|
2015-02-12 14:20:58 +11:00
|
|
|
export DUMP_F2FS_PROG="`set_prog_path dump.f2fs`"
|
2011-12-07 14:33:53 +01:00
|
|
|
export BTRFS_UTIL_PROG="`set_prog_path btrfs`"
|
2013-08-23 13:07:11 +00:00
|
|
|
export BTRFS_SHOW_SUPER_PROG="`set_prog_path btrfs-show-super`"
|
2007-04-20 03:59:08 +00:00
|
|
|
export XFS_FSR_PROG="`set_prog_path xfs_fsr`"
|
|
|
|
|
export MKFS_NFS_PROG="false"
|
2014-09-08 22:26:52 +10:00
|
|
|
export MKFS_CIFS_PROG="false"
|
2015-12-21 18:07:47 +11:00
|
|
|
export MKFS_OVERLAY_PROG="false"
|
2014-12-24 14:56:07 +11:00
|
|
|
export MKFS_REISER4_PROG="`set_prog_path mkfs.reiser4`"
|
2007-04-20 03:59:08 +00:00
|
|
|
;;
|
2004-06-15 07:32:36 +00:00
|
|
|
esac
|
|
|
|
|
|
2014-05-13 15:30:15 +10:00
|
|
|
# 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
|
|
|
|
|
|
2015-05-26 12:51:57 +10:00
|
|
|
# check if mkfs.xfs supports v5 xfs
|
|
|
|
|
XFS_MKFS_HAS_NO_META_SUPPORT=""
|
|
|
|
|
touch /tmp/crc_check.img
|
|
|
|
|
$MKFS_XFS_PROG -N -d file,name=/tmp/crc_check.img,size=32m -m crc=0 \
|
|
|
|
|
>/dev/null 2>&1;
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
XFS_MKFS_HAS_NO_META_SUPPORT=true
|
|
|
|
|
fi
|
|
|
|
|
rm -f /tmp/crc_check.img
|
|
|
|
|
export XFS_MKFS_HAS_NO_META_SUPPORT
|
|
|
|
|
|
2014-04-04 17:18:15 +11:00
|
|
|
_mount_opts()
|
|
|
|
|
{
|
|
|
|
|
case $FSTYP in
|
|
|
|
|
xfs)
|
|
|
|
|
export MOUNT_OPTIONS=$XFS_MOUNT_OPTIONS
|
|
|
|
|
;;
|
|
|
|
|
udf)
|
|
|
|
|
export MOUNT_OPTIONS=$UDF_MOUNT_OPTIONS
|
|
|
|
|
;;
|
|
|
|
|
nfs)
|
|
|
|
|
export MOUNT_OPTIONS=$NFS_MOUNT_OPTIONS
|
|
|
|
|
;;
|
2014-09-08 22:26:52 +10:00
|
|
|
cifs)
|
|
|
|
|
export MOUNT_OPTIONS=$CIFS_MOUNT_OPTIONS
|
|
|
|
|
;;
|
2015-12-21 18:07:47 +11:00
|
|
|
overlay)
|
|
|
|
|
export MOUNT_OPTIONS=$OVERLAY_MOUNT_OPTIONS
|
|
|
|
|
;;
|
2014-04-04 17:18:15 +11:00
|
|
|
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"
|
|
|
|
|
;;
|
2014-12-24 14:56:26 +11:00
|
|
|
f2fs)
|
|
|
|
|
export MOUNT_OPTIONS="-o acl,user_xattr $F2FS_MOUNT_OPTIONS"
|
|
|
|
|
;;
|
2014-04-04 17:18:15 +11:00
|
|
|
reiserfs)
|
|
|
|
|
# acls & xattrs aren't turned on by default on reiserfs
|
|
|
|
|
export MOUNT_OPTIONS="-o acl,user_xattr $REISERFS_MOUNT_OPTIONS"
|
|
|
|
|
;;
|
2014-12-24 14:56:07 +11:00
|
|
|
reiser4)
|
|
|
|
|
# acls & xattrs aren't supported by reiser4
|
|
|
|
|
export MOUNT_OPTIONS=$REISER4_MOUNT_OPTIONS
|
|
|
|
|
;;
|
2014-04-04 17:18:15 +11:00
|
|
|
gfs2)
|
|
|
|
|
# acls aren't turned on by default on gfs2
|
|
|
|
|
export MOUNT_OPTIONS="-o acl $GFS2_MOUNT_OPTIONS"
|
|
|
|
|
;;
|
2014-04-22 10:46:25 +10:00
|
|
|
tmpfs)
|
|
|
|
|
# We need to specify the size at mount, use 512 MB by default
|
|
|
|
|
export MOUNT_OPTIONS="-o size=512M $TMPFS_MOUNT_OPTIONS"
|
|
|
|
|
;;
|
2014-04-04 17:18:15 +11:00
|
|
|
*)
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-08 22:26:52 +10:00
|
|
|
_test_mount_opts()
|
|
|
|
|
{
|
|
|
|
|
case $FSTYP in
|
|
|
|
|
cifs)
|
|
|
|
|
export TEST_FS_MOUNT_OPTS=$CIFS_MOUNT_OPTIONS
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-04 17:18:15 +11:00
|
|
|
_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
|
|
|
|
|
;;
|
2014-09-08 22:26:52 +10:00
|
|
|
cifs)
|
|
|
|
|
export MKFS_OPTIONS=$CIFS_MKFS_OPTIONS
|
|
|
|
|
;;
|
2014-04-04 17:18:15 +11:00
|
|
|
reiserfs)
|
|
|
|
|
export MKFS_OPTIONS="$REISERFS_MKFS_OPTIONS -q"
|
|
|
|
|
;;
|
2014-12-24 14:56:07 +11:00
|
|
|
reiser4)
|
|
|
|
|
export MKFS_OPTIONS=$REISER4_MKFS_OPTIONS
|
|
|
|
|
;;
|
2014-04-04 17:18:15 +11:00
|
|
|
gfs2)
|
|
|
|
|
export MKFS_OPTIONS="$GFS2_MKFS_OPTIONS -O -p lock_nolock"
|
|
|
|
|
;;
|
|
|
|
|
jfs)
|
|
|
|
|
export MKFS_OPTIONS="$JFS_MKFS_OPTIONS -q"
|
|
|
|
|
;;
|
2015-12-21 18:01:54 +11:00
|
|
|
f2fs)
|
|
|
|
|
export MKFS_OPTIONS="$F2FS_MKFS_OPTIONS"
|
|
|
|
|
;;
|
2014-04-04 17:18:15 +11:00
|
|
|
*)
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_fsck_opts()
|
|
|
|
|
{
|
|
|
|
|
case $FSTYP in
|
|
|
|
|
ext2|ext3|ext4|ext4dev)
|
|
|
|
|
export FSCK_OPTIONS="-nf"
|
|
|
|
|
;;
|
2014-12-24 14:56:07 +11:00
|
|
|
reiser*)
|
2014-04-04 17:18:15 +11:00
|
|
|
export FSCK_OPTIONS="--yes"
|
|
|
|
|
;;
|
2014-12-24 14:56:26 +11:00
|
|
|
f2fs)
|
|
|
|
|
export FSCK_OPTIONS=""
|
|
|
|
|
;;
|
2014-04-04 17:18:15 +11:00
|
|
|
*)
|
|
|
|
|
export FSCK_OPTIONS="-n"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-25 01:18:54 +00:00
|
|
|
known_hosts()
|
|
|
|
|
{
|
2013-07-11 10:38:00 +00:00
|
|
|
[ "$HOST_CONFIG_DIR" ] || HOST_CONFIG_DIR=`pwd`/configs
|
2008-01-03 05:15:27 +00:00
|
|
|
|
2013-07-11 10:38:00 +00:00
|
|
|
[ -f /etc/xfsqa.config ] && export HOST_OPTIONS=/etc/xfsqa.config
|
|
|
|
|
[ -f $HOST_CONFIG_DIR/$HOST ] && export HOST_OPTIONS=$HOST_CONFIG_DIR/$HOST
|
|
|
|
|
[ -f $HOST_CONFIG_DIR/$HOST.config ] && export HOST_OPTIONS=$HOST_CONFIG_DIR/$HOST.config
|
2003-08-25 01:18:54 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-04 17:18:04 +11:00
|
|
|
# Returns a list of sections in config file
|
|
|
|
|
# Each section starts with the section name in the format
|
|
|
|
|
# [section_name1]. Only alphanumeric characters and '_' is allowed
|
|
|
|
|
# in the section name otherwise the section will not be resognised.
|
|
|
|
|
# Section name must be contained between square brackets.
|
|
|
|
|
get_config_sections() {
|
|
|
|
|
sed -n -e "s/^\[\([[:alnum:]_]*\)\]/\1/p" < $1
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-11 10:38:00 +00:00
|
|
|
if [ ! -f "$HOST_OPTIONS" ]; then
|
|
|
|
|
known_hosts
|
|
|
|
|
fi
|
|
|
|
|
|
2014-04-04 17:18:04 +11:00
|
|
|
export HOST_OPTIONS_SECTIONS="-no-sections-"
|
|
|
|
|
export OPTIONS_HAVE_SECTIONS=false
|
2003-08-25 01:18:54 +00:00
|
|
|
if [ -f "$HOST_OPTIONS" ]; then
|
2014-04-04 17:18:04 +11:00
|
|
|
export HOST_OPTIONS_SECTIONS=`get_config_sections $HOST_OPTIONS`
|
|
|
|
|
if [ -z "$HOST_OPTIONS_SECTIONS" ]; then
|
|
|
|
|
. $HOST_OPTIONS
|
|
|
|
|
export HOST_OPTIONS_SECTIONS="-no-sections-"
|
|
|
|
|
else
|
|
|
|
|
export OPTIONS_HAVE_SECTIONS=true
|
|
|
|
|
fi
|
2003-08-25 01:18:54 +00:00
|
|
|
fi
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2014-04-04 17:18:04 +11:00
|
|
|
# Parse config section options. This function will parse all the configuration
|
|
|
|
|
# within a single section which name is passed as an argument. For section
|
|
|
|
|
# name format see comments in get_config_sections().
|
|
|
|
|
# Empty lines and everything after '#' will be ignored.
|
|
|
|
|
# Configuration options should be defined in the format
|
|
|
|
|
#
|
|
|
|
|
# CONFIG_OPTION=value
|
|
|
|
|
#
|
|
|
|
|
# This 'CONFIG_OPTION' variable and will be exported as an environment variable.
|
|
|
|
|
parse_config_section() {
|
|
|
|
|
SECTION=$1
|
|
|
|
|
if ! $OPTIONS_HAVE_SECTIONS; then
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
eval `sed -e 's/[[:space:]]*\=[[:space:]]*/=/g' \
|
|
|
|
|
-e 's/#.*$//' \
|
|
|
|
|
-e 's/[[:space:]]*$//' \
|
|
|
|
|
-e 's/^[[:space:]]*//' \
|
2014-04-11 10:09:48 +10:00
|
|
|
-e "s/^\([^=]*\)=\"\?'\?\([^\"']*\)\"\?'\?$/export \1=\"\2\"/" \
|
2014-04-04 17:18:04 +11:00
|
|
|
< $HOST_OPTIONS \
|
|
|
|
|
| sed -n -e "/^\[$SECTION\]/,/^\s*\[/{/^[^#].*\=.*/p;}"`
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-11 10:38:00 +00:00
|
|
|
get_next_config() {
|
2014-04-09 09:55:50 +10:00
|
|
|
if [ ! -z "$CONFIG_INCLUDED" ] && ! $OPTIONS_HAVE_SECTIONS; then
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
2014-04-04 17:18:15 +11:00
|
|
|
local OLD_FSTYP=$FSTYP
|
|
|
|
|
local OLD_MOUNT_OPTIONS=$MOUNT_OPTIONS
|
2014-09-08 22:26:52 +10:00
|
|
|
local OLD_TEST_FS_MOUNT_OPTS=$TEST_FS_MOUNT_OPTS
|
2014-04-04 17:18:15 +11:00
|
|
|
local OLD_MKFS_OPTIONS=$MKFS_OPTIONS
|
|
|
|
|
local OLD_FSCK_OPTIONS=$FSCK_OPTIONS
|
|
|
|
|
|
|
|
|
|
unset MOUNT_OPTIONS
|
|
|
|
|
unset MKFS_OPTIONS
|
|
|
|
|
unset FSCK_OPTIONS
|
2014-04-09 09:55:52 +10:00
|
|
|
# We might have deduced SCRATCH_DEV from the SCRATCH_DEV_POOL in the previous
|
|
|
|
|
# run, so we have to unset it now.
|
|
|
|
|
if [ "$SCRATCH_DEV_NOT_SET" == "true" ]; then
|
|
|
|
|
unset SCRATCH_DEV
|
|
|
|
|
fi
|
2014-04-04 17:18:15 +11:00
|
|
|
|
2014-04-04 17:18:04 +11:00
|
|
|
parse_config_section $1
|
|
|
|
|
|
2014-04-09 09:55:52 +10:00
|
|
|
if [ ! -z "$OLD_FSTYP" ] && [ $OLD_FSTYP != $FSTYP ]; then
|
2014-04-04 17:18:15 +11:00
|
|
|
[ -z "$MOUNT_OPTIONS" ] && _mount_opts
|
2014-09-08 22:26:52 +10:00
|
|
|
[ -z "$TEST_FS_MOUNT_OPTS" ] && _test_mount_opts
|
2014-04-04 17:18:15 +11:00
|
|
|
[ -z "$MKFS_OPTIONS" ] && _mkfs_opts
|
|
|
|
|
[ -z "$FSCK_OPTIONS" ] && _fsck_opts
|
|
|
|
|
else
|
|
|
|
|
[ -z "$MOUNT_OPTIONS" ] && export MOUNT_OPTIONS=$OLD_MOUNT_OPTIONS
|
2014-09-08 22:26:52 +10:00
|
|
|
[ -z "$TEST_FS_MOUNT_OPTS" ] && export TEST_FS_MOUNT_OPTS=$OLD_TEST_FS_MOUNT_OPTS
|
2014-04-04 17:18:15 +11:00
|
|
|
[ -z "$MKFS_OPTIONS" ] && export MKFS_OPTIONS=$OLD_MKFS_OPTIONS
|
|
|
|
|
[ -z "$FSCK_OPTIONS" ] && export FSCK_OPTIONS=$OLD_FSCK_OPTIONS
|
|
|
|
|
fi
|
|
|
|
|
|
2013-07-11 10:38:01 +00:00
|
|
|
# set default RESULT_BASE
|
|
|
|
|
if [ -z "$RESULT_BASE" ]; then
|
|
|
|
|
export RESULT_BASE="$here/results/"
|
|
|
|
|
fi
|
|
|
|
|
|
2013-07-11 10:38:00 +00:00
|
|
|
# Mandatory Config values.
|
|
|
|
|
MC=""
|
|
|
|
|
[ -z "$EMAIL" ] && MC="$MC EMAIL"
|
|
|
|
|
[ -z "$TEST_DIR" ] && MC="$MC TEST_DIR"
|
|
|
|
|
[ -z "$TEST_DEV" ] && MC="$MC TEST_DEV"
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2013-07-11 10:38:00 +00:00
|
|
|
if [ -n "$MC" ]; then
|
|
|
|
|
echo "Warning: need to define parameters for host $HOST"
|
|
|
|
|
echo " or set variables:"
|
|
|
|
|
echo " $MC"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2014-09-08 22:26:52 +10:00
|
|
|
echo $TEST_DEV | grep -qE ":|//" > /dev/null 2>&1
|
2015-12-21 18:07:47 +11:00
|
|
|
if [ ! -b "$TEST_DEV" -a "$?" != "0" -a "$FSTYP" != "overlay" ]; then
|
2014-09-08 22:26:52 +10:00
|
|
|
echo "common/config: Error: \$TEST_DEV ($TEST_DEV) is not a block device or a network filesystem"
|
2013-07-11 10:38:00 +00:00
|
|
|
exit 1
|
2015-12-21 18:07:47 +11:00
|
|
|
elif [ "$FSTYP" == "overlay" -a ! -d "$TEST_DEV" ]; then
|
|
|
|
|
echo "common/config: Error: \$TEST_DEV ($TEST_DEV) is not a directory for overlay"
|
|
|
|
|
exit 1
|
2013-07-11 10:38:00 +00:00
|
|
|
fi
|
2011-10-20 23:41:19 +08:00
|
|
|
|
2013-07-11 10:38:00 +00:00
|
|
|
if [ ! -d "$TEST_DIR" ]; then
|
|
|
|
|
echo "common/config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2013-07-11 10:38:00 +00:00
|
|
|
# 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
|
2014-04-09 09:55:50 +10:00
|
|
|
echo "common/config: Error: \$SCRATCH_DEV ($SCRATCH_DEV) should be unset when \$SCRATCH_DEV_POOL ($SCRATCH_DEV_POOL) is set"
|
2013-07-11 10:38:00 +00:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
SCRATCH_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
|
2014-04-09 09:55:50 +10:00
|
|
|
export SCRATCH_DEV
|
2014-04-09 09:55:52 +10:00
|
|
|
export SCRATCH_DEV_NOT_SET=true
|
2013-07-11 10:38:00 +00:00
|
|
|
fi
|
|
|
|
|
|
2014-09-08 22:26:52 +10:00
|
|
|
echo $SCRATCH_DEV | grep -qE ":|//" > /dev/null 2>&1
|
2015-12-21 18:07:47 +11:00
|
|
|
if [ ! -z "$SCRATCH_DEV" -a ! -b "$SCRATCH_DEV" -a "$?" != "0" -a "$FSTYP" != "overlay" ]; then
|
2014-09-08 22:26:52 +10:00
|
|
|
echo "common/config: Error: \$SCRATCH_DEV ($SCRATCH_DEV) is not a block device or a network filesystem"
|
2013-07-11 10:38:00 +00:00
|
|
|
exit 1
|
2015-12-21 18:07:47 +11:00
|
|
|
elif [ ! -z "$SCRATCH_DEV" -a "$FSTYP" == "overlay" -a ! -d "$SCRATCH_DEV" ]; then
|
|
|
|
|
echo "common/config: Error: \$SCRATCH_DEV ($SCRATCH_DEV) is not a directory for overlay"
|
|
|
|
|
exit 1
|
2013-07-11 10:38:00 +00:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-04 17:18:04 +11:00
|
|
|
if [ -z "$CONFIG_INCLUDED" ]; then
|
|
|
|
|
get_next_config `echo $HOST_OPTIONS_SECTIONS | cut -f1 -d" "`
|
|
|
|
|
export CONFIG_INCLUDED=true
|
2014-04-09 09:55:52 +10:00
|
|
|
|
|
|
|
|
# Autodetect fs type based on what's on $TEST_DEV unless it's been set
|
|
|
|
|
# externally
|
|
|
|
|
if [ -z "$FSTYP" ] && \
|
|
|
|
|
[ "$HOSTOS" == "Linux" -o "$OSTYPE" == "linux-gnu" ] && \
|
|
|
|
|
[ ! -z "$TEST_DEV" ]; then
|
|
|
|
|
FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
|
|
|
|
|
fi
|
|
|
|
|
FSTYP=${FSTYP:=xfs}
|
|
|
|
|
export FSTYP
|
|
|
|
|
[ -z "$MOUNT_OPTIONS" ] && _mount_opts
|
2014-09-08 22:26:52 +10:00
|
|
|
[ -z "$TEST_FS_MOUNT_OPTS" ] && _test_mount_opts
|
2014-04-09 09:55:52 +10:00
|
|
|
[ -z "$MKFS_OPTIONS" ] && _mkfs_opts
|
|
|
|
|
[ -z "$FSCK_OPTIONS" ] && _fsck_opts
|
2014-04-04 17:18:04 +11:00
|
|
|
fi
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2016-01-11 15:13:20 +11:00
|
|
|
# canonicalize the mount points
|
|
|
|
|
# this follows symlinks and removes all trailing "/"s
|
|
|
|
|
export TEST_DIR=`readlink -e "$TEST_DIR"`
|
|
|
|
|
export SCRATCH_MNT=`readlink -e "$SCRATCH_MNT"`
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
# make sure this script returns success
|
|
|
|
|
/bin/true
|