diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-05-17 08:15:30 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-05-23 01:22:20 -0400 |
commit | 56e46742e846e4de167dde0e1e1071ace1c882a5 (patch) | |
tree | ffed000ab5bb33d482878bd72420474bdab1eec4 /fs/ubifs | |
parent | bdc1a1b6100c78a6002b1761ebe36d5fe8f8585b (diff) |
UBIFS: switch to dynamic printks
Switch to debugging using dynamic printk (pr_debug()). There is no good reason
to carry custom debugging prints if there is so cool and powerful generic
dynamic printk infrastructure, see Documentation/dynamic-debug-howto.txt. With
dynamic printks we can switch on/of individual prints, per-file, per-function
and per format messages. This means that instead of doing old-fashioned
echo 1 > /sys/module/ubifs/parameters/debug_msgs
to enable general messages, we can do:
echo 'format "UBIFS DBG gen" +ptlf' > control
to enable general messages and additionally ask the dynamic printk
infrastructure to print process ID, line number and function name. So there is
no reason to keep UBIFS-specific crud if there is more powerful generic thing.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs')
-rw-r--r-- | fs/ubifs/debug.c | 3 | ||||
-rw-r--r-- | fs/ubifs/debug.h | 132 |
2 files changed, 41 insertions, 94 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index f46d77e9f031..0bb2bcef0de9 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
@@ -42,15 +42,12 @@ DEFINE_SPINLOCK(dbg_lock); | |||
42 | static char dbg_key_buf0[128]; | 42 | static char dbg_key_buf0[128]; |
43 | static char dbg_key_buf1[128]; | 43 | static char dbg_key_buf1[128]; |
44 | 44 | ||
45 | unsigned int ubifs_msg_flags; | ||
46 | unsigned int ubifs_chk_flags; | 45 | unsigned int ubifs_chk_flags; |
47 | unsigned int ubifs_tst_flags; | 46 | unsigned int ubifs_tst_flags; |
48 | 47 | ||
49 | module_param_named(debug_msgs, ubifs_msg_flags, uint, S_IRUGO | S_IWUSR); | ||
50 | module_param_named(debug_chks, ubifs_chk_flags, uint, S_IRUGO | S_IWUSR); | 48 | module_param_named(debug_chks, ubifs_chk_flags, uint, S_IRUGO | S_IWUSR); |
51 | module_param_named(debug_tsts, ubifs_tst_flags, uint, S_IRUGO | S_IWUSR); | 49 | module_param_named(debug_tsts, ubifs_tst_flags, uint, S_IRUGO | S_IWUSR); |
52 | 50 | ||
53 | MODULE_PARM_DESC(debug_msgs, "Debug message type flags"); | ||
54 | MODULE_PARM_DESC(debug_chks, "Debug check flags"); | 51 | MODULE_PARM_DESC(debug_chks, "Debug check flags"); |
55 | MODULE_PARM_DESC(debug_tsts, "Debug special test flags"); | 52 | MODULE_PARM_DESC(debug_tsts, "Debug special test flags"); |
56 | 53 | ||
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h index 7538bf23c243..a811ac4a26bb 100644 --- a/fs/ubifs/debug.h +++ b/fs/ubifs/debug.h | |||
@@ -109,19 +109,6 @@ struct ubifs_debug_info { | |||
109 | 109 | ||
110 | #define dbg_dump_stack() dump_stack() | 110 | #define dbg_dump_stack() dump_stack() |
111 | 111 | ||
112 | /* Generic debugging messages */ | ||
113 | #define dbg_msg(fmt, ...) do { \ | ||
114 | spin_lock(&dbg_lock); \ | ||
115 | printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "\n", current->pid, \ | ||
116 | __func__, ##__VA_ARGS__); \ | ||
117 | spin_unlock(&dbg_lock); \ | ||
118 | } while (0) | ||
119 | |||
120 | #define dbg_do_msg(typ, fmt, ...) do { \ | ||
121 | if (ubifs_msg_flags & typ) \ | ||
122 | dbg_msg(fmt, ##__VA_ARGS__); \ | ||
123 | } while (0) | ||
124 | |||
125 | #define dbg_err(fmt, ...) do { \ | 112 | #define dbg_err(fmt, ...) do { \ |
126 | spin_lock(&dbg_lock); \ | 113 | spin_lock(&dbg_lock); \ |
127 | ubifs_err(fmt, ##__VA_ARGS__); \ | 114 | ubifs_err(fmt, ##__VA_ARGS__); \ |
@@ -140,77 +127,40 @@ const char *dbg_key_str1(const struct ubifs_info *c, | |||
140 | #define DBGKEY(key) dbg_key_str0(c, (key)) | 127 | #define DBGKEY(key) dbg_key_str0(c, (key)) |
141 | #define DBGKEY1(key) dbg_key_str1(c, (key)) | 128 | #define DBGKEY1(key) dbg_key_str1(c, (key)) |
142 | 129 | ||
143 | /* General messages */ | 130 | #define ubifs_dbg_msg(type, fmt, ...) do { \ |
144 | #define dbg_gen(fmt, ...) dbg_do_msg(UBIFS_MSG_GEN, fmt, ##__VA_ARGS__) | 131 | spin_lock(&dbg_lock); \ |
132 | pr_debug("UBIFS DBG " type ": " fmt "\n", ##__VA_ARGS__); \ | ||
133 | spin_unlock(&dbg_lock); \ | ||
134 | } while (0) | ||
145 | 135 | ||
136 | /* Just a debugging messages not related to any specific UBIFS subsystem */ | ||
137 | #define dbg_msg(fmt, ...) ubifs_dbg_msg("msg", fmt, ##__VA_ARGS__) | ||
138 | /* General messages */ | ||
139 | #define dbg_gen(fmt, ...) ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__) | ||
146 | /* Additional journal messages */ | 140 | /* Additional journal messages */ |
147 | #define dbg_jnl(fmt, ...) dbg_do_msg(UBIFS_MSG_JNL, fmt, ##__VA_ARGS__) | 141 | #define dbg_jnl(fmt, ...) ubifs_dbg_msg("jnl", fmt, ##__VA_ARGS__) |
148 | |||
149 | /* Additional TNC messages */ | 142 | /* Additional TNC messages */ |
150 | #define dbg_tnc(fmt, ...) dbg_do_msg(UBIFS_MSG_TNC, fmt, ##__VA_ARGS__) | 143 | #define dbg_tnc(fmt, ...) ubifs_dbg_msg("tnc", fmt, ##__VA_ARGS__) |
151 | |||
152 | /* Additional lprops messages */ | 144 | /* Additional lprops messages */ |
153 | #define dbg_lp(fmt, ...) dbg_do_msg(UBIFS_MSG_LP, fmt, ##__VA_ARGS__) | 145 | #define dbg_lp(fmt, ...) ubifs_dbg_msg("lp", fmt, ##__VA_ARGS__) |
154 | |||
155 | /* Additional LEB find messages */ | 146 | /* Additional LEB find messages */ |
156 | #define dbg_find(fmt, ...) dbg_do_msg(UBIFS_MSG_FIND, fmt, ##__VA_ARGS__) | 147 | #define dbg_find(fmt, ...) ubifs_dbg_msg("find", fmt, ##__VA_ARGS__) |
157 | |||
158 | /* Additional mount messages */ | 148 | /* Additional mount messages */ |
159 | #define dbg_mnt(fmt, ...) dbg_do_msg(UBIFS_MSG_MNT, fmt, ##__VA_ARGS__) | 149 | #define dbg_mnt(fmt, ...) ubifs_dbg_msg("mnt", fmt, ##__VA_ARGS__) |
160 | |||
161 | /* Additional I/O messages */ | 150 | /* Additional I/O messages */ |
162 | #define dbg_io(fmt, ...) dbg_do_msg(UBIFS_MSG_IO, fmt, ##__VA_ARGS__) | 151 | #define dbg_io(fmt, ...) ubifs_dbg_msg("io", fmt, ##__VA_ARGS__) |
163 | |||
164 | /* Additional commit messages */ | 152 | /* Additional commit messages */ |
165 | #define dbg_cmt(fmt, ...) dbg_do_msg(UBIFS_MSG_CMT, fmt, ##__VA_ARGS__) | 153 | #define dbg_cmt(fmt, ...) ubifs_dbg_msg("cmt", fmt, ##__VA_ARGS__) |
166 | |||
167 | /* Additional budgeting messages */ | 154 | /* Additional budgeting messages */ |
168 | #define dbg_budg(fmt, ...) dbg_do_msg(UBIFS_MSG_BUDG, fmt, ##__VA_ARGS__) | 155 | #define dbg_budg(fmt, ...) ubifs_dbg_msg("budg", fmt, ##__VA_ARGS__) |
169 | |||
170 | /* Additional log messages */ | 156 | /* Additional log messages */ |
171 | #define dbg_log(fmt, ...) dbg_do_msg(UBIFS_MSG_LOG, fmt, ##__VA_ARGS__) | 157 | #define dbg_log(fmt, ...) ubifs_dbg_msg("log", fmt, ##__VA_ARGS__) |
172 | |||
173 | /* Additional gc messages */ | 158 | /* Additional gc messages */ |
174 | #define dbg_gc(fmt, ...) dbg_do_msg(UBIFS_MSG_GC, fmt, ##__VA_ARGS__) | 159 | #define dbg_gc(fmt, ...) ubifs_dbg_msg("gc", fmt, ##__VA_ARGS__) |
175 | |||
176 | /* Additional scan messages */ | 160 | /* Additional scan messages */ |
177 | #define dbg_scan(fmt, ...) dbg_do_msg(UBIFS_MSG_SCAN, fmt, ##__VA_ARGS__) | 161 | #define dbg_scan(fmt, ...) ubifs_dbg_msg("scan", fmt, ##__VA_ARGS__) |
178 | |||
179 | /* Additional recovery messages */ | 162 | /* Additional recovery messages */ |
180 | #define dbg_rcvry(fmt, ...) dbg_do_msg(UBIFS_MSG_RCVRY, fmt, ##__VA_ARGS__) | 163 | #define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__) |
181 | |||
182 | /* | ||
183 | * Debugging message type flags. | ||
184 | * | ||
185 | * UBIFS_MSG_GEN: general messages | ||
186 | * UBIFS_MSG_JNL: journal messages | ||
187 | * UBIFS_MSG_MNT: mount messages | ||
188 | * UBIFS_MSG_CMT: commit messages | ||
189 | * UBIFS_MSG_FIND: LEB find messages | ||
190 | * UBIFS_MSG_BUDG: budgeting messages | ||
191 | * UBIFS_MSG_GC: garbage collection messages | ||
192 | * UBIFS_MSG_TNC: TNC messages | ||
193 | * UBIFS_MSG_LP: lprops messages | ||
194 | * UBIFS_MSG_IO: I/O messages | ||
195 | * UBIFS_MSG_LOG: log messages | ||
196 | * UBIFS_MSG_SCAN: scan messages | ||
197 | * UBIFS_MSG_RCVRY: recovery messages | ||
198 | */ | ||
199 | enum { | ||
200 | UBIFS_MSG_GEN = 0x1, | ||
201 | UBIFS_MSG_JNL = 0x2, | ||
202 | UBIFS_MSG_MNT = 0x4, | ||
203 | UBIFS_MSG_CMT = 0x8, | ||
204 | UBIFS_MSG_FIND = 0x10, | ||
205 | UBIFS_MSG_BUDG = 0x20, | ||
206 | UBIFS_MSG_GC = 0x40, | ||
207 | UBIFS_MSG_TNC = 0x80, | ||
208 | UBIFS_MSG_LP = 0x100, | ||
209 | UBIFS_MSG_IO = 0x200, | ||
210 | UBIFS_MSG_LOG = 0x400, | ||
211 | UBIFS_MSG_SCAN = 0x800, | ||
212 | UBIFS_MSG_RCVRY = 0x1000, | ||
213 | }; | ||
214 | 164 | ||
215 | /* | 165 | /* |
216 | * Debugging check flags. | 166 | * Debugging check flags. |
@@ -368,33 +318,33 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c); | |||
368 | __func__, __LINE__, current->pid); \ | 318 | __func__, __LINE__, current->pid); \ |
369 | } while (0) | 319 | } while (0) |
370 | 320 | ||
371 | #define dbg_err(fmt, ...) do { \ | 321 | #define dbg_err(fmt, ...) do { \ |
372 | if (0) \ | 322 | if (0) \ |
373 | ubifs_err(fmt, ##__VA_ARGS__); \ | 323 | ubifs_err(fmt, ##__VA_ARGS__); \ |
374 | } while (0) | 324 | } while (0) |
375 | 325 | ||
376 | #define dbg_msg(fmt, ...) do { \ | 326 | #define ubifs_dbg_msg(fmt, ...) do { \ |
377 | if (0) \ | 327 | if (0) \ |
378 | printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "\n", \ | 328 | pr_debug(fmt "\n", ##__VA_ARGS__); \ |
379 | current->pid, __func__, ##__VA_ARGS__); \ | ||
380 | } while (0) | 329 | } while (0) |
381 | 330 | ||
382 | #define dbg_dump_stack() | 331 | #define dbg_dump_stack() |
383 | #define ubifs_assert_cmt_locked(c) | 332 | #define ubifs_assert_cmt_locked(c) |
384 | 333 | ||
385 | #define dbg_gen(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 334 | #define dbg_msg(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
386 | #define dbg_jnl(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 335 | #define dbg_gen(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
387 | #define dbg_tnc(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 336 | #define dbg_jnl(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
388 | #define dbg_lp(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 337 | #define dbg_tnc(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
389 | #define dbg_find(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 338 | #define dbg_lp(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
390 | #define dbg_mnt(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 339 | #define dbg_find(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
391 | #define dbg_io(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 340 | #define dbg_mnt(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
392 | #define dbg_cmt(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 341 | #define dbg_io(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
393 | #define dbg_budg(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 342 | #define dbg_cmt(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
394 | #define dbg_log(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 343 | #define dbg_budg(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
395 | #define dbg_gc(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 344 | #define dbg_log(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
396 | #define dbg_scan(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 345 | #define dbg_gc(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
397 | #define dbg_rcvry(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 346 | #define dbg_scan(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
347 | #define dbg_rcvry(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) | ||
398 | 348 | ||
399 | #define DBGKEY(key) ((char *)(key)) | 349 | #define DBGKEY(key) ((char *)(key)) |
400 | #define DBGKEY1(key) ((char *)(key)) | 350 | #define DBGKEY1(key) ((char *)(key)) |