Blame view

fs/ubifs/debug.h 20.8 KB
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  /*
   * This file is part of UBIFS.
   *
   * Copyright (C) 2006-2008 Nokia Corporation.
   *
   * This program is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 as published by
   * the Free Software Foundation.
   *
   * This program is distributed in the hope that it will be useful, but WITHOUT
   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   * more details.
   *
   * You should have received a copy of the GNU General Public License along with
   * this program; if not, write to the Free Software Foundation, Inc., 51
   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
   *
   * Authors: Artem Bityutskiy (Битюцкий Артём)
   *          Adrian Hunter
   */
  
  #ifndef __UBIFS_DEBUG_H__
  #define __UBIFS_DEBUG_H__
1dcffad74   Maksim Rayskiy   UBIFS: fix compil...
25
26
27
28
29
  /* 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);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
30
  #ifdef CONFIG_UBIFS_FS_DEBUG
ae380ce04   Artem Bityutskiy   UBIFS: lessen the...
31
32
33
34
35
36
  /*
   * 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   Artem Bityutskiy   UBIFS: separate d...
37
38
  /**
   * ubifs_debug_info - per-FS debugging information.
17c2f9f85   Artem Bityutskiy   UBIFS: separate d...
39
40
41
   * @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   Artem Bityutskiy   UBIFS: switch sel...
42
   *
d27462a51   Artem Bityutskiy   UBIFS: rename rec...
43
44
45
46
47
   * @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   Artem Bityutskiy   UBIFS: switch sel...
48
   *
17c2f9f85   Artem Bityutskiy   UBIFS: separate d...
49
50
51
52
53
   * @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   Artem Bityutskiy   UBIFS: add re-mou...
54
55
   * @new_ihead_lnum: used by debugging to check @c->ihead_lnum
   * @new_ihead_offs: used by debugging to check @c->ihead_offs
552ff3179   Artem Bityutskiy   UBIFS: add debugf...
56
   *
84abf972c   Artem Bityutskiy   UBIFS: add re-mou...
57
   * @saved_lst: saved lprops statistics (used by 'dbg_save_space_info()')
f1bd66afb   Artem Bityutskiy   UBIFS: improve sp...
58
59
60
   * @saved_bi: saved budgeting information
   * @saved_free: saved amount of free space
   * @saved_idx_gc_cnt: saved value of @c->idx_gc_cnt
84abf972c   Artem Bityutskiy   UBIFS: add re-mou...
61
   *
81e79d38d   Artem Bityutskiy   UBIFS: switch sel...
62
63
64
65
66
67
68
   * @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   Artem Bityutskiy   UBIFS: fix kernel...
69
70
71
72
73
   * @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   Artem Bityutskiy   UBIFS: switch sel...
74
75
76
77
78
79
   * @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
17c2f9f85   Artem Bityutskiy   UBIFS: separate d...
80
81
   */
  struct ubifs_debug_info {
17c2f9f85   Artem Bityutskiy   UBIFS: separate d...
82
83
84
  	struct ubifs_zbranch old_zroot;
  	int old_zroot_level;
  	unsigned long long old_zroot_sqnum;
81e79d38d   Artem Bityutskiy   UBIFS: switch sel...
85

d27462a51   Artem Bityutskiy   UBIFS: rename rec...
86
87
88
89
90
  	int pc_happened;
  	int pc_delay;
  	unsigned long pc_timeout;
  	unsigned int pc_cnt;
  	unsigned int pc_cnt_max;
81e79d38d   Artem Bityutskiy   UBIFS: switch sel...
91

17c2f9f85   Artem Bityutskiy   UBIFS: separate d...
92
93
94
95
96
97
98
  	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   Artem Bityutskiy   UBIFS: add debugf...
99

84abf972c   Artem Bityutskiy   UBIFS: add re-mou...
100
  	struct ubifs_lp_stats saved_lst;
f1bd66afb   Artem Bityutskiy   UBIFS: improve sp...
101
  	struct ubifs_budg_info saved_bi;
84abf972c   Artem Bityutskiy   UBIFS: add re-mou...
102
  	long long saved_free;
f1bd66afb   Artem Bityutskiy   UBIFS: improve sp...
103
  	int saved_idx_gc_cnt;
84abf972c   Artem Bityutskiy   UBIFS: add re-mou...
104

81e79d38d   Artem Bityutskiy   UBIFS: switch sel...
105
106
107
108
109
110
  	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   Artem Bityutskiy   UBIFS: lessen the...
111
  	char dfs_dir_name[UBIFS_DFS_DIR_LEN + 1];
84abf972c   Artem Bityutskiy   UBIFS: add re-mou...
112
113
114
115
  	struct dentry *dfs_dir;
  	struct dentry *dfs_dump_lprops;
  	struct dentry *dfs_dump_budg;
  	struct dentry *dfs_dump_tnc;
81e79d38d   Artem Bityutskiy   UBIFS: switch sel...
116
117
118
119
120
121
  	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;
17c2f9f85   Artem Bityutskiy   UBIFS: separate d...
122
  };
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
123

