X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=scripts%2Fcommon.sh.in;h=56706194ccb7875a8e20a0bfea152e433c75873d;hb=f783130a1f11616632a7a6f519140f97389688a6;hp=2583efcb209bb9b2e109fc481caba0629180a918;hpb=cf47fad67d798f42e6d2edc8b0e9f9b43175703b;p=zfs.git diff --git a/scripts/common.sh.in b/scripts/common.sh.in index 2583efc..5670619 100644 --- a/scripts/common.sh.in +++ b/scripts/common.sh.in @@ -36,6 +36,9 @@ libexecdir=@libexecdir@ pkglibexecdir=${libexecdir}/@PACKAGE@ bindir=@bindir@ sbindir=@sbindir@ +udevdir=@udevdir@ +udevruledir=@udevruledir@ +sysconfdir=@sysconfdir@ ETCDIR=${ETCDIR:-/etc} DEVDIR=${DEVDIR:-/dev/disk/zpool} @@ -113,6 +116,19 @@ skip() { echo -e "${COLOR_BROWN}Skip${COLOR_RESET}" } +init() { + # Disable the udev rule 90-zfs.rules to prevent the zfs module + # stack from being loaded due to the detection of a zfs device. + # This is important because the test scripts require full control + # over when and how the modules are loaded/unloaded. A trap is + # set to ensure the udev rule is correctly replaced on exit. + local RULE=${udevruledir}/90-zfs.rules + if test -e ${RULE}; then + trap "mv ${RULE}.disabled ${RULE}; exit $?" INT TERM EXIT + mv ${RULE} ${RULE}.disabled + fi +} + spl_dump_log() { ${SYSCTL} -w kernel.spl.debug.dump=1 &>/dev/null local NAME=`dmesg | tail -n 1 | cut -f5 -d' '` @@ -430,7 +446,7 @@ scsi_rescan() { # udev_trigger() { if [ -f ${UDEVADM} ]; then - ${UDEVADM} trigger + ${UDEVADM} trigger --action=change --subsystem-match=block ${UDEVADM} settle else /sbin/udevtrigger @@ -635,3 +651,29 @@ wait_udev() { return 0 } + +stack_clear() { + local STACK_MAX_SIZE=/sys/kernel/debug/tracing/stack_max_size + local STACK_TRACER_ENABLED=/proc/sys/kernel/stack_tracer_enabled + + if [ -e $STACK_MAX_SIZE ]; then + echo 1 >$STACK_TRACER_ENABLED + echo 0 >$STACK_MAX_SIZE + fi +} + +stack_check() { + local STACK_MAX_SIZE=/sys/kernel/debug/tracing/stack_max_size + local STACK_TRACE=/sys/kernel/debug/tracing/stack_trace + local STACK_LIMIT=7000 + + if [ -e $STACK_MAX_SIZE ]; then + STACK_SIZE=`cat $STACK_MAX_SIZE` + + if [ $STACK_SIZE -ge $STACK_LIMIT ]; then + echo + echo "Warning: max stack size $STACK_SIZE bytes" + cat $STACK_TRACE + fi + fi +}