mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
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.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
\*****************************************************************************/
|
||||
|
||||
#include <sys/condvar.h>
|
||||
#include <spl-debug.h>
|
||||
|
||||
#ifdef DEBUG_SUBSYSTEM
|
||||
#undef DEBUG_SUBSYSTEM
|
||||
|
||||
+29
-41
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
\*****************************************************************************/
|
||||
|
||||
#include <sys/kmem.h>
|
||||
#include <spl-debug.h>
|
||||
|
||||
#ifdef DEBUG_SUBSYSTEM
|
||||
# undef DEBUG_SUBSYSTEM
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
\*****************************************************************************/
|
||||
|
||||
#include <sys/kobj.h>
|
||||
#include <spl-debug.h>
|
||||
|
||||
#ifdef DEBUG_SUBSYSTEM
|
||||
#undef DEBUG_SUBSYSTEM
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <sys/thread.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <spl-debug.h>
|
||||
|
||||
#ifdef DEBUG_SUBSYSTEM
|
||||
#undef DEBUG_SUBSYSTEM
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user