e7717060d   Artem Bityutskiy   UBIFS: add global...
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
  /**
   * 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;
  };
840dc6b89   Artem Bityutskiy   UBIFS: improve ar...
142
  #define ubifs_assert(expr) do {                                                \
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
  	if (unlikely(!(expr))) {                                               \
  		printk(KERN_CRIT "UBIFS assert failed in %s at %u (pid %d)
  ", \
  		       __func__, __LINE__, current->pid);                      \
  		dbg_dump_stack();                                              \
  	}                                                                      \
  } while (0)
  
  #define ubifs_assert_cmt_locked(c) do {                                        \
  	if (unlikely(down_write_trylock(&(c)->commit_sem))) {                  \
  		up_write(&(c)->commit_sem);                                    \
  		printk(KERN_CRIT "commit lock is not locked!
  ");              \
  		ubifs_assert(0);                                               \
  	}                                                                      \
  } while (0)
ec0681426   Artem Bityutskiy   UBIFS: dump the s...
159
  #define dbg_dump_stack() dump_stack()
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
160

1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
161
162
163
164
165
  #define dbg_err(fmt, ...) do {                                                 \
  	spin_lock(&dbg_lock);                                                  \
  	ubifs_err(fmt, ##__VA_ARGS__);                                         \
  	spin_unlock(&dbg_lock);                                                \
  } while (0)
1f5d78dc4   Artem Bityutskiy   UBIFS: make debug...
166
167
168
  #define ubifs_dbg_msg(type, fmt, ...) \
  	pr_debug("UBIFS DBG " type ": " fmt "
  ", ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
169

515315a12   Artem Bityutskiy   UBIFS: fix key pr...
170
171
172
173
174
175
176
  #define DBG_KEY_BUF_LEN 32
  #define ubifs_dbg_msg_key(type, key, fmt, ...) do {                            \
  	char __tmp_key_buf[DBG_KEY_BUF_LEN];                                   \
  	pr_debug("UBIFS DBG " type ": " fmt "%s
  ", ##__VA_ARGS__,             \
  		 dbg_snprintf_key(c, key, __tmp_key_buf, DBG_KEY_BUF_LEN));    \
  } while (0)
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
177
  /* Just a debugging messages not related to any specific UBIFS subsystem */
515315a12   Artem Bityutskiy   UBIFS: fix key pr...
178
179
180
  #define dbg_msg(fmt, ...)                                                      \
  	printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "
  ", current->pid,   \
d34315da9   Artem Bityutskiy   UBIFS: fix debugg...
181
  	       __func__, ##__VA_ARGS__)
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
182
183
  /* General messages */
  #define dbg_gen(fmt, ...)   ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
184
  /* Additional journal messages */
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
185
  #define dbg_jnl(fmt, ...)   ubifs_dbg_msg("jnl", fmt, ##__VA_ARGS__)
