freebsd-dev/scripts/zfs.sh
Brian Behlendorf 10715a0187 Add default stack checking
When your kernel is built with kernel stack tracing enabled and you
have the debugfs filesystem mounted.  Then the zfs.sh script will clear
the worst observed kernel stack depth on module load and check the worst
case usage on module removal.  If the stack depth ever exceeds 7000
bytes the full stack will be printed for debugging.  This is dangerously
close to overrunning the default 8k stack.

This additional advisory debugging is particularly valuable when running
the regression tests on a kernel built with 16k stacks.  In this case,
almost no matter how bad the stack overrun is you will see be able to
get a clean stack trace for debugging.  Since the worst case stack usage
can be highly variable it's helpful to always check the worst case usage.
2011-06-13 13:50:21 -07:00

79 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
#
# A simple script to simply the loading/unloading the ZFS module stack.
basedir="$(dirname $0)"
SCRIPT_COMMON=common.sh
if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
. "${basedir}/${SCRIPT_COMMON}"
else
echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
fi
PROG=zfs.sh
UNLOAD=
usage() {
cat << EOF
USAGE:
$0 [hvud] [module-options]
DESCRIPTION:
Load/unload the ZFS module stack.
OPTIONS:
-h Show this message
-v Verbose
-u Unload modules
-d Save debug log on unload
MODULE-OPTIONS:
Must be of the from module="options", for example:
$0 zfs="zfs_prefetch_disable=1"
$0 zfs="zfs_prefetch_disable=1 zfs_mdcomp_disable=1"
$0 spl="spl_debug_mask=0"
EOF
}
while getopts 'hvud' OPTION; do
case $OPTION in
h)
usage
exit 1
;;
v)
VERBOSE=1
;;
u)
UNLOAD=1
;;
d)
DUMP_LOG=1
;;
?)
usage
exit
;;
esac
done
if [ $(id -u) != 0 ]; then
die "Must run as root"
fi
if [ ${UNLOAD} ]; then
umount -t zfs -a
stack_check
unload_modules
else
stack_clear
check_modules || die "${ERROR}"
load_modules "$@"
wait_udev /dev/zfs 30
fi
exit 0