3 # Wrapper script for easily running zpios based tests
6 basedir="$(dirname $0)"
8 SCRIPT_COMMON=common.sh
9 if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
10 . "${basedir}/${SCRIPT_COMMON}"
12 echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
16 DATE=`date +%Y%m%d-%H%M%S`
17 if [ "${ZPIOS_MODULES}" ]; then
18 MODULES=(${ZPIOS_MODULES[*]})
26 $0 [hvp] <-c config> <-t test>
29 Helper script for easy zpios benchmarking.
36 -c Zpool configuration
38 -o Additional zpios options
39 -l Additional zpool options
40 -s Additional zfs options
46 echo --------------------- ZPIOS RESULTS ----------------------------
47 echo -n "Date: "; date
48 echo -n "Kernel: "; uname -r
49 dmesg | grep "Loaded Solaris Porting Layer" | tail -n1
50 dmesg | grep "Loaded ZFS Filesystem" | tail -n1
55 echo --------------------- SPL Tunings ------------------------------
56 ${SYSCTL} -A | grep spl
58 if [ -d /sys/module/spl/parameters ]; then
59 grep [0-9] /sys/module/spl/parameters/*
61 grep [0-9] /sys/module/spl/*
68 echo --------------------- ZFS Tunings ------------------------------
69 ${SYSCTL} -A | grep zfs
71 if [ -d /sys/module/zfs/parameters ]; then
72 grep [0-9] /sys/module/zfs/parameters/*
74 grep [0-9] /sys/module/zfs/*
81 echo ---------------------- Statistics -------------------------------
82 ${SYSCTL} -A | grep spl | grep stack_max
84 if [ -d /proc/spl/kstat/ ]; then
85 if [ -f /proc/spl/kstat/zfs/arcstats ]; then
87 cat /proc/spl/kstat/zfs/arcstats
91 if [ -f /proc/spl/kstat/zfs/vdev_cache_stats ]; then
93 cat /proc/spl/kstat/zfs/vdev_cache_stats
98 if [ -f /proc/spl/kmem/slab ]; then
100 cat /proc/spl/kmem/slab
109 if [ ! -f ${ZPIOS_TEST} ]; then
110 local NAME=`basename ${ZPIOS_TEST} .sh`
111 ERROR="Unknown test '${NAME}', available tests are:\n"
113 for TST in `ls ${ZPIOSDIR}/ | grep ".sh"`; do
114 local NAME=`basename ${TST} .sh`
115 ERROR="${ERROR}${NAME}\n"
124 zpios_profile_config() {
125 cat > ${PROFILE_DIR}/zpios-config.sh << EOF
127 # Zpios Profiling Configuration
130 PROFILE_DIR=/tmp/zpios/${ZPOOL_CONFIG}+${ZPIOS_TEST_ARG}+${DATE}
131 PROFILE_PRE=${ZPIOSPROFILEDIR}/zpios-profile-pre.sh
132 PROFILE_POST=${ZPIOSPROFILEDIR}/zpios-profile-post.sh
133 PROFILE_USER=${ZPIOSPROFILEDIR}/zpios-profile.sh
134 PROFILE_PIDS=${ZPIOSPROFILEDIR}/zpios-profile-pids.sh
135 PROFILE_DISK=${ZPIOSPROFILEDIR}/zpios-profile-disk.sh
136 PROFILE_ARC_PROC=/proc/spl/kstat/zfs/arcstats
137 PROFILE_VDEV_CACHE_PROC=/proc/spl/kstat/zfs/vdev_cache_stats
139 OPROFILE_KERNEL="/boot/vmlinux-`uname -r`"
140 OPROFILE_KERNEL_DIR="/lib/modules/`uname -r`/kernel/"
141 OPROFILE_SPL_DIR=${SPLBUILD}/module/
142 OPROFILE_ZFS_DIR=${MODDIR}
147 zpios_profile_start() {
148 PROFILE_DIR=/tmp/zpios/${ZPOOL_CONFIG}+${ZPIOS_TEST_ARG}+${DATE}
150 mkdir -p ${PROFILE_DIR}
152 . ${PROFILE_DIR}/zpios-config.sh
154 ZPIOS_OPTIONS="${ZPIOS_OPTIONS} --log=${PROFILE_DIR}"
155 ZPIOS_OPTIONS="${ZPIOS_OPTIONS} --prerun=${PROFILE_PRE}"
156 ZPIOS_OPTIONS="${ZPIOS_OPTIONS} --postrun=${PROFILE_POST}"
158 /usr/bin/opcontrol --init
159 /usr/bin/opcontrol --setup --vmlinux=${OPROFILE_KERNEL}
162 zpios_profile_stop() {
163 /usr/bin/opcontrol --shutdown
164 /usr/bin/opcontrol --deinit
168 ZPOOL_CONFIG=zpool-config.sh
169 ZPIOS_TEST=zpios-test.sh
175 while getopts 'hvfpc:t:o:l:s:' OPTION; do
193 ZPOOL_CONFIG=${OPTARG}
196 ZPIOS_TEST_ARG=${OPTARG}
197 ZPIOS_TEST=${ZPIOSDIR}/${OPTARG}.sh
200 ZPIOS_OPTIONS=${OPTARG}
202 l) # Passed through to zpool-create.sh
203 ZPOOL_OPTIONS=${OPTARG}
205 s) # Passed through to zpool-create.sh
206 ZFS_OPTIONS=${OPTARG}
215 if [ $(id -u) != 0 ]; then
216 die "Must run as root"
219 # Validate and source your test config
220 check_test || die "${ERROR}"
223 # Pull in the zpios test module is not loaded. If this fails it is
224 # likely because the full module stack was not yet loaded with zfs.sh
225 if check_modules; then
226 if ! load_modules; then
227 die "Run 'zfs.sh' to ensure the full module stack is loaded"
231 # Wait for device creation
232 while [ ! -c /dev/zpios ]; do
236 if [ ${VERBOSE} ]; then
242 # Create the zpool configuration
243 ${ZPOOL_CREATE_SH} ${VERBOSE_FLAG} ${FORCE_FLAG} \
244 -p ${ZPOOL_NAME} -c ${ZPOOL_CONFIG} \
245 -l "${ZPOOL_OPTIONS}" -s "${ZFS_OPTIONS}" || exit 1
247 if [ ${PROFILE} ]; then
254 if [ ${PROFILE} ]; then
258 if [ ${VERBOSE} ]; then
262 # Destroy the zpool configuration
263 ${ZPOOL_CREATE_SH} ${VERBOSE_FLAG} ${FORCE_FLAG} \
264 -p ${ZPOOL_NAME} -c ${ZPOOL_CONFIG} -d || exit 1
266 # Unload the test module stack and wait for device removal
268 while [ -c /dev/zpios ]; do