blob: c4f8eef5ca68b79d82aee1314166ce61802a90b7 [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.
David Woodhouse6088c052010-08-08 14:15:22 +01005 * Copyright © 2004-2010 David Woodhouse <dwmw2@infradead.org>
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +01006 *
7 * Created by David Woodhouse <dwmw2@infradead.org>
8 *
9 * For licensing information, see the file 'LICENCE' in this directory.
10 *
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010011 */
David Woodhousec00c3102007-04-25 14:16:47 +010012
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010013#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
David Woodhouse2c61cb22008-04-23 16:43:15 +010042#define JFFS2_DBG_READINODE2_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010043#define JFFS2_DBG_MEMALLOC_MESSAGES
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010044#endif
45
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010046/* Sanity checks are supposed to be light-weight and enabled by default */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010047#define JFFS2_DBG_SANITY_CHECKS
48
Thomas Gleixner182ec4e2005-11-07 11:16:07 +000049/*
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010050 * Dx() are mainly used for debugging messages, they must go away and be
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010051 * superseded by nicer dbg_xxx() macros...
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010052 */
53#if CONFIG_JFFS2_FS_DEBUG > 0
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010054#define D1(x) x
55#else
56#define D1(x)
57#endif
58
59#if CONFIG_JFFS2_FS_DEBUG > 1
60#define D2(x) x
61#else
62#define D2(x)
63#endif
64
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010065/* The prefixes of JFFS2 messages */
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010066#define JFFS2_DBG_PREFIX "[JFFS2 DBG]"
67#define JFFS2_ERR_PREFIX "JFFS2 error:"
68#define JFFS2_WARN_PREFIX "JFFS2 warning:"
69#define JFFS2_NOTICE_PREFIX "JFFS2 notice:"
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010070
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010071#define JFFS2_ERR KERN_ERR
72#define JFFS2_WARN KERN_WARNING
73#define JFFS2_NOT KERN_NOTICE
74#define JFFS2_DBG KERN_DEBUG
75
76#define JFFS2_DBG_MSG_PREFIX JFFS2_DBG JFFS2_DBG_PREFIX
77#define JFFS2_ERR_MSG_PREFIX JFFS2_ERR JFFS2_ERR_PREFIX
78#define JFFS2_WARN_MSG_PREFIX JFFS2_WARN JFFS2_WARN_PREFIX
79#define JFFS2_NOTICE_MSG_PREFIX JFFS2_NOT JFFS2_NOTICE_PREFIX
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010080
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010081/* JFFS2 message macros */
82#define JFFS2_ERROR(fmt, ...) \
83 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010084 printk(JFFS2_ERR_MSG_PREFIX \
Pavel Emelyanovba25f9d2007-10-18 23:40:40 -070085 " (%d) %s: " fmt, task_pid_nr(current), \
Harvey Harrison8e24eea2008-04-30 00:55:09 -070086 __func__ , ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010087 } while(0)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010088
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010089#define JFFS2_WARNING(fmt, ...) \
90 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010091 printk(JFFS2_WARN_MSG_PREFIX \
Pavel Emelyanovba25f9d2007-10-18 23:40:40 -070092 " (%d) %s: " fmt, task_pid_nr(current), \
Harvey Harrison8e24eea2008-04-30 00:55:09 -070093 __func__ , ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010094 } while(0)
Thomas Gleixner182ec4e2005-11-07 11:16:07 +000095
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010096#define JFFS2_NOTICE(fmt, ...) \
97 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010098 printk(JFFS2_NOTICE_MSG_PREFIX \
Pavel Emelyanovba25f9d2007-10-18 23:40:40 -070099 " (%d) %s: " fmt, task_pid_nr(current), \
Harvey Harrison8e24eea2008-04-30 00:55:09 -0700100 __func__ , ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100101 } while(0)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100102
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100103#define JFFS2_DEBUG(fmt, ...) \
104 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +0100105 printk(JFFS2_DBG_MSG_PREFIX \
Pavel Emelyanovba25f9d2007-10-18 23:40:40 -0700106 " (%d) %s: " fmt, task_pid_nr(current), \
Harvey Harrison8e24eea2008-04-30 00:55:09 -0700107 __func__ , ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100108 } while(0)
109
Thomas Gleixner182ec4e2005-11-07 11:16:07 +0000110/*
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100111 * We split our debugging messages on several parts, depending on the JFFS2
112 * subsystem the message belongs to.
113 */
114/* Read inode debugging messages */
115#ifdef JFFS2_DBG_READINODE_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100116#define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100117#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100118#define dbg_readinode(fmt, ...)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100119#endif
David Woodhouse2c61cb22008-04-23 16:43:15 +0100120#ifdef JFFS2_DBG_READINODE2_MESSAGES
121#define dbg_readinode2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
122#else
123#define dbg_readinode2(fmt, ...)
124#endif
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100125
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100126/* Fragtree build debugging messages */
127#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100128#define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100129#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100130#define dbg_fragtree(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100131#endif
Artem B. Bityutskiye0e30062005-07-31 10:08:41 +0100132#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100133#define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0e30062005-07-31 10:08:41 +0100134#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100135#define dbg_fragtree2(fmt, ...)
Artem B. Bityutskiye0e30062005-07-31 10:08:41 +0100136#endif
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100137
138/* Directory entry list manilulation debugging messages */
139#ifdef JFFS2_DBG_DENTLIST_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100140#define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100141#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100142#define dbg_dentlist(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100143#endif
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100144
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100145/* Print the messages about manipulating node_refs */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100146#ifdef JFFS2_DBG_NODEREF_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100147#define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100148#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100149#define dbg_noderef(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100150#endif
151
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100152/* Manipulations with the list of inodes (JFFS2 inocache) */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100153#ifdef JFFS2_DBG_INOCACHE_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100154#define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100155#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100156#define dbg_inocache(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100157#endif
158
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100159/* Summary debugging messages */
160#ifdef JFFS2_DBG_SUMMARY_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100161#define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100162#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100163#define dbg_summary(fmt, ...)
164#endif
165
166/* File system build messages */
167#ifdef JFFS2_DBG_FSBUILD_MESSAGES
168#define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
169#else
170#define dbg_fsbuild(fmt, ...)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100171#endif
172
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100173/* Watch the object allocations */
174#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100175#define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100176#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100177#define dbg_memalloc(fmt, ...)
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100178#endif
179
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900180/* Watch the XATTR subsystem */
181#ifdef JFFS2_DBG_XATTR_MESSAGES
182#define dbg_xattr(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
183#else
184#define dbg_xattr(fmt, ...)
185#endif
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100186
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100187/* "Sanity" checks */
188void
189__jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
190 struct jffs2_eraseblock *jeb);
191void
192__jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
193 struct jffs2_eraseblock *jeb);
194
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100195/* "Paranoia" checks */
196void
197__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
198void
199__jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
200void
201__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
202 struct jffs2_eraseblock *jeb);
203void
204__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
205 struct jffs2_eraseblock *jeb);
206void
207__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
208 uint32_t ofs, int len);
209
210/* "Dump" functions */
211void
212__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
213void
214__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
215void
216__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
217void
218__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
219void
220__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
221 struct jffs2_eraseblock *jeb);
222void
223__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
224 struct jffs2_eraseblock *jeb);
225void
226__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
227void
228__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
229void
230__jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
231void
232__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
233
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100234#ifdef JFFS2_DBG_PARANOIA_CHECKS
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100235#define jffs2_dbg_fragtree_paranoia_check(f) \
236 __jffs2_dbg_fragtree_paranoia_check(f)
237#define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
238 __jffs2_dbg_fragtree_paranoia_check_nolock(f)
239#define jffs2_dbg_acct_paranoia_check(c, jeb) \
240 __jffs2_dbg_acct_paranoia_check(c,jeb)
241#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
242 __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
243#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
244 __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100245#else
246#define jffs2_dbg_fragtree_paranoia_check(f)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100247#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100248#define jffs2_dbg_acct_paranoia_check(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100249#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100250#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
251#endif /* !JFFS2_PARANOIA_CHECKS */
252
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100253#ifdef JFFS2_DBG_DUMPS
254#define jffs2_dbg_dump_jeb(c, jeb) \
255 __jffs2_dbg_dump_jeb(c, jeb);
256#define jffs2_dbg_dump_jeb_nolock(jeb) \
257 __jffs2_dbg_dump_jeb_nolock(jeb);
258#define jffs2_dbg_dump_block_lists(c) \
259 __jffs2_dbg_dump_block_lists(c)
260#define jffs2_dbg_dump_block_lists_nolock(c) \
261 __jffs2_dbg_dump_block_lists_nolock(c)
262#define jffs2_dbg_dump_fragtree(f) \
263 __jffs2_dbg_dump_fragtree(f);
264#define jffs2_dbg_dump_fragtree_nolock(f) \
265 __jffs2_dbg_dump_fragtree_nolock(f);
266#define jffs2_dbg_dump_buffer(buf, len, offs) \
267 __jffs2_dbg_dump_buffer(*buf, len, offs);
268#define jffs2_dbg_dump_node(c, ofs) \
269 __jffs2_dbg_dump_node(c, ofs);
270#else
271#define jffs2_dbg_dump_jeb(c, jeb)
272#define jffs2_dbg_dump_jeb_nolock(jeb)
273#define jffs2_dbg_dump_block_lists(c)
274#define jffs2_dbg_dump_block_lists_nolock(c)
275#define jffs2_dbg_dump_fragtree(f)
276#define jffs2_dbg_dump_fragtree_nolock(f)
277#define jffs2_dbg_dump_buffer(buf, len, offs)
278#define jffs2_dbg_dump_node(c, ofs)
279#endif /* !JFFS2_DBG_DUMPS */
280
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100281#ifdef JFFS2_DBG_SANITY_CHECKS
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100282#define jffs2_dbg_acct_sanity_check(c, jeb) \
283 __jffs2_dbg_acct_sanity_check(c, jeb)
284#define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \
285 __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100286#else
287#define jffs2_dbg_acct_sanity_check(c, jeb)
288#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100289#endif /* !JFFS2_DBG_SANITY_CHECKS */
290
291#endif /* _JFFS2_DEBUG_H_ */