1
2
3
4
5
6
7
8 #ifndef O2CLUSTER_MASKLOG_H
9 #define O2CLUSTER_MASKLOG_H
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 #include <linux/sched.h>
68
69
70
71 #define ML_TCP 0x0000000000000001ULL
72 #define ML_MSG 0x0000000000000002ULL
73 #define ML_SOCKET 0x0000000000000004ULL
74 #define ML_HEARTBEAT 0x0000000000000008ULL
75 #define ML_HB_BIO 0x0000000000000010ULL
76 #define ML_DLMFS 0x0000000000000020ULL
77 #define ML_DLM 0x0000000000000040ULL
78 #define ML_DLM_DOMAIN 0x0000000000000080ULL
79 #define ML_DLM_THREAD 0x0000000000000100ULL
80 #define ML_DLM_MASTER 0x0000000000000200ULL
81 #define ML_DLM_RECOVERY 0x0000000000000400ULL
82 #define ML_DLM_GLUE 0x0000000000000800ULL
83 #define ML_VOTE 0x0000000000001000ULL
84 #define ML_CONN 0x0000000000002000ULL
85 #define ML_QUORUM 0x0000000000004000ULL
86 #define ML_BASTS 0x0000000000008000ULL
87 #define ML_CLUSTER 0x0000000000010000ULL
88
89
90 #define ML_ERROR 0x1000000000000000ULL
91 #define ML_NOTICE 0x2000000000000000ULL
92 #define ML_KTHREAD 0x4000000000000000ULL
93
94 #define MLOG_INITIAL_AND_MASK (ML_ERROR|ML_NOTICE)
95 #ifndef MLOG_MASK_PREFIX
96 #define MLOG_MASK_PREFIX 0
97 #endif
98
99
100
101
102
103
104 #if defined(CONFIG_OCFS2_DEBUG_MASKLOG)
105 #define ML_ALLOWED_BITS ~0
106 #else
107 #define ML_ALLOWED_BITS (ML_ERROR|ML_NOTICE)
108 #endif
109
110 #define MLOG_MAX_BITS 64
111
112 struct mlog_bits {
113 unsigned long words[MLOG_MAX_BITS / BITS_PER_LONG];
114 };
115
116 extern struct mlog_bits mlog_and_bits, mlog_not_bits;
117
118 #if BITS_PER_LONG == 32
119
120 #define __mlog_test_u64(mask, bits) \
121 ( (u32)(mask & 0xffffffff) & bits.words[0] || \
122 ((u64)(mask) >> 32) & bits.words[1] )
123 #define __mlog_set_u64(mask, bits) do { \
124 bits.words[0] |= (u32)(mask & 0xffffffff); \
125 bits.words[1] |= (u64)(mask) >> 32; \
126 } while (0)
127 #define __mlog_clear_u64(mask, bits) do { \
128 bits.words[0] &= ~((u32)(mask & 0xffffffff)); \
129 bits.words[1] &= ~((u64)(mask) >> 32); \
130 } while (0)
131 #define MLOG_BITS_RHS(mask) { \
132 { \
133 [0] = (u32)(mask & 0xffffffff), \
134 [1] = (u64)(mask) >> 32, \
135 } \
136 }
137
138 #else
139
140 #define __mlog_test_u64(mask, bits) ((mask) & bits.words[0])
141 #define __mlog_set_u64(mask, bits) do { \
142 bits.words[0] |= (mask); \
143 } while (0)
144 #define __mlog_clear_u64(mask, bits) do { \
145 bits.words[0] &= ~(mask); \
146 } while (0)
147 #define MLOG_BITS_RHS(mask) { { (mask) } }
148
149 #endif
150
151 __printf(4, 5)
152 void __mlog_printk(const u64 *m, const char *func, int line,
153 const char *fmt, ...);
154
155
156
157
158
159 #define mlog(mask, fmt, ...) \
160 do { \
161 u64 _m = MLOG_MASK_PREFIX | (mask); \
162 if (_m & ML_ALLOWED_BITS) \
163 __mlog_printk(&_m, __func__, __LINE__, fmt, \
164 ##__VA_ARGS__); \
165 } while (0)
166
167 #define mlog_ratelimited(mask, fmt, ...) \
168 do { \
169 static DEFINE_RATELIMIT_STATE(_rs, \
170 DEFAULT_RATELIMIT_INTERVAL, \
171 DEFAULT_RATELIMIT_BURST); \
172 if (__ratelimit(&_rs)) \
173 mlog(mask, fmt, ##__VA_ARGS__); \
174 } while (0)
175
176 #define mlog_errno(st) ({ \
177 int _st = (st); \
178 if (_st != -ERESTARTSYS && _st != -EINTR && \
179 _st != AOP_TRUNCATED_PAGE && _st != -ENOSPC && \
180 _st != -EDQUOT) \
181 mlog(ML_ERROR, "status = %lld\n", (long long)_st); \
182 _st; \
183 })
184
185 #define mlog_bug_on_msg(cond, fmt, args...) do { \
186 if (cond) { \
187 mlog(ML_ERROR, "bug expression: " #cond "\n"); \
188 mlog(ML_ERROR, fmt, ##args); \
189 BUG(); \
190 } \
191 } while (0)
192
193 #include <linux/kobject.h>
194 #include <linux/sysfs.h>
195 int mlog_sys_init(struct kset *o2cb_subsys);
196 void mlog_sys_shutdown(void);
197
198 #endif