Blame view
fs/ubifs/debug.h
11.9 KB
2b27bdcc2 treewide: Replace... |
1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
1e51764a3 UBIFS: add new fl... |
2 3 4 5 6 |
/* * This file is part of UBIFS. * * Copyright (C) 2006-2008 Nokia Corporation. * |
1e51764a3 UBIFS: add new fl... |
7 8 9 10 11 12 |
* Authors: Artem Bityutskiy (Битюцкий Артём) * Adrian Hunter */ #ifndef __UBIFS_DEBUG_H__ #define __UBIFS_DEBUG_H__ |
1dcffad74 UBIFS: fix compil... |
13 14 15 16 17 |
/* Checking helper functions */ typedef int (*dbg_leaf_callback)(struct ubifs_info *c, struct ubifs_zbranch *zbr, void *priv); typedef int (*dbg_znode_callback)(struct ubifs_info *c, struct ubifs_znode *znode, void *priv); |
ae380ce04 UBIFS: lessen the... |
18 19 20 21 22 23 |
/* * The UBIFS debugfs directory name pattern and maximum name length (3 for "ubi" * + 1 for "_" and plus 2x2 for 2 UBI numbers and 1 for the trailing zero byte. */ #define UBIFS_DFS_DIR_NAME "ubi%d_%d" #define UBIFS_DFS_DIR_LEN (3 + 1 + 2*2 + 1) |
17c2f9f85 UBIFS: separate d... |
24 25 |
/** * ubifs_debug_info - per-FS debugging information. |
17c2f9f85 UBIFS: separate d... |
26 27 28 |
* @old_zroot: old index root - used by 'dbg_check_old_index()' * @old_zroot_level: old index root level - used by 'dbg_check_old_index()' * @old_zroot_sqnum: old index root sqnum - used by 'dbg_check_old_index()' |
81e79d38d UBIFS: switch sel... |
29 |
* |
d27462a51 UBIFS: rename rec... |
30 31 32 33 34 |
* @pc_happened: non-zero if an emulated power cut happened * @pc_delay: 0=>don't delay, 1=>delay a time, 2=>delay a number of calls * @pc_timeout: time in jiffies when delay of failure mode expires * @pc_cnt: current number of calls to failure mode I/O functions * @pc_cnt_max: number of calls by which to delay failure mode |
81e79d38d UBIFS: switch sel... |
35 |
* |
17c2f9f85 UBIFS: separate d... |
36 37 38 39 40 |
* @chk_lpt_sz: used by LPT tree size checker * @chk_lpt_sz2: used by LPT tree size checker * @chk_lpt_wastage: used by LPT tree size checker * @chk_lpt_lebs: used by LPT tree size checker * @new_nhead_offs: used by LPT tree size checker |
84abf972c UBIFS: add re-mou... |
41 42 |
* @new_ihead_lnum: used by debugging to check @c->ihead_lnum * @new_ihead_offs: used by debugging to check @c->ihead_offs |
552ff3179 UBIFS: add debugf... |
43 |
* |
84abf972c UBIFS: add re-mou... |
44 |
* @saved_lst: saved lprops statistics (used by 'dbg_save_space_info()') |
f1bd66afb UBIFS: improve sp... |
45 46 47 |
* @saved_bi: saved budgeting information * @saved_free: saved amount of free space * @saved_idx_gc_cnt: saved value of @c->idx_gc_cnt |
84abf972c UBIFS: add re-mou... |
48 |
* |
81e79d38d UBIFS: switch sel... |
49 50 51 52 53 54 55 |
* @chk_gen: if general extra checks are enabled * @chk_index: if index xtra checks are enabled * @chk_orph: if orphans extra checks are enabled * @chk_lprops: if lprops extra checks are enabled * @chk_fs: if UBIFS contents extra checks are enabled * @tst_rcvry: if UBIFS recovery testing mode enabled * |
bdc1a1b61 UBIFS: fix kernel... |
56 57 58 59 60 |
* @dfs_dir_name: name of debugfs directory containing this file-system's files * @dfs_dir: direntry object of the file-system debugfs directory * @dfs_dump_lprops: "dump lprops" debugfs knob * @dfs_dump_budg: "dump budgeting information" debugfs knob * @dfs_dump_tnc: "dump TNC" debugfs knob |
81e79d38d UBIFS: switch sel... |
61 62 63 64 65 66 |
* @dfs_chk_gen: debugfs knob to enable UBIFS general extra checks * @dfs_chk_index: debugfs knob to enable UBIFS index extra checks * @dfs_chk_orph: debugfs knob to enable UBIFS orphans extra checks * @dfs_chk_lprops: debugfs knob to enable UBIFS LEP properties extra checks * @dfs_chk_fs: debugfs knob to enable UBIFS contents extra checks * @dfs_tst_rcvry: debugfs knob to enable UBIFS recovery testing |
06bef9451 UBIFS: add debugf... |
67 68 69 70 |
* @dfs_ro_error: debugfs knob to switch UBIFS to R/O mode (different to * re-mounting to R/O mode because it does not flush any buffers * and UBIFS just starts returning -EROFS on all write * operations) |
17c2f9f85 UBIFS: separate d... |
71 72 |
*/ struct ubifs_debug_info { |
17c2f9f85 UBIFS: separate d... |
73 74 75 |
struct ubifs_zbranch old_zroot; int old_zroot_level; unsigned long long old_zroot_sqnum; |
81e79d38d UBIFS: switch sel... |
76 |
|
d27462a51 UBIFS: rename rec... |
77 78 79 80 81 |
int pc_happened; int pc_delay; unsigned long pc_timeout; unsigned int pc_cnt; unsigned int pc_cnt_max; |
81e79d38d UBIFS: switch sel... |
82 |
|
17c2f9f85 UBIFS: separate d... |
83 84 85 86 87 88 89 |
long long chk_lpt_sz; long long chk_lpt_sz2; long long chk_lpt_wastage; int chk_lpt_lebs; int new_nhead_offs; int new_ihead_lnum; int new_ihead_offs; |
552ff3179 UBIFS: add debugf... |
90 |
|
84abf972c UBIFS: add re-mou... |
91 |
struct ubifs_lp_stats saved_lst; |
f1bd66afb UBIFS: improve sp... |
92 |
struct ubifs_budg_info saved_bi; |
84abf972c UBIFS: add re-mou... |
93 |
long long saved_free; |
f1bd66afb UBIFS: improve sp... |
94 |
int saved_idx_gc_cnt; |
84abf972c UBIFS: add re-mou... |
95 |
|
81e79d38d UBIFS: switch sel... |
96 97 98 99 100 101 |
unsigned int chk_gen:1; unsigned int chk_index:1; unsigned int chk_orph:1; unsigned int chk_lprops:1; unsigned int chk_fs:1; unsigned int tst_rcvry:1; |
ae380ce04 UBIFS: lessen the... |
102 |
char dfs_dir_name[UBIFS_DFS_DIR_LEN + 1]; |
84abf972c UBIFS: add re-mou... |
103 104 105 106 |
struct dentry *dfs_dir; struct dentry *dfs_dump_lprops; struct dentry *dfs_dump_budg; struct dentry *dfs_dump_tnc; |
81e79d38d UBIFS: switch sel... |
107 108 109 110 111 112 |
struct dentry *dfs_chk_gen; struct dentry *dfs_chk_index; struct dentry *dfs_chk_orph; struct dentry *dfs_chk_lprops; struct dentry *dfs_chk_fs; struct dentry *dfs_tst_rcvry; |
06bef9451 UBIFS: add debugf... |
113 |
struct dentry *dfs_ro_error; |
17c2f9f85 UBIFS: separate d... |
114 |
}; |
1e51764a3 UBIFS: add new fl... |
115 |
|
e7717060d UBIFS: add global... |
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
/** * ubifs_global_debug_info - global (not per-FS) UBIFS debugging information. * * @chk_gen: if general extra checks are enabled * @chk_index: if index xtra checks are enabled * @chk_orph: if orphans extra checks are enabled * @chk_lprops: if lprops extra checks are enabled * @chk_fs: if UBIFS contents extra checks are enabled * @tst_rcvry: if UBIFS recovery testing mode enabled */ struct ubifs_global_debug_info { unsigned int chk_gen:1; unsigned int chk_index:1; unsigned int chk_orph:1; unsigned int chk_lprops:1; unsigned int chk_fs:1; unsigned int tst_rcvry:1; }; |
2e52eb744 ubifs: Rework ubi... |
134 135 |
void ubifs_assert_failed(struct ubifs_info *c, const char *expr, const char *file, int line); |
6eb61d587 ubifs: Pass struc... |
136 |
#define ubifs_assert(c, expr) do { \ |
1e51764a3 UBIFS: add new fl... |
137 |
if (unlikely(!(expr))) { \ |
2e52eb744 ubifs: Rework ubi... |
138 139 |
ubifs_assert_failed((struct ubifs_info *)c, #expr, __FILE__, \ __LINE__); \ |
1e51764a3 UBIFS: add new fl... |
140 141 142 143 144 145 |
} \ } while (0) #define ubifs_assert_cmt_locked(c) do { \ if (unlikely(down_write_trylock(&(c)->commit_sem))) { \ up_write(&(c)->commit_sem); \ |
2e52eb744 ubifs: Rework ubi... |
146 147 |
ubifs_err(c, "commit lock is not locked! "); \ |
6eb61d587 ubifs: Pass struc... |
148 |
ubifs_assert(c, 0); \ |
1e51764a3 UBIFS: add new fl... |
149 150 |
} \ } while (0) |
1f5d78dc4 UBIFS: make debug... |
151 |
#define ubifs_dbg_msg(type, fmt, ...) \ |
c45640d87 UBIFS: print PID ... |
152 153 154 |
pr_debug("UBIFS DBG " type " (pid %d): " fmt " ", current->pid, \ ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
155 |
|
65b455b12 UBIFS: fix compla... |
156 |
#define DBG_KEY_BUF_LEN 48 |
515315a12 UBIFS: fix key pr... |
157 158 |
#define ubifs_dbg_msg_key(type, key, fmt, ...) do { \ char __tmp_key_buf[DBG_KEY_BUF_LEN]; \ |
c45640d87 UBIFS: print PID ... |
159 160 161 |
pr_debug("UBIFS DBG " type " (pid %d): " fmt "%s ", current->pid, \ ##__VA_ARGS__, \ |
515315a12 UBIFS: fix key pr... |
162 163 |
dbg_snprintf_key(c, key, __tmp_key_buf, DBG_KEY_BUF_LEN)); \ } while (0) |
56e46742e UBIFS: switch to ... |
164 165 |
/* General messages */ #define dbg_gen(fmt, ...) ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
166 |
/* Additional journal messages */ |
56e46742e UBIFS: switch to ... |
167 |
#define dbg_jnl(fmt, ...) ubifs_dbg_msg("jnl", fmt, ##__VA_ARGS__) |
515315a12 UBIFS: fix key pr... |
168 169 |
#define dbg_jnlk(key, fmt, ...) \ ubifs_dbg_msg_key("jnl", key, fmt, ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
170 |
/* Additional TNC messages */ |
56e46742e UBIFS: switch to ... |
171 |
#define dbg_tnc(fmt, ...) ubifs_dbg_msg("tnc", fmt, ##__VA_ARGS__) |
515315a12 UBIFS: fix key pr... |
172 173 |
#define dbg_tnck(key, fmt, ...) \ ubifs_dbg_msg_key("tnc", key, fmt, ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
174 |
/* Additional lprops messages */ |
56e46742e UBIFS: switch to ... |
175 |
#define dbg_lp(fmt, ...) ubifs_dbg_msg("lp", fmt, ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
176 |
/* Additional LEB find messages */ |
56e46742e UBIFS: switch to ... |
177 |
#define dbg_find(fmt, ...) ubifs_dbg_msg("find", fmt, ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
178 |
/* Additional mount messages */ |
56e46742e UBIFS: switch to ... |
179 |
#define dbg_mnt(fmt, ...) ubifs_dbg_msg("mnt", fmt, ##__VA_ARGS__) |
515315a12 UBIFS: fix key pr... |
180 181 |
#define dbg_mntk(key, fmt, ...) \ ubifs_dbg_msg_key("mnt", key, fmt, ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
182 |
/* Additional I/O messages */ |
56e46742e UBIFS: switch to ... |
183 |
#define dbg_io(fmt, ...) ubifs_dbg_msg("io", fmt, ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
184 |
/* Additional commit messages */ |
56e46742e UBIFS: switch to ... |
185 |
#define dbg_cmt(fmt, ...) ubifs_dbg_msg("cmt", fmt, ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
186 |
/* Additional budgeting messages */ |
56e46742e UBIFS: switch to ... |
187 |
#define dbg_budg(fmt, ...) ubifs_dbg_msg("budg", fmt, ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
188 |
/* Additional log messages */ |
56e46742e UBIFS: switch to ... |
189 |
#define dbg_log(fmt, ...) ubifs_dbg_msg("log", fmt, ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
190 |
/* Additional gc messages */ |
56e46742e UBIFS: switch to ... |
191 |
#define dbg_gc(fmt, ...) ubifs_dbg_msg("gc", fmt, ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
192 |
/* Additional scan messages */ |
56e46742e UBIFS: switch to ... |
193 |
#define dbg_scan(fmt, ...) ubifs_dbg_msg("scan", fmt, ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
194 |
/* Additional recovery messages */ |
56e46742e UBIFS: switch to ... |
195 |
#define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__) |
1e51764a3 UBIFS: add new fl... |
196 |
|
e7717060d UBIFS: add global... |
197 |
extern struct ubifs_global_debug_info ubifs_dbg; |
2b1844a8c UBIFS: introduce ... |
198 |
|
2b1844a8c UBIFS: introduce ... |
199 200 |
static inline int dbg_is_chk_gen(const struct ubifs_info *c) { |
e7717060d UBIFS: add global... |
201 |
return !!(ubifs_dbg.chk_gen || c->dbg->chk_gen); |
2b1844a8c UBIFS: introduce ... |
202 |
} |
8d7819b4a UBIFS: lessen amo... |
203 |
static inline int dbg_is_chk_index(const struct ubifs_info *c) |
2b1844a8c UBIFS: introduce ... |
204 |
{ |
e7717060d UBIFS: add global... |
205 |
return !!(ubifs_dbg.chk_index || c->dbg->chk_index); |
2b1844a8c UBIFS: introduce ... |
206 207 208 |
} static inline int dbg_is_chk_orph(const struct ubifs_info *c) { |
e7717060d UBIFS: add global... |
209 |
return !!(ubifs_dbg.chk_orph || c->dbg->chk_orph); |
2b1844a8c UBIFS: introduce ... |
210 |
} |
2b1844a8c UBIFS: introduce ... |
211 212 |
static inline int dbg_is_chk_lprops(const struct ubifs_info *c) { |
e7717060d UBIFS: add global... |
213 |
return !!(ubifs_dbg.chk_lprops || c->dbg->chk_lprops); |
2b1844a8c UBIFS: introduce ... |
214 215 216 |
} static inline int dbg_is_chk_fs(const struct ubifs_info *c) { |
e7717060d UBIFS: add global... |
217 |
return !!(ubifs_dbg.chk_fs || c->dbg->chk_fs); |
2b1844a8c UBIFS: introduce ... |
218 219 220 |
} static inline int dbg_is_tst_rcvry(const struct ubifs_info *c) { |
e7717060d UBIFS: add global... |
221 |
return !!(ubifs_dbg.tst_rcvry || c->dbg->tst_rcvry); |
2b1844a8c UBIFS: introduce ... |
222 |
} |
83cef708c UBIFS: introduce ... |
223 224 |
static inline int dbg_is_power_cut(const struct ubifs_info *c) { |
d27462a51 UBIFS: rename rec... |
225 |
return !!c->dbg->pc_happened; |
83cef708c UBIFS: introduce ... |
226 |
} |
2b1844a8c UBIFS: introduce ... |
227 |
|
17c2f9f85 UBIFS: separate d... |
228 229 |
int ubifs_debugging_init(struct ubifs_info *c); void ubifs_debugging_exit(struct ubifs_info *c); |
1e51764a3 UBIFS: add new fl... |
230 |
/* Dump functions */ |
1e51764a3 UBIFS: add new fl... |
231 232 |
const char *dbg_ntype(int type); const char *dbg_cstate(int cmt_state); |
77a7ae580 UBIFS: improve jo... |
233 |
const char *dbg_jhead(int jhead); |
1e51764a3 UBIFS: add new fl... |
234 235 |
const char *dbg_get_key_dump(const struct ubifs_info *c, const union ubifs_key *key); |
515315a12 UBIFS: fix key pr... |
236 237 |
const char *dbg_snprintf_key(const struct ubifs_info *c, const union ubifs_key *key, char *buffer, int len); |
edf6be245 UBIFS: rename dum... |
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode); void ubifs_dump_node(const struct ubifs_info *c, const void *node); void ubifs_dump_budget_req(const struct ubifs_budget_req *req); void ubifs_dump_lstats(const struct ubifs_lp_stats *lst); void ubifs_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi); void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp); void ubifs_dump_lprops(struct ubifs_info *c); void ubifs_dump_lpt_info(struct ubifs_info *c); void ubifs_dump_leb(const struct ubifs_info *c, int lnum); void ubifs_dump_sleb(const struct ubifs_info *c, const struct ubifs_scan_leb *sleb, int offs); void ubifs_dump_znode(const struct ubifs_info *c, const struct ubifs_znode *znode); void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat); void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, struct ubifs_nnode *parent, int iip); void ubifs_dump_tnc(struct ubifs_info *c); void ubifs_dump_index(struct ubifs_info *c); void ubifs_dump_lpt_lebs(const struct ubifs_info *c); |
1e51764a3 UBIFS: add new fl... |
259 |
|
1e51764a3 UBIFS: add new fl... |
260 261 262 263 |
int dbg_walk_index(struct ubifs_info *c, dbg_leaf_callback leaf_cb, dbg_znode_callback znode_cb, void *priv); /* Checking functions */ |
84abf972c UBIFS: add re-mou... |
264 265 |
void dbg_save_space_info(struct ubifs_info *c); int dbg_check_space_info(struct ubifs_info *c); |
1e51764a3 UBIFS: add new fl... |
266 |
int dbg_check_lprops(struct ubifs_info *c); |
1e51764a3 UBIFS: add new fl... |
267 268 |
int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot); int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot); |
1e51764a3 UBIFS: add new fl... |
269 |
int dbg_check_cats(struct ubifs_info *c); |
1e51764a3 UBIFS: add new fl... |
270 |
int dbg_check_ltab(struct ubifs_info *c); |
73944a6de UBIFS: add more d... |
271 272 |
int dbg_chk_lpt_free_spc(struct ubifs_info *c); int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len); |
d808efb40 UBIFS: amend debu... |
273 |
int dbg_check_synced_i_size(const struct ubifs_info *c, struct inode *inode); |
1b51e9836 UBIFS: rename dbg... |
274 |
int dbg_check_dir(struct ubifs_info *c, const struct inode *dir); |
1e51764a3 UBIFS: add new fl... |
275 |
int dbg_check_tnc(struct ubifs_info *c, int extra); |
1e51764a3 UBIFS: add new fl... |
276 |
int dbg_check_idx_size(struct ubifs_info *c, long long idx_size); |
1e51764a3 UBIFS: add new fl... |
277 |
int dbg_check_filesystem(struct ubifs_info *c); |
1e51764a3 UBIFS: add new fl... |
278 279 |
void dbg_check_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat, int add_pos); |
1e51764a3 UBIFS: add new fl... |
280 281 |
int dbg_check_lpt_nodes(struct ubifs_info *c, struct ubifs_cnode *cnode, int row, int col); |
e3c3efc24 UBIFS: add inode ... |
282 283 |
int dbg_check_inode_size(struct ubifs_info *c, const struct inode *inode, loff_t size); |
3bb66b47a UBIFS: introduce ... |
284 285 |
int dbg_check_data_nodes_order(struct ubifs_info *c, struct list_head *head); int dbg_check_nondata_nodes_order(struct ubifs_info *c, struct list_head *head); |
1e51764a3 UBIFS: add new fl... |
286 |
|
f57cb188c UBIFS: remove cus... |
287 |
int dbg_leb_write(struct ubifs_info *c, int lnum, const void *buf, int offs, |
b36a261e8 UBI: Kill data ty... |
288 289 |
int len); int dbg_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len); |
f57cb188c UBIFS: remove cus... |
290 |
int dbg_leb_unmap(struct ubifs_info *c, int lnum); |
b36a261e8 UBI: Kill data ty... |
291 |
int dbg_leb_map(struct ubifs_info *c, int lnum); |
1e51764a3 UBIFS: add new fl... |
292 |
|
552ff3179 UBIFS: add debugf... |
293 |
/* Debugfs-related stuff */ |
702d6a834 ubifs: no need to... |
294 |
void dbg_debugfs_init(void); |
552ff3179 UBIFS: add debugf... |
295 |
void dbg_debugfs_exit(void); |
702d6a834 ubifs: no need to... |
296 |
void dbg_debugfs_init_fs(struct ubifs_info *c); |
552ff3179 UBIFS: add debugf... |
297 |
void dbg_debugfs_exit_fs(struct ubifs_info *c); |
1e51764a3 UBIFS: add new fl... |
298 |
#endif /* !__UBIFS_DEBUG_H__ */ |