blob: a113ecc3bafeeb5f74172d8d5eb98e09f6eb6979 [file] [log] [blame]
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +01001/*
2 * JFFS2 -- Journalling Flash File System, Version 2.
3 *
David Woodhousec00c3102007-04-25 14:16:47 +01004 * Copyright © 2001-2007 Red Hat, Inc.
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +01005 *
6 * Created by David Woodhouse <dwmw2@infradead.org>
7 *
8 * For licensing information, see the file 'LICENCE' in this directory.
9 *
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010010 */
David Woodhousec00c3102007-04-25 14:16:47 +010011
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010012#ifndef _JFFS2_DEBUG_H_
13#define _JFFS2_DEBUG_H_
14
David Woodhousee499e012007-01-13 08:19:03 +080015#include <linux/sched.h>
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010016
17#ifndef CONFIG_JFFS2_FS_DEBUG
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +010018#define CONFIG_JFFS2_FS_DEBUG 0
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010019#endif
20
Artem B. Bityutskiy008531f2005-10-24 17:22:36 +010021#if CONFIG_JFFS2_FS_DEBUG > 0
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010022/* Enable "paranoia" checks and dumps */
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010023#define JFFS2_DBG_PARANOIA_CHECKS
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010024#define JFFS2_DBG_DUMPS
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010025
Thomas Gleixner182ec4e2005-11-07 11:16:07 +000026/*
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010027 * By defining/undefining the below macros one may select debugging messages
28 * fro specific JFFS2 subsystems.
29 */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010030#define JFFS2_DBG_READINODE_MESSAGES
31#define JFFS2_DBG_FRAGTREE_MESSAGES
32#define JFFS2_DBG_DENTLIST_MESSAGES
33#define JFFS2_DBG_NODEREF_MESSAGES
34#define JFFS2_DBG_INOCACHE_MESSAGES
Ferenc Havasie631ddb2005-09-07 09:35:26 +010035#define JFFS2_DBG_SUMMARY_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010036#define JFFS2_DBG_FSBUILD_MESSAGES
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010037#endif
38
Artem B. Bityutskiy008531f2005-10-24 17:22:36 +010039#if CONFIG_JFFS2_FS_DEBUG > 1
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010040#define JFFS2_DBG_FRAGTREE2_MESSAGES
David Woodhouse2c61cb22008-04-23 16:43:15 +010041#define JFFS2_DBG_READINODE2_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 \
Pavel Emelyanovba25f9d2007-10-18 23:40:40 -070084 " (%d) %s: " fmt, task_pid_nr(current), \
Harvey Harrison8e24eea2008-04-30 00:55:09 -070085 __func__ , ##__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 \
Pavel Emelyanovba25f9d2007-10-18 23:40:40 -070091 " (%d) %s: " fmt, task_pid_nr(current), \
Harvey Harrison8e24eea2008-04-30 00:55:09 -070092 __func__ , ##__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 \
Pavel Emelyanovba25f9d2007-10-18 23:40:40 -070098 " (%d) %s: " fmt, task_pid_nr(current), \
Harvey Harrison8e24eea2008-04-30 00:55:09 -070099 __func__ , ##__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 \
Pavel Emelyanovba25f9d2007-10-18 23:40:40 -0700105 " (%d) %s: " fmt, task_pid_nr(current), \
Harvey Harrison8e24eea2008-04-30 00:55:09 -0700106 __func__ , ##__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
David Woodhouse2c61cb22008-04-23 16:43:15 +0100119#ifdef JFFS2_DBG_READINODE2_MESSAGES
120#define dbg_readinode2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
121#else
122#define dbg_readinode2(fmt, ...)
123#endif
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100124
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100125/* Fragtree build debugging messages */
126#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100127#define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100128#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100129#define dbg_fragtree(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100130#endif
Artem B. Bityutskiye0e30062005-07-31 10:08:41 +0100131#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100132#define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0e30062005-07-31 10:08:41 +0100133#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100134#define dbg_fragtree2(fmt, ...)
Artem B. Bityutskiye0e30062005-07-31 10:08:41 +0100135#endif
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100136
137/* Directory entry list manilulation debugging messages */
138#ifdef JFFS2_DBG_DENTLIST_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100139#define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100140#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100141#define dbg_dentlist(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100142#endif
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100143
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100144/* Print the messages about manipulating node_refs */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100145#ifdef JFFS2_DBG_NODEREF_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100146#define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100147#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100148#define dbg_noderef(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100149#endif
150
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100151/* Manipulations with the list of inodes (JFFS2 inocache) */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100152#ifdef JFFS2_DBG_INOCACHE_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100153#define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100154#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100155#define dbg_inocache(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100156#endif
157
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100158/* Summary debugging messages */
159#ifdef JFFS2_DBG_SUMMARY_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100160#define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100161#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100162#define dbg_summary(fmt, ...)
163#endif
164
165/* File system build messages */
166#ifdef JFFS2_DBG_FSBUILD_MESSAGES
167#define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
168#else
169#define dbg_fsbuild(fmt, ...)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100170#endif
171
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100172/* Watch the object allocations */
173#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100174#define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100175#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100176#define dbg_memalloc(fmt, ...)
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100177#endif
178
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900179/* Watch the XATTR subsystem */
180#ifdef JFFS2_DBG_XATTR_MESSAGES
181#define dbg_xattr(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
182#else
183#define dbg_xattr(fmt, ...)
184#endif
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100185
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100186/* "Sanity" checks */
187void
188__jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
189 struct jffs2_eraseblock *jeb);
190void
191__jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
192 struct jffs2_eraseblock *jeb);
193
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100194/* "Paranoia" checks */
195void
196__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
197void
198__jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
199void
200__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
201 struct jffs2_eraseblock *jeb);
202void
203__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
204 struct jffs2_eraseblock *jeb);
205void
206__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
207 uint32_t ofs, int len);
208
209/* "Dump" functions */
210void
211__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
212void
213__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
214void
215__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
216void
217__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
218void
219__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
220 struct jffs2_eraseblock *jeb);
221void
222__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
223 struct jffs2_eraseblock *jeb);
224void
225__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
226void
227__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
228void
229__jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
230void
231__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
232
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100233#ifdef JFFS2_DBG_PARANOIA_CHECKS
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100234#define jffs2_dbg_fragtree_paranoia_check(f) \
235 __jffs2_dbg_fragtree_paranoia_check(f)
236#define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
237 __jffs2_dbg_fragtree_paranoia_check_nolock(f)
238#define jffs2_dbg_acct_paranoia_check(c, jeb) \
239 __jffs2_dbg_acct_paranoia_check(c,jeb)
240#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
241 __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
242#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
243 __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100244#else
245#define jffs2_dbg_fragtree_paranoia_check(f)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100246#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100247#define jffs2_dbg_acct_paranoia_check(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100248#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100249#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
250#endif /* !JFFS2_PARANOIA_CHECKS */
251
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100252#ifdef JFFS2_DBG_DUMPS
253#define jffs2_dbg_dump_jeb(c, jeb) \
254 __jffs2_dbg_dump_jeb(c, jeb);
255#define jffs2_dbg_dump_jeb_nolock(jeb) \
256 __jffs2_dbg_dump_jeb_nolock(jeb);
257#define jffs2_dbg_dump_block_lists(c) \
258 __jffs2_dbg_dump_block_lists(c)
259#define jffs2_dbg_dump_block_lists_nolock(c) \
260 __jffs2_dbg_dump_block_lists_nolock(c)
261#define jffs2_dbg_dump_fragtree(f) \
262 __jffs2_dbg_dump_fragtree(f);
263#define jffs2_dbg_dump_fragtree_nolock(f) \
264 __jffs2_dbg_dump_fragtree_nolock(f);
265#define jffs2_dbg_dump_buffer(buf, len, offs) \
266 __jffs2_dbg_dump_buffer(*buf, len, offs);
267#define jffs2_dbg_dump_node(c, ofs) \
268 __jffs2_dbg_dump_node(c, ofs);
269#else
270#define jffs2_dbg_dump_jeb(c, jeb)
271#define jffs2_dbg_dump_jeb_nolock(jeb)
272#define jffs2_dbg_dump_block_lists(c)
273#define jffs2_dbg_dump_block_lists_nolock(c)
274#define jffs2_dbg_dump_fragtree(f)
275#define jffs2_dbg_dump_fragtree_nolock(f)
276#define jffs2_dbg_dump_buffer(buf, len, offs)
277#define jffs2_dbg_dump_node(c, ofs)
278#endif /* !JFFS2_DBG_DUMPS */
279
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100280#ifdef JFFS2_DBG_SANITY_CHECKS
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100281#define jffs2_dbg_acct_sanity_check(c, jeb) \
282 __jffs2_dbg_acct_sanity_check(c, jeb)
283#define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \
284 __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100285#else
286#define jffs2_dbg_acct_sanity_check(c, jeb)
287#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100288#endif /* !JFFS2_DBG_SANITY_CHECKS */
289
290#endif /* _JFFS2_DEBUG_H_ */