debug.h 7.7 KB
Newer Older
1 2 3 4 5 6 7 8 9
/*
 * JFFS2 -- Journalling Flash File System, Version 2.
 *
 * Copyright (C) 2001-2003 Red Hat, Inc.
 *
 * Created by David Woodhouse <dwmw2@infradead.org>
 *
 * For licensing information, see the file 'LICENCE' in this directory.
 *
10
 * $Id: debug.h,v 1.16 2005/09/14 16:57:32 dedekind Exp $
11 12 13 14 15 16 17 18
 *
 */
#ifndef _JFFS2_DEBUG_H_
#define _JFFS2_DEBUG_H_

#include <linux/config.h>

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

22 23
#if CONFIG_JFFS2_FS_DEBUG == 1
/* Enable "paranoia" checks and dumps */
24
#define JFFS2_DBG_PARANOIA_CHECKS
25 26 27 28 29 30
#define JFFS2_DBG_DUMPS
#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
31
#define JFFS2_DBG_SUMMARY_MESSAGES
32 33 34 35 36 37
#endif

#if CONFIG_JFFS2_FS_DEBUG == 2
#define JFFS2_DBG_FRAGTREE2_MESSAGES
#endif

38
/* Sanity checks are supposed to be light-weight and enabled by default */
39 40 41 42 43 44 45
#define JFFS2_DBG_SANITY_CHECKS

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

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

57
/* The prefixes of JFFS2 messages */
58 59 60 61
#define JFFS2_DBG_PREFIX	"[JFFS2 DBG]"
#define JFFS2_ERR_PREFIX	"JFFS2 error:"
#define JFFS2_WARN_PREFIX	"JFFS2 warning:"
#define JFFS2_NOTICE_PREFIX	"JFFS2 notice:"
62

63 64 65 66 67 68 69 70 71
#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
72

73 74 75
/* JFFS2 message macros */
#define JFFS2_ERROR(fmt, ...)						\
	do {								\
76
		printk(JFFS2_ERR_MSG_PREFIX				\
77
			" (%d) %s: " fmt, current->pid,			\
78
			__FUNCTION__, ##__VA_ARGS__);			\
79
	} while(0)
80

81 82
#define JFFS2_WARNING(fmt, ...)						\
	do {								\
83
		printk(JFFS2_WARN_MSG_PREFIX				\
84
			" (%d) %s: " fmt, current->pid,			\
85
			__FUNCTION__, ##__VA_ARGS__);			\
86 87 88 89
	} while(0)
			
#define JFFS2_NOTICE(fmt, ...)						\
	do {								\
90
		printk(JFFS2_NOTICE_MSG_PREFIX				\
91
			" (%d) %s: " fmt, current->pid,			\
92
			__FUNCTION__, ##__VA_ARGS__);			\
93
	} while(0)
94

95 96
#define JFFS2_DEBUG(fmt, ...)						\
	do {								\
97
		printk(JFFS2_DBG_MSG_PREFIX				\
98
			" (%d) %s: " fmt, current->pid,			\
99
			__FUNCTION__, ##__VA_ARGS__);			\
100 101 102 103 104 105 106 107 108 109 110
	} while(0)

/* 
 * 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
#define JFFS2_DBG_READINODE(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_READINODE(fmt, ...)
111 112
#endif

113 114 115 116 117 118
/* Fragtree build debugging messages */
#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
#define JFFS2_DBG_FRAGTREE(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_FRAGTREE(fmt, ...)
#endif
119 120 121 122 123
#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
#define JFFS2_DBG_FRAGTREE2(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_FRAGTREE2(fmt, ...)
#endif
124 125 126 127 128 129 130 131

/* Directory entry list manilulation debugging messages */
#ifdef JFFS2_DBG_DENTLIST_MESSAGES
#define JFFS2_DBG_DENTLIST(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_DENTLIST(fmt, ...)
#endif

132
/* Print the messages about manipulating node_refs */
133 134 135 136 137
#ifdef JFFS2_DBG_NODEREF_MESSAGES
#define JFFS2_DBG_NODEREF(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_NODEREF(fmt, ...)
#endif
138

139
/* Manipulations with the list of inodes (JFFS2 inocache) */
140 141 142 143 144 145
#ifdef JFFS2_DBG_INOCACHE_MESSAGES
#define JFFS2_DBG_INOCACHE(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_INOCACHE(fmt, ...)
#endif

146 147 148 149 150 151 152
/* Summary debugging messages */
#ifdef JFFS2_DBG_SUMMARY_MESSAGES
#define JFFS2_DBG_SUMMARY(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_SUMMARY(fmt, ...)
#endif

153 154 155 156 157 158 159 160
/* Watch the object allocations */
#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
#define JFFS2_DBG_MEMALLOC(fmt, ...)	JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define JFFS2_DBG_MEMALLOC(fmt, ...)
#endif


161 162 163 164 165 166 167 168
/* "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);

169 170 171
/* "Paranoia" checks */
void
__jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
172
void
173 174 175 176 177 178 179 180 181 182
__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);
183

184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
/* "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);
203
void
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
__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)
219 220
#else
#define jffs2_dbg_fragtree_paranoia_check(f)
221
#define jffs2_dbg_fragtree_paranoia_check_nolock(f)
222
#define jffs2_dbg_acct_paranoia_check(c, jeb)
223
#define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
224 225 226
#define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
#endif /* !JFFS2_PARANOIA_CHECKS */

227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
#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 */

255
#ifdef JFFS2_DBG_SANITY_CHECKS
256 257 258 259
#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)
260 261 262
#else
#define jffs2_dbg_acct_sanity_check(c, jeb)
#define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
263 264 265
#endif /* !JFFS2_DBG_SANITY_CHECKS */

#endif /* _JFFS2_DEBUG_H_ */