Whamcloud - gitweb
LU-5149 utils: Create debug upcall to dump ldlm namespaces 17/10617/6
authorRyan Haasken <haasken@cray.com>
Thu, 5 Jun 2014 21:51:59 +0000 (16:51 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 26 Aug 2015 15:44:11 +0000 (15:44 +0000)
Created a script to be used as the debug_log_upcall which will dump
ldlm namespace information in raw/binary format and append it to the
given debug log file.

Signed-off-by: Ryan Haasken <haasken@cray.com>
Change-Id: I69f08f1b9563024c962f0213fd47a95b33b7da23
Reviewed-on: http://review.whamcloud.com/10617
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Chris Horn <hornc@cray.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/Makefile.am
lustre/utils/ldlm_debug_upcall [new file with mode: 0755]

index 4995e6b..82ffcab 100644 (file)
@@ -24,6 +24,7 @@ if UTILS
 rootsbin_PROGRAMS = mount.lustre
 bin_SCRIPTS   = llstat llobdstat plot-llstat
 bin_PROGRAMS  = lfs
+sbin_SCRIPTS  = ldlm_debug_upcall
 sbin_PROGRAMS = lctl l_getidentity llverfs lustre_rsync ltrack_stats
 
 if TESTS
@@ -173,7 +174,7 @@ wiretest_SOURCES = wiretest.c
 
 endif # UTILS
 
-EXTRA_DIST = llstat llobdstat plot-llstat
+EXTRA_DIST = llstat llobdstat plot-llstat ldlm_debug_upcall
 
 # NOTE: this should only be run on i386.
 newwiretest: wirehdr.c wirecheck
diff --git a/lustre/utils/ldlm_debug_upcall b/lustre/utils/ldlm_debug_upcall
new file mode 100755 (executable)
index 0000000..21b751f
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# usage: debug_upcall.sh <lctl-dk-log-file>
+#
+# Dumps locks to the Lustre kernel ring buffer and then appends the contents of
+# the Lustre kernel ring buffer to the given debug log file.
+#
+# This is meant to be set as the debug_log_upcall, which is called by Lustre
+# after dumping logs with libcfs_debug_dumplog_internal().  Lustre passes the
+# upcall the name of the file to which the trace buffer was dumped.
+#
+# To set the Lustre debug_upcall to this script, set the debug_upcall to the
+# path to this script using "lctl set_param" as follows:
+#
+# # lctl set_param debug_log_upcall=/path/to/this/script
+
+debugLogFile="$1"
+
+# Enable dlmtrace to get locks dumped, but save the old state first
+oldDebug=$(lctl get_param -n debug)
+lctl set_param debug=+dlmtrace
+lctl set_param ldlm.dump_namespaces=1
+
+# Dump logs in raw form
+tmpLockDump=$(mktemp /tmp/lustre-ldlm-dump.XXXXX)
+lctl dk $tmpLockDump 1
+# Remove the line indicating how many lines were dumped
+sed '/^Debug log:/d' $tmpLockDump >> $debugLogFile
+rm $tmpLockDump
+
+# Restore the old debug state
+lctl set_param debug="$oldDebug"