diff options
author | Brian Behlendorf <[email protected]> | 2012-01-20 15:02:57 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2012-02-02 11:24:30 -0800 |
commit | d7e398ce1a3e6f9c705af43955a684685a798c32 (patch) | |
tree | 06ff1d5c4431f8194d5b50c1824532b816902dc0 /include | |
parent | 0c5dde492ff4fadcc9c43477c81b3d3824ac41db (diff) |
Cleanup ZFS debug infrastructure
Historically the internal zfs debug infrastructure has been
scattered throughout the code. Since we expect to start making
more use of this code this patch performs some cleanup.
* Consolidate the zfs debug infrastructure in the zfs_debug.[ch]
files. This includes moving the zfs_flags and zfs_recover
variables, plus moving the zfs_panic_recover() function.
* Remove the existing unused functionality in zfs_debug.c and
replace it with code which correctly utilized the spl logging
infrastructure.
* Remove the __dprintf() function from zfs_ioctl.c. This is
dead code, the dprintf() functionality in the kernel relies
on the spl log support.
* Remove dprintf() from hdr_recl(). This wasn't particularly
useful and was missing the required format specifier anyway.
* Subsequent patches should unify the dprintf() and zfs_dbgmsg()
functions.
Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'include')
-rw-r--r-- | include/sys/zfs_context.h | 5 | ||||
-rw-r--r-- | include/sys/zfs_debug.h | 58 |
2 files changed, 24 insertions, 39 deletions
diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index 4abafcc6f..e4af6fc37 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -134,10 +134,9 @@ extern int aok; * ZFS debugging */ -#ifdef ZFS_DEBUG extern void dprintf_setup(int *argc, char **argv); -#endif /* ZFS_DEBUG */ - +extern void __dprintf(const char *file, const char *func, + int line, const char *fmt, ...); extern void cmn_err(int, const char *, ...); extern void vcmn_err(int, const char *, __va_list); extern void panic(const char *, ...); diff --git a/include/sys/zfs_debug.h b/include/sys/zfs_debug.h index f08d7cd2b..e83b66147 100644 --- a/include/sys/zfs_debug.h +++ b/include/sys/zfs_debug.h @@ -25,10 +25,6 @@ #ifndef _SYS_ZFS_DEBUG_H #define _SYS_ZFS_DEBUG_H -#ifdef __cplusplus -extern "C" { -#endif - #ifndef TRUE #define TRUE 1 #endif @@ -38,14 +34,14 @@ extern "C" { #endif /* - * ZFS debugging + * ZFS debugging - Always enabled for user space builds. */ - #if defined(DEBUG) || !defined(_KERNEL) #define ZFS_DEBUG #endif extern int zfs_flags; +extern int zfs_recover; #define ZFS_DEBUG_DPRINTF 0x0001 #define ZFS_DEBUG_DBUF_VERIFY 0x0002 @@ -53,43 +49,33 @@ extern int zfs_flags; #define ZFS_DEBUG_SNAPNAMES 0x0008 #define ZFS_DEBUG_MODIFY 0x0010 -#ifdef ZFS_DEBUG -#if defined(_KERNEL) && defined(HAVE_SPL) /* - * Log ZFS debug messages as the spl SS_USER1 subsystem. + * Always log zfs debug messages to the spl debug subsystem as SS_USER1. + * When the SPL is configured with debugging enabled these messages will + * appear in the internal spl debug log, otherwise they are a no-op. */ +#if defined(_KERNEL) + #include <spl-debug.h> +#define dprintf(...) \ + if (zfs_flags & ZFS_DEBUG_DPRINTF) \ + __SDEBUG(NULL, SS_USER1, SD_DPRINTF, __VA_ARGS__) -#ifdef SS_DEBUG_SUBSYS -#undef SS_DEBUG_SUBSYS -#endif -#define SS_DEBUG_SUBSYS SS_USER1 -#define dprintf(...) SDEBUG_LIMIT(SD_DPRINTF, __VA_ARGS__) +/* + * When zfs is running is user space the debugging is always enabled. + * The messages will be printed using the __dprintf() function and + * filtered based on the zfs_flags variable. + */ #else -extern void __dprintf(const char *file, const char *func, - int line, const char *fmt, ...); -#define dprintf(...) \ - if (zfs_flags & ZFS_DEBUG_DPRINTF) \ +#define dprintf(...) \ + if (zfs_flags & ZFS_DEBUG_DPRINTF) \ __dprintf(__FILE__, __func__, __LINE__, __VA_ARGS__) -#endif /* _KERNEL && HAVE_SPL */ -#else -#define dprintf(...) ((void)0) -#endif /* ZFS_DEBUG */ - -extern void zfs_panic_recover(const char *fmt, ...); -typedef struct zfs_dbgmsg { - list_node_t zdm_node; - time_t zdm_timestamp; - char zdm_msg[1]; /* variable length allocation */ -} zfs_dbgmsg_t; +#endif /* _KERNEL */ -extern void zfs_dbgmsg_init(void); -extern void zfs_dbgmsg_fini(void); -extern void zfs_dbgmsg(const char *fmt, ...); - -#ifdef __cplusplus -} -#endif +void zfs_panic_recover(const char *fmt, ...); +#define zfs_dbgmsg(...) dprintf(__VA_ARGS__) +void zfs_dbgmsg_init(void); +void zfs_dbgmsg_fini(void); #endif /* _SYS_ZFS_DEBUG_H */ |