2005-07-17 10:56:26 +04:00
/*
* 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 .
*
2005-11-07 14:16:07 +03:00
* $ Id : debug . h , v 1.21 2005 / 11 / 07 11 : 14 : 39 gleixner Exp $
2005-07-17 10:56:26 +04:00
*
*/
# ifndef _JFFS2_DEBUG_H_
# define _JFFS2_DEBUG_H_
2007-01-13 03:19:03 +03:00
# include <linux/sched.h>
2005-07-17 10:56:26 +04:00
# ifndef CONFIG_JFFS2_FS_DEBUG
2005-07-27 18:16:57 +04:00
# define CONFIG_JFFS2_FS_DEBUG 0
2005-07-17 10:56:26 +04:00
# endif
2005-10-24 20:22:36 +04:00
# if CONFIG_JFFS2_FS_DEBUG > 0
2005-07-24 19:14:17 +04:00
/* Enable "paranoia" checks and dumps */
2005-07-17 10:56:26 +04:00
# define JFFS2_DBG_PARANOIA_CHECKS
2005-07-24 19:14:17 +04:00
# define JFFS2_DBG_DUMPS
2005-09-22 15:25:00 +04:00
2005-11-07 14:16:07 +03:00
/*
2005-09-22 15:25:00 +04:00
* By defining / undefining the below macros one may select debugging messages
* fro specific JFFS2 subsystems .
*/
2005-07-24 19:14:17 +04:00
# 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
2005-09-07 12:35:26 +04:00
# define JFFS2_DBG_SUMMARY_MESSAGES
2005-09-22 15:25:00 +04:00
# define JFFS2_DBG_FSBUILD_MESSAGES
2005-07-24 19:14:17 +04:00
# endif
2005-10-24 20:22:36 +04:00
# if CONFIG_JFFS2_FS_DEBUG > 1
2005-07-24 19:14:17 +04:00
# define JFFS2_DBG_FRAGTREE2_MESSAGES
2005-09-22 15:25:00 +04:00
# define JFFS2_DBG_MEMALLOC_MESSAGES
2005-07-24 19:14:17 +04:00
# endif
2005-08-05 15:43:47 +04:00
/* Sanity checks are supposed to be light-weight and enabled by default */
2005-07-24 19:14:17 +04:00
# define JFFS2_DBG_SANITY_CHECKS
2005-11-07 14:16:07 +03:00
/*
2005-07-24 19:14:17 +04:00
* Dx ( ) are mainly used for debugging messages , they must go away and be
2005-09-22 15:25:00 +04:00
* superseded by nicer dbg_xxx ( ) macros . . .
2005-07-24 19:14:17 +04:00
*/
# if CONFIG_JFFS2_FS_DEBUG > 0
2005-07-17 10:56:26 +04:00
# define D1(x) x
# else
# define D1(x)
# endif
# if CONFIG_JFFS2_FS_DEBUG > 1
# define D2(x) x
# else
# define D2(x)
# endif
2005-07-24 19:14:17 +04:00
/* The prefixes of JFFS2 messages */
2005-09-14 20:57:35 +04:00
# define JFFS2_DBG_PREFIX "[JFFS2 DBG]"
# define JFFS2_ERR_PREFIX "JFFS2 error:"
# define JFFS2_WARN_PREFIX "JFFS2 warning:"
# define JFFS2_NOTICE_PREFIX "JFFS2 notice:"
2005-07-17 10:56:26 +04:00
2005-09-14 20:57:35 +04:00
# 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
2005-07-17 10:56:26 +04:00
2005-07-24 19:14:17 +04:00
/* JFFS2 message macros */
# define JFFS2_ERROR(fmt, ...) \
do { \
2005-09-14 20:57:35 +04:00
printk ( JFFS2_ERR_MSG_PREFIX \
2005-08-17 18:13:48 +04:00
" (%d) %s: " fmt , current - > pid , \
2005-11-24 00:37:47 +03:00
__FUNCTION__ , # # __VA_ARGS__ ) ; \
2005-07-24 19:14:17 +04:00
} while ( 0 )
2005-07-17 10:56:26 +04:00
2005-07-24 19:14:17 +04:00
# define JFFS2_WARNING(fmt, ...) \
do { \
2005-09-14 20:57:35 +04:00
printk ( JFFS2_WARN_MSG_PREFIX \
2005-08-17 18:13:48 +04:00
" (%d) %s: " fmt , current - > pid , \
2005-11-24 00:37:47 +03:00
__FUNCTION__ , # # __VA_ARGS__ ) ; \
2005-07-24 19:14:17 +04:00
} while ( 0 )
2005-11-07 14:16:07 +03:00
2005-07-24 19:14:17 +04:00
# define JFFS2_NOTICE(fmt, ...) \
do { \
2005-09-14 20:57:35 +04:00
printk ( JFFS2_NOTICE_MSG_PREFIX \
2005-08-17 18:13:48 +04:00
" (%d) %s: " fmt , current - > pid , \
2005-11-24 00:37:47 +03:00
__FUNCTION__ , # # __VA_ARGS__ ) ; \
2005-07-24 19:14:17 +04:00
} while ( 0 )
2005-07-17 10:56:26 +04:00
2005-07-24 19:14:17 +04:00
# define JFFS2_DEBUG(fmt, ...) \
do { \
2005-09-14 20:57:35 +04:00
printk ( JFFS2_DBG_MSG_PREFIX \
2005-08-17 18:13:48 +04:00
" (%d) %s: " fmt , current - > pid , \
2005-11-24 00:37:47 +03:00
__FUNCTION__ , # # __VA_ARGS__ ) ; \
2005-07-24 19:14:17 +04:00
} while ( 0 )
2005-11-07 14:16:07 +03:00
/*
2005-07-24 19:14:17 +04:00
* 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
2005-09-22 15:25:00 +04:00
# define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
2005-07-24 19:14:17 +04:00
# else
2005-09-22 15:25:00 +04:00
# define dbg_readinode(fmt, ...)
2005-07-17 10:56:26 +04:00
# endif
2005-07-24 19:14:17 +04:00
/* Fragtree build debugging messages */
# ifdef JFFS2_DBG_FRAGTREE_MESSAGES
2005-09-22 15:25:00 +04:00
# define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
2005-07-24 19:14:17 +04:00
# else
2005-09-22 15:25:00 +04:00
# define dbg_fragtree(fmt, ...)
2005-07-24 19:14:17 +04:00
# endif
2005-07-31 13:08:41 +04:00
# ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
2005-09-22 15:25:00 +04:00
# define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
2005-07-31 13:08:41 +04:00
# else
2005-09-22 15:25:00 +04:00
# define dbg_fragtree2(fmt, ...)
2005-07-31 13:08:41 +04:00
# endif
2005-07-24 19:14:17 +04:00
/* Directory entry list manilulation debugging messages */
# ifdef JFFS2_DBG_DENTLIST_MESSAGES
2005-09-22 15:25:00 +04:00
# define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
2005-07-24 19:14:17 +04:00
# else
2005-09-22 15:25:00 +04:00
# define dbg_dentlist(fmt, ...)
2005-07-24 19:14:17 +04:00
# endif
2005-07-27 18:16:57 +04:00
/* Print the messages about manipulating node_refs */
2005-07-24 19:14:17 +04:00
# ifdef JFFS2_DBG_NODEREF_MESSAGES
2005-09-22 15:25:00 +04:00
# define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
2005-07-24 19:14:17 +04:00
# else
2005-09-22 15:25:00 +04:00
# define dbg_noderef(fmt, ...)
2005-07-24 19:14:17 +04:00
# endif
2005-07-17 10:56:26 +04:00
2005-07-27 18:16:57 +04:00
/* Manipulations with the list of inodes (JFFS2 inocache) */
2005-07-24 19:14:17 +04:00
# ifdef JFFS2_DBG_INOCACHE_MESSAGES
2005-09-22 15:25:00 +04:00
# define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
2005-07-24 19:14:17 +04:00
# else
2005-09-22 15:25:00 +04:00
# define dbg_inocache(fmt, ...)
2005-07-24 19:14:17 +04:00
# endif
2005-09-07 12:35:26 +04:00
/* Summary debugging messages */
# ifdef JFFS2_DBG_SUMMARY_MESSAGES
2005-09-22 15:25:00 +04:00
# 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__)
2005-09-07 12:35:26 +04:00
# else
2005-09-22 15:25:00 +04:00
# define dbg_fsbuild(fmt, ...)
2005-09-07 12:35:26 +04:00
# endif
2005-07-27 18:16:57 +04:00
/* Watch the object allocations */
# ifdef JFFS2_DBG_MEMALLOC_MESSAGES
2005-09-22 15:25:00 +04:00
# define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
2005-07-27 18:16:57 +04:00
# else
2005-09-22 15:25:00 +04:00
# define dbg_memalloc(fmt, ...)
2005-07-27 18:16:57 +04:00
# endif
2006-05-13 10:09:47 +04:00
/* Watch the XATTR subsystem */
# ifdef JFFS2_DBG_XATTR_MESSAGES
# define dbg_xattr(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
# else
# define dbg_xattr(fmt, ...)
# endif
2005-07-27 18:16:57 +04:00
2005-08-05 15:43:47 +04:00
/* "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 ) ;
2005-07-24 19:14:17 +04:00
/* "Paranoia" checks */
void
__jffs2_dbg_fragtree_paranoia_check ( struct jffs2_inode_info * f ) ;
2005-07-17 10:56:26 +04:00
void
2005-07-24 19:14:17 +04:00
__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 ) ;
2005-07-17 10:56:26 +04:00
2005-07-24 19:14:17 +04:00
/* "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 ) ;
2005-07-17 10:56:26 +04:00
void
2005-07-24 19:14:17 +04:00
__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 )
2005-07-17 10:56:26 +04:00
# else
# define jffs2_dbg_fragtree_paranoia_check(f)
2005-07-24 19:14:17 +04:00
# define jffs2_dbg_fragtree_paranoia_check_nolock(f)
2005-07-17 10:56:26 +04:00
# define jffs2_dbg_acct_paranoia_check(c, jeb)
2005-07-24 19:14:17 +04:00
# define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
2005-07-17 10:56:26 +04:00
# define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
# endif /* !JFFS2_PARANOIA_CHECKS */
2005-07-24 19:14:17 +04:00
# 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 */
2005-07-17 10:56:26 +04:00
# ifdef JFFS2_DBG_SANITY_CHECKS
2005-08-05 15:43:47 +04:00
# 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 )
2005-07-24 19:14:17 +04:00
# else
# define jffs2_dbg_acct_sanity_check(c, jeb)
# define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
2005-07-17 10:56:26 +04:00
# endif /* !JFFS2_DBG_SANITY_CHECKS */
# endif /* _JFFS2_DEBUG_H_ */