summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/common.sh.in26
-rwxr-xr-xscripts/zfs.sh2
2 files changed, 28 insertions, 0 deletions
diff --git a/scripts/common.sh.in b/scripts/common.sh.in
index cf5585945..51671ebc0 100644
--- a/scripts/common.sh.in
+++ b/scripts/common.sh.in
@@ -635,3 +635,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
+}
diff --git a/scripts/zfs.sh b/scripts/zfs.sh
index 4a707fabf..f44053e88 100755
--- a/scripts/zfs.sh
+++ b/scripts/zfs.sh
@@ -66,8 +66,10 @@ 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