3 # usage: debug_upcall.sh <lctl-dk-log-file>
5 # Dumps locks to the Lustre kernel ring buffer and then appends the contents of
6 # the Lustre kernel ring buffer to the given debug log file.
8 # This is meant to be set as the debug_log_upcall, which is called by Lustre
9 # after dumping logs with libcfs_debug_dumplog_internal(). Lustre passes the
10 # upcall the name of the file to which the trace buffer was dumped.
12 # To set the Lustre debug_upcall to this script, set the debug_upcall to the
13 # path to this script using "lctl set_param" as follows:
15 # # lctl set_param debug_log_upcall=/path/to/this/script
19 # Enable dlmtrace to get locks dumped, but save the old state first
20 oldDebug=$(lctl get_param -n debug)
21 lctl set_param debug=+dlmtrace
22 lctl set_param ldlm.dump_namespaces=1
24 # Dump logs in raw form
25 tmpLockDump=$(mktemp /tmp/lustre-ldlm-dump.XXXXX)
26 lctl dk $tmpLockDump 1
27 # Remove the line indicating how many lines were dumped
28 sed '/^Debug log:/d' $tmpLockDump >> $debugLogFile
31 # Restore the old debug state
32 lctl set_param debug="$oldDebug"