Skip to content

Commit

Permalink
ctdb-scripts: Dump stack traces of smbd processes after shutdown
Browse files Browse the repository at this point in the history
If any processes remain then they may be stuck in D state and this
might tell us why.

Update tests: tweak pidof stub, add support for smbd stack traces and
add some new tests for the shutdown event.

Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>

Autobuild-User(master): Amitay Isaacs <[email protected]>
Autobuild-Date(master): Mon Oct 10 12:54:24 CEST 2016 on sn-devel-144
  • Loading branch information
martin-schwenke authored and Amitay Isaacs committed Oct 10, 2016
1 parent b3d938c commit 72e415b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 6 deletions.
1 change: 1 addition & 0 deletions ctdb/config/events.d/50.samba
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ service_start ()
service_stop ()
{
service "$CTDB_SERVICE_SMB" stop
program_stack_traces "smbd" 5
if [ -n "$CTDB_SERVICE_NMB" ] ; then
service "$CTDB_SERVICE_NMB" stop
fi
Expand Down
12 changes: 12 additions & 0 deletions ctdb/tests/eventscripts/50.samba.shutdown.001.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

. "${TEST_SCRIPTS_DIR}/unit.sh"

define_test "shutdown, simple"

setup_samba

ok <<EOF
Stopping smb: OK
EOF
simple_test
15 changes: 15 additions & 0 deletions ctdb/tests/eventscripts/50.samba.shutdown.002.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

. "${TEST_SCRIPTS_DIR}/unit.sh"

define_test "shutdown, simple"

setup_samba

samba_setup_fake_threads 1 2 3 4 5 6

ok <<EOF
Stopping smb: OK
$SAMBA_STACK_TRACES
EOF
simple_test
33 changes: 29 additions & 4 deletions ctdb/tests/eventscripts/scripts/local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,23 @@ setup_samba ()
fi
}

samba_setup_fake_threads ()
{
export FAKE_SMBD_THREAD_PIDS="$*"

_nl="
"
_out=""
_count=0
for _pid ; do
[ "$_count" -lt 5 ] || break
_t=$(program_stack_trace "smbd" $_pid)
_out="${_out:+${_out}${_nl}}${_t}"
_count=$((_count + 1))
done
SAMBA_STACK_TRACES="$_out"
}

setup_winbind ()
{
setup_ctdb
Expand Down Expand Up @@ -999,6 +1016,17 @@ nfs_setup_fake_threads ()
esac
}

program_stack_trace ()
{
_prog="$1"
_pid="$2"

cat <<EOF
Stack trace for ${_prog}[${_pid}]:
[<ffffffff87654321>] fake_stack_trace_for_pid_${_pid}/stack+0x0/0xff
EOF
}

program_stack_traces ()
{
_prog="$1"
Expand All @@ -1008,10 +1036,7 @@ program_stack_traces ()
for _pid in ${FAKE_NFSD_THREAD_PIDS:-$FAKE_RPC_THREAD_PIDS} ; do
[ $_count -le $_max ] || break

cat <<EOF
Stack trace for ${_prog}[${_pid}]:
[<ffffffff87654321>] fake_stack_trace_for_pid_${_pid}/stack+0x0/0xff
EOF
program_stack_trace "$_prog" "$_pid"
_count=$(($_count + 1))
done
}
Expand Down
7 changes: 5 additions & 2 deletions ctdb/tests/eventscripts/stubs/pidof
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/bin/sh

case "$1" in
nfsd)
nfsd)
echo "$FAKE_NFSD_THREAD_PIDS"
;;
rpc.statd|rpc.rquotad|rpc.mountd)
rpc.statd|rpc.rquotad|rpc.mountd)
echo "$FAKE_RPC_THREAD_PIDS"
;;
smbd)
echo "$FAKE_SMBD_THREAD_PIDS"
;;
*)
echo "pidof: \"$1\" not implemented"
exit 1
Expand Down

0 comments on commit 72e415b

Please sign in to comment.