diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2011-06-03 01:31:29 -0400 |
---|---|---|
committer | Artem Bityutskiy <dedekind1@gmail.com> | 2011-07-04 03:54:28 -0400 |
commit | 2b1844a8c934723134ee1ff313e51d0d281cdef1 (patch) | |
tree | 1c490adba95a54eb14f9b00890ce9b09050358f7 /fs/ubifs/debug.h | |
parent | d808efb407e1a2cf83a8d21411157195f26bdef9 (diff) |
UBIFS: introduce helper functions for debugging checks and tests
This patch introduces helper functions for all debugging checks, so instead of
doing
if (!(ubifs_chk_flags & UBIFS_CHK_GEN))
we now do
if (!dbg_is_chk_gen(c))
This is a preparation to further changes where the flags will go away, and
we'll need to only change the helper functions, but the code which utilizes
them won't be touched.
At the same time this patch removes 'dbg_force_in_the_gaps()',
'dbg_force_in_the_gaps_enabled()', and dbg_failure_mode helpers for
consistency.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/debug.h')
-rw-r--r-- | fs/ubifs/debug.h | 66 |
1 files changed, 46 insertions, 20 deletions
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h index 90805bd49456..c3d1ffd0610a 100644 --- a/fs/ubifs/debug.h +++ b/fs/ubifs/debug.h | |||
@@ -31,8 +31,6 @@ 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 | |||
36 | /* | 34 | /* |
37 | * The UBIFS debugfs directory name pattern and maximum name length (3 for "ubi" | 35 | * The UBIFS debugfs directory name pattern and maximum name length (3 for "ubi" |
38 | * + 1 for "_" and plus 2x2 for 2 UBI numbers and 1 for the trailing zero byte. | 36 | * + 1 for "_" and plus 2x2 for 2 UBI numbers and 1 for the trailing zero byte. |
@@ -169,6 +167,8 @@ const char *dbg_key_str1(const struct ubifs_info *c, | |||
169 | /* Additional recovery messages */ | 167 | /* Additional recovery messages */ |
170 | #define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__) | 168 | #define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__) |
171 | 169 | ||
170 | extern spinlock_t dbg_lock; | ||
171 | |||
172 | /* | 172 | /* |
173 | * Debugging check flags. | 173 | * Debugging check flags. |
174 | * | 174 | * |
@@ -199,12 +199,43 @@ enum { | |||
199 | UBIFS_TST_RCVRY = 0x4, | 199 | UBIFS_TST_RCVRY = 0x4, |
200 | }; | 200 | }; |
201 | 201 | ||
202 | extern spinlock_t dbg_lock; | ||
203 | |||
204 | extern unsigned int ubifs_msg_flags; | 202 | extern unsigned int ubifs_msg_flags; |
205 | extern unsigned int ubifs_chk_flags; | 203 | extern unsigned int ubifs_chk_flags; |
206 | extern unsigned int ubifs_tst_flags; | 204 | extern unsigned int ubifs_tst_flags; |
207 | 205 | ||
206 | static inline int dbg_is_chk_gen(const struct ubifs_info *c) | ||
207 | { | ||
208 | return !!(ubifs_chk_flags & UBIFS_CHK_GEN); | ||
209 | } | ||
210 | static inline int dbg_is_chk_tnc(const struct ubifs_info *c) | ||
211 | { | ||
212 | return !!(ubifs_chk_flags & UBIFS_CHK_TNC); | ||
213 | } | ||
214 | static inline int dbg_is_chk_idx_sz(const struct ubifs_info *c) | ||
215 | { | ||
216 | return !!(ubifs_chk_flags & UBIFS_CHK_IDX_SZ); | ||
217 | } | ||
218 | static inline int dbg_is_chk_orph(const struct ubifs_info *c) | ||
219 | { | ||
220 | return !!(ubifs_chk_flags & UBIFS_CHK_ORPH); | ||
221 | } | ||
222 | static inline int dbg_is_chk_old_idx(const struct ubifs_info *c) | ||
223 | { | ||
224 | return !!(ubifs_chk_flags & UBIFS_CHK_OLD_IDX); | ||
225 | } | ||
226 | static inline int dbg_is_chk_lprops(const struct ubifs_info *c) | ||
227 | { | ||
228 | return !!(ubifs_chk_flags & UBIFS_CHK_LPROPS); | ||
229 | } | ||
230 | static inline int dbg_is_chk_fs(const struct ubifs_info *c) | ||
231 | { | ||
232 | return !!(ubifs_chk_flags & UBIFS_CHK_FS); | ||
233 | } | ||
234 | static inline int dbg_is_tst_rcvry(const struct ubifs_info *c) | ||
235 | { | ||
236 | return !!(ubifs_tst_flags & UBIFS_TST_RCVRY); | ||
237 | } | ||
238 | |||
208 | int ubifs_debugging_init(struct ubifs_info *c); | 239 | int ubifs_debugging_init(struct ubifs_info *c); |
209 | void ubifs_debugging_exit(struct ubifs_info *c); | 240 | void ubifs_debugging_exit(struct ubifs_info *c); |
210 | 241 | ||
@@ -261,16 +292,6 @@ int dbg_check_inode_size(struct ubifs_info *c, const struct inode *inode, | |||
261 | int dbg_check_data_nodes_order(struct ubifs_info *c, struct list_head *head); | 292 | int dbg_check_data_nodes_order(struct ubifs_info *c, struct list_head *head); |
262 | int dbg_check_nondata_nodes_order(struct ubifs_info *c, struct list_head *head); | 293 | int dbg_check_nondata_nodes_order(struct ubifs_info *c, struct list_head *head); |
263 | 294 | ||
264 | /* Force the use of in-the-gaps method for testing */ | ||
265 | static inline int dbg_force_in_the_gaps_enabled(void) | ||
266 | { | ||
267 | return ubifs_chk_flags & UBIFS_CHK_GEN; | ||
268 | } | ||
269 | int dbg_force_in_the_gaps(void); | ||
270 | |||
271 | /* Failure mode for recovery testing */ | ||
272 | #define dbg_failure_mode (ubifs_tst_flags & UBIFS_TST_RCVRY) | ||
273 | |||
274 | #ifndef UBIFS_DBG_PRESERVE_UBI | 295 | #ifndef UBIFS_DBG_PRESERVE_UBI |
275 | #define ubi_leb_read dbg_leb_read | 296 | #define ubi_leb_read dbg_leb_read |
276 | #define ubi_leb_write dbg_leb_write | 297 | #define ubi_leb_write dbg_leb_write |
@@ -330,6 +351,9 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c); | |||
330 | ubifs_err(fmt, ##__VA_ARGS__); \ | 351 | ubifs_err(fmt, ##__VA_ARGS__); \ |
331 | } while (0) | 352 | } while (0) |
332 | 353 | ||
354 | #define DBGKEY(key) ((char *)(key)) | ||
355 | #define DBGKEY1(key) ((char *)(key)) | ||
356 | |||
333 | #define ubifs_dbg_msg(fmt, ...) do { \ | 357 | #define ubifs_dbg_msg(fmt, ...) do { \ |
334 | if (0) \ | 358 | if (0) \ |
335 | pr_debug(fmt "\n", ##__VA_ARGS__); \ | 359 | pr_debug(fmt "\n", ##__VA_ARGS__); \ |
@@ -353,9 +377,6 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c); | |||
353 | #define dbg_scan(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) | 377 | #define dbg_scan(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
354 | #define dbg_rcvry(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) | 378 | #define dbg_rcvry(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__) |
355 | 379 | ||
356 | #define DBGKEY(key) ((char *)(key)) | ||
357 | #define DBGKEY1(key) ((char *)(key)) | ||
358 | |||
359 | static inline int ubifs_debugging_init(struct ubifs_info *c) { return 0; } | 380 | static inline int ubifs_debugging_init(struct ubifs_info *c) { return 0; } |
360 | static inline void ubifs_debugging_exit(struct ubifs_info *c) { return; } | 381 | static inline void ubifs_debugging_exit(struct ubifs_info *c) { return; } |
361 | static inline const char *dbg_ntype(int type) { return ""; } | 382 | static inline const char *dbg_ntype(int type) { return ""; } |
@@ -440,9 +461,14 @@ static inline int | |||
440 | dbg_check_nondata_nodes_order(struct ubifs_info *c, | 461 | dbg_check_nondata_nodes_order(struct ubifs_info *c, |
441 | struct list_head *head) { return 0; } | 462 | struct list_head *head) { return 0; } |
442 | 463 | ||
443 | static inline int dbg_force_in_the_gaps(void) { return 0; } | 464 | static inline int dbg_is_chk_gen(const struct ubifs_info *c) { return 0; } |
444 | #define dbg_force_in_the_gaps_enabled() 0 | 465 | static inline int dbg_is_chk_tnc(const struct ubifs_info *c) { return 0; } |
445 | #define dbg_failure_mode 0 | 466 | static inline int dbg_is_chk_idx_sz(const struct ubifs_info *c) { return 0; } |
467 | static inline int dbg_is_chk_orph(const struct ubifs_info *c) { return 0; } | ||
468 | static inline int dbg_is_chk_old_idx(const struct ubifs_info *c) { return 0; } | ||
469 | static inline int dbg_is_chk_lprops(const struct ubifs_info *c) { return 0; } | ||
470 | static inline int dbg_is_chk_fs(const struct ubifs_info *c) { return 0; } | ||
471 | static inline int dbg_is_tst_rcvry(const struct ubifs_info *c) { return 0; } | ||
446 | 472 | ||
447 | static inline int dbg_debugfs_init(void) { return 0; } | 473 | static inline int dbg_debugfs_init(void) { return 0; } |
448 | static inline void dbg_debugfs_exit(void) { return; } | 474 | static inline void dbg_debugfs_exit(void) { return; } |