blob: 60e5dbb3946a36589f9e6470e54ba2f10bb05449 [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 *
Ferenc Havasie631ddb2005-09-07 09:35:26 +010010 * $Id: debug.h,v 1.15 2005/09/07 08:34:54 havasi 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 */
58#define JFFS2_DBG_MSG_PREFIX "[JFFS2 DBG]"
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010059#define JFFS2_ERR_MSG_PREFIX "JFFS2 error:"
60#define JFFS2_WARN_MSG_PREFIX "JFFS2 warning:"
61#define JFFS2_NOTICE_MSG_PREFIX "JFFS2 notice:"
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010062
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010063#define JFFS2_ERR_LVL KERN_ERR
64#define JFFS2_WARN_LVL KERN_WARNING
65#define JFFS2_NOTICE_LVL KERN_NOTICE
66#define JFFS2_DBG_LVL KERN_DEBUG
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010067
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010068/* JFFS2 message macros */
69#define JFFS2_ERROR(fmt, ...) \
70 do { \
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010071 printk(JFFS2_ERR_LVL JFFS2_ERR_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010072 " (%d) %s: " fmt, current->pid, \
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010073 __FUNCTION__, ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010074 } while(0)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010075
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010076#define JFFS2_WARNING(fmt, ...) \
77 do { \
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010078 printk(JFFS2_WARN_LVL JFFS2_WARN_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010079 " (%d) %s: " fmt, current->pid, \
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010080 __FUNCTION__, ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010081 } while(0)
82
83#define JFFS2_NOTICE(fmt, ...) \
84 do { \
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010085 printk(JFFS2_NOTICE_LVL JFFS2_NOTICE_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010086 " (%d) %s: " fmt, current->pid, \
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010087 __FUNCTION__, ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010088 } while(0)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010089
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010090#define JFFS2_DEBUG(fmt, ...) \
91 do { \
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010092 printk(JFFS2_DBG_LVL JFFS2_DBG_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010093 " (%d) %s: " fmt, current->pid, \
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010094 __FUNCTION__, ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010095 } while(0)
96
97/*
98 * We split our debugging messages on several parts, depending on the JFFS2
99 * subsystem the message belongs to.
100 */
101/* Read inode debugging messages */
102#ifdef JFFS2_DBG_READINODE_MESSAGES
103#define JFFS2_DBG_READINODE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
104#else
105#define JFFS2_DBG_READINODE(fmt, ...)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100106#endif
107
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100108/* Fragtree build debugging messages */
109#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
110#define JFFS2_DBG_FRAGTREE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
111#else
112#define JFFS2_DBG_FRAGTREE(fmt, ...)
113#endif
Artem B. Bityutskiye0e30062005-07-31 10:08:41 +0100114#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
115#define JFFS2_DBG_FRAGTREE2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
116#else
117#define JFFS2_DBG_FRAGTREE2(fmt, ...)
118#endif
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100119
120/* Directory entry list manilulation debugging messages */
121#ifdef JFFS2_DBG_DENTLIST_MESSAGES
122#define JFFS2_DBG_DENTLIST(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
123#else
124#define JFFS2_DBG_DENTLIST(fmt, ...)
125#endif
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100126
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100127/* Print the messages about manipulating node_refs */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100128#ifdef JFFS2_DBG_NODEREF_MESSAGES
129#define JFFS2_DBG_NODEREF(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
130#else
131#define JFFS2_DBG_NODEREF(fmt, ...)
132#endif
133
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100134/* Manipulations with the list of inodes (JFFS2 inocache) */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100135#ifdef JFFS2_DBG_INOCACHE_MESSAGES
136#define JFFS2_DBG_INOCACHE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
137#else
138#define JFFS2_DBG_INOCACHE(fmt, ...)
139#endif
140
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100141/* Summary debugging messages */
142#ifdef JFFS2_DBG_SUMMARY_MESSAGES
143#define JFFS2_DBG_SUMMARY(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
144#else
145#define JFFS2_DBG_SUMMARY(fmt, ...)
146#endif
147
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100148/* Watch the object allocations */
149#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
150#define JFFS2_DBG_MEMALLOC(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
151#else
152#define JFFS2_DBG_MEMALLOC(fmt, ...)
153#endif
154
155
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100156/* "Sanity" checks */
157void
158__jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
159 struct jffs2_eraseblock *jeb);
160void
161__jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
162 struct jffs2_eraseblock *jeb);
163
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100164/* "Paranoia" checks */
165void
166__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
167void
168__jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
169void
170__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
171 struct jffs2_eraseblock *jeb);
172void
173__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
174 struct jffs2_eraseblock *jeb);
175void
176__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
177 uint32_t ofs, int len);
178
179/* "Dump" functions */
180void
181__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
182void
183__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
184void
185__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
186void
187__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
188void
189__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
190 struct jffs2_eraseblock *jeb);
191void
192__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
193 struct jffs2_eraseblock *jeb);
194void
195__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
196void
197__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
198void
199__jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
200void
201__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
202
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100203#ifdef JFFS2_DBG_PARANOIA_CHECKS
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100204#define jffs2_dbg_fragtree_paranoia_check(f) \
205 __jffs2_dbg_fragtree_paranoia_check(f)
206#define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
207 __jffs2_dbg_fragtree_paranoia_check_nolock(f)
208#define jffs2_dbg_acct_paranoia_check(c, jeb) \
209 __jffs2_dbg_acct_paranoia_check(c,jeb)
210#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
211 __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
212#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
213 __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100214#else
215#define jffs2_dbg_fragtree_paranoia_check(f)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100216#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100217#define jffs2_dbg_acct_paranoia_check(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100218#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100219#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
220#endif /* !JFFS2_PARANOIA_CHECKS */
221
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100222#ifdef JFFS2_DBG_DUMPS
223#define jffs2_dbg_dump_jeb(c, jeb) \
224 __jffs2_dbg_dump_jeb(c, jeb);
225#define jffs2_dbg_dump_jeb_nolock(jeb) \
226 __jffs2_dbg_dump_jeb_nolock(jeb);
227#define jffs2_dbg_dump_block_lists(c) \
228 __jffs2_dbg_dump_block_lists(c)
229#define jffs2_dbg_dump_block_lists_nolock(c) \
230 __jffs2_dbg_dump_block_lists_nolock(c)
231#define jffs2_dbg_dump_fragtree(f) \
232 __jffs2_dbg_dump_fragtree(f);
233#define jffs2_dbg_dump_fragtree_nolock(f) \
234 __jffs2_dbg_dump_fragtree_nolock(f);
235#define jffs2_dbg_dump_buffer(buf, len, offs) \
236 __jffs2_dbg_dump_buffer(*buf, len, offs);
237#define jffs2_dbg_dump_node(c, ofs) \
238 __jffs2_dbg_dump_node(c, ofs);
239#else
240#define jffs2_dbg_dump_jeb(c, jeb)
241#define jffs2_dbg_dump_jeb_nolock(jeb)
242#define jffs2_dbg_dump_block_lists(c)
243#define jffs2_dbg_dump_block_lists_nolock(c)
244#define jffs2_dbg_dump_fragtree(f)
245#define jffs2_dbg_dump_fragtree_nolock(f)
246#define jffs2_dbg_dump_buffer(buf, len, offs)
247#define jffs2_dbg_dump_node(c, ofs)
248#endif /* !JFFS2_DBG_DUMPS */
249
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100250#ifdef JFFS2_DBG_SANITY_CHECKS
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100251#define jffs2_dbg_acct_sanity_check(c, jeb) \
252 __jffs2_dbg_acct_sanity_check(c, jeb)
253#define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \
254 __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100255#else
256#define jffs2_dbg_acct_sanity_check(c, jeb)
257#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100258#endif /* !JFFS2_DBG_SANITY_CHECKS */
259
260#endif /* _JFFS2_DEBUG_H_ */