debug.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*
  2. * JFFS2 -- Journalling Flash File System, Version 2.
  3. *
  4. * Copyright © 2001-2007 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. *
  10. */
  11. #ifndef _JFFS2_DEBUG_H_
  12. #define _JFFS2_DEBUG_H_
  13. #include <linux/sched.h>
  14. #ifndef CONFIG_JFFS2_FS_DEBUG
  15. #define CONFIG_JFFS2_FS_DEBUG 0
  16. #endif
  17. #if CONFIG_JFFS2_FS_DEBUG > 0
  18. /* Enable "paranoia" checks and dumps */
  19. #define JFFS2_DBG_PARANOIA_CHECKS
  20. #define JFFS2_DBG_DUMPS
  21. /*
  22. * By defining/undefining the below macros one may select debugging messages
  23. * fro specific JFFS2 subsystems.
  24. */
  25. #define JFFS2_DBG_READINODE_MESSAGES
  26. #define JFFS2_DBG_FRAGTREE_MESSAGES
  27. #define JFFS2_DBG_DENTLIST_MESSAGES
  28. #define JFFS2_DBG_NODEREF_MESSAGES
  29. #define JFFS2_DBG_INOCACHE_MESSAGES
  30. #define JFFS2_DBG_SUMMARY_MESSAGES
  31. #define JFFS2_DBG_FSBUILD_MESSAGES
  32. #endif
  33. #if CONFIG_JFFS2_FS_DEBUG > 1
  34. #define JFFS2_DBG_FRAGTREE2_MESSAGES
  35. #define JFFS2_DBG_READINODE2_MESSAGES
  36. #define JFFS2_DBG_MEMALLOC_MESSAGES
  37. #endif
  38. /* Sanity checks are supposed to be light-weight and enabled by default */
  39. #define JFFS2_DBG_SANITY_CHECKS
  40. /*
  41. * Dx() are mainly used for debugging messages, they must go away and be
  42. * superseded by nicer dbg_xxx() macros...
  43. */
  44. #if CONFIG_JFFS2_FS_DEBUG > 0
  45. #define D1(x) x
  46. #else
  47. #define D1(x)
  48. #endif
  49. #if CONFIG_JFFS2_FS_DEBUG > 1
  50. #define D2(x) x
  51. #else
  52. #define D2(x)
  53. #endif
  54. /* The prefixes of JFFS2 messages */
  55. #define JFFS2_DBG_PREFIX "[JFFS2 DBG]"
  56. #define JFFS2_ERR_PREFIX "JFFS2 error:"
  57. #define JFFS2_WARN_PREFIX "JFFS2 warning:"
  58. #define JFFS2_NOTICE_PREFIX "JFFS2 notice:"
  59. #define JFFS2_ERR KERN_ERR
  60. #define JFFS2_WARN KERN_WARNING
  61. #define JFFS2_NOT KERN_NOTICE
  62. #define JFFS2_DBG KERN_DEBUG
  63. #define JFFS2_DBG_MSG_PREFIX JFFS2_DBG JFFS2_DBG_PREFIX
  64. #define JFFS2_ERR_MSG_PREFIX JFFS2_ERR JFFS2_ERR_PREFIX
  65. #define JFFS2_WARN_MSG_PREFIX JFFS2_WARN JFFS2_WARN_PREFIX
  66. #define JFFS2_NOTICE_MSG_PREFIX JFFS2_NOT JFFS2_NOTICE_PREFIX
  67. /* JFFS2 message macros */
  68. #define JFFS2_ERROR(fmt, ...) \
  69. do { \
  70. printk(JFFS2_ERR_MSG_PREFIX \
  71. " (%d) %s: " fmt, task_pid_nr(current), \
  72. __func__ , ##__VA_ARGS__); \
  73. } while(0)
  74. #define JFFS2_WARNING(fmt, ...) \
  75. do { \
  76. printk(JFFS2_WARN_MSG_PREFIX \
  77. " (%d) %s: " fmt, task_pid_nr(current), \
  78. __func__ , ##__VA_ARGS__); \
  79. } while(0)
  80. #define JFFS2_NOTICE(fmt, ...) \
  81. do { \
  82. printk(JFFS2_NOTICE_MSG_PREFIX \
  83. " (%d) %s: " fmt, task_pid_nr(current), \
  84. __func__ , ##__VA_ARGS__); \
  85. } while(0)
  86. #define JFFS2_DEBUG(fmt, ...) \
  87. do { \
  88. printk(JFFS2_DBG_MSG_PREFIX \
  89. " (%d) %s: " fmt, task_pid_nr(current), \
  90. __func__ , ##__VA_ARGS__); \
  91. } while(0)
  92. /*
  93. * We split our debugging messages on several parts, depending on the JFFS2
  94. * subsystem the message belongs to.
  95. */
  96. /* Read inode debugging messages */
  97. #ifdef JFFS2_DBG_READINODE_MESSAGES
  98. #define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
  99. #else
  100. #define dbg_readinode(fmt, ...)
  101. #endif
  102. #ifdef JFFS2_DBG_READINODE2_MESSAGES
  103. #define dbg_readinode2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
  104. #else
  105. #define dbg_readinode2(fmt, ...)
  106. #endif
  107. /* Fragtree build debugging messages */
  108. #ifdef JFFS2_DBG_FRAGTREE_MESSAGES
  109. #define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
  110. #else
  111. #define dbg_fragtree(fmt, ...)
  112. #endif
  113. #ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
  114. #define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
  115. #else
  116. #define dbg_fragtree2(fmt, ...)
  117. #endif
  118. /* Directory entry list manilulation debugging messages */
  119. #ifdef JFFS2_DBG_DENTLIST_MESSAGES
  120. #define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
  121. #else
  122. #define dbg_dentlist(fmt, ...)
  123. #endif
  124. /* Print the messages about manipulating node_refs */
  125. #ifdef JFFS2_DBG_NODEREF_MESSAGES
  126. #define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
  127. #else
  128. #define dbg_noderef(fmt, ...)
  129. #endif
  130. /* Manipulations with the list of inodes (JFFS2 inocache) */
  131. #ifdef JFFS2_DBG_INOCACHE_MESSAGES
  132. #define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
  133. #else
  134. #define dbg_inocache(fmt, ...)
  135. #endif
  136. /* Summary debugging messages */
  137. #ifdef JFFS2_DBG_SUMMARY_MESSAGES
  138. #define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
  139. #else
  140. #define dbg_summary(fmt, ...)
  141. #endif
  142. /* File system build messages */
  143. #ifdef JFFS2_DBG_FSBUILD_MESSAGES
  144. #define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
  145. #else
  146. #define dbg_fsbuild(fmt, ...)
  147. #endif
  148. /* Watch the object allocations */
  149. #ifdef JFFS2_DBG_MEMALLOC_MESSAGES
  150. #define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
  151. #else
  152. #define dbg_memalloc(fmt, ...)
  153. #endif
  154. /* Watch the XATTR subsystem */
  155. #ifdef JFFS2_DBG_XATTR_MESSAGES
  156. #define dbg_xattr(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
  157. #else
  158. #define dbg_xattr(fmt, ...)
  159. #endif
  160. /* "Sanity" checks */
  161. void
  162. __jffs2_dbg_acct_sanity_check_nolock(struct jffs2_sb_info *c,
  163. struct jffs2_eraseblock *jeb);
  164. void
  165. __jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c,
  166. struct jffs2_eraseblock *jeb);
  167. /* "Paranoia" checks */
  168. void
  169. __jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f);
  170. void
  171. __jffs2_dbg_fragtree_paranoia_check_nolock(struct jffs2_inode_info *f);
  172. void
  173. __jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c,
  174. struct jffs2_eraseblock *jeb);
  175. void
  176. __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
  177. struct jffs2_eraseblock *jeb);
  178. void
  179. __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
  180. uint32_t ofs, int len);
  181. /* "Dump" functions */
  182. void
  183. __jffs2_dbg_dump_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
  184. void
  185. __jffs2_dbg_dump_jeb_nolock(struct jffs2_eraseblock *jeb);
  186. void
  187. __jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c);
  188. void
  189. __jffs2_dbg_dump_block_lists_nolock(struct jffs2_sb_info *c);
  190. void
  191. __jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c,
  192. struct jffs2_eraseblock *jeb);
  193. void
  194. __jffs2_dbg_dump_node_refs_nolock(struct jffs2_sb_info *c,
  195. struct jffs2_eraseblock *jeb);
  196. void
  197. __jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f);
  198. void
  199. __jffs2_dbg_dump_fragtree_nolock(struct jffs2_inode_info *f);
  200. void
  201. __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs);
  202. void
  203. __jffs2_dbg_dump_node(struct jffs2_sb_info *c, uint32_t ofs);
  204. #ifdef JFFS2_DBG_PARANOIA_CHECKS
  205. #define jffs2_dbg_fragtree_paranoia_check(f) \
  206. __jffs2_dbg_fragtree_paranoia_check(f)
  207. #define jffs2_dbg_fragtree_paranoia_check_nolock(f) \
  208. __jffs2_dbg_fragtree_paranoia_check_nolock(f)
  209. #define jffs2_dbg_acct_paranoia_check(c, jeb) \
  210. __jffs2_dbg_acct_paranoia_check(c,jeb)
  211. #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb) \
  212. __jffs2_dbg_acct_paranoia_check_nolock(c,jeb)
  213. #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) \
  214. __jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
  215. #else
  216. #define jffs2_dbg_fragtree_paranoia_check(f)
  217. #define jffs2_dbg_fragtree_paranoia_check_nolock(f)
  218. #define jffs2_dbg_acct_paranoia_check(c, jeb)
  219. #define jffs2_dbg_acct_paranoia_check_nolock(c, jeb)
  220. #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len)
  221. #endif /* !JFFS2_PARANOIA_CHECKS */
  222. #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. #ifdef JFFS2_DBG_SANITY_CHECKS
  250. #define jffs2_dbg_acct_sanity_check(c, jeb) \
  251. __jffs2_dbg_acct_sanity_check(c, jeb)
  252. #define jffs2_dbg_acct_sanity_check_nolock(c, jeb) \
  253. __jffs2_dbg_acct_sanity_check_nolock(c, jeb)
  254. #else
  255. #define jffs2_dbg_acct_sanity_check(c, jeb)
  256. #define jffs2_dbg_acct_sanity_check_nolock(c, jeb)
  257. #endif /* !JFFS2_DBG_SANITY_CHECKS */
  258. #endif /* _JFFS2_DEBUG_H_ */