debug.h 8.1 KB
Newer Older
1 2 3
/*
 * JFFS2 -- Journalling Flash File System, Version 2.
 *
4
 * Copyright © 2001-2007 Red Hat, Inc.
5 6 7 8 9 10
 *
 * Created by David Woodhouse <dwmw2@infradead.org>
 *
 * For licensing information, see the file 'LICENCE' in this directory.
 *
 */
11

12 13 14
#ifndef _JFFS2_DEBUG_H_
#define _JFFS2_DEBUG_H_

15
#include <linux/sched.h>
16 17

#ifndef CONFIG_JFFS2_FS_DEBUG
18
#define CONFIG_JFFS2_FS_DEBUG 0
19 20
#endif

21
#if CONFIG_JFFS2_FS_DEBUG > 0
22
/* Enable "paranoia" checks and dumps */
23
#define JFFS2_DBG_PARANOIA_CHECKS
24
#define JFFS2_DBG_DUMPS
25

26
/*
27 28 29
 * By defining/undefining the below macros one may select debugging messages
 * fro specific JFFS2 subsystems.
 */
30 31 32 33 34
#define JFFS2_DBG_READINODE_MESSAGES
#define JFFS2_DBG_FRAGTREE_MESSAGES
#define JFFS2_DBG_DENTLIST_MESSAGES
#define JFFS2_DBG_NODEREF_MESSAGES
#define JFFS2_DBG_INOCACHE_MESSAGES
35
#define JFFS2_DBG_SUMMARY_MESSAGES
36
#define JFFS2_DBG_FSBUILD_MESSAGES
37 38
#endif

39
#if CONFIG_JFFS2_FS_DEBUG > 1
40
#define JFFS2_DBG_FRAGTREE2_MESSAGES
41
#define JFFS2_DBG_MEMALLOC_MESSAGES
42 43
#endif

44
/* Sanity checks are supposed to be light-weight and enabled by default */
45 46
#define JFFS2_DBG_SANITY_CHECKS

47
/*
48
 * Dx() are mainly used for debugging messages, they must go away and be
49
 * superseded by nicer dbg_xxx() macros...
50 51
 */
#if CONFIG_JFFS2_FS_DEBUG > 0
52 53 54 55 56 57 58 59 60 61 62
#define D1(x) x
#else
#define D1(x)
#endif

#if CONFIG_JFFS2_FS_DEBUG > 1
#define D2(x) x
#else
#define D2(x)
#endif

63
/* The prefixes of JFFS2 messages */
64 65 66 67
#define JFFS2_DBG_PREFIX	"[JFFS2 DBG]"
#define JFFS2_ERR_PREFIX	"JFFS2 error:"
#define JFFS2_WARN_PREFIX	"JFFS2 warning:"
#define JFFS2_NOTICE_PREFIX	"JFFS2 notice:"
68

69 70 71 72 73 74 75 76 77
#define JFFS2_ERR	KERN_ERR
#define JFFS2_WARN	KERN_WARNING
#define JFFS2_NOT	KERN_NOTICE
#define JFFS2_DBG	KERN_DEBUG

#define JFFS2_DBG_MSG_PREFIX	JFFS2_DBG JFFS2_DBG_PREFIX
#define JFFS2_ERR_MSG_PREFIX	JFFS2_ERR JFFS2_ERR_PREFIX
#define JFFS2_WARN_MSG_PREFIX	JFFS2_WARN JFFS2_WARN_PREFIX
#define JFFS2_NOTICE_MSG_PREFIX	JFFS2_NOT JFFS2_NOTICE_PREFIX
78

