Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 1 | /* |
| 2 | * JFFS2 -- Journalling Flash File System, Version 2. |
| 3 | * |
| 4 | * Copyright (C) 2001-2003 Red Hat, Inc. |
| 5 | * |
| 6 | * Created by David Woodhouse <dwmw2@infradead.org> |
| 7 | * |
| 8 | * For licensing information, see the file 'LICENCE' in this directory. |
| 9 | * |
Artem B. Bityutskiy | 81e39cf | 2005-09-14 17:57:35 +0100 | [diff] [blame^] | 10 | * $Id: debug.h,v 1.16 2005/09/14 16:57:32 dedekind Exp $ |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 11 | * |
| 12 | */ |
| 13 | #ifndef _JFFS2_DEBUG_H_ |
| 14 | #define _JFFS2_DEBUG_H_ |
| 15 | |
| 16 | #include <linux/config.h> |
| 17 | |
| 18 | #ifndef CONFIG_JFFS2_FS_DEBUG |
Artem B. Bityutskiy | f538c96 | 2005-07-27 15:16:57 +0100 | [diff] [blame] | 19 | #define CONFIG_JFFS2_FS_DEBUG 0 |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 20 | #endif |
| 21 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 22 | #if CONFIG_JFFS2_FS_DEBUG == 1 |
| 23 | /* Enable "paranoia" checks and dumps */ |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 24 | #define JFFS2_DBG_PARANOIA_CHECKS |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 25 | #define JFFS2_DBG_DUMPS |
| 26 | #define JFFS2_DBG_READINODE_MESSAGES |
| 27 | #define JFFS2_DBG_FRAGTREE_MESSAGES |
| 28 | #define JFFS2_DBG_DENTLIST_MESSAGES |
| 29 | #define JFFS2_DBG_NODEREF_MESSAGES |
| 30 | #define JFFS2_DBG_INOCACHE_MESSAGES |
Ferenc Havasi | e631ddb | 2005-09-07 09:35:26 +0100 | [diff] [blame] | 31 | #define JFFS2_DBG_SUMMARY_MESSAGES |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 32 | #endif |
| 33 | |
| 34 | #if CONFIG_JFFS2_FS_DEBUG == 2 |
| 35 | #define JFFS2_DBG_FRAGTREE2_MESSAGES |
| 36 | #endif |
| 37 | |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 38 | /* Sanity checks are supposed to be light-weight and enabled by default */ |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 39 | #define JFFS2_DBG_SANITY_CHECKS |
| 40 | |
| 41 | /* |
| 42 | * Dx() are mainly used for debugging messages, they must go away and be |
| 43 | * superseded by nicer JFFS2_DBG_XXX() macros... |
| 44 | */ |
| 45 | #if CONFIG_JFFS2_FS_DEBUG > 0 |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 46 | #define D1(x) x |
| 47 | #else |
| 48 | #define D1(x) |
| 49 | #endif |
| 50 | |
| 51 | #if CONFIG_JFFS2_FS_DEBUG > 1 |
| 52 | #define D2(x) x |
| 53 | #else |
| 54 | #define D2(x) |
| 55 | #endif |
| 56 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 57 | /* The prefixes of JFFS2 messages */ |
Artem B. Bityutskiy | 81e39cf | 2005-09-14 17:57:35 +0100 | [diff] [blame^] | 58 | #define JFFS2_DBG_PREFIX "[JFFS2 DBG]" |
| 59 | #define JFFS2_ERR_PREFIX "JFFS2 error:" |
| 60 | #define JFFS2_WARN_PREFIX "JFFS2 warning:" |
| 61 | #define JFFS2_NOTICE_PREFIX "JFFS2 notice:" |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 62 | |
Artem B. Bityutskiy | 81e39cf | 2005-09-14 17:57:35 +0100 | [diff] [blame^] | 63 | #define JFFS2_ERR KERN_ERR |
| 64 | #define JFFS2_WARN KERN_WARNING |
| 65 | #define JFFS2_NOT KERN_NOTICE |
| 66 | #define JFFS2_DBG KERN_DEBUG |
| 67 | |
| 68 | #define JFFS2_DBG_MSG_PREFIX JFFS2_DBG JFFS2_DBG_PREFIX |
| 69 | #define JFFS2_ERR_MSG_PREFIX JFFS2_ERR JFFS2_ERR_PREFIX |
| 70 | #define JFFS2_WARN_MSG_PREFIX JFFS2_WARN JFFS2_WARN_PREFIX |
| 71 | #define JFFS2_NOTICE_MSG_PREFIX JFFS2_NOT JFFS2_NOTICE_PREFIX |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 72 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 73 | /* JFFS2 message macros */ |
| 74 | #define JFFS2_ERROR(fmt, ...) \ |
| 75 | do { \ |
Artem B. Bityutskiy | 81e39cf | 2005-09-14 17:57:35 +0100 | [diff] [blame^] | 76 | printk(JFFS2_ERR_MSG_PREFIX \ |
Artem B. Bityutskiy | 8d5df40 | 2005-08-17 15:13:48 +0100 | [diff] [blame] | 77 | " (%d) %s: " fmt, current->pid, \ |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 78 | __FUNCTION__, ##__VA_ARGS__); \ |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 79 | } while(0) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 80 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 81 | #define JFFS2_WARNING(fmt, ...) \ |
| 82 | do { \ |
Artem B. Bityutskiy | 81e39cf | 2005-09-14 17:57:35 +0100 | [diff] [blame^] | 83 | printk(JFFS2_WARN_MSG_PREFIX \ |
Artem B. Bityutskiy | 8d5df40 | 2005-08-17 15:13:48 +0100 | [diff] [blame] | 84 | " (%d) %s: " fmt, current->pid, \ |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 85 | __FUNCTION__, ##__VA_ARGS__); \ |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 86 | } while(0) |
| 87 | |
| 88 | #define JFFS2_NOTICE(fmt, ...) \ |
| 89 | do { \ |
Artem B. Bityutskiy | 81e39cf | 2005-09-14 17:57:35 +0100 | [diff] [blame^] | 90 | printk(JFFS2_NOTICE_MSG_PREFIX \ |
Artem B. Bityutskiy | 8d5df40 | 2005-08-17 15:13:48 +0100 | [diff] [blame] | 91 | " (%d) %s: " fmt, current->pid, \ |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 92 | __FUNCTION__, ##__VA_ARGS__); \ |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 93 | } while(0) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 94 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 95 | #define JFFS2_DEBUG(fmt, ...) \ |
| 96 | do { \ |
Artem B. Bityutskiy | 81e39cf | 2005-09-14 17:57:35 +0100 | [diff] [blame^] | 97 | printk(JFFS2_DBG_MSG_PREFIX \ |
Artem B. Bityutskiy | 8d5df40 | 2005-08-17 15:13:48 +0100 | [diff] [blame] | 98 | " (%d) %s: " fmt, current->pid, \ |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 99 | __FUNCTION__, ##__VA_ARGS__); \ |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 100 | } while(0) |
| 101 | |
| 102 | /* |
| 103 | * We split our debugging messages on several parts, depending on the JFFS2 |
| 104 | * subsystem the message belongs to. |
| 105 | */ |
| 106 | /* Read inode debugging messages */ |
| 107 | #ifdef JFFS2_DBG_READINODE_MESSAGES |
| 108 | #define JFFS2_DBG_READINODE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 109 | #else |
| 110 | #define JFFS2_DBG_READINODE(fmt, ...) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 111 | #endif |
| 112 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 113 | /* Fragtree build debugging messages */ |
| 114 | #ifdef JFFS2_DBG_FRAGTREE_MESSAGES |
| 115 | #define JFFS2_DBG_FRAGTREE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 116 | #else |
| 117 | #define JFFS2_DBG_FRAGTREE(fmt, ...) |
| 118 | #endif |
Artem B. Bityutskiy | e0e3006f | 2005-07-31 10:08:41 +0100 | [diff] [blame] | 119 | #ifdef JFFS2_DBG_FRAGTREE2_MESSAGES |
| 120 | #define JFFS2_DBG_FRAGTREE2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 121 | #else |
| 122 | #define JFFS2_DBG_FRAGTREE2(fmt, ...) |
| 123 | #endif |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 124 | |
| 125 | /* Directory entry list manilulation debugging messages */ |
| 126 | #ifdef JFFS2_DBG_DENTLIST_MESSAGES |
| 127 | #define JFFS2_DBG_DENTLIST(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 128 | #else |
| 129 | #define JFFS2_DBG_DENTLIST(fmt, ...) |
| 130 | #endif |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 131 | |
Artem B. Bityutskiy | f538c96 | 2005-07-27 15:16:57 +0100 | [diff] [blame] | 132 | /* Print the messages about manipulating node_refs */ |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 133 | #ifdef JFFS2_DBG_NODEREF_MESSAGES |
| 134 | #define JFFS2_DBG_NODEREF(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 135 | #else |
| 136 | #define JFFS2_DBG_NODEREF(fmt, ...) |
| 137 | #endif |
| 138 | |
Artem B. Bityutskiy | f538c96 | 2005-07-27 15:16:57 +0100 | [diff] [blame] | 139 | /* Manipulations with the list of inodes (JFFS2 inocache) */ |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 140 | #ifdef JFFS2_DBG_INOCACHE_MESSAGES |
| 141 | #define JFFS2_DBG_INOCACHE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 142 | #else |
| 143 | #define JFFS2_DBG_INOCACHE(fmt, ...) |
| 144 | #endif |
| 145 | |
Ferenc Havasi | e631ddb | 2005-09-07 09:35:26 +0100 | [diff] [blame] | 146 | /* Summary debugging messages */ |
| 147 | #ifdef JFFS2_DBG_SUMMARY_MESSAGES |
| 148 | #define JFFS2_DBG_SUMMARY(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 149 | #else |
| 150 | #define JFFS2_DBG_SUMMARY(fmt, ...) |
| 151 | #endif |
| 152 | |
Artem B. Bityutskiy | f538c96 | 2005-07-27 15:16:57 +0100 | [diff] [blame] | 153 | /* Watch the object allocations */ |
| 154 | #ifdef JFFS2_DBG_MEMALLOC_MESSAGES |
| 155 | #define JFFS2_DBG_MEMALLOC(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 156 | #else |
| 157 | #define JFFS2_DBG_MEMALLOC(fmt, ...) |
| 158 | #endif |
| 159 | |
| 160 | |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 161 | /* "Sanity" checks */ |
| 162 | void |
| 163 | __jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c, |
| 164 | struct jffs2_eraseblock *jeb); |
| 165 | void |
| 166 | __jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, |
| 167 | struct jffs2_eraseblock *jeb); |
| 168 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 169 | /* "Paranoia" checks */ |
| 170 | void |
| 171 | __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f); |
| 172 | void |
| 173 | __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f); |
| 174 | void |
| 175 | __jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, |
| 176 | struct jffs2_eraseblock *jeb); |
| 177 | void |
| 178 | __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c, |
| 179 | struct jffs2_eraseblock *jeb); |
| 180 | void |
| 181 | __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, |
| 182 | uint32_t ofs, int len); |
| 183 | |
| 184 | /* "Dump" functions */ |
| 185 | void |
| 186 | __jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); |
| 187 | void |
| 188 | __jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb); |
| 189 | void |
| 190 | __jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c); |
| 191 | void |
| 192 | __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c); |
| 193 | void |
| 194 | __jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, |
| 195 | struct jffs2_eraseblock *jeb); |
| 196 | void |
| 197 | __jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c, |
| 198 | struct jffs2_eraseblock *jeb); |
| 199 | void |
| 200 | __jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f); |
| 201 | void |
| 202 | __jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f); |
| 203 | void |
| 204 | __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs); |
| 205 | void |
| 206 | __jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs); |
| 207 | |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 208 | #ifdef JFFS2_DBG_PARANOIA_CHECKS |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 209 | #define jffs2_dbg_fragtree_paranoia_check(f) \ |
| 210 | __jffs2_dbg_fragtree_paranoia_check(f) |
| 211 | #define jffs2_dbg_fragtree_paranoia_check_nolock(f) \ |
| 212 | __jffs2_dbg_fragtree_paranoia_check_nolock(f) |
| 213 | #define jffs2_dbg_acct_paranoia_check(c, jeb) \ |
| 214 | __jffs2_dbg_acct_paranoia_check(c,jeb) |
| 215 | #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \ |
| 216 | __jffs2_dbg_acct_paranoia_check_nolock(c,jeb) |
| 217 | #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \ |
| 218 | __jffs2_dbg_prewrite_paranoia_check(c, ofs, len) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 219 | #else |
| 220 | #define jffs2_dbg_fragtree_paranoia_check(f) |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 221 | #define jffs2_dbg_fragtree_paranoia_check_nolock(f) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 222 | #define jffs2_dbg_acct_paranoia_check(c, jeb) |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 223 | #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 224 | #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) |
| 225 | #endif /* !JFFS2_PARANOIA_CHECKS */ |
| 226 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 227 | #ifdef JFFS2_DBG_DUMPS |
| 228 | #define jffs2_dbg_dump_jeb(c, jeb) \ |
| 229 | __jffs2_dbg_dump_jeb(c, jeb); |
| 230 | #define jffs2_dbg_dump_jeb_nolock(jeb) \ |
| 231 | __jffs2_dbg_dump_jeb_nolock(jeb); |
| 232 | #define jffs2_dbg_dump_block_lists(c) \ |
| 233 | __jffs2_dbg_dump_block_lists(c) |
| 234 | #define jffs2_dbg_dump_block_lists_nolock(c) \ |
| 235 | __jffs2_dbg_dump_block_lists_nolock(c) |
| 236 | #define jffs2_dbg_dump_fragtree(f) \ |
| 237 | __jffs2_dbg_dump_fragtree(f); |
| 238 | #define jffs2_dbg_dump_fragtree_nolock(f) \ |
| 239 | __jffs2_dbg_dump_fragtree_nolock(f); |
| 240 | #define jffs2_dbg_dump_buffer(buf, len, offs) \ |
| 241 | __jffs2_dbg_dump_buffer(*buf, len, offs); |
| 242 | #define jffs2_dbg_dump_node(c, ofs) \ |
| 243 | __jffs2_dbg_dump_node(c, ofs); |
| 244 | #else |
| 245 | #define jffs2_dbg_dump_jeb(c, jeb) |
| 246 | #define jffs2_dbg_dump_jeb_nolock(jeb) |
| 247 | #define jffs2_dbg_dump_block_lists(c) |
| 248 | #define jffs2_dbg_dump_block_lists_nolock(c) |
| 249 | #define jffs2_dbg_dump_fragtree(f) |
| 250 | #define jffs2_dbg_dump_fragtree_nolock(f) |
| 251 | #define jffs2_dbg_dump_buffer(buf, len, offs) |
| 252 | #define jffs2_dbg_dump_node(c, ofs) |
| 253 | #endif /* !JFFS2_DBG_DUMPS */ |
| 254 | |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 255 | #ifdef JFFS2_DBG_SANITY_CHECKS |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 256 | #define jffs2_dbg_acct_sanity_check(c, jeb) \ |
| 257 | __jffs2_dbg_acct_sanity_check(c, jeb) |
| 258 | #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \ |
| 259 | __jffs2_dbg_acct_sanity_check_nolock(c, jeb) |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 260 | #else |
| 261 | #define jffs2_dbg_acct_sanity_check(c, jeb) |
| 262 | #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 263 | #endif /* !JFFS2_DBG_SANITY_CHECKS */ |
| 264 | |
| 265 | #endif /* _JFFS2_DEBUG_H_ */ |