diff options
Diffstat (limited to 'fs/ubifs/debug.h')
-rw-r--r-- | fs/ubifs/debug.h | 178 |
1 files changed, 64 insertions, 114 deletions
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h index e6493cac193d..a811ac4a26bb 100644 --- a/fs/ubifs/debug.h +++ b/fs/ubifs/debug.h | |||
@@ -31,6 +31,8 @@ typedef int (*dbg_znode_callback)(struct ubifs_info *c, | |||
31 | 31 | ||
32 | #ifdef CONFIG_UBIFS_FS_DEBUG | 32 | #ifdef CONFIG_UBIFS_FS_DEBUG |
33 | 33 | ||
34 | #include <linux/random.h> | ||
35 | |||
34 | /** | 36 | /** |
35 | * ubifs_debug_info - per-FS debugging information. | 37 | * ubifs_debug_info - per-FS debugging information. |
36 | * @old_zroot: old index root - used by 'dbg_check_old_index()' | 38 | * @old_zroot: old index root - used by 'dbg_check_old_index()' |
@@ -50,13 +52,15 @@ typedef int (*dbg_znode_callback)(struct ubifs_info *c, | |||
50 | * @new_ihead_offs: used by debugging to check @c->ihead_offs | 52 | * @new_ihead_offs: used by debugging to check @c->ihead_offs |
51 | * | 53 | * |
52 | * @saved_lst: saved lprops statistics (used by 'dbg_save_space_info()') | 54 | * @saved_lst: saved lprops statistics (used by 'dbg_save_space_info()') |
53 | * @saved_free: saved free space (used by 'dbg_save_space_info()') | 55 | * @saved_bi: saved budgeting information |
56 | * @saved_free: saved amount of free space | ||
57 | * @saved_idx_gc_cnt: saved value of @c->idx_gc_cnt | ||
54 | * | 58 | * |
55 | * dfs_dir_name: name of debugfs directory containing this file-system's files | 59 | * @dfs_dir_name: name of debugfs directory containing this file-system's files |
56 | * dfs_dir: direntry object of the file-system debugfs directory | 60 | * @dfs_dir: direntry object of the file-system debugfs directory |
57 | * dfs_dump_lprops: "dump lprops" debugfs knob | 61 | * @dfs_dump_lprops: "dump lprops" debugfs knob |
58 | * dfs_dump_budg: "dump budgeting information" debugfs knob | 62 | * @dfs_dump_budg: "dump budgeting information" debugfs knob |
59 | * dfs_dump_tnc: "dump TNC" debugfs knob | 63 | * @dfs_dump_tnc: "dump TNC" debugfs knob |
60 | */ | 64 | */ |
61 | struct ubifs_debug_info { | 65 | struct ubifs_debug_info { |
62 | struct ubifs_zbranch old_zroot; | 66 | struct ubifs_zbranch old_zroot; |
@@ -76,7 +80,9 @@ struct ubifs_debug_info { | |||
76 | int new_ihead_offs; | 80 | int new_ihead_offs; |
77 | 81 | ||
78 | struct ubifs_lp_stats saved_lst; | 82 | struct ubifs_lp_stats saved_lst; |
83 | struct ubifs_budg_info saved_bi; | ||
79 | long long saved_free; | 84 | long long saved_free; |
85 | int saved_idx_gc_cnt; | ||
80 | 86 | ||
81 | char dfs_dir_name[100]; | 87 | char dfs_dir_name[100]; |
82 | struct dentry *dfs_dir; | 88 | struct dentry *dfs_dir; |
@@ -101,23 +107,7 @@ struct ubifs_debug_info { | |||
101 | } \ | 107 | } \ |
102 | } while (0) | 108 | } while (0) |
103 | 109 | ||
104 | #define dbg_dump_stack() do { \ | 110 | #define dbg_dump_stack() dump_stack() |
105 | if (!dbg_failure_mode) \ | ||
106 | dump_stack(); \ | ||
107 | } while (0) | ||
108 | |||
109 | /* Generic debugging messages */ | ||
110 | #define dbg_msg(fmt, ...) do { \ | ||
111 | spin_lock(&dbg_lock); \ | ||
112 | printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "\n", current->pid, \ | ||
113 | __func__, ##__VA_ARGS__); \ | ||
114 | spin_unlock(&dbg_lock); \ | ||
115 | } while (0) | ||
116 | |||
117 | #define dbg_do_msg(typ, fmt, ...) do { \ | ||
118 | if (ubifs_msg_flags & typ) \ | ||
119 | dbg_msg(fmt, ##__VA_ARGS__); \ | ||
120 | } while (0) | ||
121 | 111 | ||
122 | #define dbg_err(fmt, ...) do { \ | 112 | #define dbg_err(fmt, ...) do { \ |
123 | spin_lock(&dbg_lock); \ | 113 | spin_lock(&dbg_lock); \ |
@@ -137,77 +127,40 @@ const char *dbg_key_str1(const struct ubifs_info *c, | |||
137 | #define DBGKEY(key) dbg_key_str0(c, (key)) | 127 | #define DBGKEY(key) dbg_key_str0(c, (key)) |
138 | #define DBGKEY1(key) dbg_key_str1(c, (key)) | 128 | #define DBGKEY1(key) dbg_key_str1(c, (key)) |
139 | 129 | ||
140 | /* General messages */ | 130 | #define ubifs_dbg_msg(type, fmt, ...) do { \ |
141 | #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) | ||
142 | 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__) | ||
143 | /* Additional journal messages */ | 140 | /* Additional journal messages */ |
144 | #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__) |
145 | |||
146 | /* Additional TNC messages */ | 142 | /* Additional TNC messages */ |
147 | #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__) |
148 | |||
149 | /* Additional lprops messages */ | 144 | /* Additional lprops messages */ |
150 | #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__) |
151 | |||
152 | /* Additional LEB find messages */ | 146 | /* Additional LEB find messages */ |
153 | #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__) |
154 | |||
155 | /* Additional mount messages */ | 148 | /* Additional mount messages */ |
156 | #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__) |
157 | |||
158 | /* Additional I/O messages */ | 150 | /* Additional I/O messages */ |
159 | #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__) |
160 | |||
161 | /* Additional commit messages */ | 152 | /* Additional commit messages */ |
162 | #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__) |
163 | |||
164 | /* Additional budgeting messages */ | 154 | /* Additional budgeting messages */ |
165 | #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__) |
166 | |||
167 | /* Additional log messages */ | 156 | /* Additional log messages */ |
168 | #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__) |
169 | |||
170 | /* Additional gc messages */ | 158 | /* Additional gc messages */ |
171 | #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__) |
172 | |||
173 | /* Additional scan messages */ | 160 | /* Additional scan messages */ |
174 | #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__) |
175 | |||
176 | /* Additional recovery messages */ | 162 | /* Additional recovery messages */ |
177 | #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__) |
178 | |||
179 | /* | ||
180 | * Debugging message type flags. | ||
181 | * | ||
182 | * UBIFS_MSG_GEN: general messages | ||
183 | * UBIFS_MSG_JNL: journal messages | ||
184 | * UBIFS_MSG_MNT: mount messages | ||
185 | * UBIFS_MSG_CMT: commit messages | ||
186 | * UBIFS_MSG_FIND: LEB find messages | ||
187 | * UBIFS_MSG_BUDG: budgeting messages | ||
188 | * UBIFS_MSG_GC: garbage collection messages | ||
189 | * UBIFS_MSG_TNC: TNC messages | ||
190 | * UBIFS_MSG_LP: lprops messages | ||
191 | * UBIFS_MSG_IO: I/O messages | ||
192 | * UBIFS_MSG_LOG: log messages | ||
193 | * UBIFS_MSG_SCAN: scan messages | ||
194 | * UBIFS_MSG_RCVRY: recovery messages | ||
195 | */ | ||
196 | enum { | ||
197 | UBIFS_MSG_GEN = 0x1, | ||
198 | UBIFS_MSG_JNL = 0x2, | ||
199 | UBIFS_MSG_MNT = 0x4, | ||
200 | UBIFS_MSG_CMT = 0x8, | ||
201 | UBIFS_MSG_FIND = 0x10, | ||
202 | UBIFS_MSG_BUDG = 0x20, | ||
203 | UBIFS_MSG_GC = 0x40, | ||
204 | UBIFS_MSG_TNC = 0x80, | ||
205 | UBIFS_MSG_LP = 0x100, | ||
206 | UBIFS_MSG_IO = 0x200, | ||
207 | UBIFS_MSG_LOG = 0x400, | ||
208 | UBIFS_MSG_SCAN = 0x800, | ||
209 | UBIFS_MSG_RCVRY = 0x1000, | ||
210 | }; | ||
211 | 164 | ||
212 | /* | 165 | /* |
213 | * Debugging check flags. | 166 | * Debugging check flags. |
@@ -233,11 +186,9 @@ enum { | |||
233 | /* | 186 | /* |
234 | * Special testing flags. | 187 | * Special testing flags. |
235 | * | 188 | * |
236 | * UBIFS_TST_FORCE_IN_THE_GAPS: force the use of in-the-gaps method | ||
237 | * UBIFS_TST_RCVRY: failure mode for recovery testing | 189 | * UBIFS_TST_RCVRY: failure mode for recovery testing |
238 | */ | 190 | */ |
239 | enum { | 191 | enum { |
240 | UBIFS_TST_FORCE_IN_THE_GAPS = 0x2, | ||
241 | UBIFS_TST_RCVRY = 0x4, | 192 | UBIFS_TST_RCVRY = 0x4, |
242 | }; | 193 | }; |
243 | 194 | ||
@@ -262,7 +213,7 @@ void dbg_dump_lpt_node(const struct ubifs_info *c, void *node, int lnum, | |||
262 | int offs); | 213 | int offs); |
263 | void dbg_dump_budget_req(const struct ubifs_budget_req *req); | 214 | void dbg_dump_budget_req(const struct ubifs_budget_req *req); |
264 | void dbg_dump_lstats(const struct ubifs_lp_stats *lst); | 215 | void dbg_dump_lstats(const struct ubifs_lp_stats *lst); |
265 | void dbg_dump_budg(struct ubifs_info *c); | 216 | void dbg_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi); |
266 | void dbg_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp); | 217 | void dbg_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp); |
267 | void dbg_dump_lprops(struct ubifs_info *c); | 218 | void dbg_dump_lprops(struct ubifs_info *c); |
268 | void dbg_dump_lpt_info(struct ubifs_info *c); | 219 | void dbg_dump_lpt_info(struct ubifs_info *c); |
@@ -304,18 +255,16 @@ int dbg_check_data_nodes_order(struct ubifs_info *c, struct list_head *head); | |||
304 | int dbg_check_nondata_nodes_order(struct ubifs_info *c, struct list_head *head); | 255 | int dbg_check_nondata_nodes_order(struct ubifs_info *c, struct list_head *head); |
305 | 256 | ||
306 | /* Force the use of in-the-gaps method for testing */ | 257 | /* Force the use of in-the-gaps method for testing */ |
307 | 258 | static inline int dbg_force_in_the_gaps_enabled(void) | |
308 | #define dbg_force_in_the_gaps_enabled \ | 259 | { |
309 | (ubifs_tst_flags & UBIFS_TST_FORCE_IN_THE_GAPS) | 260 | return ubifs_chk_flags & UBIFS_CHK_GEN; |
310 | 261 | } | |
311 | int dbg_force_in_the_gaps(void); | 262 | int dbg_force_in_the_gaps(void); |
312 | 263 | ||
313 | /* Failure mode for recovery testing */ | 264 | /* Failure mode for recovery testing */ |
314 | |||
315 | #define dbg_failure_mode (ubifs_tst_flags & UBIFS_TST_RCVRY) | 265 | #define dbg_failure_mode (ubifs_tst_flags & UBIFS_TST_RCVRY) |
316 | 266 | ||
317 | #ifndef UBIFS_DBG_PRESERVE_UBI | 267 | #ifndef UBIFS_DBG_PRESERVE_UBI |
318 | |||
319 | #define ubi_leb_read dbg_leb_read | 268 | #define ubi_leb_read dbg_leb_read |
320 | #define ubi_leb_write dbg_leb_write | 269 | #define ubi_leb_write dbg_leb_write |
321 | #define ubi_leb_change dbg_leb_change | 270 | #define ubi_leb_change dbg_leb_change |
@@ -323,7 +272,6 @@ int dbg_force_in_the_gaps(void); | |||
323 | #define ubi_leb_unmap dbg_leb_unmap | 272 | #define ubi_leb_unmap dbg_leb_unmap |
324 | #define ubi_is_mapped dbg_is_mapped | 273 | #define ubi_is_mapped dbg_is_mapped |
325 | #define ubi_leb_map dbg_leb_map | 274 | #define ubi_leb_map dbg_leb_map |
326 | |||
327 | #endif | 275 | #endif |
328 | 276 | ||
329 | int dbg_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset, | 277 | int dbg_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset, |
@@ -370,33 +318,33 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c); | |||
370 | __func__, __LINE__, current->pid); \ | 318 | __func__, __LINE__, current->pid); \ |
371 | } while (0) | 319 | } while (0) |
372 | 320 | ||
373 | #define dbg_err(fmt, ...) do { \ | 321 | #define dbg_err(fmt, ...) do { \ |
374 | if (0) \ | 322 | if (0) \ |
375 | ubifs_err(fmt, ##__VA_ARGS__); \ | 323 | ubifs_err(fmt, ##__VA_ARGS__); \ |
376 | } while (0) | 324 | } while (0) |
377 | 325 | ||
378 | #define dbg_msg(fmt, ...) do { \ | 326 | #define ubifs_dbg_msg(fmt, ...) do { \ |
379 | if (0) \ | 327 | if (0) \ |
380 | printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "\n", \ | 328 | pr_debug(fmt "\n", ##__VA_ARGS__); \ |
381 | current->pid, __func__, ##__VA_ARGS__); \ | ||
382 | } while (0) | 329 | } while (0) |
383 | 330 | ||
384 | #define dbg_dump_stack() | 331 | #define dbg_dump_stack() |
385 | #define ubifs_assert_cmt_locked(c) | 332 | #define ubifs_assert_cmt_locked(c) |
386 | 333 | ||
387 | #define dbg_gen(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 334 | #define dbg_msg(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
388 | #define dbg_jnl(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 335 | #define dbg_gen(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
389 | #define dbg_tnc(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 336 | #define dbg_jnl(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
390 | #define dbg_lp(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 337 | #define dbg_tnc(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
391 | #define dbg_find(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 338 | #define dbg_lp(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
392 | #define dbg_mnt(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 339 | #define dbg_find(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
393 | #define dbg_io(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 340 | #define dbg_mnt(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
394 | #define dbg_cmt(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 341 | #define dbg_io(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
395 | #define dbg_budg(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 342 | #define dbg_cmt(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
396 | #define dbg_log(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 343 | #define dbg_budg(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
397 | #define dbg_gc(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 344 | #define dbg_log(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
398 | #define dbg_scan(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) | 345 | #define dbg_gc(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
399 | #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__) | ||
400 | 348 | ||
401 | #define DBGKEY(key) ((char *)(key)) | 349 | #define DBGKEY(key) ((char *)(key)) |
402 | #define DBGKEY1(key) ((char *)(key)) | 350 | #define DBGKEY1(key) ((char *)(key)) |
@@ -420,7 +368,9 @@ static inline void | |||
420 | dbg_dump_budget_req(const struct ubifs_budget_req *req) { return; } | 368 | dbg_dump_budget_req(const struct ubifs_budget_req *req) { return; } |
421 | static inline void | 369 | static inline void |
422 | dbg_dump_lstats(const struct ubifs_lp_stats *lst) { return; } | 370 | dbg_dump_lstats(const struct ubifs_lp_stats *lst) { return; } |
423 | static inline void dbg_dump_budg(struct ubifs_info *c) { return; } | 371 | static inline void |
372 | dbg_dump_budg(struct ubifs_info *c, | ||
373 | const struct ubifs_budg_info *bi) { return; } | ||
424 | static inline void dbg_dump_lprop(const struct ubifs_info *c, | 374 | static inline void dbg_dump_lprop(const struct ubifs_info *c, |
425 | const struct ubifs_lprops *lp) { return; } | 375 | const struct ubifs_lprops *lp) { return; } |
426 | static inline void dbg_dump_lprops(struct ubifs_info *c) { return; } | 376 | static inline void dbg_dump_lprops(struct ubifs_info *c) { return; } |
@@ -482,8 +432,8 @@ dbg_check_nondata_nodes_order(struct ubifs_info *c, | |||
482 | struct list_head *head) { return 0; } | 432 | struct list_head *head) { return 0; } |
483 | 433 | ||
484 | static inline int dbg_force_in_the_gaps(void) { return 0; } | 434 | static inline int dbg_force_in_the_gaps(void) { return 0; } |
485 | #define dbg_force_in_the_gaps_enabled 0 | 435 | #define dbg_force_in_the_gaps_enabled() 0 |
486 | #define dbg_failure_mode 0 | 436 | #define dbg_failure_mode 0 |
487 | 437 | ||
488 | static inline int dbg_debugfs_init(void) { return 0; } | 438 | static inline int dbg_debugfs_init(void) { return 0; } |
489 | static inline void dbg_debugfs_exit(void) { return; } | 439 | static inline void dbg_debugfs_exit(void) { return; } |