515315a12   Artem Bityutskiy   UBIFS: fix key pr...
186
187
  #define dbg_jnlk(key, fmt, ...) \
  	ubifs_dbg_msg_key("jnl", key, fmt, ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
188
  /* Additional TNC messages */
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
189
  #define dbg_tnc(fmt, ...)   ubifs_dbg_msg("tnc", fmt, ##__VA_ARGS__)
515315a12   Artem Bityutskiy   UBIFS: fix key pr...
190
191
  #define dbg_tnck(key, fmt, ...) \
  	ubifs_dbg_msg_key("tnc", key, fmt, ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
192
  /* Additional lprops messages */
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
193
  #define dbg_lp(fmt, ...)    ubifs_dbg_msg("lp", fmt, ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
194
  /* Additional LEB find messages */
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
195
  #define dbg_find(fmt, ...)  ubifs_dbg_msg("find", fmt, ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
196
  /* Additional mount messages */
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
197
  #define dbg_mnt(fmt, ...)   ubifs_dbg_msg("mnt", fmt, ##__VA_ARGS__)
515315a12   Artem Bityutskiy   UBIFS: fix key pr...
198
199
  #define dbg_mntk(key, fmt, ...) \
  	ubifs_dbg_msg_key("mnt", key, fmt, ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
200
  /* Additional I/O messages */
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
201
  #define dbg_io(fmt, ...)    ubifs_dbg_msg("io", fmt, ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
202
  /* Additional commit messages */
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
203
  #define dbg_cmt(fmt, ...)   ubifs_dbg_msg("cmt", fmt, ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
204
  /* Additional budgeting messages */
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
205
  #define dbg_budg(fmt, ...)  ubifs_dbg_msg("budg", fmt, ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
206
  /* Additional log messages */
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
207
  #define dbg_log(fmt, ...)   ubifs_dbg_msg("log", fmt, ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
208
  /* Additional gc messages */
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
209
  #define dbg_gc(fmt, ...)    ubifs_dbg_msg("gc", fmt, ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
210
  /* Additional scan messages */
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
211
  #define dbg_scan(fmt, ...)  ubifs_dbg_msg("scan", fmt, ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
212
  /* Additional recovery messages */
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
213
  #define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
214

515315a12   Artem Bityutskiy   UBIFS: fix key pr...
215
  extern spinlock_t dbg_lock;
e7717060d   Artem Bityutskiy   UBIFS: add global...
216
  extern struct ubifs_global_debug_info ubifs_dbg;
2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
217

2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
218
219
  static inline int dbg_is_chk_gen(const struct ubifs_info *c)
  {
e7717060d   Artem Bityutskiy   UBIFS: add global...
220
  	return !!(ubifs_dbg.chk_gen || c->dbg->chk_gen);
2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
221
  }
8d7819b4a   Artem Bityutskiy   UBIFS: lessen amo...
222
  static inline int dbg_is_chk_index(const struct ubifs_info *c)
2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
223
  {
e7717060d   Artem Bityutskiy   UBIFS: add global...
224
  	return !!(ubifs_dbg.chk_index || c->dbg->chk_index);
2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
225
226
227
  }
  static inline int dbg_is_chk_orph(const struct ubifs_info *c)
  {
e7717060d   Artem Bityutskiy   UBIFS: add global...
228
  	return !!(ubifs_dbg.chk_orph || c->dbg->chk_orph);
2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
229
  }
2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
230
231
  static inline int dbg_is_chk_lprops(const struct ubifs_info *c)
  {
e7717060d   Artem Bityutskiy   UBIFS: add global...
232
  	return !!(ubifs_dbg.chk_lprops || c->dbg->chk_lprops);
2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
233
234
235
  }
  static inline int dbg_is_chk_fs(const struct ubifs_info *c)
  {
e7717060d   Artem Bityutskiy   UBIFS: add global...
236
  	return !!(ubifs_dbg.chk_fs || c->dbg->chk_fs);
2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
237
238
239
  }
  static inline int dbg_is_tst_rcvry(const struct ubifs_info *c)
  {
e7717060d   Artem Bityutskiy   UBIFS: add global...
240
  	return !!(ubifs_dbg.tst_rcvry || c->dbg->tst_rcvry);
2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
241
  }
83cef708c   Artem Bityutskiy   UBIFS: introduce ...
242
243
  static inline int dbg_is_power_cut(const struct ubifs_info *c)
  {
d27462a51   Artem Bityutskiy   UBIFS: rename rec...
244
  	return !!c->dbg->pc_happened;
83cef708c   Artem Bityutskiy   UBIFS: introduce ...
245
  }
2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
246

17c2f9f85   Artem Bityutskiy   UBIFS: separate d...
247
248
  int ubifs_debugging_init(struct ubifs_info *c);
  void ubifs_debugging_exit(struct ubifs_info *c);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
249
  /* Dump functions */
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
250
251
  const char *dbg_ntype(int type);
  const char *dbg_cstate(int cmt_state);
77a7ae580   Artem Bityutskiy   UBIFS: improve jo...
252
  const char *dbg_jhead(int jhead);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
253
254
  const char *dbg_get_key_dump(const struct ubifs_info *c,
  			     const union ubifs_key *key);
515315a12   Artem Bityutskiy   UBIFS: fix key pr...
255
256
  const char *dbg_snprintf_key(const struct ubifs_info *c,
  			     const union ubifs_key *key, char *buffer, int len);
4315fb407   Artem Bityutskiy   UBIFS: improve in...
257
  void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
258
  void dbg_dump_node(const struct ubifs_info *c, const void *node);
2ba5f7ae8   Artem Bityutskiy   UBIFS: introduce ...
259
260
  void dbg_dump_lpt_node(const struct ubifs_info *c, void *node, int lnum,
  		       int offs);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
261
262
  void dbg_dump_budget_req(const struct ubifs_budget_req *req);
  void dbg_dump_lstats(const struct ubifs_lp_stats *lst);
f1bd66afb   Artem Bityutskiy   UBIFS: improve sp...
263
  void dbg_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
264
265
  void dbg_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp);
  void dbg_dump_lprops(struct ubifs_info *c);
73944a6de   Adrian Hunter   UBIFS: add more d...
266
  void dbg_dump_lpt_info(struct ubifs_info *c);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
267
  void dbg_dump_leb(const struct ubifs_info *c, int lnum);
d37854cf9   Artem Bityutskiy   UBIFS: introduce ...
268
269
  void dbg_dump_sleb(const struct ubifs_info *c,
  		   const struct ubifs_scan_leb *sleb, int offs);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
270
271
272
273
274
275
276
  void dbg_dump_znode(const struct ubifs_info *c,
  		    const struct ubifs_znode *znode);
  void dbg_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat);
  void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
  		    struct ubifs_nnode *parent, int iip);
  void dbg_dump_tnc(struct ubifs_info *c);
  void dbg_dump_index(struct ubifs_info *c);
