diff mbox series

[22/49] lnet: libcfs: restore LNET_DUMP_ON_PANIC functionality.

Message ID 1618459361-17909-23-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: sync to OpenSFS as of March 30 2021 | expand

Commit Message

James Simmons April 15, 2021, 4:02 a.m. UTC
From: Mr NeilBrown <neilb@suse.de>

The functionality enabled by CONFIG_LNET_DUMP_ON_PANIC was never
implemented for the Linux client.

Restore this functionality.

While we are there, add conditional-compliation for other code that is
only needed when this is enabled.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14427
Lustre-commit: f9b75c5fb4d4e397 ("LU-14427 libcfs: restore LNET_DUMP_ON_PANIC functionality.")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/41488
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/Kconfig            | 9 +++++++++
 net/lnet/libcfs/debug.c     | 9 +++++++++
 net/lnet/libcfs/tracefile.c | 2 ++
 3 files changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/net/lnet/Kconfig b/net/lnet/Kconfig
index 6062a82..b5ee5fa 100644
--- a/net/lnet/Kconfig
+++ b/net/lnet/Kconfig
@@ -8,6 +8,15 @@  config LNET
 	  case of Lustre routers only the LNet layer is required. Lately other
 	  projects are also looking into using LNet as their networking API as well.
 
+config LNET_DUMP_ON_PANIC
+	bool "LNet dump logs on panic"
+	depends on LNET
+	help
+	  Special funcitonality to enable collecting extra logs when LNet panics.
+	  Normally only used by developers for debugging purposes.
+
+	  If unsure, say N.
+
 config LNET_SELFTEST
 	tristate "Lustre networking self testing"
 	depends on LNET
diff --git a/net/lnet/libcfs/debug.c b/net/lnet/libcfs/debug.c
index e68dd91..e519fdb 100644
--- a/net/lnet/libcfs/debug.c
+++ b/net/lnet/libcfs/debug.c
@@ -503,6 +503,15 @@  static int panic_notifier(struct notifier_block *self, unsigned long unused1,
 	libcfs_panic_in_progress = 1;
 	mb();
 
+#ifdef CONFIG_LNET_DUMP_ON_PANIC
+	/* This is currently disabled because it spews far too much to the
+	 * console on the rare cases it is ever triggered.
+	 */
+	if (in_interrupt())
+		cfs_trace_debug_print();
+	else
+		libcfs_debug_dumplog_internal((void *)(long)current->pid);
+#endif
 	return 0;
 }
 
diff --git a/net/lnet/libcfs/tracefile.c b/net/lnet/libcfs/tracefile.c
index 4e1900d..32bab98 100644
--- a/net/lnet/libcfs/tracefile.c
+++ b/net/lnet/libcfs/tracefile.c
@@ -764,6 +764,7 @@  static void put_pages_on_daemon_list(struct page_collection *pc)
 	}
 }
 
+#ifdef CONFIG_LNET_DUMP_ON_PANIC
 void cfs_trace_debug_print(void)
 {
 	struct page_collection pc;
@@ -801,6 +802,7 @@  void cfs_trace_debug_print(void)
 		cfs_tage_free(tage);
 	}
 }
+#endif /* CONFIG_LNET_DUMP_ON_PANIC */
 
 int cfs_tracefile_dump_all_pages(char *filename)
 {