4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * libcfs/libcfs/linux/linux-debug.c
34 * Author: Phil Schwan <phil@clusterfs.com>
37 #include <linux/module.h>
38 #include <linux/kmod.h>
39 #include <linux/notifier.h>
40 #include <linux/kernel.h>
42 #include <linux/string.h>
43 #include <linux/stat.h>
44 #include <linux/errno.h>
45 #include <linux/unistd.h>
46 #include <linux/interrupt.h>
47 #include <linux/completion.h>
49 #include <linux/uaccess.h>
50 #include <linux/miscdevice.h>
52 # define DEBUG_SUBSYSTEM S_LNET
54 #include "../../../include/linux/libcfs/libcfs.h"
56 #include "../tracefile.h"
58 #include <linux/kallsyms.h>
60 char lnet_debug_log_upcall[1024] = "/usr/lib/lustre/lnet_debug_log_upcall";
63 * Upcall function once a Lustre log has been dumped.
65 * \param file path of the dumped log
67 void libcfs_run_debug_log_upcall(char *file)
71 static const char * const envp[] = {
73 "PATH=/sbin:/bin:/usr/sbin:/usr/bin",
77 argv[0] = lnet_debug_log_upcall;
79 LASSERTF(file, "called on a null filename\n");
80 argv[1] = file; /* only need to pass the path of the file */
84 rc = call_usermodehelper(argv[0], argv, (char **)envp, 1);
85 if (rc < 0 && rc != -ENOENT) {
86 CERROR("Error %d invoking LNET debug log upcall %s %s; check /sys/kernel/debug/lnet/debug_log_upcall\n",
87 rc, argv[0], argv[1]);
89 CDEBUG(D_HA, "Invoked LNET debug log upcall %s %s\n",
95 void __noreturn lbug_with_loc(struct libcfs_debug_msg_data *msgdata)
97 libcfs_catastrophe = 1;
98 libcfs_debug_msg(msgdata, "LBUG\n");
100 if (in_interrupt()) {
101 panic("LBUG in interrupt.\n");
106 if (!libcfs_panic_on_lbug)
107 libcfs_debug_dumplog();
108 if (libcfs_panic_on_lbug)
110 set_task_state(current, TASK_UNINTERRUPTIBLE);
114 EXPORT_SYMBOL(lbug_with_loc);
116 static int panic_notifier(struct notifier_block *self, unsigned long unused1,
119 if (libcfs_panic_in_progress)
122 libcfs_panic_in_progress = 1;
128 static struct notifier_block libcfs_panic_notifier = {
129 .notifier_call = panic_notifier,
134 void libcfs_register_panic_notifier(void)
136 atomic_notifier_chain_register(&panic_notifier_list,
137 &libcfs_panic_notifier);
140 void libcfs_unregister_panic_notifier(void)
142 atomic_notifier_chain_unregister(&panic_notifier_list,
143 &libcfs_panic_notifier);