diff options
author | Zach Brown <zach.brown@oracle.com> | 2005-12-15 17:31:23 -0500 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2006-01-03 14:45:45 -0500 |
commit | 52fd3d6fea441835fe3a35b7280e5e128bdeca9b (patch) | |
tree | 0e3dfdd639ebba904327616375971a37d7aff14f /fs/ocfs2/cluster/masklog.c | |
parent | 994fc28c7b1e697ac56befe4aecabf23f0689f46 (diff) |
[PATCH] OCFS2: The Second Oracle Cluster Filesystem
Very simple printk wrapper which adds the ability to enable various
sets of debug messages at run-time.
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Signed-off-by: Kurt Hackel <kurt.hackel@oracle.com>
Diffstat (limited to 'fs/ocfs2/cluster/masklog.c')
-rw-r--r-- | fs/ocfs2/cluster/masklog.c | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c new file mode 100644 index 000000000000..fd741cea5705 --- /dev/null +++ b/fs/ocfs2/cluster/masklog.c | |||
@@ -0,0 +1,166 @@ | |||
1 | /* -*- mode: c; c-basic-offset: 8; -*- | ||
2 | * vim: noexpandtab sw=8 ts=8 sts=0: | ||
3 | * | ||
4 | * Copyright (C) 2004, 2005 Oracle. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public | ||
17 | * License along with this program; if not, write to the | ||
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
19 | * Boston, MA 021110-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/proc_fs.h> | ||
25 | #include <linux/seq_file.h> | ||
26 | #include <linux/string.h> | ||
27 | #include <asm/uaccess.h> | ||
28 | |||
29 | #include "masklog.h" | ||
30 | |||
31 | struct mlog_bits mlog_and_bits = MLOG_BITS_RHS(MLOG_INITIAL_AND_MASK); | ||
32 | EXPORT_SYMBOL_GPL(mlog_and_bits); | ||
33 | struct mlog_bits mlog_not_bits = MLOG_BITS_RHS(MLOG_INITIAL_NOT_MASK); | ||
34 | EXPORT_SYMBOL_GPL(mlog_not_bits); | ||
35 | |||
36 | static ssize_t mlog_mask_show(u64 mask, char *buf) | ||
37 | { | ||
38 | char *state; | ||
39 | |||
40 | if (__mlog_test_u64(mask, mlog_and_bits)) | ||
41 | state = "allow"; | ||
42 | else if (__mlog_test_u64(mask, mlog_not_bits)) | ||
43 | state = "deny"; | ||
44 | else | ||
45 | state = "off"; | ||
46 | |||
47 | return snprintf(buf, PAGE_SIZE, "%s\n", state); | ||
48 | } | ||
49 | |||
50 | static ssize_t mlog_mask_store(u64 mask, const char *buf, size_t count) | ||
51 | { | ||
52 | if (!strnicmp(buf, "allow", 5)) { | ||
53 | __mlog_set_u64(mask, mlog_and_bits); | ||
54 | __mlog_clear_u64(mask, mlog_not_bits); | ||
55 | } else if (!strnicmp(buf, "deny", 4)) { | ||
56 | __mlog_set_u64(mask, mlog_not_bits); | ||
57 | __mlog_clear_u64(mask, mlog_and_bits); | ||
58 | } else if (!strnicmp(buf, "off", 3)) { | ||
59 | __mlog_clear_u64(mask, mlog_not_bits); | ||
60 | __mlog_clear_u64(mask, mlog_and_bits); | ||
61 | } else | ||
62 | return -EINVAL; | ||
63 | |||
64 | return count; | ||
65 | } | ||
66 | |||
67 | struct mlog_attribute { | ||
68 | struct attribute attr; | ||
69 | u64 mask; | ||
70 | }; | ||
71 | |||
72 | #define to_mlog_attr(_attr) container_of(_attr, struct mlog_attribute, attr) | ||
73 | |||
74 | #define define_mask(_name) { \ | ||
75 | .attr = { \ | ||
76 | .name = #_name, \ | ||
77 | .mode = S_IRUGO | S_IWUSR, \ | ||
78 | }, \ | ||
79 | .mask = ML_##_name, \ | ||
80 | } | ||
81 | |||
82 | static struct mlog_attribute mlog_attrs[MLOG_MAX_BITS] = { | ||
83 | define_mask(ENTRY), | ||
84 | define_mask(EXIT), | ||
85 | define_mask(TCP), | ||
86 | define_mask(MSG), | ||
87 | define_mask(SOCKET), | ||
88 | define_mask(HEARTBEAT), | ||
89 | define_mask(HB_BIO), | ||
90 | define_mask(DLMFS), | ||
91 | define_mask(DLM), | ||
92 | define_mask(DLM_DOMAIN), | ||
93 | define_mask(DLM_THREAD), | ||
94 | define_mask(DLM_MASTER), | ||
95 | define_mask(DLM_RECOVERY), | ||
96 | define_mask(AIO), | ||
97 | define_mask(JOURNAL), | ||
98 | define_mask(DISK_ALLOC), | ||
99 | define_mask(SUPER), | ||
100 | define_mask(FILE_IO), | ||
101 | define_mask(EXTENT_MAP), | ||
102 | define_mask(DLM_GLUE), | ||
103 | define_mask(BH_IO), | ||
104 | define_mask(UPTODATE), | ||
105 | define_mask(NAMEI), | ||
106 | define_mask(INODE), | ||
107 | define_mask(VOTE), | ||
108 | define_mask(DCACHE), | ||
109 | define_mask(CONN), | ||
110 | define_mask(QUORUM), | ||
111 | define_mask(EXPORT), | ||
112 | define_mask(ERROR), | ||
113 | define_mask(NOTICE), | ||
114 | define_mask(KTHREAD), | ||
115 | }; | ||
116 | |||
117 | static struct attribute *mlog_attr_ptrs[MLOG_MAX_BITS] = {NULL, }; | ||
118 | |||
119 | static ssize_t mlog_show(struct kobject *obj, struct attribute *attr, | ||
120 | char *buf) | ||
121 | { | ||
122 | struct mlog_attribute *mlog_attr = to_mlog_attr(attr); | ||
123 | |||
124 | return mlog_mask_show(mlog_attr->mask, buf); | ||
125 | } | ||
126 | |||
127 | static ssize_t mlog_store(struct kobject *obj, struct attribute *attr, | ||
128 | const char *buf, size_t count) | ||
129 | { | ||
130 | struct mlog_attribute *mlog_attr = to_mlog_attr(attr); | ||
131 | |||
132 | return mlog_mask_store(mlog_attr->mask, buf, count); | ||
133 | } | ||
134 | |||
135 | static struct sysfs_ops mlog_attr_ops = { | ||
136 | .show = mlog_show, | ||
137 | .store = mlog_store, | ||
138 | }; | ||
139 | |||
140 | static struct kobj_type mlog_ktype = { | ||
141 | .default_attrs = mlog_attr_ptrs, | ||
142 | .sysfs_ops = &mlog_attr_ops, | ||
143 | }; | ||
144 | |||
145 | static struct kset mlog_kset = { | ||
146 | .kobj = {.name = "logmask", .ktype = &mlog_ktype}, | ||
147 | }; | ||
148 | |||
149 | int mlog_sys_init(struct subsystem *o2cb_subsys) | ||
150 | { | ||
151 | int i = 0; | ||
152 | |||
153 | while (mlog_attrs[i].attr.mode) { | ||
154 | mlog_attr_ptrs[i] = &mlog_attrs[i].attr; | ||
155 | i++; | ||
156 | } | ||
157 | mlog_attr_ptrs[i] = NULL; | ||
158 | |||
159 | mlog_kset.subsys = o2cb_subsys; | ||
160 | return kset_register(&mlog_kset); | ||
161 | } | ||
162 | |||
163 | void mlog_sys_shutdown(void) | ||
164 | { | ||
165 | kset_unregister(&mlog_kset); | ||
166 | } | ||