2ba5f7ae8   Artem Bityutskiy   UBIFS: introduce ...
277
  void dbg_dump_lpt_lebs(const struct ubifs_info *c);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
278

1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
279
280
281
282
  int dbg_walk_index(struct ubifs_info *c, dbg_leaf_callback leaf_cb,
  		   dbg_znode_callback znode_cb, void *priv);
  
  /* Checking functions */
84abf972c   Artem Bityutskiy   UBIFS: add re-mou...
283
284
  void dbg_save_space_info(struct ubifs_info *c);
  int dbg_check_space_info(struct ubifs_info *c);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
285
  int dbg_check_lprops(struct ubifs_info *c);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
286
287
  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   Artem Bityutskiy   UBIFS: add new fl...
288
  int dbg_check_cats(struct ubifs_info *c);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
289
  int dbg_check_ltab(struct ubifs_info *c);
73944a6de   Adrian Hunter   UBIFS: add more d...
290
291
  int dbg_chk_lpt_free_spc(struct ubifs_info *c);
  int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len);
d808efb40   Artem Bityutskiy   UBIFS: amend debu...
292
  int dbg_check_synced_i_size(const struct ubifs_info *c, struct inode *inode);
1b51e9836   Artem Bityutskiy   UBIFS: rename dbg...
293
  int dbg_check_dir(struct ubifs_info *c, const struct inode *dir);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
294
  int dbg_check_tnc(struct ubifs_info *c, int extra);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
295
  int dbg_check_idx_size(struct ubifs_info *c, long long idx_size);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
296
  int dbg_check_filesystem(struct ubifs_info *c);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
297
298
  void dbg_check_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat,
  		    int add_pos);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
