debug.h 8.4 KB

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