]> git.proxmox.com Git - mirror_zfs-debian.git/blame - module/zfs/zfs_debug.c
Cleanup ZFS debug infrastructure
[mirror_zfs-debian.git] / module / zfs / zfs_debug.c
CommitLineData
428870ff
BB
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
d7e398ce
BB
27/*
28 * Enable various debugging features.
29 */
30int 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 */
37int zfs_recover = 0;
428870ff 38
428870ff
BB
39
40void
d7e398ce 41zfs_panic_recover(const char *fmt, ...)
428870ff 42{
d7e398ce 43 va_list adx;
428870ff 44
d7e398ce
BB
45 va_start(adx, fmt);
46 vcmn_err(zfs_recover ? CE_WARN : CE_PANIC, fmt, adx);
47 va_end(adx);
428870ff
BB
48}
49
50/*
d7e398ce
BB
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.
428870ff
BB
55 */
56void
d7e398ce 57zfs_dbgmsg_init(void)
428870ff 58{
d7e398ce
BB
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}
428870ff 69
d7e398ce
BB
70void
71zfs_dbgmsg_fini(void)
72{
73 return;
74}
428870ff 75
428870ff 76
d7e398ce
BB
77#if defined(_KERNEL)
78module_param(zfs_flags, int, 0644);
79MODULE_PARM_DESC(zfs_flags, "Set additional debugging flags");
428870ff 80
d7e398ce
BB
81module_param(zfs_recover, int, 0644);
82MODULE_PARM_DESC(zfs_recover, "Set to attempt to recover from fatal errors");
83#endif /* _KERNEL */