2008-12-05 19:32:34 +00:00
|
|
|
#!/bin/bash
|
2009-01-16 20:19:15 +00:00
|
|
|
#
|
|
|
|
# Wrapper script for easily running zpios based tests
|
|
|
|
#
|
|
|
|
|
2010-03-09 22:51:49 +00:00
|
|
|
basedir="$(dirname $0)"
|
|
|
|
|
2009-08-18 04:50:55 +00:00
|
|
|
SCRIPT_COMMON=common.sh
|
2010-03-09 22:51:49 +00:00
|
|
|
if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
|
|
|
|
. "${basedir}/${SCRIPT_COMMON}"
|
2009-08-18 04:50:55 +00:00
|
|
|
elif [ -f /usr/libexec/zfs/${SCRIPT_COMMON} ]; then
|
|
|
|
. /usr/libexec/zfs/${SCRIPT_COMMON}
|
|
|
|
else
|
|
|
|
echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
|
|
|
|
fi
|
|
|
|
|
2009-01-16 20:19:15 +00:00
|
|
|
PROG=zpios.sh
|
2009-02-19 22:51:40 +00:00
|
|
|
DATE=`date +%Y%m%d-%H%M%S`
|
2009-08-18 04:50:55 +00:00
|
|
|
if [ "${ZPIOS_MODULES}" ]; then
|
|
|
|
MODULES=(${ZPIOS_MODULES[*]})
|
|
|
|
else
|
|
|
|
MODULES=(zpios)
|
|
|
|
fi
|
2009-01-16 20:19:15 +00:00
|
|
|
|
|
|
|
usage() {
|
|
|
|
cat << EOF
|
|
|
|
USAGE:
|
2009-01-16 23:07:30 +00:00
|
|
|
$0 [hvp] <-c config> <-t test>
|
2009-01-16 20:19:15 +00:00
|
|
|
|
|
|
|
DESCRIPTION:
|
|
|
|
Helper script for easy zpios benchmarking.
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-h Show this message
|
|
|
|
-v Verbose
|
2009-10-23 18:56:15 +00:00
|
|
|
-f Force everything
|
2009-01-16 20:19:15 +00:00
|
|
|
-p Enable profiling
|
2009-02-06 22:58:31 +00:00
|
|
|
-c Zpool configuration
|
2009-01-16 23:07:30 +00:00
|
|
|
-t Zpios test
|
2009-02-06 22:58:31 +00:00
|
|
|
-o Additional zpios options
|
|
|
|
-l Additional zpool options
|
|
|
|
-s Additional zfs options
|
2009-01-16 20:19:15 +00:00
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
print_header() {
|
|
|
|
echo --------------------- ZPIOS RESULTS ----------------------------
|
|
|
|
echo -n "Date: "; date
|
|
|
|
echo -n "Kernel: "; uname -r
|
|
|
|
dmesg | grep "Loaded Solaris Porting Layer" | tail -n1
|
|
|
|
dmesg | grep "Loaded ZFS Filesystem" | tail -n1
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
print_spl_info() {
|
|
|
|
echo --------------------- SPL Tunings ------------------------------
|
2009-08-18 04:50:55 +00:00
|
|
|
${SYSCTL} -A | grep spl
|
2008-12-05 19:32:34 +00:00
|
|
|
|
2009-01-16 20:19:15 +00:00
|
|
|
if [ -d /sys/module/spl/parameters ]; then
|
|
|
|
grep [0-9] /sys/module/spl/parameters/*
|
|
|
|
else
|
|
|
|
grep [0-9] /sys/module/spl/*
|
|
|
|
fi
|
2008-12-05 19:32:34 +00:00
|
|
|
|
2009-01-16 20:19:15 +00:00
|
|
|
echo
|
|
|
|
}
|
2008-12-05 19:32:34 +00:00
|
|
|
|
2009-01-16 20:19:15 +00:00
|
|
|
print_zfs_info() {
|
|
|
|
echo --------------------- ZFS Tunings ------------------------------
|
2009-08-18 04:50:55 +00:00
|
|
|
${SYSCTL} -A | grep zfs
|
2008-12-05 19:32:34 +00:00
|
|
|
|
2009-01-16 20:19:15 +00:00
|
|
|
if [ -d /sys/module/zfs/parameters ]; then
|
|
|
|
grep [0-9] /sys/module/zfs/parameters/*
|
|
|
|
else
|
|
|
|
grep [0-9] /sys/module/zfs/*
|
|
|
|
fi
|
2008-12-05 19:32:34 +00:00
|
|
|
|
2009-01-16 20:19:15 +00:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
print_stats() {
|
|
|
|
echo ---------------------- Statistics -------------------------------
|
2009-08-18 04:50:55 +00:00
|
|
|
${SYSCTL} -A | grep spl | grep stack_max
|
2009-01-16 20:19:15 +00:00
|
|
|
|
|
|
|
if [ -d /proc/spl/kstat/ ]; then
|
|
|
|
if [ -f /proc/spl/kstat/zfs/arcstats ]; then
|
|
|
|
echo "* ARC"
|
|
|
|
cat /proc/spl/kstat/zfs/arcstats
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f /proc/spl/kstat/zfs/vdev_cache_stats ]; then
|
|
|
|
echo "* VDEV Cache"
|
|
|
|
cat /proc/spl/kstat/zfs/vdev_cache_stats
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
fi
|
2009-01-14 17:18:16 +00:00
|
|
|
|
2009-01-16 20:19:15 +00:00
|
|
|
if [ -f /proc/spl/kmem/slab ]; then
|
|
|
|
echo "* SPL SLAB"
|
|
|
|
cat /proc/spl/kmem/slab
|
|
|
|
echo
|
|
|
|
fi
|
2009-01-20 23:34:02 +00:00
|
|
|
|
|
|
|
echo
|
2009-01-16 20:19:15 +00:00
|
|
|
}
|
2009-01-14 18:40:50 +00:00
|
|
|
|
2009-01-16 20:19:15 +00:00
|
|
|
check_test() {
|
|
|
|
|
|
|
|
if [ ! -f ${ZPIOS_TEST} ]; then
|
2009-01-20 22:32:02 +00:00
|
|
|
local NAME=`basename ${ZPIOS_TEST} .sh`
|
2009-01-16 20:19:15 +00:00
|
|
|
ERROR="Unknown test '${NAME}', available tests are:\n"
|
|
|
|
|
2009-08-18 04:50:55 +00:00
|
|
|
for TST in `ls ${ZPIOSDIR}/ | grep ".sh"`; do
|
2009-01-20 22:32:02 +00:00
|
|
|
local NAME=`basename ${TST} .sh`
|
2009-01-16 20:19:15 +00:00
|
|
|
ERROR="${ERROR}${NAME}\n"
|
|
|
|
done
|
|
|
|
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2009-02-19 22:51:40 +00:00
|
|
|
zpios_profile_config() {
|
2009-02-21 06:27:18 +00:00
|
|
|
cat > ${PROFILE_DIR}/zpios-config.sh << EOF
|
2009-02-19 22:51:40 +00:00
|
|
|
#
|
|
|
|
# Zpios Profiling Configuration
|
|
|
|
#
|
|
|
|
|
2009-02-21 06:27:18 +00:00
|
|
|
PROFILE_DIR=/tmp/zpios/${ZPOOL_CONFIG}+${ZPIOS_TEST_ARG}+${DATE}
|
2009-08-18 04:50:55 +00:00
|
|
|
PROFILE_PRE=${ZPIOSPROFILEDIR}/zpios-profile-pre.sh
|
|
|
|
PROFILE_POST=${ZPIOSPROFILEDIR}/zpios-profile-post.sh
|
|
|
|
PROFILE_USER=${ZPIOSPROFILEDIR}/zpios-profile.sh
|
|
|
|
PROFILE_PIDS=${ZPIOSPROFILEDIR}/zpios-profile-pids.sh
|
|
|
|
PROFILE_DISK=${ZPIOSPROFILEDIR}/zpios-profile-disk.sh
|
2009-02-21 06:27:18 +00:00
|
|
|
PROFILE_ARC_PROC=/proc/spl/kstat/zfs/arcstats
|
|
|
|
PROFILE_VDEV_CACHE_PROC=/proc/spl/kstat/zfs/vdev_cache_stats
|
2009-02-20 22:28:00 +00:00
|
|
|
|
2009-02-21 06:27:18 +00:00
|
|
|
OPROFILE_KERNEL="/boot/vmlinux-`uname -r`"
|
|
|
|
OPROFILE_KERNEL_DIR="/lib/modules/`uname -r`/kernel/"
|
2009-08-18 04:50:55 +00:00
|
|
|
OPROFILE_SPL_DIR=${SPLBUILD}/module/
|
|
|
|
OPROFILE_ZFS_DIR=${MODDIR}
|
2009-02-19 22:51:40 +00:00
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
zpios_profile_start() {
|
2009-02-21 06:27:18 +00:00
|
|
|
PROFILE_DIR=/tmp/zpios/${ZPOOL_CONFIG}+${ZPIOS_TEST_ARG}+${DATE}
|
2009-02-19 22:51:40 +00:00
|
|
|
|
2009-02-21 06:27:18 +00:00
|
|
|
mkdir -p ${PROFILE_DIR}
|
2009-02-19 22:51:40 +00:00
|
|
|
zpios_profile_config
|
2009-02-21 06:27:18 +00:00
|
|
|
. ${PROFILE_DIR}/zpios-config.sh
|
2009-02-20 22:28:00 +00:00
|
|
|
|
2009-02-21 06:27:18 +00:00
|
|
|
ZPIOS_OPTIONS="${ZPIOS_OPTIONS} --log=${PROFILE_DIR}"
|
|
|
|
ZPIOS_OPTIONS="${ZPIOS_OPTIONS} --prerun=${PROFILE_PRE}"
|
|
|
|
ZPIOS_OPTIONS="${ZPIOS_OPTIONS} --postrun=${PROFILE_POST}"
|
2009-02-19 22:51:40 +00:00
|
|
|
|
2009-02-20 22:28:00 +00:00
|
|
|
/usr/bin/opcontrol --init
|
2009-02-21 06:27:18 +00:00
|
|
|
/usr/bin/opcontrol --setup --vmlinux=${OPROFILE_KERNEL}
|
2009-02-19 22:51:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
zpios_profile_stop() {
|
|
|
|
/usr/bin/opcontrol --shutdown
|
|
|
|
/usr/bin/opcontrol --deinit
|
|
|
|
}
|
|
|
|
|
2009-01-16 20:19:15 +00:00
|
|
|
PROFILE=
|
2009-01-20 22:32:02 +00:00
|
|
|
ZPOOL_CONFIG=zpool-config.sh
|
|
|
|
ZPIOS_TEST=zpios-test.sh
|
2009-01-16 21:25:16 +00:00
|
|
|
ZPOOL_NAME=zpios
|
2009-02-06 22:58:31 +00:00
|
|
|
ZPIOS_OPTIONS=
|
|
|
|
ZPOOL_OPTIONS=""
|
|
|
|
ZFS_OPTIONS=""
|
2009-01-16 20:19:15 +00:00
|
|
|
|
2009-10-23 18:56:15 +00:00
|
|
|
while getopts 'hvfpc:t:o:l:s:' OPTION; do
|
2009-01-16 20:19:15 +00:00
|
|
|
case $OPTION in
|
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
v)
|
|
|
|
VERBOSE=1
|
2009-01-16 21:25:16 +00:00
|
|
|
VERBOSE_FLAG="-v"
|
2009-01-16 20:19:15 +00:00
|
|
|
;;
|
2009-10-23 18:56:15 +00:00
|
|
|
f)
|
|
|
|
FORCE=1
|
|
|
|
FORCE_FLAG="-f"
|
|
|
|
;;
|
2009-01-16 20:19:15 +00:00
|
|
|
p)
|
|
|
|
PROFILE=1
|
|
|
|
;;
|
|
|
|
c)
|
2009-01-16 20:23:53 +00:00
|
|
|
ZPOOL_CONFIG=${OPTARG}
|
2009-01-16 20:19:15 +00:00
|
|
|
;;
|
|
|
|
t)
|
2009-02-19 22:51:40 +00:00
|
|
|
ZPIOS_TEST_ARG=${OPTARG}
|
2009-08-18 04:50:55 +00:00
|
|
|
ZPIOS_TEST=${ZPIOSDIR}/${OPTARG}.sh
|
2009-01-16 20:19:15 +00:00
|
|
|
;;
|
2009-02-06 22:58:31 +00:00
|
|
|
o)
|
|
|
|
ZPIOS_OPTIONS=${OPTARG}
|
|
|
|
;;
|
|
|
|
l) # Passed through to zpool-create.sh
|
|
|
|
ZPOOL_OPTIONS=${OPTARG}
|
|
|
|
;;
|
|
|
|
s) # Passed through to zpool-create.sh
|
|
|
|
ZFS_OPTIONS=${OPTARG}
|
|
|
|
;;
|
2009-01-16 20:19:15 +00:00
|
|
|
?)
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $(id -u) != 0 ]; then
|
|
|
|
die "Must run as root"
|
2009-01-13 19:16:12 +00:00
|
|
|
fi
|
|
|
|
|
2009-01-20 22:32:02 +00:00
|
|
|
# Validate and source your test config
|
2009-01-16 20:19:15 +00:00
|
|
|
check_test || die "${ERROR}"
|
2009-01-20 22:32:02 +00:00
|
|
|
. ${ZPIOS_TEST}
|
2009-01-16 20:19:15 +00:00
|
|
|
|
|
|
|
# Pull in the zpios test module is not loaded. If this fails it is
|
|
|
|
# likely because the full module stack was not yet loaded with zfs.sh
|
|
|
|
if check_modules; then
|
|
|
|
if ! load_modules; then
|
|
|
|
die "Run 'zfs.sh' to ensure the full module stack is loaded"
|
|
|
|
fi
|
2008-12-05 19:32:34 +00:00
|
|
|
fi
|
|
|
|
|
2009-01-21 05:34:09 +00:00
|
|
|
# Wait for device creation
|
2009-01-16 21:25:16 +00:00
|
|
|
while [ ! -c /dev/zpios ]; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
2009-01-16 20:19:15 +00:00
|
|
|
if [ ${VERBOSE} ]; then
|
|
|
|
print_header
|
|
|
|
print_spl_info
|
|
|
|
print_zfs_info
|
|
|
|
fi
|
|
|
|
|
2009-01-16 20:23:53 +00:00
|
|
|
# Create the zpool configuration
|
2009-10-23 18:56:15 +00:00
|
|
|
${ZPOOL_CREATE_SH} ${VERBOSE_FLAG} ${FORCE_FLAG} \
|
|
|
|
-p ${ZPOOL_NAME} -c ${ZPOOL_CONFIG} \
|
2009-02-06 22:58:31 +00:00
|
|
|
-l "${ZPOOL_OPTIONS}" -s "${ZFS_OPTIONS}" || exit 1
|
2008-12-05 19:32:34 +00:00
|
|
|
|
2009-02-19 22:51:40 +00:00
|
|
|
if [ ${PROFILE} ]; then
|
|
|
|
zpios_profile_start
|
2009-01-16 20:19:15 +00:00
|
|
|
fi
|
|
|
|
|
2009-01-20 22:32:02 +00:00
|
|
|
zpios_start
|
|
|
|
zpios_stop
|
2009-01-21 05:34:09 +00:00
|
|
|
|
2009-02-19 22:51:40 +00:00
|
|
|
if [ ${PROFILE} ]; then
|
|
|
|
zpios_profile_stop
|
|
|
|
fi
|
|
|
|
|
2009-01-21 05:34:09 +00:00
|
|
|
if [ ${VERBOSE} ]; then
|
|
|
|
print_stats
|
|
|
|
fi
|
2009-01-16 22:58:48 +00:00
|
|
|
|
2009-01-20 22:32:02 +00:00
|
|
|
# Destroy the zpool configuration
|
2009-10-23 18:56:15 +00:00
|
|
|
${ZPOOL_CREATE_SH} ${VERBOSE_FLAG} ${FORCE_FLAG} \
|
|
|
|
-p ${ZPOOL_NAME} -c ${ZPOOL_CONFIG} -d || exit 1
|
2008-12-05 19:32:34 +00:00
|
|
|
|
2009-01-21 05:34:09 +00:00
|
|
|
# Unload the test module stack and wait for device removal
|
2009-01-16 22:58:48 +00:00
|
|
|
unload_modules
|
2009-01-21 05:34:09 +00:00
|
|
|
while [ -c /dev/zpios ]; do
|
|
|
|
sleep 1
|
|
|
|
done
|
2009-01-09 00:53:29 +00:00
|
|
|
|
|
|
|
exit 0
|