299
300
  int dbg_check_lpt_nodes(struct ubifs_info *c, struct ubifs_cnode *cnode,
  			int row, int col);
e3c3efc24   Artem Bityutskiy   UBIFS: add inode ...
301
302
  int dbg_check_inode_size(struct ubifs_info *c, const struct inode *inode,
  			 loff_t size);
3bb66b47a   Artem Bityutskiy   UBIFS: introduce ...
303
304
  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   Artem Bityutskiy   UBIFS: add new fl...
305

f57cb188c   Artem Bityutskiy   UBIFS: remove cus...
306
307
308
309
310
311
  int dbg_leb_write(struct ubifs_info *c, int lnum, const void *buf, int offs,
  		  int len, int dtype);
  int dbg_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len,
  		   int dtype);
  int dbg_leb_unmap(struct ubifs_info *c, int lnum);
  int dbg_leb_map(struct ubifs_info *c, int lnum, int dtype);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
312

552ff3179   Artem Bityutskiy   UBIFS: add debugf...
313
314
315
316
317
  /* Debugfs-related stuff */
  int dbg_debugfs_init(void);
  void dbg_debugfs_exit(void);
  int dbg_debugfs_init_fs(struct ubifs_info *c);
  void dbg_debugfs_exit_fs(struct ubifs_info *c);
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
318
  #else /* !CONFIG_UBIFS_FS_DEBUG */
840dc6b89   Artem Bityutskiy   UBIFS: improve ar...
319
320
  /* Use "if (0)" to make compiler check arguments even if debugging is off */
  #define ubifs_assert(expr)  do {                                               \
ae380ce04   Artem Bityutskiy   UBIFS: lessen the...
321
  	if (0)                                                                 \
