xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfs_debug.h (revision 7fd05ac4dec0c343d2f68f310d3718b715ecfbaf)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
56b4acc8bSahrens  * Common Development and Distribution License (the "License").
66b4acc8bSahrens  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21fa9e4066Sahrens /*
223f9d6ad7SLin Ling  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23b4952e17SGeorge Wilson  * Copyright (c) 2013 by Delphix. All rights reserved.
24fa9e4066Sahrens  */
25fa9e4066Sahrens 
26fa9e4066Sahrens #ifndef _SYS_ZFS_DEBUG_H
27fa9e4066Sahrens #define	_SYS_ZFS_DEBUG_H
28fa9e4066Sahrens 
29fa9e4066Sahrens #ifdef	__cplusplus
30fa9e4066Sahrens extern "C" {
31fa9e4066Sahrens #endif
32fa9e4066Sahrens 
33fa9e4066Sahrens #ifndef TRUE
34fa9e4066Sahrens #define	TRUE 1
35fa9e4066Sahrens #endif
36fa9e4066Sahrens 
37fa9e4066Sahrens #ifndef FALSE
38fa9e4066Sahrens #define	FALSE 0
39fa9e4066Sahrens #endif
40fa9e4066Sahrens 
41fa9e4066Sahrens /*
42fa9e4066Sahrens  * ZFS debugging
43fa9e4066Sahrens  */
44fa9e4066Sahrens 
45fa9e4066Sahrens #if defined(DEBUG) || !defined(_KERNEL)
46fa9e4066Sahrens #define	ZFS_DEBUG
47fa9e4066Sahrens #endif
48fa9e4066Sahrens 
49fa9e4066Sahrens extern int zfs_flags;
50*7fd05ac4SMatthew Ahrens extern boolean_t zfs_recover;
51*7fd05ac4SMatthew Ahrens extern boolean_t zfs_free_leak_on_eio;
52fa9e4066Sahrens 
533b2aab18SMatthew Ahrens #define	ZFS_DEBUG_DPRINTF	(1<<0)
543b2aab18SMatthew Ahrens #define	ZFS_DEBUG_DBUF_VERIFY	(1<<1)
553b2aab18SMatthew Ahrens #define	ZFS_DEBUG_DNODE_VERIFY	(1<<2)
563b2aab18SMatthew Ahrens #define	ZFS_DEBUG_SNAPNAMES	(1<<3)
573b2aab18SMatthew Ahrens #define	ZFS_DEBUG_MODIFY	(1<<4)
583b2aab18SMatthew Ahrens #define	ZFS_DEBUG_SPA		(1<<5)
593b2aab18SMatthew Ahrens #define	ZFS_DEBUG_ZIO_FREE	(1<<6)
60fa9e4066Sahrens 
61fa9e4066Sahrens #ifdef ZFS_DEBUG
62fa9e4066Sahrens extern void __dprintf(const char *file, const char *func,
63fa9e4066Sahrens     int line, const char *fmt, ...);
64fa9e4066Sahrens #define	dprintf(...) \
65fa9e4066Sahrens 	if (zfs_flags & ZFS_DEBUG_DPRINTF) \
66fa9e4066Sahrens 		__dprintf(__FILE__, __func__, __LINE__, __VA_ARGS__)
67fa9e4066Sahrens #else
68fa9e4066Sahrens #define	dprintf(...) ((void)0)
69fa9e4066Sahrens #endif /* ZFS_DEBUG */
70fa9e4066Sahrens 
710125049cSahrens extern void zfs_panic_recover(const char *fmt, ...);
720125049cSahrens 
733f9d6ad7SLin Ling typedef struct zfs_dbgmsg {
743f9d6ad7SLin Ling 	list_node_t zdm_node;
753f9d6ad7SLin Ling 	time_t zdm_timestamp;
763f9d6ad7SLin Ling 	char zdm_msg[1]; /* variable length allocation */
773f9d6ad7SLin Ling } zfs_dbgmsg_t;
783f9d6ad7SLin Ling 
793f9d6ad7SLin Ling extern void zfs_dbgmsg_init(void);
803f9d6ad7SLin Ling extern void zfs_dbgmsg_fini(void);
813f9d6ad7SLin Ling extern void zfs_dbgmsg(const char *fmt, ...);
82b4952e17SGeorge Wilson extern void zfs_dbgmsg_print(const char *tag);
833f9d6ad7SLin Ling 
84cd1c8b85SMatthew Ahrens #ifndef _KERNEL
85cd1c8b85SMatthew Ahrens extern int dprintf_find_string(const char *string);
86cd1c8b85SMatthew Ahrens #endif
87cd1c8b85SMatthew Ahrens 
88fa9e4066Sahrens #ifdef	__cplusplus
89fa9e4066Sahrens }
90fa9e4066Sahrens #endif
91fa9e4066Sahrens 
92fa9e4066Sahrens #endif	/* _SYS_ZFS_DEBUG_H */
93