]>
Commit | Line | Data |
---|---|---|
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. | |
c06d4368 | 23 | * Copyright (c) 2012 by Delphix. All rights reserved. |
428870ff BB |
24 | */ |
25 | ||
26 | #include <sys/zfs_context.h> | |
27 | ||
d7e398ce BB |
28 | /* |
29 | * Enable various debugging features. | |
30 | */ | |
31 | int zfs_flags = 0; | |
32 | ||
33 | /* | |
34 | * zfs_recover can be set to nonzero to attempt to recover from | |
35 | * otherwise-fatal errors, typically caused by on-disk corruption. When | |
36 | * set, calls to zfs_panic_recover() will turn into warning messages. | |
37 | */ | |
38 | int zfs_recover = 0; | |
428870ff | 39 | |
428870ff BB |
40 | |
41 | void | |
d7e398ce | 42 | zfs_panic_recover(const char *fmt, ...) |
428870ff | 43 | { |
d7e398ce | 44 | va_list adx; |
428870ff | 45 | |
d7e398ce BB |
46 | va_start(adx, fmt); |
47 | vcmn_err(zfs_recover ? CE_WARN : CE_PANIC, fmt, adx); | |
48 | va_end(adx); | |
428870ff BB |
49 | } |
50 | ||
51 | /* | |
d7e398ce BB |
52 | * Debug logging is enabled by default for production kernel builds. |
53 | * The overhead for this is negligible and the logs can be valuable when | |
54 | * debugging. For non-production user space builds all debugging except | |
55 | * logging is enabled since performance is no longer a concern. | |
428870ff BB |
56 | */ |
57 | void | |
d7e398ce | 58 | zfs_dbgmsg_init(void) |
428870ff | 59 | { |
d7e398ce BB |
60 | if (zfs_flags == 0) { |
61 | #if defined(_KERNEL) | |
62 | zfs_flags = ZFS_DEBUG_DPRINTF; | |
a31acb46 BB |
63 | spl_debug_set_mask(spl_debug_get_mask() | SD_DPRINTF); |
64 | spl_debug_set_subsys(spl_debug_get_subsys() | SS_USER1); | |
d7e398ce BB |
65 | #else |
66 | zfs_flags = ~ZFS_DEBUG_DPRINTF; | |
67 | #endif /* _KERNEL */ | |
68 | } | |
69 | } | |
428870ff | 70 | |
d7e398ce BB |
71 | void |
72 | zfs_dbgmsg_fini(void) | |
73 | { | |
74 | return; | |
75 | } | |
428870ff | 76 | |
428870ff | 77 | |
d7e398ce BB |
78 | #if defined(_KERNEL) |
79 | module_param(zfs_flags, int, 0644); | |
80 | MODULE_PARM_DESC(zfs_flags, "Set additional debugging flags"); | |
428870ff | 81 | |
d7e398ce BB |
82 | module_param(zfs_recover, int, 0644); |
83 | MODULE_PARM_DESC(zfs_recover, "Set to attempt to recover from fatal errors"); | |
84 | #endif /* _KERNEL */ |