blob: f89c85d5a3f8cd28946ace7eebf03103706ca9cd [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
David Woodhousee499e012007-01-13 08:19:03 +080016#include <linux/sched.h>
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010017
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
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900174/* Watch the XATTR subsystem */
175#ifdef JFFS2_DBG_XATTR_MESSAGES
176#define dbg_xattr(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
177#else
178#define dbg_xattr(fmt, ...)
179#endif
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100180
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100181/* "Sanity" checks */
182void
183__jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
184 struct jffs2_eraseblock *jeb);
185void
186__jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
187 struct jffs2_eraseblock *jeb);
188
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100189/* "Paranoia" checks */
190void
191__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
192void
193__jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
194void
195__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
196 struct jffs2_eraseblock *jeb);
197void
198__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
199 struct jffs2_eraseblock *jeb);
200void
201__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
202 uint32_t ofs, int len);
203
204/* "Dump" functions */
205void
206__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
207void
208__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
209void
210__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
211void
212__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
213void
214__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
215 struct jffs2_eraseblock *jeb);
216void
217__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
218 struct jffs2_eraseblock *jeb);
219void
220__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
221void
222__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
223void
224__jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
225void
226__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
227
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100228#ifdef JFFS2_DBG_PARANOIA_CHECKS
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100229#define jffs2_dbg_fragtree_paranoia_check(f) \
230 __jffs2_dbg_fragtree_paranoia_check(f)
231#define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
232 __jffs2_dbg_fragtree_paranoia_check_nolock(f)
233#define jffs2_dbg_acct_paranoia_check(c, jeb) \
234 __jffs2_dbg_acct_paranoia_check(c,jeb)
235#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
236 __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
237#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
238 __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100239#else
240#define jffs2_dbg_fragtree_paranoia_check(f)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100241#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100242#define jffs2_dbg_acct_paranoia_check(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100243#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100244#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
245#endif /* !JFFS2_PARANOIA_CHECKS */
246
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100247#ifdef JFFS2_DBG_DUMPS
248#define jffs2_dbg_dump_jeb(c, jeb) \
249 __jffs2_dbg_dump_jeb(c, jeb);
250#define jffs2_dbg_dump_jeb_nolock(jeb) \
251 __jffs2_dbg_dump_jeb_nolock(jeb);
252#define jffs2_dbg_dump_block_lists(c) \
253 __jffs2_dbg_dump_block_lists(c)
254#define jffs2_dbg_dump_block_lists_nolock(c) \
255 __jffs2_dbg_dump_block_lists_nolock(c)
256#define jffs2_dbg_dump_fragtree(f) \
257 __jffs2_dbg_dump_fragtree(f);
258#define jffs2_dbg_dump_fragtree_nolock(f) \
259 __jffs2_dbg_dump_fragtree_nolock(f);
260#define jffs2_dbg_dump_buffer(buf, len, offs) \
261 __jffs2_dbg_dump_buffer(*buf, len, offs);
262#define jffs2_dbg_dump_node(c, ofs) \
263 __jffs2_dbg_dump_node(c, ofs);
264#else
265#define jffs2_dbg_dump_jeb(c, jeb)
266#define jffs2_dbg_dump_jeb_nolock(jeb)
267#define jffs2_dbg_dump_block_lists(c)
268#define jffs2_dbg_dump_block_lists_nolock(c)
269#define jffs2_dbg_dump_fragtree(f)
270#define jffs2_dbg_dump_fragtree_nolock(f)
271#define jffs2_dbg_dump_buffer(buf, len, offs)
272#define jffs2_dbg_dump_node(c, ofs)
273#endif /* !JFFS2_DBG_DUMPS */
274
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100275#ifdef JFFS2_DBG_SANITY_CHECKS
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100276#define jffs2_dbg_acct_sanity_check(c, jeb) \
277 __jffs2_dbg_acct_sanity_check(c, jeb)
278#define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \
279 __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100280#else
281#define jffs2_dbg_acct_sanity_check(c, jeb)
282#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100283#endif /* !JFFS2_DBG_SANITY_CHECKS */
284
285#endif /* _JFFS2_DEBUG_H_ */