]> git.proxmox.com Git - mirror_zfs.git/blob - module/zfs/zfs_debug.c
Cleanup ZFS debug infrastructure
[mirror_zfs.git] / module / zfs / zfs_debug.c
1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #include <sys/zfs_context.h>
26
27 /*
28 * Enable various debugging features.
29 */
30 int zfs_flags = 0;
31
32 /*
33 * zfs_recover can be set to nonzero to attempt to recover from
34 * otherwise-fatal errors, typically caused by on-disk corruption. When
35 * set, calls to zfs_panic_recover() will turn into warning messages.
36 */
37 int zfs_recover = 0;
38
39
40 void
41 zfs_panic_recover(const char *fmt, ...)
42 {
43 va_list adx;
44
45 va_start(adx, fmt);
46 vcmn_err(zfs_recover ? CE_WARN : CE_PANIC, fmt, adx);
47 va_end(adx);
48 }
49
50 /*
51 * Debug logging is enabled by default for production kernel builds.
52 * The overhead for this is negligible and the logs can be valuable when
53 * debugging. For non-production user space builds all debugging except
54 * logging is enabled since performance is no longer a concern.
55 */
56 void
57 zfs_dbgmsg_init(void)
58 {
59 if (zfs_flags == 0) {
60 #if defined(_KERNEL)
61 zfs_flags = ZFS_DEBUG_DPRINTF;
62 spl_debug_mask |= SD_DPRINTF;
63 spl_debug_subsys |= SS_USER1;
64 #else
65 zfs_flags = ~ZFS_DEBUG_DPRINTF;
66 #endif /* _KERNEL */
67 }
68 }
69
70 void
71 zfs_dbgmsg_fini(void)
72 {
73 return;
74 }
75
76
77 #if defined(_KERNEL)
78 module_param(zfs_flags, int, 0644);
79 MODULE_PARM_DESC(zfs_flags, "Set additional debugging flags");
80
81 module_param(zfs_recover, int, 0644);
82 MODULE_PARM_DESC(zfs_recover, "Set to attempt to recover from fatal errors");
83 #endif /* _KERNEL */