blob: 162af6dfe292c216f0c61f9a1db301b3ceb630b4 [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 *
Thomas Gleixner182ec4e2005-11-07 11:16:07 +000010 * $Id: debug.h,v 1.21 2005/11/07 11:14:39 gleixner 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. Bityutskiy008531f2005-10-24 17:22:36 +010022#if CONFIG_JFFS2_FS_DEBUG > 0
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010023/* 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
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010026
Thomas Gleixner182ec4e2005-11-07 11:16:07 +000027/*
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010028 * By defining/undefining the below macros one may select debugging messages
29 * fro specific JFFS2 subsystems.
30 */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010031#define JFFS2_DBG_READINODE_MESSAGES
32#define JFFS2_DBG_FRAGTREE_MESSAGES
33#define JFFS2_DBG_DENTLIST_MESSAGES
34#define JFFS2_DBG_NODEREF_MESSAGES
35#define JFFS2_DBG_INOCACHE_MESSAGES
Ferenc Havasie631ddb2005-09-07 09:35:26 +010036#define JFFS2_DBG_SUMMARY_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010037#define JFFS2_DBG_FSBUILD_MESSAGES
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010038#endif
39
Artem B. Bityutskiy008531f2005-10-24 17:22:36 +010040#if CONFIG_JFFS2_FS_DEBUG > 1
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010041#define JFFS2_DBG_FRAGTREE2_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010042#define JFFS2_DBG_MEMALLOC_MESSAGES
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010043#endif
44
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010045/* Sanity checks are supposed to be light-weight and enabled by default */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010046#define JFFS2_DBG_SANITY_CHECKS
47
Thomas Gleixner182ec4e2005-11-07 11:16:07 +000048/*
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010049 * Dx() are mainly used for debugging messages, they must go away and be
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010050 * superseded by nicer dbg_xxx() macros...
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010051 */
52#if CONFIG_JFFS2_FS_DEBUG > 0
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010053#define D1(x) x
54#else
55#define D1(x)
56#endif
57
58#if CONFIG_JFFS2_FS_DEBUG > 1
59#define D2(x) x
60#else
61#define D2(x)
62#endif
63
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010064/* The prefixes of JFFS2 messages */
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010065#define JFFS2_DBG_PREFIX "[JFFS2 DBG]"
66#define JFFS2_ERR_PREFIX "JFFS2 error:"
67#define JFFS2_WARN_PREFIX "JFFS2 warning:"
68#define JFFS2_NOTICE_PREFIX "JFFS2 notice:"
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010069
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010070#define JFFS2_ERR KERN_ERR
71#define JFFS2_WARN KERN_WARNING
72#define JFFS2_NOT KERN_NOTICE
73#define JFFS2_DBG KERN_DEBUG
74
75#define JFFS2_DBG_MSG_PREFIX JFFS2_DBG JFFS2_DBG_PREFIX
76#define JFFS2_ERR_MSG_PREFIX JFFS2_ERR JFFS2_ERR_PREFIX
77#define JFFS2_WARN_MSG_PREFIX JFFS2_WARN JFFS2_WARN_PREFIX
78#define JFFS2_NOTICE_MSG_PREFIX JFFS2_NOT JFFS2_NOTICE_PREFIX
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010079
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010080/* JFFS2 message macros */
81#define JFFS2_ERROR(fmt, ...) \
82 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010083 printk(JFFS2_ERR_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010084 " (%d) %s: " fmt, current->pid, \
Andrew Morton02b70682005-11-23 13:37:47 -080085 __FUNCTION__ , ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010086 } while(0)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010087
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010088#define JFFS2_WARNING(fmt, ...) \
89 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010090 printk(JFFS2_WARN_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010091 " (%d) %s: " fmt, current->pid, \
Andrew Morton02b70682005-11-23 13:37:47 -080092 __FUNCTION__ , ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010093 } while(0)
Thomas Gleixner182ec4e2005-11-07 11:16:07 +000094
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010095#define JFFS2_NOTICE(fmt, ...) \
96 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010097 printk(JFFS2_NOTICE_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010098 " (%d) %s: " fmt, current->pid, \
Andrew Morton02b70682005-11-23 13:37:47 -080099 __FUNCTION__ , ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100100 } while(0)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100101
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100102#define JFFS2_DEBUG(fmt, ...) \
103 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +0100104 printk(JFFS2_DBG_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +0100105 " (%d) %s: " fmt, current->pid, \
Andrew Morton02b70682005-11-23 13:37:47 -0800106 __FUNCTION__ , ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100107 } while(0)
108
Thomas Gleixner182ec4e2005-11-07 11:16:07 +0000109/*
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100110 * We split our debugging messages on several parts, depending on the JFFS2
111 * subsystem the message belongs to.
112 */
113/* Read inode debugging messages */
114#ifdef JFFS2_DBG_READINODE_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100115#define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100116#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100117#define dbg_readinode(fmt, ...)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100118#endif
119
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100120/* Fragtree build debugging messages */
121#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100122#define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100123#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100124#define dbg_fragtree(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100125#endif
Artem B. Bityutskiye0e30062005-07-31 10:08:41 +0100126#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100127#define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0e30062005-07-31 10:08:41 +0100128#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100129#define dbg_fragtree2(fmt, ...)
Artem B. Bityutskiye0e30062005-07-31 10:08:41 +0100130#endif
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100131
132/* Directory entry list manilulation debugging messages */
133#ifdef JFFS2_DBG_DENTLIST_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100134#define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100135#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100136#define dbg_dentlist(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100137#endif
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100138
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100139/* Print the messages about manipulating node_refs */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100140#ifdef JFFS2_DBG_NODEREF_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100141#define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100142#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100143#define dbg_noderef(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100144#endif
145
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100146/* Manipulations with the list of inodes (JFFS2 inocache) */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100147#ifdef JFFS2_DBG_INOCACHE_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100148#define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100149#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100150#define dbg_inocache(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100151#endif
152
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100153/* Summary debugging messages */
154#ifdef JFFS2_DBG_SUMMARY_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100155#define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100156#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100157#define dbg_summary(fmt, ...)
158#endif
159
160/* File system build messages */
161#ifdef JFFS2_DBG_FSBUILD_MESSAGES
162#define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
163#else
164#define dbg_fsbuild(fmt, ...)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100165#endif
166
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100167/* Watch the object allocations */
168#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100169#define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100170#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100171#define dbg_memalloc(fmt, ...)
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100172#endif
173
174
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100175/* "Sanity" checks */
176void
177__jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
178 struct jffs2_eraseblock *jeb);
179void
180__jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
181 struct jffs2_eraseblock *jeb);
182
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100183/* "Paranoia" checks */
184void
185__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
186void
187__jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
188void
189__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
190 struct jffs2_eraseblock *jeb);
191void
192__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
193 struct jffs2_eraseblock *jeb);
194void
195__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
196 uint32_t ofs, int len);
197
198/* "Dump" functions */
199void
200__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
201void
202__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
203void
204__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
205void
206__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
207void
208__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
209 struct jffs2_eraseblock *jeb);
210void
211__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
212 struct jffs2_eraseblock *jeb);
213void
214__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
215void
216__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
217void
218__jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
219void
220__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
221
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100222#ifdef JFFS2_DBG_PARANOIA_CHECKS
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100223#define jffs2_dbg_fragtree_paranoia_check(f) \
224 __jffs2_dbg_fragtree_paranoia_check(f)
225#define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
226 __jffs2_dbg_fragtree_paranoia_check_nolock(f)
227#define jffs2_dbg_acct_paranoia_check(c, jeb) \
228 __jffs2_dbg_acct_paranoia_check(c,jeb)
229#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
230 __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
231#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
232 __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100233#else
234#define jffs2_dbg_fragtree_paranoia_check(f)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100235#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100236#define jffs2_dbg_acct_paranoia_check(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100237#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100238#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
239#endif /* !JFFS2_PARANOIA_CHECKS */
240
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100241#ifdef JFFS2_DBG_DUMPS
242#define jffs2_dbg_dump_jeb(c, jeb) \
243 __jffs2_dbg_dump_jeb(c, jeb);
244#define jffs2_dbg_dump_jeb_nolock(jeb) \
245 __jffs2_dbg_dump_jeb_nolock(jeb);
246#define jffs2_dbg_dump_block_lists(c) \
247 __jffs2_dbg_dump_block_lists(c)
248#define jffs2_dbg_dump_block_lists_nolock(c) \
249 __jffs2_dbg_dump_block_lists_nolock(c)
250#define jffs2_dbg_dump_fragtree(f) \
251 __jffs2_dbg_dump_fragtree(f);
252#define jffs2_dbg_dump_fragtree_nolock(f) \
253 __jffs2_dbg_dump_fragtree_nolock(f);
254#define jffs2_dbg_dump_buffer(buf, len, offs) \
255 __jffs2_dbg_dump_buffer(*buf, len, offs);
256#define jffs2_dbg_dump_node(c, ofs) \
257 __jffs2_dbg_dump_node(c, ofs);
258#else
259#define jffs2_dbg_dump_jeb(c, jeb)
260#define jffs2_dbg_dump_jeb_nolock(jeb)
261#define jffs2_dbg_dump_block_lists(c)
262#define jffs2_dbg_dump_block_lists_nolock(c)
263#define jffs2_dbg_dump_fragtree(f)
264#define jffs2_dbg_dump_fragtree_nolock(f)
265#define jffs2_dbg_dump_buffer(buf, len, offs)
266#define jffs2_dbg_dump_node(c, ofs)
267#endif /* !JFFS2_DBG_DUMPS */
268
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100269#ifdef JFFS2_DBG_SANITY_CHECKS
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100270#define jffs2_dbg_acct_sanity_check(c, jeb) \
271 __jffs2_dbg_acct_sanity_check(c, jeb)
272#define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \
273 __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100274#else
275#define jffs2_dbg_acct_sanity_check(c, jeb)
276#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100277#endif /* !JFFS2_DBG_SANITY_CHECKS */
278
279#endif /* _JFFS2_DEBUG_H_ */