summaryrefslogtreecommitdiffstats
path: root/module/zfs
diff options
context:
space:
mode:
Diffstat (limited to 'module/zfs')
-rw-r--r--module/zfs/arc.c1
-rw-r--r--module/zfs/spa_misc.c28
-rw-r--r--module/zfs/zfs_debug.c96
-rw-r--r--module/zfs/zfs_ioctl.c36
4 files changed, 42 insertions, 119 deletions
diff --git a/module/zfs/arc.c b/module/zfs/arc.c
index 95d14a9e7..2220c4d9d 100644
--- a/module/zfs/arc.c
+++ b/module/zfs/arc.c
@@ -885,7 +885,6 @@ buf_dest(void *vbuf, void *unused)
static void
hdr_recl(void *unused)
{
- dprintf("hdr_recl called\n");
/*
* umem calls the reclaim func when we destroy the buf cache,
* which is after we do arc_fini().
diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c
index e4e0c35f0..1016ac7be 100644
--- a/module/zfs/spa_misc.c
+++ b/module/zfs/spa_misc.c
@@ -234,21 +234,6 @@ static avl_tree_t spa_l2cache_avl;
kmem_cache_t *spa_buffer_pool;
int spa_mode_global;
-#ifdef ZFS_DEBUG
-/* Everything except dprintf is on by default in debug builds */
-int zfs_flags = ~ZFS_DEBUG_DPRINTF;
-#else
-int zfs_flags = 0;
-#endif
-
-/*
- * zfs_recover can be set to nonzero to attempt to recover from
- * otherwise-fatal errors, typically caused by on-disk corruption. When
- * set, calls to zfs_panic_recover() will turn into warning messages.
- */
-int zfs_recover = 0;
-
-
/*
* ==========================================================================
* SPA config locking
@@ -1217,16 +1202,6 @@ spa_freeze(spa_t *spa)
txg_wait_synced(spa_get_dsl(spa), freeze_txg);
}
-void
-zfs_panic_recover(const char *fmt, ...)
-{
- va_list adx;
-
- va_start(adx, fmt);
- vcmn_err(zfs_recover ? CE_WARN : CE_PANIC, fmt, adx);
- va_end(adx);
-}
-
/*
* This is a stripped-down version of strtoull, suitable only for converting
* lowercase hexidecimal numbers that don't overflow.
@@ -1765,7 +1740,4 @@ EXPORT_SYMBOL(spa_writeable);
EXPORT_SYMBOL(spa_mode);
EXPORT_SYMBOL(spa_namespace_lock);
-
-module_param(zfs_recover, int, 0644);
-MODULE_PARM_DESC(zfs_recover, "Set to attempt to recover from fatal errors");
#endif
diff --git a/module/zfs/zfs_debug.c b/module/zfs/zfs_debug.c
index d0f411a99..f4b5e6fa1 100644
--- a/module/zfs/zfs_debug.c
+++ b/module/zfs/zfs_debug.c
@@ -24,72 +24,60 @@
#include <sys/zfs_context.h>
-list_t zfs_dbgmsgs;
-int zfs_dbgmsg_size;
-kmutex_t zfs_dbgmsgs_lock;
-int zfs_dbgmsg_maxsize = 1<<20; /* 1MB */
+/*
+ * Enable various debugging features.
+ */
+int zfs_flags = 0;
+
+/*
+ * zfs_recover can be set to nonzero to attempt to recover from
+ * otherwise-fatal errors, typically caused by on-disk corruption. When
+ * set, calls to zfs_panic_recover() will turn into warning messages.
+ */
+int zfs_recover = 0;
-void
-zfs_dbgmsg_init(void)
-{
- list_create(&zfs_dbgmsgs, sizeof (zfs_dbgmsg_t),
- offsetof(zfs_dbgmsg_t, zdm_node));
- mutex_init(&zfs_dbgmsgs_lock, NULL, MUTEX_DEFAULT, NULL);
-}
void
-zfs_dbgmsg_fini(void)
+zfs_panic_recover(const char *fmt, ...)
{
- zfs_dbgmsg_t *zdm;
+ va_list adx;
- while ((zdm = list_remove_head(&zfs_dbgmsgs)) != NULL) {
- int size = sizeof (zfs_dbgmsg_t) + strlen(zdm->zdm_msg);
- kmem_free(zdm, size);
- zfs_dbgmsg_size -= size;
- }
- mutex_destroy(&zfs_dbgmsgs_lock);
- ASSERT3U(zfs_dbgmsg_size, ==, 0);
+ va_start(adx, fmt);
+ vcmn_err(zfs_recover ? CE_WARN : CE_PANIC, fmt, adx);
+ va_end(adx);
}
/*
- * Print these messages by running:
- * echo ::zfs_dbgmsg | mdb -k
- *
- * Monitor these messages by running:
- * dtrace -q -n 'zfs-dbgmsg{printf("%s\n", stringof(arg0))}'
+ * Debug logging is enabled by default for production kernel builds.
+ * The overhead for this is negligible and the logs can be valuable when
+ * debugging. For non-production user space builds all debugging except
+ * logging is enabled since performance is no longer a concern.
*/
void
-zfs_dbgmsg(const char *fmt, ...)
+zfs_dbgmsg_init(void)
{
- int size;
- va_list adx;
- zfs_dbgmsg_t *zdm;
-
- va_start(adx, fmt);
- size = vsnprintf(NULL, 0, fmt, adx);
- va_end(adx);
+ if (zfs_flags == 0) {
+#if defined(_KERNEL)
+ zfs_flags = ZFS_DEBUG_DPRINTF;
+ spl_debug_mask |= SD_DPRINTF;
+ spl_debug_subsys |= SS_USER1;
+#else
+ zfs_flags = ~ZFS_DEBUG_DPRINTF;
+#endif /* _KERNEL */
+ }
+}
- /*
- * There is one byte of string in sizeof (zfs_dbgmsg_t), used
- * for the terminating null.
- */
- zdm = kmem_alloc(sizeof (zfs_dbgmsg_t) + size, KM_SLEEP);
- zdm->zdm_timestamp = gethrestime_sec();
+void
+zfs_dbgmsg_fini(void)
+{
+ return;
+}
- va_start(adx, fmt);
- (void) vsnprintf(zdm->zdm_msg, size + 1, fmt, adx);
- va_end(adx);
- DTRACE_PROBE1(zfs__dbgmsg, char *, zdm->zdm_msg);
+#if defined(_KERNEL)
+module_param(zfs_flags, int, 0644);
+MODULE_PARM_DESC(zfs_flags, "Set additional debugging flags");
- mutex_enter(&zfs_dbgmsgs_lock);
- list_insert_tail(&zfs_dbgmsgs, zdm);
- zfs_dbgmsg_size += sizeof (zfs_dbgmsg_t) + size;
- while (zfs_dbgmsg_size > zfs_dbgmsg_maxsize) {
- zdm = list_remove_head(&zfs_dbgmsgs);
- size = sizeof (zfs_dbgmsg_t) + strlen(zdm->zdm_msg);
- kmem_free(zdm, size);
- zfs_dbgmsg_size -= size;
- }
- mutex_exit(&zfs_dbgmsgs_lock);
-}
+module_param(zfs_recover, int, 0644);
+MODULE_PARM_DESC(zfs_recover, "Set to attempt to recover from fatal errors");
+#endif /* _KERNEL */
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c
index c8ff03595..532f17aa1 100644
--- a/module/zfs/zfs_ioctl.c
+++ b/module/zfs/zfs_ioctl.c
@@ -119,42 +119,6 @@ static int zfs_fill_zplprops_root(uint64_t, nvlist_t *, nvlist_t *,
boolean_t *);
int zfs_set_prop_nvlist(const char *, zprop_source_t, nvlist_t *, nvlist_t **);
-/* _NOTE(PRINTFLIKE(4)) - this is printf-like, but lint is too whiney */
-void
-__dprintf(const char *file, const char *func, int line, const char *fmt, ...)
-{
- const char *newfile;
- char buf[512];
- va_list adx;
-
- /*
- * Get rid of annoying "../common/" prefix to filename.
- */
- newfile = strrchr(file, '/');
- if (newfile != NULL) {
- newfile = newfile + 1; /* Get rid of leading / */
- } else {
- newfile = file;
- }
-
- va_start(adx, fmt);
- (void) vsnprintf(buf, sizeof (buf), fmt, adx);
- va_end(adx);
-
- /*
- * To get this data, use the zfs-dprintf probe as so:
- * dtrace -q -n 'zfs-dprintf \
- * /stringof(arg0) == "dbuf.c"/ \
- * {printf("%s: %s", stringof(arg1), stringof(arg3))}'
- * arg0 = file name
- * arg1 = function name
- * arg2 = line number
- * arg3 = message
- */
- DTRACE_PROBE4(zfs__dprintf,
- char *, newfile, char *, func, int, line, char *, buf);
-}
-
static void
history_str_free(char *buf)
{