summaryrefslogtreecommitdiffstats
path: root/module/spl/spl-debug.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2010-07-19 14:16:05 -0700
committerBrian Behlendorf <[email protected]>2010-07-20 13:29:35 -0700
commit55abb0929e4fbe326a9737650a167a1a988ad86b (patch)
tree7fa8db9d12b4416f7f7e8e21cde864b501303924 /module/spl/spl-debug.c
parent8f813bb168eb21cd5d64b930ee015dcf93575331 (diff)
Split <sys/debug.h> header
To avoid symbol conflicts with dependent packages the debug header must be split in to several parts. The <sys/debug.h> header now only contains the Solaris macro's such as ASSERT and VERIFY. The spl-debug.h header contain the spl specific debugging infrastructure and should be included by any package which needs to use the spl logging. Finally the spl-trace.h header contains internal data structures only used for the log facility and should not be included by anythign by spl-debug.c. This way dependent packages can include the standard Solaris headers without picking up any SPL debug macros. However, if the dependant package want to integrate with the SPL debugging subsystem they can then explicitly include spl-debug.h. Along with this change I have dropped the CHECK_STACK macros because the upstream Linux kernel now has much better stack depth checking built in and we don't need this complexity. Additionally SBUG has been replaced with PANIC and provided as part of the Solaris macro set. While the Solaris version is really panic() that conflicts with the Linux kernel so we'll just have to make due to PANIC. It should rarely be called directly, the prefered usage would be an ASSERT or VERIFY. There's lots of change here but this cleanup was overdue.
Diffstat (limited to 'module/spl/spl-debug.c')
-rw-r--r--module/spl/spl-debug.c70
1 files changed, 29 insertions, 41 deletions
diff --git a/module/spl/spl-debug.c b/module/spl/spl-debug.c
index 75778752b..5284eb339 100644
--- a/module/spl/spl-debug.c
+++ b/module/spl/spl-debug.c
@@ -37,7 +37,8 @@
#include <linux/proc_compat.h>
#include <linux/file_compat.h>
#include <sys/sysmacros.h>
-#include <sys/debug.h>
+#include <spl-debug.h>
+#include <spl-trace.h>
#include <spl-ctl.h>
#ifdef DEBUG_SUBSYSTEM
@@ -48,17 +49,17 @@
unsigned long spl_debug_subsys = ~0;
EXPORT_SYMBOL(spl_debug_subsys);
-module_param(spl_debug_subsys, long, 0644);
+module_param(spl_debug_subsys, ulong, 0644);
MODULE_PARM_DESC(spl_debug_subsys, "Subsystem debugging level mask.");
unsigned long spl_debug_mask = (D_EMERG | D_ERROR | D_WARNING | D_CONSOLE);
EXPORT_SYMBOL(spl_debug_mask);
-module_param(spl_debug_mask, long, 0644);
+module_param(spl_debug_mask, ulong, 0644);
MODULE_PARM_DESC(spl_debug_mask, "Debugging level mask.");
unsigned long spl_debug_printk = D_CANTMASK;
EXPORT_SYMBOL(spl_debug_printk);
-module_param(spl_debug_printk, long, 0644);
+module_param(spl_debug_printk, ulong, 0644);
MODULE_PARM_DESC(spl_debug_printk, "Console printk level mask.");
int spl_debug_mb = -1;
@@ -74,7 +75,7 @@ EXPORT_SYMBOL(spl_debug_catastrophe);
unsigned int spl_debug_panic_on_bug = 0;
EXPORT_SYMBOL(spl_debug_panic_on_bug);
-module_param(spl_debug_panic_on_bug, int, 0644);
+module_param(spl_debug_panic_on_bug, uint, 0644);
MODULE_PARM_DESC(spl_debug_panic_on_bug, "Panic on BUG");
static char spl_debug_file_name[PATH_MAX];
@@ -633,10 +634,10 @@ trace_get_tage(struct trace_cpu_data *tcd, unsigned long len)
}
int
-spl_debug_vmsg(spl_debug_limit_state_t *cdls, int subsys, int mask,
- const char *file, const char *fn, const int line,
- const char *format1, va_list args, const char *format2, ...)
+spl_debug_msg(void *arg, int subsys, int mask, const char *file,
+ const char *fn, const int line, const char *format, ...)
{
+ spl_debug_limit_state_t *cdls = arg;
struct trace_cpu_data *tcd = NULL;
struct spl_debug_header header = { 0, };
struct trace_page *tage;
@@ -650,10 +651,16 @@ spl_debug_vmsg(spl_debug_limit_state_t *cdls, int subsys, int mask,
int i;
int remain;
+ if (subsys == 0)
+ subsys = DEBUG_SUBSYSTEM;
+
+ if (mask == 0)
+ mask = D_EMERG;
+
if (strchr(file, '/'))
file = strrchr(file, '/') + 1;
- trace_set_debug_header(&header, subsys, mask, line, CDEBUG_STACK());
+ trace_set_debug_header(&header, subsys, mask, line, 0);
tcd = trace_get_tcd();
if (tcd == NULL)
@@ -698,19 +705,14 @@ spl_debug_vmsg(spl_debug_limit_state_t *cdls, int subsys, int mask,
}
needed = 0;
- if (format1) {
- va_copy(ap, args);
- needed = vsnprintf(string_buf, max_nob, format1, ap);
- va_end(ap);
- }
-
- if (format2) {
+ if (format) {
remain = max_nob - needed;
if (remain < 0)
remain = 0;
- va_start(ap, format2);
- needed += vsnprintf(string_buf+needed, remain, format2, ap);
+ va_start(ap, format);
+ needed += vsnprintf(string_buf+needed, remain,
+ format, ap);
va_end(ap);
}
@@ -784,16 +786,12 @@ console:
string_buf = trace_get_console_buffer();
needed = 0;
- if (format1 != NULL) {
- va_copy(ap, args);
- needed = vsnprintf(string_buf, TRACE_CONSOLE_BUFFER_SIZE, format1, ap);
- va_end(ap);
- }
- if (format2 != NULL) {
+ if (format != NULL) {
remain = TRACE_CONSOLE_BUFFER_SIZE - needed;
if (remain > 0) {
- va_start(ap, format2);
- needed += vsnprintf(string_buf+needed, remain, format2, ap);
+ va_start(ap, format);
+ needed += vsnprintf(string_buf+needed, remain,
+ format, ap);
va_end(ap);
}
}
@@ -819,7 +817,7 @@ console:
return 0;
}
-EXPORT_SYMBOL(spl_debug_vmsg);
+EXPORT_SYMBOL(spl_debug_msg);
/* Do the collect_pages job on a single CPU: assumes that all other
* CPUs have been stopped during a panic. If this isn't true for
@@ -881,9 +879,6 @@ put_pages_back_on_all_cpus(struct page_collection *pc)
list_for_each_entry_safe(tage, tmp, &pc->pc_pages,
linkage) {
-
- __ASSERT_TAGE_INVARIANT(tage);
-
if (tage->cpu != cpu || tage->type != i)
continue;
@@ -935,8 +930,6 @@ spl_debug_dump_all_pages(dumplog_priv_t *dp, char *filename)
set_fs(get_ds());
list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) {
- __ASSERT_TAGE_INVARIANT(tage);
-
rc = spl_filp_write(filp, page_address(tage->page),
tage->used, spl_filp_poff(filp));
if (rc != (int)tage->used) {
@@ -979,7 +972,6 @@ spl_debug_flush_pages(void)
collect_pages(&dp, &pc);
list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) {
- __ASSERT_TAGE_INVARIANT(tage);
list_del(&tage->linkage);
tage_free(tage);
}
@@ -1077,12 +1069,10 @@ EXPORT_SYMBOL(spl_debug_dumpstack);
void spl_debug_bug(char *file, const char *func, const int line, int flags)
{
spl_debug_catastrophe = 1;
- spl_debug_msg(NULL, 0, D_EMERG, file, func, line, "SBUG\n");
+ spl_debug_msg(NULL, 0, D_EMERG, file, func, line, "SPL PANIC\n");
- if (in_interrupt()) {
- panic("SBUG in interrupt.\n");
- /* not reached */
- }
+ if (in_interrupt())
+ panic("SPL PANIC in interrupt.\n");
if (in_atomic() || irqs_disabled())
flags |= DL_NOTHREAD;
@@ -1095,7 +1085,7 @@ void spl_debug_bug(char *file, const char *func, const int line, int flags)
spl_debug_dumplog(flags);
if (spl_debug_panic_on_bug)
- panic("SBUG");
+ panic("SPL PANIC");
set_task_state(current, TASK_UNINTERRUPTIBLE);
while (1)
@@ -1208,8 +1198,6 @@ trace_cleanup_on_all_cpus(void)
list_for_each_entry_safe(tage, tmp, &tcd->tcd_pages,
linkage) {
- __ASSERT_TAGE_INVARIANT(tage);
-
list_del(&tage->linkage);
tage_free(tage);
}