diff options
author | Brian Behlendorf <[email protected]> | 2010-07-19 14:16:05 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2010-07-20 13:29:35 -0700 |
commit | 55abb0929e4fbe326a9737650a167a1a988ad86b (patch) | |
tree | 7fa8db9d12b4416f7f7e8e21cde864b501303924 /module | |
parent | 8f813bb168eb21cd5d64b930ee015dcf93575331 (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')
-rw-r--r-- | module/spl/spl-condvar.c | 1 | ||||
-rw-r--r-- | module/spl/spl-debug.c | 70 | ||||
-rw-r--r-- | module/spl/spl-err.c | 3 | ||||
-rw-r--r-- | module/spl/spl-generic.c | 5 | ||||
-rw-r--r-- | module/spl/spl-kmem.c | 1 | ||||
-rw-r--r-- | module/spl/spl-kobj.c | 1 | ||||
-rw-r--r-- | module/spl/spl-kstat.c | 13 | ||||
-rw-r--r-- | module/spl/spl-module.c | 2 | ||||
-rw-r--r-- | module/spl/spl-proc.c | 10 | ||||
-rw-r--r-- | module/spl/spl-taskq.c | 13 | ||||
-rw-r--r-- | module/spl/spl-thread.c | 1 | ||||
-rw-r--r-- | module/spl/spl-vnode.c | 3 | ||||
-rw-r--r-- | module/spl/spl-xdr.c | 3 | ||||
-rw-r--r-- | module/splat/splat-atomic.c | 2 | ||||
-rw-r--r-- | module/splat/splat-internal.h | 1 |
15 files changed, 60 insertions, 69 deletions
diff --git a/module/spl/spl-condvar.c b/module/spl/spl-condvar.c index 269b0ab61..002dcdb45 100644 --- a/module/spl/spl-condvar.c +++ b/module/spl/spl-condvar.c @@ -25,6 +25,7 @@ \*****************************************************************************/ #include <sys/condvar.h> +#include <spl-debug.h> #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM 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); } diff --git a/module/spl/spl-err.c b/module/spl/spl-err.c index 1d5202827..1b059f0c8 100644 --- a/module/spl/spl-err.c +++ b/module/spl/spl-err.c @@ -26,6 +26,7 @@ #include <sys/sysmacros.h> #include <sys/cmn_err.h> +#include <spl-debug.h> #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM @@ -44,7 +45,7 @@ vpanic(const char *fmt, va_list ap) char msg[MAXMSGLEN]; vsnprintf(msg, MAXMSGLEN - 1, fmt, ap); - panic("%s", msg); + PANIC("%s", msg); } /* vpanic() */ EXPORT_SYMBOL(vpanic); diff --git a/module/spl/spl-generic.c b/module/spl/spl-generic.c index 6a3f49ae0..b875f7d7f 100644 --- a/module/spl/spl-generic.c +++ b/module/spl/spl-generic.c @@ -39,6 +39,7 @@ #include <sys/file.h> #include <linux/kmod.h> #include <linux/proc_compat.h> +#include <spl-debug.h> #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM @@ -339,12 +340,12 @@ EXPORT_SYMBOL(ddi_copyout); * never be putting away the last reference on a task structure so this will * not be called. However, we still need to define it so the module does not * have undefined symbol at load time. That all said if this impossible - * thing does somehow happen SBUG() immediately so we know about it. + * thing does somehow happen PANIC immediately so we know about it. */ void __put_task_struct(struct task_struct *t) { - SBUG(); + PANIC("Unexpectly put last reference on task %d\n", (int)t->pid); } EXPORT_SYMBOL(__put_task_struct); #endif /* HAVE_PUT_TASK_STRUCT */ diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c index a348021d8..e0b7e12e2 100644 --- a/module/spl/spl-kmem.c +++ b/module/spl/spl-kmem.c @@ -25,6 +25,7 @@ \*****************************************************************************/ #include <sys/kmem.h> +#include <spl-debug.h> #ifdef DEBUG_SUBSYSTEM # undef DEBUG_SUBSYSTEM diff --git a/module/spl/spl-kobj.c b/module/spl/spl-kobj.c index 42a264172..d58a9892b 100644 --- a/module/spl/spl-kobj.c +++ b/module/spl/spl-kobj.c @@ -25,6 +25,7 @@ \*****************************************************************************/ #include <sys/kobj.h> +#include <spl-debug.h> #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM diff --git a/module/spl/spl-kstat.c b/module/spl/spl-kstat.c index 433f3e5b0..238f37ae3 100644 --- a/module/spl/spl-kstat.c +++ b/module/spl/spl-kstat.c @@ -24,8 +24,9 @@ * Solaris Porting Layer (SPL) Kstat Implementation. \*****************************************************************************/ -#include <sys/kstat.h> #include <linux/seq_file.h> +#include <sys/kstat.h> +#include <spl-debug.h> static spinlock_t kstat_lock; static struct list_head kstat_list; @@ -72,7 +73,7 @@ kstat_seq_show_headers(struct seq_file *f) "min", "max", "start", "stop"); break; default: - SBUG(); /* Unreachable */ + PANIC("Undefined kstat type %d\n", ksp->ks_type); } } @@ -135,7 +136,7 @@ kstat_seq_show_named(struct seq_file *f, kstat_named_t *knp) seq_printf(f, "%s", KSTAT_NAMED_STR_PTR(knp)); break; default: - SBUG(); /* Unreachable */ + PANIC("Undefined kstat data type %d\n", knp->data_type); } seq_printf(f, "\n"); @@ -210,7 +211,7 @@ kstat_seq_show(struct seq_file *f, void *p) rc = kstat_seq_show_timer(f, (kstat_timer_t *)p); break; default: - SBUG(); /* Unreachable */ + PANIC("Undefined kstat type %d\n", ksp->ks_type); } return rc; @@ -239,7 +240,7 @@ kstat_seq_data_addr(kstat_t *ksp, loff_t n) rc = ksp->ks_data + n * sizeof(kstat_timer_t); break; default: - SBUG(); /* Unreachable */ + PANIC("Undefined kstat type %d\n", ksp->ks_type); } RETURN(rc); @@ -377,7 +378,7 @@ __kstat_create(const char *ks_module, int ks_instance, const char *ks_name, ksp->ks_data_size = ks_ndata * sizeof(kstat_timer_t); break; default: - SBUG(); /* Unreachable */ + PANIC("Undefined kstat type %d\n", ksp->ks_type); } if (ksp->ks_flags & KSTAT_FLAG_VIRTUAL) { diff --git a/module/spl/spl-module.c b/module/spl/spl-module.c index 37dd4f4c1..787a4480e 100644 --- a/module/spl/spl-module.c +++ b/module/spl/spl-module.c @@ -24,8 +24,8 @@ * Solaris Porting Layer (SPL) Module Implementation. \*****************************************************************************/ -#include <sys/sysmacros.h> #include <sys/sunddi.h> +#include <spl-debug.h> #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM diff --git a/module/spl/spl-proc.c b/module/spl/spl-proc.c index 5a71f795c..bc6dac5b8 100644 --- a/module/spl/spl-proc.c +++ b/module/spl/spl-proc.c @@ -29,6 +29,7 @@ #include <linux/kmod.h> #include <linux/seq_file.h> #include <linux/proc_compat.h> +#include <spl-debug.h> #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM @@ -297,13 +298,10 @@ SPL_PROC_HANDLER(proc_force_bug) { ENTRY; - if (write) { - CERROR("Crashing due to forced SBUG\n"); - SBUG(); - /* Unreachable */ - } else { + if (write) + PANIC("Crashing due to forced panic\n"); + else *lenp = 0; - } RETURN(0); } diff --git a/module/spl/spl-taskq.c b/module/spl/spl-taskq.c index 9aca699c7..d9c83279c 100644 --- a/module/spl/spl-taskq.c +++ b/module/spl/spl-taskq.c @@ -26,6 +26,7 @@ #include <sys/taskq.h> #include <sys/kmem.h> +#include <spl-debug.h> #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM @@ -90,8 +91,8 @@ retry: RETURN(NULL); } - /* Unreachable, TQ_SLEEP or TQ_NOSLEEP */ - SBUG(); + /* Unreachable, Neither TQ_SLEEP or TQ_NOSLEEP set */ + PANIC("Neither TQ_SLEEP or TQ_NOSLEEP set"); } spin_unlock_irqrestore(&tq->tq_lock, tq->tq_lock_flags); @@ -254,11 +255,9 @@ __taskq_dispatch(taskq_t *tq, task_func_t func, void *arg, uint_t flags) if (!(flags & (TQ_SLEEP | TQ_NOSLEEP))) flags |= TQ_SLEEP; - if (unlikely(in_atomic() && (flags & TQ_SLEEP))) { - CERROR("May schedule while atomic: %s/0x%08x/%d\n", - current->comm, preempt_count(), current->pid); - SBUG(); - } + if (unlikely(in_atomic() && (flags & TQ_SLEEP))) + PANIC("May schedule while atomic: %s/0x%08x/%d\n", + current->comm, preempt_count(), current->pid); spin_lock_irqsave(&tq->tq_lock, tq->tq_lock_flags); diff --git a/module/spl/spl-thread.c b/module/spl/spl-thread.c index bce912c4d..e28b1261a 100644 --- a/module/spl/spl-thread.c +++ b/module/spl/spl-thread.c @@ -26,6 +26,7 @@ #include <sys/thread.h> #include <sys/kmem.h> +#include <spl-debug.h> #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c index c67fc4c7f..840bb6718 100644 --- a/module/spl/spl-vnode.c +++ b/module/spl/spl-vnode.c @@ -24,9 +24,8 @@ * Solaris Porting Layer (SPL) Vnode Implementation. \*****************************************************************************/ -#include <sys/sysmacros.h> #include <sys/vnode.h> - +#include <spl-debug.h> #ifdef DEBUG_SUBSYSTEM #undef DEBUG_SUBSYSTEM diff --git a/module/spl/spl-xdr.c b/module/spl/spl-xdr.c index 174f76f19..375b74e53 100644 --- a/module/spl/spl-xdr.c +++ b/module/spl/spl-xdr.c @@ -22,13 +22,12 @@ \*****************************************************************************/ #include <linux/string.h> - #include <sys/kmem.h> #include <sys/debug.h> #include <sys/types.h> - #include <rpc/types.h> #include <rpc/xdr.h> +#include <spl-debug.h> /* * SPL's XDR mem implementation. diff --git a/module/splat/splat-atomic.c b/module/splat/splat-atomic.c index fd86a9fa8..6162d6abf 100644 --- a/module/splat/splat-atomic.c +++ b/module/splat/splat-atomic.c @@ -109,7 +109,7 @@ splat_atomic_work(void *priv) atomic_sub_64_nv(&ap->ap_atomic, 5); break; default: - SBUG(); + PANIC("Undefined op %d\n", op); } } diff --git a/module/splat/splat-internal.h b/module/splat/splat-internal.h index ba1224fc1..c42e08d6f 100644 --- a/module/splat/splat-internal.h +++ b/module/splat/splat-internal.h @@ -66,6 +66,7 @@ #include <linux/cdev.h> #include "spl-device.h" +#include "spl-debug.h" #include "splat-ctl.h" #define SPLAT_SUBSYSTEM_INIT(type) \ |