]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - fs/jffs2/debug.h
[JFFS2] Debug code clean up - step 7
[mirror_ubuntu-bionic-kernel.git] / fs / jffs2 / debug.h
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 *
10 * $Id: debug.h,v 1.12 2005/08/05 10:43:47 dedekind Exp $
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
19 #define CONFIG_JFFS2_FS_DEBUG 0
20 #endif
21
22 #if CONFIG_JFFS2_FS_DEBUG == 1
23 /* Enable "paranoia" checks and dumps */
24 #define JFFS2_DBG_PARANOIA_CHECKS
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
37 /* Sanity checks are supposed to be light-weight and enabled by default */
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
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
56 /* The prefixes of JFFS2 messages */
57 #define JFFS2_DBG_MSG_PREFIX "[JFFS2 DBG]"
58 #define JFFS2_ERR_MSG_PREFIX "JFFS2 error:"
59 #define JFFS2_WARN_MSG_PREFIX "JFFS2 warning:"
60 #define JFFS2_NOTICE_MSG_PREFIX "JFFS2 notice:"
61
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
66
67 /* JFFS2 message macros */
68 #define JFFS2_ERROR(fmt, ...) \
69 do { \
70 printk(JFFS2_ERR_LVL JFFS2_ERR_MSG_PREFIX \
71 " %d,%s: " fmt, current->pid, \
72 __FUNCTION__, ##__VA_ARGS__); \
73 } while(0)
74
75 #define JFFS2_WARNING(fmt, ...) \
76 do { \
77 printk(JFFS2_WARN_LVL JFFS2_WARN_MSG_PREFIX \
78 " %d,%s: " fmt, current->pid, \
79 __FUNCTION__, ##__VA_ARGS__); \
80 } while(0)
81
82 #define JFFS2_NOTICE(fmt, ...) \
83 do { \
84 printk(JFFS2_NOTICE_LVL JFFS2_NOTICE_MSG_PREFIX \
85 " %d,%s: " fmt, current->pid, \
86 __FUNCTION__, ##__VA_ARGS__); \
87 } while(0)
88
89 #define JFFS2_DEBUG(fmt, ...) \
90 do { \
91 printk(JFFS2_DBG_LVL JFFS2_DBG_MSG_PREFIX \
92 " %d,%s: " fmt, current->pid, \
93 __FUNCTION__, ##__VA_ARGS__); \
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, ...)
105 #endif
106
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
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
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
125
126 /* Print the messages about manipulating node_refs */
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
133 /* Manipulations with the list of inodes (JFFS2 inocache) */
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
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
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
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
195 #ifdef JFFS2_DBG_PARANOIA_CHECKS
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)
206 #else
207 #define jffs2_dbg_fragtree_paranoia_check(f)
208 #define jffs2_dbg_fragtree_paranoia_check_nolock(f)
209 #define jffs2_dbg_acct_paranoia_check(c, jeb)
210 #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
211 #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
212 #endif /* !JFFS2_PARANOIA_CHECKS */
213
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
242 #ifdef JFFS2_DBG_SANITY_CHECKS
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)
247 #else
248 #define jffs2_dbg_acct_sanity_check(c, jeb)
249 #define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
250 #endif /* !JFFS2_DBG_SANITY_CHECKS */
251
252 #endif /* _JFFS2_DEBUG_H_ */