Whamcloud - gitweb
LU-11071 build: add files to .gitignore
[fs/lustre-release.git] / lustre / utils / ldlm_debug_upcall
1 #!/bin/bash
2 #
3 # usage: debug_upcall.sh <lctl-dk-log-file>
4 #
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.
7 #
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.
11 #
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:
14 #
15 # # lctl set_param debug_log_upcall=/path/to/this/script
16
17 debugLogFile="$1"
18
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
23
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
29 rm $tmpLockDump
30
31 # Restore the old debug state
32 lctl set_param debug="$oldDebug"