xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfs_debug.h (revision 8363e80ae72609660f6090766ca8c2c18aa53f0c)
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.
232e4c9986SGeorge Wilson  * Copyright (c) 2012, 2014 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;
507fd05ac4SMatthew Ahrens extern boolean_t zfs_recover;
517fd05ac4SMatthew Ahrens extern boolean_t zfs_free_leak_on_eio;
52fa9e4066Sahrens 
53*8363e80aSGeorge Wilson #define	ZFS_DEBUG_DPRINTF		(1 << 0)
54*8363e80aSGeorge Wilson #define	ZFS_DEBUG_DBUF_VERIFY		(1 << 1)
55*8363e80aSGeorge Wilson #define	ZFS_DEBUG_DNODE_VERIFY		(1 << 2)
56*8363e80aSGeorge Wilson #define	ZFS_DEBUG_SNAPNAMES		(1 << 3)
57*8363e80aSGeorge Wilson #define	ZFS_DEBUG_MODIFY		(1 << 4)
58*8363e80aSGeorge Wilson #define	ZFS_DEBUG_SPA			(1 << 5)
59*8363e80aSGeorge Wilson #define	ZFS_DEBUG_ZIO_FREE		(1 << 6)
60*8363e80aSGeorge Wilson #define	ZFS_DEBUG_HISTOGRAM_VERIFY	(1 << 7)
61*8363e80aSGeorge Wilson #define	ZFS_DEBUG_METASLAB_VERIFY	(1 << 8)
62fa9e4066Sahrens 
63fa9e4066Sahrens #ifdef ZFS_DEBUG
64fa9e4066Sahrens extern void __dprintf(const char *file, const char *func,
65fa9e4066Sahrens     int line, const char *fmt, ...);
66fa9e4066Sahrens #define	dprintf(...) \
67fa9e4066Sahrens 	if (zfs_flags & ZFS_DEBUG_DPRINTF) \
68fa9e4066Sahrens 		__dprintf(__FILE__, __func__, __LINE__, __VA_ARGS__)
69fa9e4066Sahrens #else
70fa9e4066Sahrens #define	dprintf(...) ((void)0)
71fa9e4066Sahrens #endif /* ZFS_DEBUG */
72fa9e4066Sahrens 
730125049cSahrens extern void zfs_panic_recover(const char *fmt, ...);
740125049cSahrens 
753f9d6ad7SLin Ling typedef struct zfs_dbgmsg {
763f9d6ad7SLin Ling 	list_node_t zdm_node;
773f9d6ad7SLin Ling 	time_t zdm_timestamp;
783f9d6ad7SLin Ling 	char zdm_msg[1]; /* variable length allocation */
793f9d6ad7SLin Ling } zfs_dbgmsg_t;
803f9d6ad7SLin Ling 
813f9d6ad7SLin Ling extern void zfs_dbgmsg_init(void);
823f9d6ad7SLin Ling extern void zfs_dbgmsg_fini(void);
833f9d6ad7SLin Ling extern void zfs_dbgmsg(const char *fmt, ...);
84b4952e17SGeorge Wilson extern void zfs_dbgmsg_print(const char *tag);
853f9d6ad7SLin Ling 
86cd1c8b85SMatthew Ahrens #ifndef _KERNEL
87cd1c8b85SMatthew Ahrens extern int dprintf_find_string(const char *string);
88cd1c8b85SMatthew Ahrens #endif
89cd1c8b85SMatthew Ahrens 
90fa9e4066Sahrens #ifdef	__cplusplus
91fa9e4066Sahrens }
92fa9e4066Sahrens #endif
93fa9e4066Sahrens 
94fa9e4066Sahrens #endif	/* _SYS_ZFS_DEBUG_H */
95