Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of UBIFS. |
| 3 | * |
| 4 | * Copyright (C) 2006-2008 Nokia Corporation. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as published by |
| 8 | * the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along with |
| 16 | * this program; if not, write to the Free Software Foundation, Inc., 51 |
| 17 | * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
| 19 | * Authors: Artem Bityutskiy (Битюцкий Артём) |
| 20 | * Adrian Hunter |
| 21 | */ |
| 22 | |
| 23 | #ifndef __UBIFS_DEBUG_H__ |
| 24 | #define __UBIFS_DEBUG_H__ |
| 25 | |
| 26 | #ifdef CONFIG_UBIFS_FS_DEBUG |
| 27 | |
Artem Bityutskiy | 17c2f9f | 2008-10-17 13:31:39 +0300 | [diff] [blame] | 28 | /** |
| 29 | * ubifs_debug_info - per-FS debugging information. |
| 30 | * @buf: a buffer of LEB size, used for various purposes |
| 31 | * @old_zroot: old index root - used by 'dbg_check_old_index()' |
| 32 | * @old_zroot_level: old index root level - used by 'dbg_check_old_index()' |
| 33 | * @old_zroot_sqnum: old index root sqnum - used by 'dbg_check_old_index()' |
| 34 | * @failure_mode: failure mode for recovery testing |
| 35 | * @fail_delay: 0=>don't delay, 1=>delay a time, 2=>delay a number of calls |
| 36 | * @fail_timeout: time in jiffies when delay of failure mode expires |
| 37 | * @fail_cnt: current number of calls to failure mode I/O functions |
| 38 | * @fail_cnt_max: number of calls by which to delay failure mode |
| 39 | * @chk_lpt_sz: used by LPT tree size checker |
| 40 | * @chk_lpt_sz2: used by LPT tree size checker |
| 41 | * @chk_lpt_wastage: used by LPT tree size checker |
| 42 | * @chk_lpt_lebs: used by LPT tree size checker |
| 43 | * @new_nhead_offs: used by LPT tree size checker |
| 44 | * @new_ihead_lnum: used by debugging to check ihead_lnum |
| 45 | * @new_ihead_offs: used by debugging to check ihead_offs |
Artem Bityutskiy | 552ff31 | 2008-10-23 11:49:28 +0300 | [diff] [blame] | 46 | * |
| 47 | * debugfs_dir_name: name of debugfs directory containing this file-system's |
| 48 | * files |
| 49 | * debugfs_dir: direntry object of the file-system debugfs directory |
| 50 | * dump_lprops: "dump lprops" debugfs knob |
| 51 | * dump_budg: "dump budgeting information" debugfs knob |
| 52 | * dump_tnc: "dump TNC" debugfs knob |
Artem Bityutskiy | 17c2f9f | 2008-10-17 13:31:39 +0300 | [diff] [blame] | 53 | */ |
| 54 | struct ubifs_debug_info { |
| 55 | void *buf; |
| 56 | struct ubifs_zbranch old_zroot; |
| 57 | int old_zroot_level; |
| 58 | unsigned long long old_zroot_sqnum; |
| 59 | int failure_mode; |
| 60 | int fail_delay; |
| 61 | unsigned long fail_timeout; |
| 62 | unsigned int fail_cnt; |
| 63 | unsigned int fail_cnt_max; |
| 64 | long long chk_lpt_sz; |
| 65 | long long chk_lpt_sz2; |
| 66 | long long chk_lpt_wastage; |
| 67 | int chk_lpt_lebs; |
| 68 | int new_nhead_offs; |
| 69 | int new_ihead_lnum; |
| 70 | int new_ihead_offs; |
Artem Bityutskiy | 552ff31 | 2008-10-23 11:49:28 +0300 | [diff] [blame] | 71 | |
| 72 | char debugfs_dir_name[100]; |
| 73 | struct dentry *debugfs_dir; |
| 74 | struct dentry *dump_lprops; |
| 75 | struct dentry *dump_budg; |
| 76 | struct dentry *dump_tnc; |
Artem Bityutskiy | 17c2f9f | 2008-10-17 13:31:39 +0300 | [diff] [blame] | 77 | }; |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 78 | |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 79 | #define ubifs_assert(expr) do { \ |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 80 | if (unlikely(!(expr))) { \ |
| 81 | printk(KERN_CRIT "UBIFS assert failed in %s at %u (pid %d)\n", \ |
| 82 | __func__, __LINE__, current->pid); \ |
| 83 | dbg_dump_stack(); \ |
| 84 | } \ |
| 85 | } while (0) |
| 86 | |
| 87 | #define ubifs_assert_cmt_locked(c) do { \ |
| 88 | if (unlikely(down_write_trylock(&(c)->commit_sem))) { \ |
| 89 | up_write(&(c)->commit_sem); \ |
| 90 | printk(KERN_CRIT "commit lock is not locked!\n"); \ |
| 91 | ubifs_assert(0); \ |
| 92 | } \ |
| 93 | } while (0) |
| 94 | |
| 95 | #define dbg_dump_stack() do { \ |
| 96 | if (!dbg_failure_mode) \ |
| 97 | dump_stack(); \ |
| 98 | } while (0) |
| 99 | |
| 100 | /* Generic debugging messages */ |
| 101 | #define dbg_msg(fmt, ...) do { \ |
| 102 | spin_lock(&dbg_lock); \ |
| 103 | printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "\n", current->pid, \ |
| 104 | __func__, ##__VA_ARGS__); \ |
| 105 | spin_unlock(&dbg_lock); \ |
| 106 | } while (0) |
| 107 | |
| 108 | #define dbg_do_msg(typ, fmt, ...) do { \ |
| 109 | if (ubifs_msg_flags & typ) \ |
| 110 | dbg_msg(fmt, ##__VA_ARGS__); \ |
| 111 | } while (0) |
| 112 | |
| 113 | #define dbg_err(fmt, ...) do { \ |
| 114 | spin_lock(&dbg_lock); \ |
| 115 | ubifs_err(fmt, ##__VA_ARGS__); \ |
| 116 | spin_unlock(&dbg_lock); \ |
| 117 | } while (0) |
| 118 | |
| 119 | const char *dbg_key_str0(const struct ubifs_info *c, |
| 120 | const union ubifs_key *key); |
| 121 | const char *dbg_key_str1(const struct ubifs_info *c, |
| 122 | const union ubifs_key *key); |
| 123 | |
| 124 | /* |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 125 | * DBGKEY macros require @dbg_lock to be held, which it is in the dbg message |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 126 | * macros. |
| 127 | */ |
| 128 | #define DBGKEY(key) dbg_key_str0(c, (key)) |
| 129 | #define DBGKEY1(key) dbg_key_str1(c, (key)) |
| 130 | |
| 131 | /* General messages */ |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 132 | #define dbg_gen(fmt, ...) dbg_do_msg(UBIFS_MSG_GEN, fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 133 | |
| 134 | /* Additional journal messages */ |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 135 | #define dbg_jnl(fmt, ...) dbg_do_msg(UBIFS_MSG_JNL, fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 136 | |
| 137 | /* Additional TNC messages */ |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 138 | #define dbg_tnc(fmt, ...) dbg_do_msg(UBIFS_MSG_TNC, fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 139 | |
| 140 | /* Additional lprops messages */ |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 141 | #define dbg_lp(fmt, ...) dbg_do_msg(UBIFS_MSG_LP, fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 142 | |
| 143 | /* Additional LEB find messages */ |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 144 | #define dbg_find(fmt, ...) dbg_do_msg(UBIFS_MSG_FIND, fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 145 | |
| 146 | /* Additional mount messages */ |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 147 | #define dbg_mnt(fmt, ...) dbg_do_msg(UBIFS_MSG_MNT, fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 148 | |
| 149 | /* Additional I/O messages */ |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 150 | #define dbg_io(fmt, ...) dbg_do_msg(UBIFS_MSG_IO, fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 151 | |
| 152 | /* Additional commit messages */ |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 153 | #define dbg_cmt(fmt, ...) dbg_do_msg(UBIFS_MSG_CMT, fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 154 | |
| 155 | /* Additional budgeting messages */ |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 156 | #define dbg_budg(fmt, ...) dbg_do_msg(UBIFS_MSG_BUDG, fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 157 | |
| 158 | /* Additional log messages */ |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 159 | #define dbg_log(fmt, ...) dbg_do_msg(UBIFS_MSG_LOG, fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 160 | |
| 161 | /* Additional gc messages */ |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 162 | #define dbg_gc(fmt, ...) dbg_do_msg(UBIFS_MSG_GC, fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 163 | |
| 164 | /* Additional scan messages */ |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 165 | #define dbg_scan(fmt, ...) dbg_do_msg(UBIFS_MSG_SCAN, fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 166 | |
| 167 | /* Additional recovery messages */ |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 168 | #define dbg_rcvry(fmt, ...) dbg_do_msg(UBIFS_MSG_RCVRY, fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 169 | |
| 170 | /* |
| 171 | * Debugging message type flags (must match msg_type_names in debug.c). |
| 172 | * |
| 173 | * UBIFS_MSG_GEN: general messages |
| 174 | * UBIFS_MSG_JNL: journal messages |
| 175 | * UBIFS_MSG_MNT: mount messages |
| 176 | * UBIFS_MSG_CMT: commit messages |
| 177 | * UBIFS_MSG_FIND: LEB find messages |
| 178 | * UBIFS_MSG_BUDG: budgeting messages |
| 179 | * UBIFS_MSG_GC: garbage collection messages |
| 180 | * UBIFS_MSG_TNC: TNC messages |
| 181 | * UBIFS_MSG_LP: lprops messages |
| 182 | * UBIFS_MSG_IO: I/O messages |
| 183 | * UBIFS_MSG_LOG: log messages |
| 184 | * UBIFS_MSG_SCAN: scan messages |
| 185 | * UBIFS_MSG_RCVRY: recovery messages |
| 186 | */ |
| 187 | enum { |
| 188 | UBIFS_MSG_GEN = 0x1, |
| 189 | UBIFS_MSG_JNL = 0x2, |
| 190 | UBIFS_MSG_MNT = 0x4, |
| 191 | UBIFS_MSG_CMT = 0x8, |
| 192 | UBIFS_MSG_FIND = 0x10, |
| 193 | UBIFS_MSG_BUDG = 0x20, |
| 194 | UBIFS_MSG_GC = 0x40, |
| 195 | UBIFS_MSG_TNC = 0x80, |
| 196 | UBIFS_MSG_LP = 0x100, |
| 197 | UBIFS_MSG_IO = 0x200, |
| 198 | UBIFS_MSG_LOG = 0x400, |
| 199 | UBIFS_MSG_SCAN = 0x800, |
| 200 | UBIFS_MSG_RCVRY = 0x1000, |
| 201 | }; |
| 202 | |
| 203 | /* Debugging message type flags for each default debug message level */ |
| 204 | #define UBIFS_MSG_LVL_0 0 |
| 205 | #define UBIFS_MSG_LVL_1 0x1 |
| 206 | #define UBIFS_MSG_LVL_2 0x7f |
| 207 | #define UBIFS_MSG_LVL_3 0xffff |
| 208 | |
| 209 | /* |
| 210 | * Debugging check flags (must match chk_names in debug.c). |
| 211 | * |
| 212 | * UBIFS_CHK_GEN: general checks |
| 213 | * UBIFS_CHK_TNC: check TNC |
| 214 | * UBIFS_CHK_IDX_SZ: check index size |
| 215 | * UBIFS_CHK_ORPH: check orphans |
| 216 | * UBIFS_CHK_OLD_IDX: check the old index |
| 217 | * UBIFS_CHK_LPROPS: check lprops |
| 218 | * UBIFS_CHK_FS: check the file-system |
| 219 | */ |
| 220 | enum { |
| 221 | UBIFS_CHK_GEN = 0x1, |
| 222 | UBIFS_CHK_TNC = 0x2, |
| 223 | UBIFS_CHK_IDX_SZ = 0x4, |
| 224 | UBIFS_CHK_ORPH = 0x8, |
| 225 | UBIFS_CHK_OLD_IDX = 0x10, |
| 226 | UBIFS_CHK_LPROPS = 0x20, |
| 227 | UBIFS_CHK_FS = 0x40, |
| 228 | }; |
| 229 | |
| 230 | /* |
| 231 | * Special testing flags (must match tst_names in debug.c). |
| 232 | * |
| 233 | * UBIFS_TST_FORCE_IN_THE_GAPS: force the use of in-the-gaps method |
| 234 | * UBIFS_TST_RCVRY: failure mode for recovery testing |
| 235 | */ |
| 236 | enum { |
| 237 | UBIFS_TST_FORCE_IN_THE_GAPS = 0x2, |
| 238 | UBIFS_TST_RCVRY = 0x4, |
| 239 | }; |
| 240 | |
| 241 | #if CONFIG_UBIFS_FS_DEBUG_MSG_LVL == 1 |
| 242 | #define UBIFS_MSG_FLAGS_DEFAULT UBIFS_MSG_LVL_1 |
| 243 | #elif CONFIG_UBIFS_FS_DEBUG_MSG_LVL == 2 |
| 244 | #define UBIFS_MSG_FLAGS_DEFAULT UBIFS_MSG_LVL_2 |
| 245 | #elif CONFIG_UBIFS_FS_DEBUG_MSG_LVL == 3 |
| 246 | #define UBIFS_MSG_FLAGS_DEFAULT UBIFS_MSG_LVL_3 |
| 247 | #else |
| 248 | #define UBIFS_MSG_FLAGS_DEFAULT UBIFS_MSG_LVL_0 |
| 249 | #endif |
| 250 | |
| 251 | #ifdef CONFIG_UBIFS_FS_DEBUG_CHKS |
| 252 | #define UBIFS_CHK_FLAGS_DEFAULT 0xffffffff |
| 253 | #else |
| 254 | #define UBIFS_CHK_FLAGS_DEFAULT 0 |
| 255 | #endif |
| 256 | |
| 257 | extern spinlock_t dbg_lock; |
| 258 | |
| 259 | extern unsigned int ubifs_msg_flags; |
| 260 | extern unsigned int ubifs_chk_flags; |
| 261 | extern unsigned int ubifs_tst_flags; |
| 262 | |
Artem Bityutskiy | 17c2f9f | 2008-10-17 13:31:39 +0300 | [diff] [blame] | 263 | int ubifs_debugging_init(struct ubifs_info *c); |
| 264 | void ubifs_debugging_exit(struct ubifs_info *c); |
| 265 | |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 266 | /* Dump functions */ |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 267 | const char *dbg_ntype(int type); |
| 268 | const char *dbg_cstate(int cmt_state); |
| 269 | const char *dbg_get_key_dump(const struct ubifs_info *c, |
| 270 | const union ubifs_key *key); |
| 271 | void dbg_dump_inode(const struct ubifs_info *c, const struct inode *inode); |
| 272 | void dbg_dump_node(const struct ubifs_info *c, const void *node); |
Artem Bityutskiy | 2ba5f7a | 2008-10-31 17:32:30 +0200 | [diff] [blame] | 273 | void dbg_dump_lpt_node(const struct ubifs_info *c, void *node, int lnum, |
| 274 | int offs); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 275 | void dbg_dump_budget_req(const struct ubifs_budget_req *req); |
| 276 | void dbg_dump_lstats(const struct ubifs_lp_stats *lst); |
| 277 | void dbg_dump_budg(struct ubifs_info *c); |
| 278 | void dbg_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp); |
| 279 | void dbg_dump_lprops(struct ubifs_info *c); |
Adrian Hunter | 73944a6 | 2008-09-12 18:13:31 +0300 | [diff] [blame] | 280 | void dbg_dump_lpt_info(struct ubifs_info *c); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 281 | void dbg_dump_leb(const struct ubifs_info *c, int lnum); |
| 282 | void dbg_dump_znode(const struct ubifs_info *c, |
| 283 | const struct ubifs_znode *znode); |
| 284 | void dbg_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat); |
| 285 | void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, |
| 286 | struct ubifs_nnode *parent, int iip); |
| 287 | void dbg_dump_tnc(struct ubifs_info *c); |
| 288 | void dbg_dump_index(struct ubifs_info *c); |
Artem Bityutskiy | 2ba5f7a | 2008-10-31 17:32:30 +0200 | [diff] [blame] | 289 | void dbg_dump_lpt_lebs(const struct ubifs_info *c); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 290 | |
| 291 | /* Checking helper functions */ |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 292 | typedef int (*dbg_leaf_callback)(struct ubifs_info *c, |
| 293 | struct ubifs_zbranch *zbr, void *priv); |
| 294 | typedef int (*dbg_znode_callback)(struct ubifs_info *c, |
| 295 | struct ubifs_znode *znode, void *priv); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 296 | int dbg_walk_index(struct ubifs_info *c, dbg_leaf_callback leaf_cb, |
| 297 | dbg_znode_callback znode_cb, void *priv); |
| 298 | |
| 299 | /* Checking functions */ |
| 300 | |
| 301 | int dbg_check_lprops(struct ubifs_info *c); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 302 | int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot); |
| 303 | int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 304 | int dbg_check_cats(struct ubifs_info *c); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 305 | int dbg_check_ltab(struct ubifs_info *c); |
Adrian Hunter | 73944a6 | 2008-09-12 18:13:31 +0300 | [diff] [blame] | 306 | int dbg_chk_lpt_free_spc(struct ubifs_info *c); |
| 307 | int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 308 | int dbg_check_synced_i_size(struct inode *inode); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 309 | int dbg_check_dir_size(struct ubifs_info *c, const struct inode *dir); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 310 | int dbg_check_tnc(struct ubifs_info *c, int extra); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 311 | int dbg_check_idx_size(struct ubifs_info *c, long long idx_size); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 312 | int dbg_check_filesystem(struct ubifs_info *c); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 313 | void dbg_check_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat, |
| 314 | int add_pos); |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 315 | int dbg_check_lprops(struct ubifs_info *c); |
| 316 | int dbg_check_lpt_nodes(struct ubifs_info *c, struct ubifs_cnode *cnode, |
| 317 | int row, int col); |
| 318 | |
| 319 | /* Force the use of in-the-gaps method for testing */ |
| 320 | |
| 321 | #define dbg_force_in_the_gaps_enabled \ |
| 322 | (ubifs_tst_flags & UBIFS_TST_FORCE_IN_THE_GAPS) |
| 323 | |
| 324 | int dbg_force_in_the_gaps(void); |
| 325 | |
| 326 | /* Failure mode for recovery testing */ |
| 327 | |
| 328 | #define dbg_failure_mode (ubifs_tst_flags & UBIFS_TST_RCVRY) |
| 329 | |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 330 | #ifndef UBIFS_DBG_PRESERVE_UBI |
| 331 | |
| 332 | #define ubi_leb_read dbg_leb_read |
| 333 | #define ubi_leb_write dbg_leb_write |
| 334 | #define ubi_leb_change dbg_leb_change |
| 335 | #define ubi_leb_erase dbg_leb_erase |
| 336 | #define ubi_leb_unmap dbg_leb_unmap |
| 337 | #define ubi_is_mapped dbg_is_mapped |
| 338 | #define ubi_leb_map dbg_leb_map |
| 339 | |
| 340 | #endif |
| 341 | |
| 342 | int dbg_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset, |
| 343 | int len, int check); |
| 344 | int dbg_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf, |
| 345 | int offset, int len, int dtype); |
| 346 | int dbg_leb_change(struct ubi_volume_desc *desc, int lnum, const void *buf, |
| 347 | int len, int dtype); |
| 348 | int dbg_leb_erase(struct ubi_volume_desc *desc, int lnum); |
| 349 | int dbg_leb_unmap(struct ubi_volume_desc *desc, int lnum); |
| 350 | int dbg_is_mapped(struct ubi_volume_desc *desc, int lnum); |
| 351 | int dbg_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype); |
| 352 | |
| 353 | static inline int dbg_read(struct ubi_volume_desc *desc, int lnum, char *buf, |
| 354 | int offset, int len) |
| 355 | { |
| 356 | return dbg_leb_read(desc, lnum, buf, offset, len, 0); |
| 357 | } |
| 358 | |
| 359 | static inline int dbg_write(struct ubi_volume_desc *desc, int lnum, |
| 360 | const void *buf, int offset, int len) |
| 361 | { |
| 362 | return dbg_leb_write(desc, lnum, buf, offset, len, UBI_UNKNOWN); |
| 363 | } |
| 364 | |
| 365 | static inline int dbg_change(struct ubi_volume_desc *desc, int lnum, |
| 366 | const void *buf, int len) |
| 367 | { |
| 368 | return dbg_leb_change(desc, lnum, buf, len, UBI_UNKNOWN); |
| 369 | } |
| 370 | |
Artem Bityutskiy | 552ff31 | 2008-10-23 11:49:28 +0300 | [diff] [blame] | 371 | /* Debugfs-related stuff */ |
| 372 | int dbg_debugfs_init(void); |
| 373 | void dbg_debugfs_exit(void); |
| 374 | int dbg_debugfs_init_fs(struct ubifs_info *c); |
| 375 | void dbg_debugfs_exit_fs(struct ubifs_info *c); |
| 376 | |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 377 | #else /* !CONFIG_UBIFS_FS_DEBUG */ |
| 378 | |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 379 | /* Use "if (0)" to make compiler check arguments even if debugging is off */ |
| 380 | #define ubifs_assert(expr) do { \ |
| 381 | if (0 && (expr)) \ |
| 382 | printk(KERN_CRIT "UBIFS assert failed in %s at %u (pid %d)\n", \ |
| 383 | __func__, __LINE__, current->pid); \ |
| 384 | } while (0) |
| 385 | |
| 386 | #define dbg_err(fmt, ...) do { \ |
| 387 | if (0) \ |
| 388 | ubifs_err(fmt, ##__VA_ARGS__); \ |
| 389 | } while (0) |
| 390 | |
| 391 | #define dbg_msg(fmt, ...) do { \ |
| 392 | if (0) \ |
| 393 | printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "\n", \ |
| 394 | current->pid, __func__, ##__VA_ARGS__); \ |
| 395 | } while (0) |
| 396 | |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 397 | #define dbg_dump_stack() |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 398 | #define ubifs_assert_cmt_locked(c) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 399 | |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 400 | #define dbg_gen(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
| 401 | #define dbg_jnl(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
| 402 | #define dbg_tnc(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
| 403 | #define dbg_lp(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
| 404 | #define dbg_find(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
| 405 | #define dbg_mnt(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
| 406 | #define dbg_io(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
| 407 | #define dbg_cmt(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
| 408 | #define dbg_budg(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
| 409 | #define dbg_log(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
| 410 | #define dbg_gc(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
| 411 | #define dbg_scan(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
| 412 | #define dbg_rcvry(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 413 | |
Artem Bityutskiy | 840dc6b | 2008-08-01 18:13:37 +0300 | [diff] [blame] | 414 | #define DBGKEY(key) ((char *)(key)) |
| 415 | #define DBGKEY1(key) ((char *)(key)) |
| 416 | |
Artem Bityutskiy | 2ba5f7a | 2008-10-31 17:32:30 +0200 | [diff] [blame] | 417 | #define ubifs_debugging_init(c) 0 |
| 418 | #define ubifs_debugging_exit(c) ({}) |
Artem Bityutskiy | 17c2f9f | 2008-10-17 13:31:39 +0300 | [diff] [blame] | 419 | |
Artem Bityutskiy | 2ba5f7a | 2008-10-31 17:32:30 +0200 | [diff] [blame] | 420 | #define dbg_ntype(type) "" |
| 421 | #define dbg_cstate(cmt_state) "" |
| 422 | #define dbg_get_key_dump(c, key) ({}) |
| 423 | #define dbg_dump_inode(c, inode) ({}) |
| 424 | #define dbg_dump_node(c, node) ({}) |
| 425 | #define dbg_dump_lpt_node(c, node, lnum, offs) ({}) |
| 426 | #define dbg_dump_budget_req(req) ({}) |
| 427 | #define dbg_dump_lstats(lst) ({}) |
| 428 | #define dbg_dump_budg(c) ({}) |
| 429 | #define dbg_dump_lprop(c, lp) ({}) |
| 430 | #define dbg_dump_lprops(c) ({}) |
| 431 | #define dbg_dump_lpt_info(c) ({}) |
| 432 | #define dbg_dump_leb(c, lnum) ({}) |
| 433 | #define dbg_dump_znode(c, znode) ({}) |
| 434 | #define dbg_dump_heap(c, heap, cat) ({}) |
| 435 | #define dbg_dump_pnode(c, pnode, parent, iip) ({}) |
| 436 | #define dbg_dump_tnc(c) ({}) |
| 437 | #define dbg_dump_index(c) ({}) |
| 438 | #define dbg_dump_lpt_lebs(c) ({}) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 439 | |
| 440 | #define dbg_walk_index(c, leaf_cb, znode_cb, priv) 0 |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 441 | #define dbg_old_index_check_init(c, zroot) 0 |
| 442 | #define dbg_check_old_index(c, zroot) 0 |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 443 | #define dbg_check_cats(c) 0 |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 444 | #define dbg_check_ltab(c) 0 |
Adrian Hunter | 73944a6 | 2008-09-12 18:13:31 +0300 | [diff] [blame] | 445 | #define dbg_chk_lpt_free_spc(c) 0 |
| 446 | #define dbg_chk_lpt_sz(c, action, len) 0 |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 447 | #define dbg_check_synced_i_size(inode) 0 |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 448 | #define dbg_check_dir_size(c, dir) 0 |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 449 | #define dbg_check_tnc(c, x) 0 |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 450 | #define dbg_check_idx_size(c, idx_size) 0 |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 451 | #define dbg_check_filesystem(c) 0 |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 452 | #define dbg_check_heap(c, heap, cat, add_pos) ({}) |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 453 | #define dbg_check_lprops(c) 0 |
| 454 | #define dbg_check_lpt_nodes(c, cnode, row, col) 0 |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 455 | #define dbg_force_in_the_gaps_enabled 0 |
| 456 | #define dbg_force_in_the_gaps() 0 |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 457 | #define dbg_failure_mode 0 |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 458 | |
Artem Bityutskiy | 552ff31 | 2008-10-23 11:49:28 +0300 | [diff] [blame] | 459 | #define dbg_debugfs_init() 0 |
| 460 | #define dbg_debugfs_exit() |
| 461 | #define dbg_debugfs_init_fs(c) 0 |
| 462 | #define dbg_debugfs_exit_fs(c) 0 |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 463 | |
Artem Bityutskiy | 552ff31 | 2008-10-23 11:49:28 +0300 | [diff] [blame] | 464 | #endif /* !CONFIG_UBIFS_FS_DEBUG */ |
Artem Bityutskiy | 1e51764 | 2008-07-14 19:08:37 +0300 | [diff] [blame] | 465 | #endif /* !__UBIFS_DEBUG_H__ */ |