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