79 80 81
/* JFFS2 message macros */
#define JFFS2_ERROR(fmt, ...)						\
	do {								\
82
		printk(JFFS2_ERR_MSG_PREFIX				\
83
			" (%d) %s: " fmt, current->pid,			\
A
Andrew Morton 已提交
84
			__FUNCTION__ , ##__VA_ARGS__);			\
85
	} while(0)
86

87 88
#define JFFS2_WARNING(fmt, ...)						\
	do {								\
89
		printk(JFFS2_WARN_MSG_PREFIX				\
90
			" (%d) %s: " fmt, current->pid,			\
A
Andrew Morton 已提交
91
			__FUNCTION__ , ##__VA_ARGS__);			\
92
	} while(0)
93

94 95
#define JFFS2_NOTICE(fmt, ...)						\
	do {								\
96
		printk(JFFS2_NOTICE_MSG_PREFIX				\
97
			" (%d) %s: " fmt, current->pid,			\
A
Andrew Morton 已提交
98
			__FUNCTION__ , ##__VA_ARGS__);			\
99
	} while(0)
100

101 102
#define JFFS2_DEBUG(fmt, ...)						\
	do {								\
103
		printk(JFFS2_DBG_MSG_PREFIX				\
104
			" (%d) %s: " fmt, current->pid,			\
A
Andrew Morton 已提交
105
			__FUNCTION__ , ##__VA_ARGS__);			\
106 107
	} while(0)

108
/*
109 110 111 112 113
 * We split our debugging messages on several parts, depending on the JFFS2
 * subsystem the message belongs to.
 */
/* Read inode debugging messages */
#ifdef JFFS2_DBG_READINODE_MESSAGES
114
#define dbg_readinode(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
115
#else
116
#define dbg_readinode(fmt, ...)
117 118
#endif

119 120
/* Fragtree build debugging messages */
#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
121
#define dbg_fragtree(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
122
#else
123
#define dbg_fragtree(fmt, ...)
124
#endif
125
#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
126
#define dbg_fragtree2(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
127
#else
128
#define dbg_fragtree2(fmt, ...)
129
#endif
130 131 132

/* Directory entry list manilulation debugging messages */
#ifdef JFFS2_DBG_DENTLIST_MESSAGES
133
#define dbg_dentlist(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
134
#else
135
#define dbg_dentlist(fmt, ...)
136 137
#endif

138
/* Print the messages about manipulating node_refs */
139
#ifdef JFFS2_DBG_NODEREF_MESSAGES
140
#define dbg_noderef(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
141
#else
142
#define dbg_noderef(fmt, ...)
143
#endif
144

145
/* Manipulations with the list of inodes (JFFS2 inocache) */
146
#ifdef JFFS2_DBG_INOCACHE_MESSAGES
147
#define dbg_inocache(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
148
#else
149
#define dbg_inocache(fmt, ...)
150 151
#endif

152 153
/* Summary debugging messages */
#ifdef JFFS2_DBG_SUMMARY_MESSAGES
154 155 156 157 158 159 160 161
#define dbg_summary(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_summary(fmt, ...)
#endif

/* File system build messages */
#ifdef JFFS2_DBG_FSBUILD_MESSAGES
#define dbg_fsbuild(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
162
#else
163
#define dbg_fsbuild(fmt, ...)
164 165
#endif

166 167
/* Watch the object allocations */
#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
168
#define dbg_memalloc(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
169
#else
170
#define dbg_memalloc(fmt, ...)
171 172
#endif

173 174 175 176 177 178
/* Watch the XATTR subsystem */
#ifdef JFFS2_DBG_XATTR_MESSAGES
#define dbg_xattr(fmt, ...)  JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_xattr(fmt, ...)
#endif 
179

180 181 182 183 184 185 186 187
/* "Sanity" checks */
void
__jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
				     struct jffs2_eraseblock *jeb);
void
__jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
			      struct jffs2_eraseblock *jeb);

188 189 190
/* "Paranoia" checks */
void
__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
191
void
192 193 194 195 196 197 198 199 200 201
__jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
void
__jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
			   	struct jffs2_eraseblock *jeb);
void
__jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
				       struct jffs2_eraseblock *jeb);
void
__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
				    uint32_t ofs, int len);
202

203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
/* "Dump" functions */
void
__jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
void
__jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
void
__jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
void
__jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
void
__jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
		 	   struct jffs2_eraseblock *jeb);
void
__jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
				  struct jffs2_eraseblock *jeb);
void
__jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
void
__jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
222
void
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
__jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
void
__jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);

#ifdef JFFS2_DBG_PARANOIA_CHECKS
#define jffs2_dbg_fragtree_paranoia_check(f)			\
	__jffs2_dbg_fragtree_paranoia_check(f)
#define jffs2_dbg_fragtree_paranoia_check_nolock(f)		\
	__jffs2_dbg_fragtree_paranoia_check_nolock(f)
#define jffs2_dbg_acct_paranoia_check(c, jeb)			\
	__jffs2_dbg_acct_paranoia_check(c,jeb)
#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)		\
	__jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)		\
	__jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
238 239
#else
#define jffs2_dbg_fragtree_paranoia_check(f)
240
#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
241
#define jffs2_dbg_acct_paranoia_check(c, jeb)
242
#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
243 244 245
#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
#endif /* !JFFS2_PARANOIA_CHECKS */

246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
#ifdef JFFS2_DBG_DUMPS
#define jffs2_dbg_dump_jeb(c, jeb)				\
	__jffs2_dbg_dump_jeb(c, jeb);
#define jffs2_dbg_dump_jeb_nolock(jeb)				\
	__jffs2_dbg_dump_jeb_nolock(jeb);
#define jffs2_dbg_dump_block_lists(c)				\
	__jffs2_dbg_dump_block_lists(c)
#define jffs2_dbg_dump_block_lists_nolock(c)			\
	__jffs2_dbg_dump_block_lists_nolock(c)
#define jffs2_dbg_dump_fragtree(f)				\
	__jffs2_dbg_dump_fragtree(f);
#define jffs2_dbg_dump_fragtree_nolock(f)			\
	__jffs2_dbg_dump_fragtree_nolock(f);
#define jffs2_dbg_dump_buffer(buf, len, offs)			\
	__jffs2_dbg_dump_buffer(*buf, len, offs);
#define jffs2_dbg_dump_node(c, ofs)				\
	__jffs2_dbg_dump_node(c, ofs);
#else
#define jffs2_dbg_dump_jeb(c, jeb)
#define jffs2_dbg_dump_jeb_nolock(jeb)
#define jffs2_dbg_dump_block_lists(c)
#define jffs2_dbg_dump_block_lists_nolock(c)
#define jffs2_dbg_dump_fragtree(f)
#define jffs2_dbg_dump_fragtree_nolock(f)
#define jffs2_dbg_dump_buffer(buf, len, offs)
#define jffs2_dbg_dump_node(c, ofs)
#endif /* !JFFS2_DBG_DUMPS */

274
#ifdef JFFS2_DBG_SANITY_CHECKS
275 276 277 278
#define jffs2_dbg_acct_sanity_check(c, jeb)			\
	__jffs2_dbg_acct_sanity_check(c, jeb)
#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)		\
	__jffs2_dbg_acct_sanity_check_nolock(c, jeb)
279 280 281
#else
#define jffs2_dbg_acct_sanity_check(c, jeb)
#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
282 283 284
#endif /* !JFFS2_DBG_SANITY_CHECKS */

#endif /* _JFFS2_DEBUG_H_ */