blob: 3daf3bca03767050d1580f6731996e1aaa4d6e6f [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
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
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010041#define JFFS2_DBG_MEMALLOC_MESSAGES
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010042#endif
43
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +010044/* Sanity checks are supposed to be light-weight and enabled by default */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010045#define JFFS2_DBG_SANITY_CHECKS
46
Thomas Gleixner182ec4e2005-11-07 11:16:07 +000047/*
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010048 * Dx() are mainly used for debugging messages, they must go away and be
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +010049 * superseded by nicer dbg_xxx() macros...
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010050 */
51#if CONFIG_JFFS2_FS_DEBUG > 0
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010052#define D1(x) x
53#else
54#define D1(x)
55#endif
56
57#if CONFIG_JFFS2_FS_DEBUG > 1
58#define D2(x) x
59#else
60#define D2(x)
61#endif
62
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010063/* The prefixes of JFFS2 messages */
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010064#define JFFS2_DBG_PREFIX "[JFFS2 DBG]"
65#define JFFS2_ERR_PREFIX "JFFS2 error:"
66#define JFFS2_WARN_PREFIX "JFFS2 warning:"
67#define JFFS2_NOTICE_PREFIX "JFFS2 notice:"
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010068
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010069#define JFFS2_ERR KERN_ERR
70#define JFFS2_WARN KERN_WARNING
71#define JFFS2_NOT KERN_NOTICE
72#define JFFS2_DBG KERN_DEBUG
73
74#define JFFS2_DBG_MSG_PREFIX JFFS2_DBG JFFS2_DBG_PREFIX
75#define JFFS2_ERR_MSG_PREFIX JFFS2_ERR JFFS2_ERR_PREFIX
76#define JFFS2_WARN_MSG_PREFIX JFFS2_WARN JFFS2_WARN_PREFIX
77#define JFFS2_NOTICE_MSG_PREFIX JFFS2_NOT JFFS2_NOTICE_PREFIX
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010078
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010079/* JFFS2 message macros */
80#define JFFS2_ERROR(fmt, ...) \
81 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010082 printk(JFFS2_ERR_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010083 " (%d) %s: " fmt, current->pid, \
Andrew Morton02b70682005-11-23 13:37:47 -080084 __FUNCTION__ , ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010085 } while(0)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +010086
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010087#define JFFS2_WARNING(fmt, ...) \
88 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010089 printk(JFFS2_WARN_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010090 " (%d) %s: " fmt, current->pid, \
Andrew Morton02b70682005-11-23 13:37:47 -080091 __FUNCTION__ , ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010092 } while(0)
Thomas Gleixner182ec4e2005-11-07 11:16:07 +000093
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010094#define JFFS2_NOTICE(fmt, ...) \
95 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +010096 printk(JFFS2_NOTICE_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +010097 " (%d) %s: " fmt, current->pid, \
Andrew Morton02b70682005-11-23 13:37:47 -080098 __FUNCTION__ , ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +010099 } while(0)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100100
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100101#define JFFS2_DEBUG(fmt, ...) \
102 do { \
Artem B. Bityutskiy81e39cf2005-09-14 17:57:35 +0100103 printk(JFFS2_DBG_MSG_PREFIX \
Artem B. Bityutskiy8d5df402005-08-17 15:13:48 +0100104 " (%d) %s: " fmt, current->pid, \
Andrew Morton02b70682005-11-23 13:37:47 -0800105 __FUNCTION__ , ##__VA_ARGS__); \
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100106 } while(0)
107
Thomas Gleixner182ec4e2005-11-07 11:16:07 +0000108/*
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100109 * We split our debugging messages on several parts, depending on the JFFS2
110 * subsystem the message belongs to.
111 */
112/* Read inode debugging messages */
113#ifdef JFFS2_DBG_READINODE_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100114#define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100115#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100116#define dbg_readinode(fmt, ...)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100117#endif
118
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100119/* Fragtree build debugging messages */
120#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100121#define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100122#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100123#define dbg_fragtree(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100124#endif
Artem B. Bityutskiye0e30062005-07-31 10:08:41 +0100125#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100126#define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0e30062005-07-31 10:08:41 +0100127#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100128#define dbg_fragtree2(fmt, ...)
Artem B. Bityutskiye0e30062005-07-31 10:08:41 +0100129#endif
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100130
131/* Directory entry list manilulation debugging messages */
132#ifdef JFFS2_DBG_DENTLIST_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100133#define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100134#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100135#define dbg_dentlist(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100136#endif
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100137
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100138/* Print the messages about manipulating node_refs */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100139#ifdef JFFS2_DBG_NODEREF_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100140#define dbg_noderef(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_noderef(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100143#endif
144
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100145/* Manipulations with the list of inodes (JFFS2 inocache) */
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100146#ifdef JFFS2_DBG_INOCACHE_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100147#define dbg_inocache(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_inocache(fmt, ...)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100150#endif
151
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100152/* Summary debugging messages */
153#ifdef JFFS2_DBG_SUMMARY_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100154#define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100155#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100156#define dbg_summary(fmt, ...)
157#endif
158
159/* File system build messages */
160#ifdef JFFS2_DBG_FSBUILD_MESSAGES
161#define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
162#else
163#define dbg_fsbuild(fmt, ...)
Ferenc Havasie631ddb2005-09-07 09:35:26 +0100164#endif
165
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100166/* Watch the object allocations */
167#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100168#define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100169#else
Artem B. Bityutskiy733802d2005-09-22 12:25:00 +0100170#define dbg_memalloc(fmt, ...)
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100171#endif
172
KaiGai Koheiaa98d7c2006-05-13 15:09:47 +0900173/* Watch the XATTR subsystem */
174#ifdef JFFS2_DBG_XATTR_MESSAGES
175#define dbg_xattr(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
176#else
177#define dbg_xattr(fmt, ...)
178#endif
Artem B. Bityutskiyf538c962005-07-27 15:16:57 +0100179
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100180/* "Sanity" checks */
181void
182__jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
183 struct jffs2_eraseblock *jeb);
184void
185__jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
186 struct jffs2_eraseblock *jeb);
187
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100188/* "Paranoia" checks */
189void
190__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
191void
192__jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
193void
194__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
195 struct jffs2_eraseblock *jeb);
196void
197__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
198 struct jffs2_eraseblock *jeb);
199void
200__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
201 uint32_t ofs, int len);
202
203/* "Dump" functions */
204void
205__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
206void
207__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
208void
209__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
210void
211__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
212void
213__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
214 struct jffs2_eraseblock *jeb);
215void
216__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
217 struct jffs2_eraseblock *jeb);
218void
219__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
220void
221__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
222void
223__jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
224void
225__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
226
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100227#ifdef JFFS2_DBG_PARANOIA_CHECKS
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100228#define jffs2_dbg_fragtree_paranoia_check(f) \
229 __jffs2_dbg_fragtree_paranoia_check(f)
230#define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
231 __jffs2_dbg_fragtree_paranoia_check_nolock(f)
232#define jffs2_dbg_acct_paranoia_check(c, jeb) \
233 __jffs2_dbg_acct_paranoia_check(c,jeb)
234#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
235 __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
236#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
237 __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100238#else
239#define jffs2_dbg_fragtree_paranoia_check(f)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100240#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100241#define jffs2_dbg_acct_paranoia_check(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100242#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100243#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
244#endif /* !JFFS2_PARANOIA_CHECKS */
245
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100246#ifdef JFFS2_DBG_DUMPS
247#define jffs2_dbg_dump_jeb(c, jeb) \
248 __jffs2_dbg_dump_jeb(c, jeb);
249#define jffs2_dbg_dump_jeb_nolock(jeb) \
250 __jffs2_dbg_dump_jeb_nolock(jeb);
251#define jffs2_dbg_dump_block_lists(c) \
252 __jffs2_dbg_dump_block_lists(c)
253#define jffs2_dbg_dump_block_lists_nolock(c) \
254 __jffs2_dbg_dump_block_lists_nolock(c)
255#define jffs2_dbg_dump_fragtree(f) \
256 __jffs2_dbg_dump_fragtree(f);
257#define jffs2_dbg_dump_fragtree_nolock(f) \
258 __jffs2_dbg_dump_fragtree_nolock(f);
259#define jffs2_dbg_dump_buffer(buf, len, offs) \
260 __jffs2_dbg_dump_buffer(*buf, len, offs);
261#define jffs2_dbg_dump_node(c, ofs) \
262 __jffs2_dbg_dump_node(c, ofs);
263#else
264#define jffs2_dbg_dump_jeb(c, jeb)
265#define jffs2_dbg_dump_jeb_nolock(jeb)
266#define jffs2_dbg_dump_block_lists(c)
267#define jffs2_dbg_dump_block_lists_nolock(c)
268#define jffs2_dbg_dump_fragtree(f)
269#define jffs2_dbg_dump_fragtree_nolock(f)
270#define jffs2_dbg_dump_buffer(buf, len, offs)
271#define jffs2_dbg_dump_node(c, ofs)
272#endif /* !JFFS2_DBG_DUMPS */
273
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100274#ifdef JFFS2_DBG_SANITY_CHECKS
Artem B. Bityutskiy45ca1b52005-08-05 12:43:47 +0100275#define jffs2_dbg_acct_sanity_check(c, jeb) \
276 __jffs2_dbg_acct_sanity_check(c, jeb)
277#define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \
278 __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiye0c8e422005-07-24 16:14:17 +0100279#else
280#define jffs2_dbg_acct_sanity_check(c, jeb)
281#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
Artem B. Bityutskiy730554d2005-07-17 07:56:26 +0100282#endif /* !JFFS2_DBG_SANITY_CHECKS */
283
284#endif /* _JFFS2_DEBUG_H_ */