X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=scripts%2Fzpios.sh;h=e16a58a3ba6cd927b9347c0f3176c7e7c30c3464;hb=7dc3830c0f591ae8dfe349cf67c0c61cc8602dc8;hp=342ecd1f5da09a7ebadacaf578e2f7a1347aa17d;hpb=100eb88b46781b3777b59a81cc2e800ff386d9f3;p=zfs.git diff --git a/scripts/zpios.sh b/scripts/zpios.sh index 342ecd1..e16a58a 100755 --- a/scripts/zpios.sh +++ b/scripts/zpios.sh @@ -1,133 +1,272 @@ #!/bin/bash +# +# Wrapper script for easily running zpios based tests +# -prog=zpios.sh -. ../.script-config +basedir="$(dirname $0)" -SPL_OPTIONS="spl_debug_mask=0 spl_debug_subsys=0 ${1}" -ZPOOL_OPTIONS=$2 -KPIOS_OPTIONS=$3 -PROFILE_KPIOS_LOGS=$4 -KPIOS_PRE=$5 -KPIOS_POST=$6 +SCRIPT_COMMON=common.sh +if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then +. "${basedir}/${SCRIPT_COMMON}" +else +echo "Missing helper script ${SCRIPT_COMMON}" && exit 1 +fi -PROFILE_KPIOS_PRE=/home/behlendo/src/zfs/scripts/profile-kpios-pre.sh -PROFILE_KPIOS_POST=/home/behlendo/src/zfs/scripts/profile-kpios-post.sh +PROG=zpios.sh +DATE=`date +%Y%m%d-%H%M%S` +if [ "${ZPIOS_MODULES}" ]; then + MODULES=(${ZPIOS_MODULES[*]}) +else + MODULES=(zpios) +fi -DEVICES="/dev/hda" +usage() { +cat << EOF +USAGE: +$0 [hvp] <-c config> <-t test> -echo ------------------------- ZFS TEST LOG --------------------------------- -echo -n "Date = "; date -echo -n "Kernel = "; uname -r -echo ------------------------------------------------------------------------ +DESCRIPTION: + Helper script for easy zpios benchmarking. -echo -./load-zfs.sh "${SPL_OPTIONS}" "${ZPOOL_OPTIONS}" +OPTIONS: + -h Show this message + -v Verbose + -f Force everything + -p Enable profiling + -c Zpool configuration + -t Zpios test + -o Additional zpios options + -l Additional zpool options + -s Additional zfs options -echo ---------------------- SPL Sysctl Tunings ------------------------------ -sysctl -A | grep spl -echo +EOF +} -echo ------------------- SPL/ZPOOL Module Tunings --------------------------- -if [ -d /sys/module/spl/parameters ]; then - grep [0-9] /sys/module/spl/parameters/* - grep [0-9] /sys/module/zpool/parameters/* -else - grep [0-9] /sys/module/spl/* - grep [0-9] /sys/module/zpool/* +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 ------------------------------ + ${SYSCTL} -A | grep spl + + if [ -d /sys/module/spl/parameters ]; then + grep [0-9] /sys/module/spl/parameters/* + else + grep [0-9] /sys/module/spl/* + fi + + echo +} + +print_zfs_info() { + echo --------------------- ZFS Tunings ------------------------------ + ${SYSCTL} -A | grep zfs + + if [ -d /sys/module/zfs/parameters ]; then + grep [0-9] /sys/module/zfs/parameters/* + else + grep [0-9] /sys/module/zfs/* + fi + + echo +} + +print_stats() { + echo ---------------------- Statistics ------------------------------- + ${SYSCTL} -A | grep spl | grep stack_max + + 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 + + if [ -f /proc/spl/kmem/slab ]; then + echo "* SPL SLAB" + cat /proc/spl/kmem/slab + echo + fi + + echo +} + +check_test() { + + if [ ! -f ${ZPIOS_TEST} ]; then + local NAME=`basename ${ZPIOS_TEST} .sh` + ERROR="Unknown test '${NAME}', available tests are:\n" + + for TST in `ls ${ZPIOSDIR}/ | grep ".sh"`; do + local NAME=`basename ${TST} .sh` + ERROR="${ERROR}${NAME}\n" + done + + return 1 + fi + + return 0 +} + +zpios_profile_config() { +cat > ${PROFILE_DIR}/zpios-config.sh << EOF +# +# Zpios Profiling Configuration +# + +PROFILE_DIR=/tmp/zpios/${ZPOOL_CONFIG}+${ZPIOS_TEST_ARG}+${DATE} +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 +PROFILE_ARC_PROC=/proc/spl/kstat/zfs/arcstats +PROFILE_VDEV_CACHE_PROC=/proc/spl/kstat/zfs/vdev_cache_stats + +OPROFILE_KERNEL="/boot/vmlinux-`uname -r`" +OPROFILE_KERNEL_DIR="/lib/modules/`uname -r`/kernel/" +OPROFILE_SPL_DIR=${SPLBUILD}/module/ +OPROFILE_ZFS_DIR=${MODDIR} + +EOF +} + +zpios_profile_start() { + PROFILE_DIR=/tmp/zpios/${ZPOOL_CONFIG}+${ZPIOS_TEST_ARG}+${DATE} + + mkdir -p ${PROFILE_DIR} + zpios_profile_config + . ${PROFILE_DIR}/zpios-config.sh + + ZPIOS_OPTIONS="${ZPIOS_OPTIONS} --log=${PROFILE_DIR}" + ZPIOS_OPTIONS="${ZPIOS_OPTIONS} --prerun=${PROFILE_PRE}" + ZPIOS_OPTIONS="${ZPIOS_OPTIONS} --postrun=${PROFILE_POST}" + + /usr/bin/opcontrol --init + /usr/bin/opcontrol --setup --vmlinux=${OPROFILE_KERNEL} +} + +zpios_profile_stop() { + /usr/bin/opcontrol --shutdown + /usr/bin/opcontrol --deinit +} + +PROFILE= +ZPOOL_CONFIG=zpool-config.sh +ZPIOS_TEST=zpios-test.sh +ZPOOL_NAME=zpios +ZPIOS_OPTIONS= +ZPOOL_OPTIONS="" +ZFS_OPTIONS="" + +while getopts 'hvfpc:t:o:l:s:' OPTION; do + case $OPTION in + h) + usage + exit 1 + ;; + v) + VERBOSE=1 + VERBOSE_FLAG="-v" + ;; + f) + FORCE=1 + FORCE_FLAG="-f" + ;; + p) + PROFILE=1 + ;; + c) + ZPOOL_CONFIG=${OPTARG} + ;; + t) + ZPIOS_TEST_ARG=${OPTARG} + ZPIOS_TEST=${ZPIOSDIR}/${OPTARG}.sh + ;; + o) + ZPIOS_OPTIONS=${OPTARG} + ;; + l) # Passed through to zpool-create.sh + ZPOOL_OPTIONS=${OPTARG} + ;; + s) # Passed through to zpool-create.sh + ZFS_OPTIONS=${OPTARG} + ;; + ?) + usage + exit + ;; + esac +done + +if [ $(id -u) != 0 ]; then + die "Must run as root" +fi + +# Validate and source your test config +check_test || die "${ERROR}" +. ${ZPIOS_TEST} + +# 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 fi -echo -echo "${CMDDIR}/zpool/zpool create -f lustre ${DEVICES}" -${CMDDIR}/zpool/zpool create -f lustre ${DEVICES} +# Wait for device creation +while [ ! -c /dev/zpios ]; do + sleep 1 +done + +if [ ${VERBOSE} ]; then + print_header + print_spl_info + print_zfs_info +fi + +# Create the zpool configuration +${ZPOOL_CREATE_SH} ${VERBOSE_FLAG} ${FORCE_FLAG} \ + -p ${ZPOOL_NAME} -c ${ZPOOL_CONFIG} \ + -l "${ZPOOL_OPTIONS}" -s "${ZFS_OPTIONS}" || exit 1 + +if [ ${PROFILE} ]; then + zpios_profile_start +fi + +zpios_start +zpios_stop + +if [ ${PROFILE} ]; then + zpios_profile_stop +fi + +if [ ${VERBOSE} ]; then + print_stats +fi -echo "${CMDDIR}/zpool/zpool status lustre" -${CMDDIR}/zpool/zpool status lustre +# Destroy the zpool configuration +${ZPOOL_CREATE_SH} ${VERBOSE_FLAG} ${FORCE_FLAG} \ + -p ${ZPOOL_NAME} -c ${ZPOOL_CONFIG} -d || exit 1 -echo "Waiting for /dev/kpios to come up..." -while [ ! -c /dev/kpios ]; do +# Unload the test module stack and wait for device removal +unload_modules +while [ -c /dev/zpios ]; do sleep 1 done -if [ -n "${KPIOS_PRE}" ]; then - ${KPIOS_PRE} -fi - -# Usage: zpios -# --chunksize -c =values -# --chunksize_low -a =value -# --chunksize_high -b =value -# --chunksize_incr -g =value -# --offset -o =values -# --offset_low -m =value -# --offset_high -q =value -# --offset_incr -r =value -# --regioncount -n =values -# --regioncount_low -i =value -# --regioncount_high -j =value -# --regioncount_incr -k =value -# --threadcount -t =values -# --threadcount_low -l =value -# --threadcount_high -h =value -# --threadcount_incr -e =value -# --regionsize -s =values -# --regionsize_low -A =value -# --regionsize_high -B =value -# --regionsize_incr -C =value -# --cleanup -x -# --verify -V -# --zerocopy -z -# --threaddelay -T =jiffies -# --regionnoise -I =shift -# --chunknoise -N =bytes -# --prerun -P =pre-command -# --postrun -R =post-command -# --log -G =log directory -# --pool | --path -p =pool name -# --load -L =dmuio -# --help -? =this help -# --verbose -v =increase verbosity - -# --prerun=${PROFILE_KPIOS_PRE} \ -# --postrun=${PROFILE_KPIOS_POST} \ - -CMD="${CMDDIR}/zpios/zpios \ - --load=dmuio \ - --path=lustre \ - --chunksize=1M \ - --regionsize=4M \ - --regioncount=64 \ - --threadcount=4 \ - --offset=4M \ - --cleanup \ - --verbose \ - --human-readable \ - ${KPIOS_OPTIONS} \ - --log=${PROFILE_KPIOS_LOGS}" -echo -date -echo ${CMD} -$CMD -date - -if [ -n "${KPIOS_POST}" ]; then - ${KPIOS_POST} -fi - -${CMDDIR}/zpool/zpool destroy lustre - -echo ---------------------- SPL Sysctl Tunings ------------------------------ -sysctl -A | grep spl -echo - -echo ------------------------ KSTAT Statistics ------------------------------ -echo ARCSTATS -cat /proc/spl/kstat/zfs/arcstats -echo -echo VDEV_CACHE_STATS -cat /proc/spl/kstat/zfs/vdev_cache_stats -echo -echo SLAB -cat /proc/spl/kmem/slab -echo - -./unload-zfs.sh +exit 0