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. 23*814dcd43SSerapheim Dimitropoulos * Copyright (c) 2012, 2019 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 538363e80aSGeorge Wilson #define ZFS_DEBUG_DPRINTF (1 << 0) 548363e80aSGeorge Wilson #define ZFS_DEBUG_DBUF_VERIFY (1 << 1) 558363e80aSGeorge Wilson #define ZFS_DEBUG_DNODE_VERIFY (1 << 2) 568363e80aSGeorge Wilson #define ZFS_DEBUG_SNAPNAMES (1 << 3) 578363e80aSGeorge Wilson #define ZFS_DEBUG_MODIFY (1 << 4) 5821f7c81cSMatthew Ahrens /* 1<<5 was previously used, try not to reuse */ 598363e80aSGeorge Wilson #define ZFS_DEBUG_ZIO_FREE (1 << 6) 608363e80aSGeorge Wilson #define ZFS_DEBUG_HISTOGRAM_VERIFY (1 << 7) 618363e80aSGeorge Wilson #define ZFS_DEBUG_METASLAB_VERIFY (1 << 8) 625cabbc6bSPrashanth Sreenivasa #define ZFS_DEBUG_INDIRECT_REMAP (1 << 9) 63084fd14fSBrian Behlendorf #define ZFS_DEBUG_TRIM (1 << 11) 64*814dcd43SSerapheim Dimitropoulos #define ZFS_DEBUG_LOG_SPACEMAP (1 << 12) 65fa9e4066Sahrens 66fa9e4066Sahrens #ifdef ZFS_DEBUG 67fa9e4066Sahrens extern void __dprintf(const char *file, const char *func, 68fa9e4066Sahrens int line, const char *fmt, ...); 69fa9e4066Sahrens #define dprintf(...) \ 70fa9e4066Sahrens if (zfs_flags & ZFS_DEBUG_DPRINTF) \ 71fa9e4066Sahrens __dprintf(__FILE__, __func__, __LINE__, __VA_ARGS__) 72fa9e4066Sahrens #else 73fa9e4066Sahrens #define dprintf(...) ((void)0) 74fa9e4066Sahrens #endif /* ZFS_DEBUG */ 75fa9e4066Sahrens 760125049cSahrens extern void zfs_panic_recover(const char *fmt, ...); 770125049cSahrens 783f9d6ad7SLin Ling typedef struct zfs_dbgmsg { 793f9d6ad7SLin Ling list_node_t zdm_node; 803f9d6ad7SLin Ling time_t zdm_timestamp; 813f9d6ad7SLin Ling char zdm_msg[1]; /* variable length allocation */ 823f9d6ad7SLin Ling } zfs_dbgmsg_t; 833f9d6ad7SLin Ling 843f9d6ad7SLin Ling extern void zfs_dbgmsg_init(void); 853f9d6ad7SLin Ling extern void zfs_dbgmsg_fini(void); 863f9d6ad7SLin Ling extern void zfs_dbgmsg(const char *fmt, ...); 87b4952e17SGeorge Wilson extern void zfs_dbgmsg_print(const char *tag); 883f9d6ad7SLin Ling 89cd1c8b85SMatthew Ahrens #ifndef _KERNEL 90cd1c8b85SMatthew Ahrens extern int dprintf_find_string(const char *string); 91cd1c8b85SMatthew Ahrens #endif 92cd1c8b85SMatthew Ahrens 93fa9e4066Sahrens #ifdef __cplusplus 94fa9e4066Sahrens } 95fa9e4066Sahrens #endif 96fa9e4066Sahrens 97fa9e4066Sahrens #endif /* _SYS_ZFS_DEBUG_H */ 98