Whamcloud - gitweb
LU-2053 crypto: Fix cfs_crypto_hash memleak
[fs/lustre-release.git] / libcfs / libcfs / linux / linux-debug.c
index 841d49f..9fc64e6 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  * Author: Phil Schwan <phil@clusterfs.com>
  */
 
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
-
-#ifndef AUTOCONF_INCLUDED
-#include <linux/config.h>
-#endif
 #include <linux/module.h>
 #include <linux/kmod.h>
 #include <linux/notifier.h>
@@ -55,7 +46,9 @@
 #include <linux/string.h>
 #include <linux/stat.h>
 #include <linux/errno.h>
+#ifdef HAVE_KERNEL_LOCKED
 #include <linux/smp_lock.h>
+#endif
 #include <linux/unistd.h>
 #include <linux/interrupt.h>
 #include <asm/system.h>
@@ -151,17 +144,17 @@ void libcfs_run_upcall(char **argv)
         }
 }
 
-void libcfs_run_lbug_upcall(const char *file, const char *fn, const int line)
+void libcfs_run_lbug_upcall(struct libcfs_debug_msg_data *msgdata)
 {
         char *argv[6];
         char buf[32];
 
         ENTRY;
-        snprintf (buf, sizeof buf, "%d", line);
+        snprintf (buf, sizeof buf, "%d", msgdata->msg_line);
 
         argv[1] = "LBUG";
-        argv[2] = (char *)file;
-        argv[3] = (char *)fn;
+        argv[2] = (char *)msgdata->msg_file;
+        argv[3] = (char *)msgdata->msg_fn;
         argv[4] = buf;
         argv[5] = NULL;
 
@@ -169,23 +162,22 @@ void libcfs_run_lbug_upcall(const char *file, const char *fn, const int line)
 }
 
 #ifdef __arch_um__
-void lbug_with_loc(const char *file, const char *func, const int line)
+void lbug_with_loc(struct libcfs_debug_msg_data *msgdata)
 {
         libcfs_catastrophe = 1;
-        libcfs_debug_msg(NULL, 0, D_EMERG, file, func, line,
-                         "LBUG - trying to dump log to %s\n",
+        libcfs_debug_msg(msgdata, "LBUG - trying to dump log to %s\n",
                          libcfs_debug_file_path);
         libcfs_debug_dumplog();
-        libcfs_run_lbug_upcall(file, func, line);
+        libcfs_run_lbug_upcall(msgdata);
         asm("int $3");
         panic("LBUG");
 }
 #else
 /* coverity[+kill] */
-void lbug_with_loc(const char *file, const char *func, const int line)
+void lbug_with_loc(struct libcfs_debug_msg_data *msgdata)
 {
         libcfs_catastrophe = 1;
-        libcfs_debug_msg(NULL, 0, D_EMERG, file, func, line, "LBUG\n");
+        libcfs_debug_msg(msgdata, "LBUG\n");
 
         if (in_interrupt()) {
                 panic("LBUG in interrupt.\n");
@@ -195,7 +187,7 @@ void lbug_with_loc(const char *file, const char *func, const int line)
         libcfs_debug_dumpstack(NULL);
         if (!libcfs_panic_on_lbug)
                 libcfs_debug_dumplog();
-        libcfs_run_lbug_upcall(file, func, line);
+        libcfs_run_lbug_upcall(msgdata);
         if (libcfs_panic_on_lbug)
                 panic("LBUG");
         set_task_state(current, TASK_UNINTERRUPTIBLE);
@@ -320,9 +312,10 @@ static int panic_notifier(struct notifier_block *self, unsigned long unused1,
         if (in_interrupt()) {
                 cfs_trace_debug_print();
         } else {
-                while (current->lock_depth >= 0)
-                        unlock_kernel();
-
+# ifdef HAVE_KERNEL_LOCKED
+               while (kernel_locked())
+                       unlock_kernel();
+# endif
                 libcfs_debug_dumplog_internal((void *)(long)cfs_curproc_pid());
         }
 #endif
@@ -337,20 +330,12 @@ static struct notifier_block libcfs_panic_notifier = {
 
 void libcfs_register_panic_notifier(void)
 {
-#ifdef HAVE_ATOMIC_PANIC_NOTIFIER
         atomic_notifier_chain_register(&panic_notifier_list, &libcfs_panic_notifier);
-#else
-        notifier_chain_register(&panic_notifier_list, &libcfs_panic_notifier);
-#endif
 }
 
 void libcfs_unregister_panic_notifier(void)
 {
-#ifdef HAVE_ATOMIC_PANIC_NOTIFIER
         atomic_notifier_chain_unregister(&panic_notifier_list, &libcfs_panic_notifier);
-#else
-        notifier_chain_unregister(&panic_notifier_list, &libcfs_panic_notifier);
-#endif
 }
 
 EXPORT_SYMBOL(libcfs_debug_dumpstack);