extern int zfs_flags;
extern int zfs_recover;
extern int zfs_free_leak_on_eio;
+extern int zfs_dbgmsg_enable;
#define ZFS_DEBUG_DPRINTF (1 << 0)
#define ZFS_DEBUG_DBUF_VERIFY (1 << 1)
extern void __dprintf(const char *file, const char *func,
int line, const char *fmt, ...);
-#define dprintf(...) \
- __dprintf(__FILE__, __func__, __LINE__, __VA_ARGS__)
#define zfs_dbgmsg(...) \
- __dprintf(__FILE__, __func__, __LINE__, __VA_ARGS__)
+ if (zfs_dbgmsg_enable) \
+ __dprintf(__FILE__, __func__, __LINE__, __VA_ARGS__)
+
+#ifdef ZFS_DEBUG
+/*
+ * To enable this:
+ *
+ * $ echo 1 >/sys/module/zfs/parameters/zfs_flags
+ */
+#define dprintf(...) \
+ if (zfs_flags & ZFS_DEBUG_DPRINTF) \
+ __dprintf(__FILE__, __func__, __LINE__, __VA_ARGS__)
+#else
+#define dprintf(...) ((void)0)
+#endif /* ZFS_DEBUG */
extern void zfs_panic_recover(const char *fmt, ...);
if (reserve + arc_tempreserve + anon_size > arc_c / 2 &&
anon_size > arc_c / 4) {
+#ifdef ZFS_DEBUG
uint64_t meta_esize =
refcount_count(&arc_anon->arcs_esize[ARC_BUFC_METADATA]);
uint64_t data_esize =
"anon_data=%lluK tempreserve=%lluK arc_c=%lluK\n",
arc_tempreserve >> 10, meta_esize >> 10,
data_esize >> 10, reserve >> 10, arc_c >> 10);
+#endif
DMU_TX_STAT_BUMP(dmu_tx_dirty_throttle);
return (SET_ERROR(ERESTART));
}
kstat_t *zfs_dbgmsg_kstat;
/*
- * By default only enable the internal ZFS debug messages when running
- * in userspace (ztest). The kernel log must be manually enabled.
+ * Internal ZFS debug messages are enabled by default.
*
- * # Enable the kernel debug message log.
- * echo 1 > /sys/module/zfs/parameters/zfs_dbgmsg_enable
+ * # Print debug messages
+ * cat /proc/spl/kstat/zfs/dbgmsg
+ *
+ * # Disable the kernel debug message log.
+ * echo 0 > /sys/module/zfs/parameters/zfs_dbgmsg_enable
*
* # Clear the kernel debug message log.
* echo 0 >/proc/spl/kstat/zfs/dbgmsg
*/
-#if defined(_KERNEL) && !defined(ZFS_DEBUG)
-int zfs_dbgmsg_enable = 0;
-#else
int zfs_dbgmsg_enable = 1;
-#endif
static int
zfs_dbgmsg_headers(char *buf, size_t size)
void
__set_error(const char *file, const char *func, int line, int err)
{
+ /*
+ * To enable this:
+ *
+ * $ echo 512 >/sys/module/zfs/parameters/zfs_flags
+ */
if (zfs_flags & ZFS_DEBUG_SET_ERROR)
__dprintf(file, func, line, "error %lu", err);
}
char *nl;
int i;
- if (!zfs_dbgmsg_enable &&
- !(zfs_flags & (ZFS_DEBUG_DPRINTF | ZFS_DEBUG_SET_ERROR)))
- return;
-
size = 1024;
buf = kmem_alloc(size, KM_SLEEP);
* To get this data enable the zfs__dprintf trace point as shown:
*
* # Enable zfs__dprintf tracepoint, clear the tracepoint ring buffer
- * $ echo 1 > /sys/module/zfs/parameters/zfs_flags
* $ echo 1 > /sys/kernel/debug/tracing/events/zfs/enable
* $ echo 0 > /sys/kernel/debug/tracing/trace
*
* # Dump the ring buffer.
* $ cat /sys/kernel/debug/tracing/trace
*/
- if (zfs_flags & (ZFS_DEBUG_DPRINTF | ZFS_DEBUG_SET_ERROR))
- DTRACE_PROBE1(zfs__dprintf, char *, buf);
+ DTRACE_PROBE1(zfs__dprintf, char *, buf);
/*
- * To get this data enable the zfs debug log as shown:
- *
- * # Set zfs_dbgmsg enable, clear the log buffer
- * $ echo 1 > /sys/module/zfs/parameters/zfs_dbgmsg_enable
- * $ echo 0 > /proc/spl/kstat/zfs/dbgmsg
+ * To get this data:
*
- * # Dump the log buffer.
* $ cat /proc/spl/kstat/zfs/dbgmsg
+ *
+ * To clear the buffer:
+ * $ echo 0 > /proc/spl/kstat/zfs/dbgmsg
*/
- if (zfs_dbgmsg_enable)
- __zfs_dbgmsg(buf);
+ __zfs_dbgmsg(buf);
kmem_free(buf, size);
}