]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - scripts/zpios.sh
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
47 while [ -c /dev
/zpios
]; do
55 echo --------------------- ZPIOS RESULTS
----------------------------
56 echo -n "Date: "; date
57 echo -n "Kernel: "; uname
-r
58 dmesg |
grep "Loaded Solaris Porting Layer" |
tail -n1
59 dmesg |
grep "Loaded ZFS Filesystem" |
tail -n1
64 echo --------------------- SPL Tunings
------------------------------
65 ${SYSCTL} -A |
grep spl
67 if [ -d /sys
/module
/spl
/parameters
]; then
68 grep [0-9] /sys
/module
/spl
/parameters
/*
70 grep [0-9] /sys
/module
/spl
/*
77 echo --------------------- ZFS Tunings
------------------------------
78 ${SYSCTL} -A |
grep zfs
80 if [ -d /sys
/module
/zfs
/parameters
]; then
81 grep [0-9] /sys
/module
/zfs
/parameters
/*
83 grep [0-9] /sys
/module
/zfs
/*
90 echo ---------------------- Statistics
-------------------------------
91 ${SYSCTL} -A |
grep spl |
grep stack_max
93 if [ -d /proc
/spl
/kstat
/ ]; then
94 if [ -f /proc
/spl
/kstat
/zfs
/arcstats
]; then
96 cat /proc
/spl
/kstat
/zfs
/arcstats
100 if [ -f /proc
/spl
/kstat
/zfs
/vdev_cache_stats
]; then
102 cat /proc
/spl
/kstat
/zfs
/vdev_cache_stats
107 if [ -f /proc
/spl
/kmem
/slab
]; then
109 cat /proc
/spl
/kmem
/slab
118 if [ ! -f ${ZPIOS_TEST} ]; then
119 local NAME
=`basename ${ZPIOS_TEST} .sh`
120 ERROR
="Unknown test '${NAME}', available tests are:\n"
122 for TST
in `ls ${ZPIOSDIR}/ | grep ".sh"`; do
123 local NAME
=`basename ${TST} .sh`
124 ERROR
="${ERROR}${NAME}\n"
133 zpios_profile_config
() {
134 cat > ${PROFILE_DIR}/zpios-config.sh
<< EOF
136 # Zpios Profiling Configuration
139 PROFILE_DIR=/tmp/zpios/${ZPOOL_CONFIG}+${ZPIOS_TEST_ARG}+${DATE}
140 PROFILE_PRE=${ZPIOSPROFILEDIR}/zpios-profile-pre.sh
141 PROFILE_POST=${ZPIOSPROFILEDIR}/zpios-profile-post.sh
142 PROFILE_USER=${ZPIOSPROFILEDIR}/zpios-profile.sh
143 PROFILE_PIDS=${ZPIOSPROFILEDIR}/zpios-profile-pids.sh
144 PROFILE_DISK=${ZPIOSPROFILEDIR}/zpios-profile-disk.sh
145 PROFILE_ARC_PROC=/proc/spl/kstat/zfs/arcstats
146 PROFILE_VDEV_CACHE_PROC=/proc/spl/kstat/zfs/vdev_cache_stats
148 OPROFILE_KERNEL="/boot/vmlinux-`uname -r`"
149 OPROFILE_KERNEL_DIR="/lib/modules/`uname -r`/kernel/"
150 OPROFILE_SPL_DIR=${SPLBUILD}/module/
151 OPROFILE_ZFS_DIR=${MODDIR}
156 zpios_profile_start
() {
157 PROFILE_DIR
=/tmp
/zpios
/${ZPOOL_CONFIG}+${ZPIOS_TEST_ARG}+${DATE}
159 mkdir
-p ${PROFILE_DIR}
161 .
${PROFILE_DIR}/zpios-config.sh
163 ZPIOS_OPTIONS
="${ZPIOS_OPTIONS} --log=${PROFILE_DIR}"
164 ZPIOS_OPTIONS
="${ZPIOS_OPTIONS} --prerun=${PROFILE_PRE}"
165 ZPIOS_OPTIONS
="${ZPIOS_OPTIONS} --postrun=${PROFILE_POST}"
167 /usr
/bin
/opcontrol
--init
168 /usr
/bin
/opcontrol
--setup --vmlinux=${OPROFILE_KERNEL}
171 zpios_profile_stop
() {
172 /usr
/bin
/opcontrol
--shutdown
173 /usr
/bin
/opcontrol
--deinit
177 ZPOOL_CONFIG
=zpool-config.sh
178 ZPIOS_TEST
=zpios-test.sh
184 while getopts 'hvfpc:t:o:l:s:' OPTION
; do
202 ZPOOL_CONFIG
=${OPTARG}
205 ZPIOS_TEST_ARG
=${OPTARG}
206 ZPIOS_TEST
=${ZPIOSDIR}/${OPTARG}.sh
209 ZPIOS_OPTIONS
=${OPTARG}
211 l
) # Passed through to zpool-create.sh
212 ZPOOL_OPTIONS
=${OPTARG}
214 s
) # Passed through to zpool-create.sh
215 ZFS_OPTIONS
=${OPTARG}
224 if [ $
(id
-u) != 0 ]; then
225 die
"Must run as root"
228 # Validate and source your test config
229 check_test || die
"${ERROR}"
232 # Pull in the zpios test module is not loaded. If this fails it is
233 # likely because the full module stack was not yet loaded with zfs.sh
234 if check_modules
; then
235 if ! load_modules
; then
236 die
"Run 'zfs.sh' to ensure the full module stack is loaded"
240 # Wait for device creation
241 while [ ! -c /dev
/zpios
]; do
245 if [ ${VERBOSE} ]; then
251 # Create the zpool configuration
252 ${ZPOOL_CREATE_SH} ${VERBOSE_FLAG} ${FORCE_FLAG} \
253 -p ${ZPOOL_NAME} -c ${ZPOOL_CONFIG} \
254 -l "${ZPOOL_OPTIONS}" -s "${ZFS_OPTIONS}" || unload_die
256 if [ ${PROFILE} ]; then
263 if [ ${PROFILE} ]; then
267 if [ ${VERBOSE} ]; then
271 # Destroy the zpool configuration
272 ${ZPOOL_CREATE_SH} ${VERBOSE_FLAG} ${FORCE_FLAG} \
273 -p ${ZPOOL_NAME} -c ${ZPOOL_CONFIG} -d || unload_die
275 # Unload the test module stack and wait for device removal
277 while [ -c /dev
/zpios
]; do