840dc6b89   Artem Bityutskiy   UBIFS: improve ar...
322
323
324
325
  		printk(KERN_CRIT "UBIFS assert failed in %s at %u (pid %d)
  ", \
  		       __func__, __LINE__, current->pid);                      \
  } while (0)
56e46742e   Artem Bityutskiy   UBIFS: switch to ...
326
327
328
  #define dbg_err(fmt, ...)   do {                   \
  	if (0)                                     \
  		ubifs_err(fmt, ##__VA_ARGS__);     \
840dc6b89   Artem Bityutskiy   UBIFS: improve ar...
329
  } while (0)
2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
330
331
  #define DBGKEY(key)  ((char *)(key))
  #define DBGKEY1(key) ((char *)(key))
016f1c544   Michal Marek   UBIFS: not build ...
332
333
334
335
  #define ubifs_dbg_msg(fmt, ...) do {                        \
  	if (0)                                              \
  		printk(KERN_DEBUG fmt "
  ", ##__VA_ARGS__); \
840dc6b89   Artem Bityutskiy   UBIFS: improve ar...
336
  } while (0)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
337
  #define dbg_dump_stack()
840dc6b89   Artem Bityutskiy   UBIFS: improve ar...
338
  #define ubifs_assert_cmt_locked(c)
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
339

e234b5f20   Dominique Martinet   UBIFS: fix non-de...
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
  #define dbg_msg(fmt, ...)       ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_gen(fmt, ...)       ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_jnl(fmt, ...)       ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_jnlk(key, fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_tnc(fmt, ...)       ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_tnck(key, fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_lp(fmt, ...)        ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_find(fmt, ...)      ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_mnt(fmt, ...)       ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_mntk(key, fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_io(fmt, ...)        ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_cmt(fmt, ...)       ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_budg(fmt, ...)      ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_log(fmt, ...)       ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_gc(fmt, ...)        ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_scan(fmt, ...)      ubifs_dbg_msg(fmt, ##__VA_ARGS__)
  #define dbg_rcvry(fmt, ...)     ubifs_dbg_msg(fmt, ##__VA_ARGS__)
840dc6b89   Artem Bityutskiy   UBIFS: improve ar...
357

1dcffad74   Maksim Rayskiy   UBIFS: fix compil...
358
359
360
361
362
363
364
365
  static inline int ubifs_debugging_init(struct ubifs_info *c)      { return 0; }
  static inline void ubifs_debugging_exit(struct ubifs_info *c)     { return; }
  static inline const char *dbg_ntype(int type)                     { return ""; }
  static inline const char *dbg_cstate(int cmt_state)               { return ""; }
  static inline const char *dbg_jhead(int jhead)                    { return ""; }
  static inline const char *
  dbg_get_key_dump(const struct ubifs_info *c,
  		 const union ubifs_key *key)                      { return ""; }
515315a12   Artem Bityutskiy   UBIFS: fix key pr...
366
367
368
369
  static inline const char *
  dbg_snprintf_key(const struct ubifs_info *c,
  		 const union ubifs_key *key, char *buffer,
  		 int len)                                         { return ""; }
4315fb407   Artem Bityutskiy   UBIFS: improve in...
370
  static inline void dbg_dump_inode(struct ubifs_info *c,
1dcffad74   Maksim Rayskiy   UBIFS: fix compil...
371
372
373
374
375
376
377
378
379
380
  				  const struct inode *inode)      { return; }
  static inline void dbg_dump_node(const struct ubifs_info *c,
  				 const void *node)                { return; }
  static inline void dbg_dump_lpt_node(const struct ubifs_info *c,
  				     void *node, int lnum,
  				     int offs)                    { return; }
  static inline void
  dbg_dump_budget_req(const struct ubifs_budget_req *req)           { return; }
  static inline void
  dbg_dump_lstats(const struct ubifs_lp_stats *lst)                 { return; }
f1bd66afb   Artem Bityutskiy   UBIFS: improve sp...
381
382
383
  static inline void
  dbg_dump_budg(struct ubifs_info *c,
  	      const struct ubifs_budg_info *bi)                   { return; }
1dcffad74   Maksim Rayskiy   UBIFS: fix compil...
384
385
386
387
388
389
390
  static inline void dbg_dump_lprop(const struct ubifs_info *c,
  				  const struct ubifs_lprops *lp)  { return; }
  static inline void dbg_dump_lprops(struct ubifs_info *c)          { return; }
  static inline void dbg_dump_lpt_info(struct ubifs_info *c)        { return; }
  static inline void dbg_dump_leb(const struct ubifs_info *c,
  				int lnum)                         { return; }
  static inline void
d37854cf9   Artem Bityutskiy   UBIFS: introduce ...
391
392
393
  dbg_dump_sleb(const struct ubifs_info *c,
  	      const struct ubifs_scan_leb *sleb, int offs)        { return; }
  static inline void
1dcffad74   Maksim Rayskiy   UBIFS: fix compil...
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
  dbg_dump_znode(const struct ubifs_info *c,
  	       const struct ubifs_znode *znode)                   { return; }
  static inline void dbg_dump_heap(struct ubifs_info *c,
  				 struct ubifs_lpt_heap *heap,
  				 int cat)                         { return; }
  static inline void dbg_dump_pnode(struct ubifs_info *c,
  				  struct ubifs_pnode *pnode,
  				  struct ubifs_nnode *parent,
  				  int iip)                        { return; }
  static inline void dbg_dump_tnc(struct ubifs_info *c)             { return; }
  static inline void dbg_dump_index(struct ubifs_info *c)           { return; }
  static inline void dbg_dump_lpt_lebs(const struct ubifs_info *c)  { return; }
  
  static inline int dbg_walk_index(struct ubifs_info *c,
  				 dbg_leaf_callback leaf_cb,
  				 dbg_znode_callback znode_cb,
  				 void *priv)                      { return 0; }
  static inline void dbg_save_space_info(struct ubifs_info *c)      { return; }
  static inline int dbg_check_space_info(struct ubifs_info *c)      { return 0; }
  static inline int dbg_check_lprops(struct ubifs_info *c)          { return 0; }
  static inline int
  dbg_old_index_check_init(struct ubifs_info *c,
  			 struct ubifs_zbranch *zroot)             { return 0; }
  static inline int
  dbg_check_old_index(struct ubifs_info *c,
  		    struct ubifs_zbranch *zroot)                  { return 0; }
  static inline int dbg_check_cats(struct ubifs_info *c)            { return 0; }
  static inline int dbg_check_ltab(struct ubifs_info *c)            { return 0; }
  static inline int dbg_chk_lpt_free_spc(struct ubifs_info *c)      { return 0; }
  static inline int dbg_chk_lpt_sz(struct ubifs_info *c,
  				 int action, int len)             { return 0; }
d808efb40   Artem Bityutskiy   UBIFS: amend debu...
425
426
427
  static inline int
  dbg_check_synced_i_size(const struct ubifs_info *c,
  			struct inode *inode)                      { return 0; }
1b51e9836   Artem Bityutskiy   UBIFS: rename dbg...
428
  static inline int dbg_check_dir(struct ubifs_info *c,
4315fb407   Artem Bityutskiy   UBIFS: improve in...
429
  				const struct inode *dir)          { return 0; }
1dcffad74   Maksim Rayskiy   UBIFS: fix compil...
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
  static inline int dbg_check_tnc(struct ubifs_info *c, int extra)  { return 0; }
  static inline int dbg_check_idx_size(struct ubifs_info *c,
  				     long long idx_size)          { return 0; }
  static inline int dbg_check_filesystem(struct ubifs_info *c)      { return 0; }
  static inline void dbg_check_heap(struct ubifs_info *c,
  				  struct ubifs_lpt_heap *heap,
  				  int cat, int add_pos)           { return; }
  static inline int dbg_check_lpt_nodes(struct ubifs_info *c,
  	struct ubifs_cnode *cnode, int row, int col)              { return 0; }
  static inline int dbg_check_inode_size(struct ubifs_info *c,
  				       const struct inode *inode,
  				       loff_t size)               { return 0; }
  static inline int
  dbg_check_data_nodes_order(struct ubifs_info *c,
  			   struct list_head *head)                { return 0; }
  static inline int
  dbg_check_nondata_nodes_order(struct ubifs_info *c,
  			      struct list_head *head)             { return 0; }
f57cb188c   Artem Bityutskiy   UBIFS: remove cus...
448
449
450
451
452
453
454
455
456
  static inline int dbg_leb_write(struct ubifs_info *c, int lnum,
  				const void *buf, int offset,
  				int len, int dtype)               { return 0; }
  static inline int dbg_leb_change(struct ubifs_info *c, int lnum,
  				 const void *buf, int len,
  				 int dtype)                       { return 0; }
  static inline int dbg_leb_unmap(struct ubifs_info *c, int lnum)   { return 0; }
  static inline int dbg_leb_map(struct ubifs_info *c, int lnum,
  			      int dtype)                          { return 0; }
83cef708c   Artem Bityutskiy   UBIFS: introduce ...
457

2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
458
  static inline int dbg_is_chk_gen(const struct ubifs_info *c)      { return 0; }
8d7819b4a   Artem Bityutskiy   UBIFS: lessen amo...
459
  static inline int dbg_is_chk_index(const struct ubifs_info *c)    { return 0; }
2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
460
  static inline int dbg_is_chk_orph(const struct ubifs_info *c)     { return 0; }
2b1844a8c   Artem Bityutskiy   UBIFS: introduce ...
461
462
463
  static inline int dbg_is_chk_lprops(const struct ubifs_info *c)   { return 0; }
  static inline int dbg_is_chk_fs(const struct ubifs_info *c)       { return 0; }
  static inline int dbg_is_tst_rcvry(const struct ubifs_info *c)    { return 0; }
83cef708c   Artem Bityutskiy   UBIFS: introduce ...
464
  static inline int dbg_is_power_cut(const struct ubifs_info *c)    { return 0; }
1dcffad74   Maksim Rayskiy   UBIFS: fix compil...
465
466
467
468
469
  
  static inline int dbg_debugfs_init(void)                          { return 0; }
  static inline void dbg_debugfs_exit(void)                         { return; }
  static inline int dbg_debugfs_init_fs(struct ubifs_info *c)       { return 0; }
  static inline int dbg_debugfs_exit_fs(struct ubifs_info *c)       { return 0; }
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
470

552ff3179   Artem Bityutskiy   UBIFS: add debugf...
471
  #endif /* !CONFIG_UBIFS_FS_DEBUG */
1e51764a3   Artem Bityutskiy   UBIFS: add new fl...
472
  #endif /* !__UBIFS_DEBUG_H__ */