blob: 7328e67bebb6b4f5e730fafb91406dfa14d9376d [file] [log] [blame]
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +01001/*
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. Bityutskiy81e39cf2005-09-14 17:57:35 +010010 * $Id: debug.h,v 1.16 2005/09/14 16:57:32 dedekind Exp $
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010011 *
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. Bityutskiyf538c962005-07-27 15:16:57 +010019#define CONFIG_JFFS2_FS_DEBUG 0
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010020#endif
21
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010022#if CONFIG_JFFS2_FS_DEBUG == 1
23/* Enable "paranoia" checks and dumps */
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010024#define JFFS2_DBG_PARANOIA_CHECKS
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010025#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
Ferenc Havasie631ddb2005-09-07 09:35:26 +010031#define JFFS2_DBG_SUMMARY_MESSAGES
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010032#endif
33
34#if CONFIG_JFFS2_FS_DEBUG == 2
35#define JFFS2_DBG_FRAGTREE2_MESSAGES
36#endif
37
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010038/* Sanity checks are supposed to be light-weight and enabled by default */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010039#define JFFS2_DBG_SANITY_CHECKS
40
41/*
42 * Dx() are mainly used for debugging messages, they must go away and be
43 * superseded by nicer JFFS2_DBG_XXX() macros...
44 */
45#if CONFIG_JFFS2_FS_DEBUG > 0
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010046#define D1(x) x
47#else
48#define D1(x)
49#endif
50
51#if CONFIG_JFFS2_FS_DEBUG > 1
52#define D2(x) x
53#else
54#define D2(x)
55#endif
56
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010057/* The prefixes of JFFS2 messages */
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010058#define JFFS2_DBG_PREFIX "[JFFS2 DBG]"
59#define JFFS2_ERR_PREFIX "JFFS2 error:"
60#define JFFS2_WARN_PREFIX "JFFS2 warning:"
61#define JFFS2_NOTICE_PREFIX "JFFS2 notice:"
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010062
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010063#define JFFS2_ERR KERN_ERR
64#define JFFS2_WARN KERN_WARNING
65#define JFFS2_NOT KERN_NOTICE
66#define JFFS2_DBG KERN_DEBUG
67
68#define JFFS2_DBG_MSG_PREFIX JFFS2_DBG JFFS2_DBG_PREFIX
69#define JFFS2_ERR_MSG_PREFIX JFFS2_ERR JFFS2_ERR_PREFIX
70#define JFFS2_WARN_MSG_PREFIX JFFS2_WARN JFFS2_WARN_PREFIX
71#define JFFS2_NOTICE_MSG_PREFIX JFFS2_NOT JFFS2_NOTICE_PREFIX
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010072
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010073/* JFFS2 message macros */
74#define JFFS2_ERROR(fmt, ...) \
75 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010076 printk(JFFS2_ERR_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010077 " (%d) %s: " fmt, current->pid, \
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010078 __FUNCTION__, ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010079 } while(0)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010080
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010081#define JFFS2_WARNING(fmt, ...) \
82 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010083 printk(JFFS2_WARN_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010084 " (%d) %s: " fmt, current->pid, \
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010085 __FUNCTION__, ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010086 } while(0)
87
88#define JFFS2_NOTICE(fmt, ...) \
89 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010090 printk(JFFS2_NOTICE_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010091 " (%d) %s: " fmt, current->pid, \
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010092 __FUNCTION__, ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010093 } while(0)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010094
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010095#define JFFS2_DEBUG(fmt, ...) \
96 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010097 printk(JFFS2_DBG_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010098 " (%d) %s: " fmt, current->pid, \
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010099 __FUNCTION__, ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100100 } while(0)
101
102/*
103 * We split our debugging messages on several parts, depending on the JFFS2
104 * subsystem the message belongs to.
105 */
106/* Read inode debugging messages */
107#ifdef JFFS2_DBG_READINODE_MESSAGES
108#define JFFS2_DBG_READINODE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
109#else
110#define JFFS2_DBG_READINODE(fmt, ...)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100111#endif
112
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100113/* Fragtree build debugging messages */
114#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
115#define JFFS2_DBG_FRAGTREE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
116#else
117#define JFFS2_DBG_FRAGTREE(fmt, ...)
118#endif
Artem B. Bityutskiye0e3006f2005-07-31 10:08:41 +0100119#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
120#define JFFS2_DBG_FRAGTREE2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
121#else
122#define JFFS2_DBG_FRAGTREE2(fmt, ...)
123#endif
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100124
125/* Directory entry list manilulation debugging messages */
126#ifdef JFFS2_DBG_DENTLIST_MESSAGES
127#define JFFS2_DBG_DENTLIST(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
128#else
129#define JFFS2_DBG_DENTLIST(fmt, ...)
130#endif
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100131
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100132/* Print the messages about manipulating node_refs */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100133#ifdef JFFS2_DBG_NODEREF_MESSAGES
134#define JFFS2_DBG_NODEREF(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
135#else
136#define JFFS2_DBG_NODEREF(fmt, ...)
137#endif
138
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100139/* Manipulations with the list of inodes (JFFS2 inocache) */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100140#ifdef JFFS2_DBG_INOCACHE_MESSAGES
141#define JFFS2_DBG_INOCACHE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
142#else
143#define JFFS2_DBG_INOCACHE(fmt, ...)
144#endif
145
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100146/* Summary debugging messages */
147#ifdef JFFS2_DBG_SUMMARY_MESSAGES
148#define JFFS2_DBG_SUMMARY(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
149#else
150#define JFFS2_DBG_SUMMARY(fmt, ...)
151#endif
152
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100153/* Watch the object allocations */
154#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
155#define JFFS2_DBG_MEMALLOC(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
156#else
157#define JFFS2_DBG_MEMALLOC(fmt, ...)
158#endif
159
160
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100161/* "Sanity" checks */
162void
163__jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
164 struct jffs2_eraseblock *jeb);
165void
166__jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
167 struct jffs2_eraseblock *jeb);
168
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100169/* "Paranoia" checks */
170void
171__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
172void
173__jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
174void
175__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
176 struct jffs2_eraseblock *jeb);
177void
178__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
179 struct jffs2_eraseblock *jeb);
180void
181__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
182 uint32_t ofs, int len);
183
184/* "Dump" functions */
185void
186__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
187void
188__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
189void
190__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
191void
192__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
193void
194__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
195 struct jffs2_eraseblock *jeb);
196void
197__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
198 struct jffs2_eraseblock *jeb);
199void
200__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
201void
202__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
203void
204__jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
205void
206__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
207
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100208#ifdef JFFS2_DBG_PARANOIA_CHECKS
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100209#define jffs2_dbg_fragtree_paranoia_check(f) \
210 __jffs2_dbg_fragtree_paranoia_check(f)
211#define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
212 __jffs2_dbg_fragtree_paranoia_check_nolock(f)
213#define jffs2_dbg_acct_paranoia_check(c, jeb) \
214 __jffs2_dbg_acct_paranoia_check(c,jeb)
215#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
216 __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
217#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
218 __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100219#else
220#define jffs2_dbg_fragtree_paranoia_check(f)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100221#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100222#define jffs2_dbg_acct_paranoia_check(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100223#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100224#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
225#endif /* !JFFS2_PARANOIA_CHECKS */
226
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100227#ifdef JFFS2_DBG_DUMPS
228#define jffs2_dbg_dump_jeb(c, jeb) \
229 __jffs2_dbg_dump_jeb(c, jeb);
230#define jffs2_dbg_dump_jeb_nolock(jeb) \
231 __jffs2_dbg_dump_jeb_nolock(jeb);
232#define jffs2_dbg_dump_block_lists(c) \
233 __jffs2_dbg_dump_block_lists(c)
234#define jffs2_dbg_dump_block_lists_nolock(c) \
235 __jffs2_dbg_dump_block_lists_nolock(c)
236#define jffs2_dbg_dump_fragtree(f) \
237 __jffs2_dbg_dump_fragtree(f);
238#define jffs2_dbg_dump_fragtree_nolock(f) \
239 __jffs2_dbg_dump_fragtree_nolock(f);
240#define jffs2_dbg_dump_buffer(buf, len, offs) \
241 __jffs2_dbg_dump_buffer(*buf, len, offs);
242#define jffs2_dbg_dump_node(c, ofs) \
243 __jffs2_dbg_dump_node(c, ofs);
244#else
245#define jffs2_dbg_dump_jeb(c, jeb)
246#define jffs2_dbg_dump_jeb_nolock(jeb)
247#define jffs2_dbg_dump_block_lists(c)
248#define jffs2_dbg_dump_block_lists_nolock(c)
249#define jffs2_dbg_dump_fragtree(f)
250#define jffs2_dbg_dump_fragtree_nolock(f)
251#define jffs2_dbg_dump_buffer(buf, len, offs)
252#define jffs2_dbg_dump_node(c, ofs)
253#endif /* !JFFS2_DBG_DUMPS */
254
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100255#ifdef JFFS2_DBG_SANITY_CHECKS
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100256#define jffs2_dbg_acct_sanity_check(c, jeb) \
257 __jffs2_dbg_acct_sanity_check(c, jeb)
258#define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \
259 __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100260#else
261#define jffs2_dbg_acct_sanity_check(c, jeb)
262#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100263#endif /* !JFFS2_DBG_SANITY_CHECKS */
264
265#endif /* _JFFS2_DEBUG_H_ */