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 | * |
Ferenc Havasi | e631ddb | 2005-09-07 09:35:26 +0100 | [diff] [blame] | 10 | * $Id: debug.h,v 1.15 2005/09/07 08:34:54 havasi 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 */ |
| 58 | #define JFFS2_DBG_MSG_PREFIX "[JFFS2 DBG]" |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 59 | #define JFFS2_ERR_MSG_PREFIX "JFFS2 error:" |
| 60 | #define JFFS2_WARN_MSG_PREFIX "JFFS2 warning:" |
| 61 | #define JFFS2_NOTICE_MSG_PREFIX "JFFS2 notice:" |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 62 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 63 | #define JFFS2_ERR_LVL KERN_ERR |
| 64 | #define JFFS2_WARN_LVL KERN_WARNING |
| 65 | #define JFFS2_NOTICE_LVL KERN_NOTICE |
| 66 | #define JFFS2_DBG_LVL KERN_DEBUG |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 67 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 68 | /* JFFS2 message macros */ |
| 69 | #define JFFS2_ERROR(fmt, ...) \ |
| 70 | do { \ |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 71 | printk(JFFS2_ERR_LVL JFFS2_ERR_MSG_PREFIX \ |
Artem B. Bityutskiy | 8d5df40 | 2005-08-17 15:13:48 +0100 | [diff] [blame] | 72 | " (%d) %s: " fmt, current->pid, \ |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 73 | __FUNCTION__, ##__VA_ARGS__); \ |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 74 | } while(0) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 75 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 76 | #define JFFS2_WARNING(fmt, ...) \ |
| 77 | do { \ |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 78 | printk(JFFS2_WARN_LVL JFFS2_WARN_MSG_PREFIX \ |
Artem B. Bityutskiy | 8d5df40 | 2005-08-17 15:13:48 +0100 | [diff] [blame] | 79 | " (%d) %s: " fmt, current->pid, \ |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 80 | __FUNCTION__, ##__VA_ARGS__); \ |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 81 | } while(0) |
| 82 | |
| 83 | #define JFFS2_NOTICE(fmt, ...) \ |
| 84 | do { \ |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 85 | printk(JFFS2_NOTICE_LVL JFFS2_NOTICE_MSG_PREFIX \ |
Artem B. Bityutskiy | 8d5df40 | 2005-08-17 15:13:48 +0100 | [diff] [blame] | 86 | " (%d) %s: " fmt, current->pid, \ |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 87 | __FUNCTION__, ##__VA_ARGS__); \ |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 88 | } while(0) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 89 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 90 | #define JFFS2_DEBUG(fmt, ...) \ |
| 91 | do { \ |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 92 | printk(JFFS2_DBG_LVL JFFS2_DBG_MSG_PREFIX \ |
Artem B. Bityutskiy | 8d5df40 | 2005-08-17 15:13:48 +0100 | [diff] [blame] | 93 | " (%d) %s: " fmt, current->pid, \ |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 94 | __FUNCTION__, ##__VA_ARGS__); \ |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 95 | } while(0) |
| 96 | |
| 97 | /* |
| 98 | * We split our debugging messages on several parts, depending on the JFFS2 |
| 99 | * subsystem the message belongs to. |
| 100 | */ |
| 101 | /* Read inode debugging messages */ |
| 102 | #ifdef JFFS2_DBG_READINODE_MESSAGES |
| 103 | #define JFFS2_DBG_READINODE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 104 | #else |
| 105 | #define JFFS2_DBG_READINODE(fmt, ...) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 106 | #endif |
| 107 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 108 | /* Fragtree build debugging messages */ |
| 109 | #ifdef JFFS2_DBG_FRAGTREE_MESSAGES |
| 110 | #define JFFS2_DBG_FRAGTREE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 111 | #else |
| 112 | #define JFFS2_DBG_FRAGTREE(fmt, ...) |
| 113 | #endif |
Artem B. Bityutskiy | e0e3006 | 2005-07-31 10:08:41 +0100 | [diff] [blame] | 114 | #ifdef JFFS2_DBG_FRAGTREE2_MESSAGES |
| 115 | #define JFFS2_DBG_FRAGTREE2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 116 | #else |
| 117 | #define JFFS2_DBG_FRAGTREE2(fmt, ...) |
| 118 | #endif |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 119 | |
| 120 | /* Directory entry list manilulation debugging messages */ |
| 121 | #ifdef JFFS2_DBG_DENTLIST_MESSAGES |
| 122 | #define JFFS2_DBG_DENTLIST(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 123 | #else |
| 124 | #define JFFS2_DBG_DENTLIST(fmt, ...) |
| 125 | #endif |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 126 | |
Artem B. Bityutskiy | f538c96 | 2005-07-27 15:16:57 +0100 | [diff] [blame] | 127 | /* Print the messages about manipulating node_refs */ |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 128 | #ifdef JFFS2_DBG_NODEREF_MESSAGES |
| 129 | #define JFFS2_DBG_NODEREF(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 130 | #else |
| 131 | #define JFFS2_DBG_NODEREF(fmt, ...) |
| 132 | #endif |
| 133 | |
Artem B. Bityutskiy | f538c96 | 2005-07-27 15:16:57 +0100 | [diff] [blame] | 134 | /* Manipulations with the list of inodes (JFFS2 inocache) */ |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 135 | #ifdef JFFS2_DBG_INOCACHE_MESSAGES |
| 136 | #define JFFS2_DBG_INOCACHE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 137 | #else |
| 138 | #define JFFS2_DBG_INOCACHE(fmt, ...) |
| 139 | #endif |
| 140 | |
Ferenc Havasi | e631ddb | 2005-09-07 09:35:26 +0100 | [diff] [blame] | 141 | /* Summary debugging messages */ |
| 142 | #ifdef JFFS2_DBG_SUMMARY_MESSAGES |
| 143 | #define JFFS2_DBG_SUMMARY(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 144 | #else |
| 145 | #define JFFS2_DBG_SUMMARY(fmt, ...) |
| 146 | #endif |
| 147 | |
Artem B. Bityutskiy | f538c96 | 2005-07-27 15:16:57 +0100 | [diff] [blame] | 148 | /* Watch the object allocations */ |
| 149 | #ifdef JFFS2_DBG_MEMALLOC_MESSAGES |
| 150 | #define JFFS2_DBG_MEMALLOC(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) |
| 151 | #else |
| 152 | #define JFFS2_DBG_MEMALLOC(fmt, ...) |
| 153 | #endif |
| 154 | |
| 155 | |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 156 | /* "Sanity" checks */ |
| 157 | void |
| 158 | __jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c, |
| 159 | struct jffs2_eraseblock *jeb); |
| 160 | void |
| 161 | __jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, |
| 162 | struct jffs2_eraseblock *jeb); |
| 163 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 164 | /* "Paranoia" checks */ |
| 165 | void |
| 166 | __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f); |
| 167 | void |
| 168 | __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f); |
| 169 | void |
| 170 | __jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, |
| 171 | struct jffs2_eraseblock *jeb); |
| 172 | void |
| 173 | __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c, |
| 174 | struct jffs2_eraseblock *jeb); |
| 175 | void |
| 176 | __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, |
| 177 | uint32_t ofs, int len); |
| 178 | |
| 179 | /* "Dump" functions */ |
| 180 | void |
| 181 | __jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); |
| 182 | void |
| 183 | __jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb); |
| 184 | void |
| 185 | __jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c); |
| 186 | void |
| 187 | __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c); |
| 188 | void |
| 189 | __jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, |
| 190 | struct jffs2_eraseblock *jeb); |
| 191 | void |
| 192 | __jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c, |
| 193 | struct jffs2_eraseblock *jeb); |
| 194 | void |
| 195 | __jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f); |
| 196 | void |
| 197 | __jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f); |
| 198 | void |
| 199 | __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs); |
| 200 | void |
| 201 | __jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs); |
| 202 | |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 203 | #ifdef JFFS2_DBG_PARANOIA_CHECKS |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 204 | #define jffs2_dbg_fragtree_paranoia_check(f) \ |
| 205 | __jffs2_dbg_fragtree_paranoia_check(f) |
| 206 | #define jffs2_dbg_fragtree_paranoia_check_nolock(f) \ |
| 207 | __jffs2_dbg_fragtree_paranoia_check_nolock(f) |
| 208 | #define jffs2_dbg_acct_paranoia_check(c, jeb) \ |
| 209 | __jffs2_dbg_acct_paranoia_check(c,jeb) |
| 210 | #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \ |
| 211 | __jffs2_dbg_acct_paranoia_check_nolock(c,jeb) |
| 212 | #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \ |
| 213 | __jffs2_dbg_prewrite_paranoia_check(c, ofs, len) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 214 | #else |
| 215 | #define jffs2_dbg_fragtree_paranoia_check(f) |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 216 | #define jffs2_dbg_fragtree_paranoia_check_nolock(f) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 217 | #define jffs2_dbg_acct_paranoia_check(c, jeb) |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 218 | #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 219 | #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) |
| 220 | #endif /* !JFFS2_PARANOIA_CHECKS */ |
| 221 | |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 222 | #ifdef JFFS2_DBG_DUMPS |
| 223 | #define jffs2_dbg_dump_jeb(c, jeb) \ |
| 224 | __jffs2_dbg_dump_jeb(c, jeb); |
| 225 | #define jffs2_dbg_dump_jeb_nolock(jeb) \ |
| 226 | __jffs2_dbg_dump_jeb_nolock(jeb); |
| 227 | #define jffs2_dbg_dump_block_lists(c) \ |
| 228 | __jffs2_dbg_dump_block_lists(c) |
| 229 | #define jffs2_dbg_dump_block_lists_nolock(c) \ |
| 230 | __jffs2_dbg_dump_block_lists_nolock(c) |
| 231 | #define jffs2_dbg_dump_fragtree(f) \ |
| 232 | __jffs2_dbg_dump_fragtree(f); |
| 233 | #define jffs2_dbg_dump_fragtree_nolock(f) \ |
| 234 | __jffs2_dbg_dump_fragtree_nolock(f); |
| 235 | #define jffs2_dbg_dump_buffer(buf, len, offs) \ |
| 236 | __jffs2_dbg_dump_buffer(*buf, len, offs); |
| 237 | #define jffs2_dbg_dump_node(c, ofs) \ |
| 238 | __jffs2_dbg_dump_node(c, ofs); |
| 239 | #else |
| 240 | #define jffs2_dbg_dump_jeb(c, jeb) |
| 241 | #define jffs2_dbg_dump_jeb_nolock(jeb) |
| 242 | #define jffs2_dbg_dump_block_lists(c) |
| 243 | #define jffs2_dbg_dump_block_lists_nolock(c) |
| 244 | #define jffs2_dbg_dump_fragtree(f) |
| 245 | #define jffs2_dbg_dump_fragtree_nolock(f) |
| 246 | #define jffs2_dbg_dump_buffer(buf, len, offs) |
| 247 | #define jffs2_dbg_dump_node(c, ofs) |
| 248 | #endif /* !JFFS2_DBG_DUMPS */ |
| 249 | |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 250 | #ifdef JFFS2_DBG_SANITY_CHECKS |
Artem B. Bityutskiy | 45ca1b5 | 2005-08-05 12:43:47 +0100 | [diff] [blame] | 251 | #define jffs2_dbg_acct_sanity_check(c, jeb) \ |
| 252 | __jffs2_dbg_acct_sanity_check(c, jeb) |
| 253 | #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \ |
| 254 | __jffs2_dbg_acct_sanity_check_nolock(c, jeb) |
Artem B. Bityutskiy | e0c8e42 | 2005-07-24 16:14:17 +0100 | [diff] [blame] | 255 | #else |
| 256 | #define jffs2_dbg_acct_sanity_check(c, jeb) |
| 257 | #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) |
Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 258 | #endif /* !JFFS2_DBG_SANITY_CHECKS */ |
| 259 | |
| 260 | #endif /* _JFFS2_DEBUG_H_ */ |