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 <behlendorf1@llnl.gov>
This commit is contained in:
Brian Behlendorf
2012-01-20 15:02:57 -08:00
parent 0c5dde492f
commit d7e398ce1a
7 changed files with 68 additions and 164 deletions
+2 -3
View File
@@ -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 *, ...);
+22 -36
View File
@@ -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, ...);
#endif /* _KERNEL */
typedef struct zfs_dbgmsg {
list_node_t zdm_node;
time_t zdm_timestamp;
char zdm_msg[1]; /* variable length allocation */
} zfs_dbgmsg_t;
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 */