1fa9e406ahrens/*
2fa9e406ahrens * CDDL HEADER START
3fa9e406ahrens *
4fa9e406ahrens * The contents of this file are subject to the terms of the
56b4acc8ahrens * Common Development and Distribution License (the "License").
66b4acc8ahrens * You may not use this file except in compliance with the License.
7fa9e406ahrens *
8fa9e406ahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e406ahrens * or http://www.opensolaris.org/os/licensing.
10fa9e406ahrens * See the License for the specific language governing permissions
11fa9e406ahrens * and limitations under the License.
12fa9e406ahrens *
13fa9e406ahrens * When distributing Covered Code, include this CDDL HEADER in each
14fa9e406ahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e406ahrens * If applicable, add the following below this CDDL HEADER, with the
16fa9e406ahrens * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e406ahrens * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e406ahrens *
19fa9e406ahrens * CDDL HEADER END
20fa9e406ahrens */
21fa9e406ahrens/*
223f9d6adLin Ling * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23814dcd4Serapheim Dimitropoulos * Copyright (c) 2012, 2019 by Delphix. All rights reserved.
24fa9e406ahrens */
25fa9e406ahrens
26fa9e406ahrens#ifndef _SYS_ZFS_DEBUG_H
27fa9e406ahrens#define	_SYS_ZFS_DEBUG_H
28fa9e406ahrens
29fa9e406ahrens#ifdef	__cplusplus
30fa9e406ahrensextern "C" {
31fa9e406ahrens#endif
32fa9e406ahrens
33fa9e406ahrens#ifndef TRUE
34fa9e406ahrens#define	TRUE 1
35fa9e406ahrens#endif
36fa9e406ahrens
37fa9e406ahrens#ifndef FALSE
38fa9e406ahrens#define	FALSE 0
39fa9e406ahrens#endif
40fa9e406ahrens
41fa9e406ahrens/*
42fa9e406ahrens * ZFS debugging
43fa9e406ahrens */
44fa9e406ahrens
45fa9e406ahrens#if defined(DEBUG) || !defined(_KERNEL)
46fa9e406ahrens#define	ZFS_DEBUG
47fa9e406ahrens#endif
48fa9e406ahrens
49fa9e406ahrensextern int zfs_flags;
507fd05acMatthew Ahrensextern boolean_t zfs_recover;
517fd05acMatthew Ahrensextern boolean_t zfs_free_leak_on_eio;
52fa9e406ahrens
538363e80George Wilson#define	ZFS_DEBUG_DPRINTF		(1 << 0)
548363e80George Wilson#define	ZFS_DEBUG_DBUF_VERIFY		(1 << 1)
558363e80George Wilson#define	ZFS_DEBUG_DNODE_VERIFY		(1 << 2)
568363e80George Wilson#define	ZFS_DEBUG_SNAPNAMES		(1 << 3)
578363e80George Wilson#define	ZFS_DEBUG_MODIFY		(1 << 4)
5821f7c81Matthew Ahrens/* 1<<5 was previously used, try not to reuse */
598363e80George Wilson#define	ZFS_DEBUG_ZIO_FREE		(1 << 6)
608363e80George Wilson#define	ZFS_DEBUG_HISTOGRAM_VERIFY	(1 << 7)
618363e80George Wilson#define	ZFS_DEBUG_METASLAB_VERIFY	(1 << 8)
625cabbc6Prashanth Sreenivasa#define	ZFS_DEBUG_INDIRECT_REMAP	(1 << 9)
63084fd14Brian Behlendorf#define	ZFS_DEBUG_TRIM			(1 << 11)
64814dcd4Serapheim Dimitropoulos#define	ZFS_DEBUG_LOG_SPACEMAP		(1 << 12)
65fa9e406ahrens
66fa9e406ahrens#ifdef ZFS_DEBUG
67fa9e406ahrensextern void __dprintf(const char *file, const char *func,
68fa9e406ahrens    int line, const char *fmt, ...);
69fa9e406ahrens#define	dprintf(...) \
70fa9e406ahrens	if (zfs_flags & ZFS_DEBUG_DPRINTF) \
71fa9e406ahrens		__dprintf(__FILE__, __func__, __LINE__, __VA_ARGS__)
72fa9e406ahrens#else
73fa9e406ahrens#define	dprintf(...) ((void)0)
74fa9e406ahrens#endif /* ZFS_DEBUG */
75fa9e406ahrens
760125049ahrensextern void zfs_panic_recover(const char *fmt, ...);
770125049ahrens
783f9d6adLin Lingtypedef struct zfs_dbgmsg {
793f9d6adLin Ling	list_node_t zdm_node;
803f9d6adLin Ling	time_t zdm_timestamp;
813f9d6adLin Ling	char zdm_msg[1]; /* variable length allocation */
823f9d6adLin Ling} zfs_dbgmsg_t;
833f9d6adLin Ling
843f9d6adLin Lingextern void zfs_dbgmsg_init(void);
853f9d6adLin Lingextern void zfs_dbgmsg_fini(void);
863f9d6adLin Lingextern void zfs_dbgmsg(const char *fmt, ...);
87b4952e1George Wilsonextern void zfs_dbgmsg_print(const char *tag);
883f9d6adLin Ling
89cd1c8b8Matthew Ahrens#ifndef _KERNEL
90cd1c8b8Matthew Ahrensextern int dprintf_find_string(const char *string);
91cd1c8b8Matthew Ahrens#endif
92cd1c8b8Matthew Ahrens
93fa9e406ahrens#ifdef	__cplusplus
94fa9e406ahrens}
95fa9e406ahrens#endif
96fa9e406ahrens
97fa9e406ahrens#endif	/* _SYS_ZFS_DEBUG_H */
98