jfs_debug.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (c) International Business Machines Corp., 2000-2002
  3. * Portions Copyright (c) Christoph Hellwig, 2001-2002
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  13. * the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef _H_JFS_DEBUG
  20. #define _H_JFS_DEBUG
  21. /*
  22. * jfs_debug.h
  23. *
  24. * global debug message, data structure/macro definitions
  25. * under control of CONFIG_JFS_DEBUG, CONFIG_JFS_STATISTICS;
  26. */
  27. /*
  28. * Create /proc/fs/jfs if procfs is enabled andeither
  29. * CONFIG_JFS_DEBUG or CONFIG_JFS_STATISTICS is defined
  30. */
  31. #if defined(CONFIG_PROC_FS) && (defined(CONFIG_JFS_DEBUG) || defined(CONFIG_JFS_STATISTICS))
  32. #define PROC_FS_JFS
  33. #endif
  34. /*
  35. * assert with traditional printf/panic
  36. */
  37. #ifdef CONFIG_KERNEL_ASSERTS
  38. /* kgdb stuff */
  39. #define assert(p) KERNEL_ASSERT(#p, p)
  40. #else
  41. #define assert(p) do { \
  42. if (!(p)) { \
  43. printk(KERN_CRIT "BUG at %s:%d assert(%s)\n", \
  44. __FILE__, __LINE__, #p); \
  45. BUG(); \
  46. } \
  47. } while (0)
  48. #endif
  49. /*
  50. * debug ON
  51. * --------
  52. */
  53. #ifdef CONFIG_JFS_DEBUG
  54. #define ASSERT(p) assert(p)
  55. /* printk verbosity */
  56. #define JFS_LOGLEVEL_ERR 1
  57. #define JFS_LOGLEVEL_WARN 2
  58. #define JFS_LOGLEVEL_DEBUG 3
  59. #define JFS_LOGLEVEL_INFO 4
  60. extern int jfsloglevel;
  61. /* dump memory contents */
  62. extern void dump_mem(char *label, void *data, int length);
  63. /* information message: e.g., configuration, major event */
  64. #define jfs_info(fmt, arg...) do { \
  65. if (jfsloglevel >= JFS_LOGLEVEL_INFO) \
  66. printk(KERN_INFO fmt "\n", ## arg); \
  67. } while (0)
  68. /* debug message: ad hoc */
  69. #define jfs_debug(fmt, arg...) do { \
  70. if (jfsloglevel >= JFS_LOGLEVEL_DEBUG) \
  71. printk(KERN_DEBUG fmt "\n", ## arg); \
  72. } while (0)
  73. /* warn message: */
  74. #define jfs_warn(fmt, arg...) do { \
  75. if (jfsloglevel >= JFS_LOGLEVEL_WARN) \
  76. printk(KERN_WARNING fmt "\n", ## arg); \
  77. } while (0)
  78. /* error event message: e.g., i/o error */
  79. #define jfs_err(fmt, arg...) do { \
  80. if (jfsloglevel >= JFS_LOGLEVEL_ERR) \
  81. printk(KERN_ERR fmt "\n", ## arg); \
  82. } while (0)
  83. /*
  84. * debug OFF
  85. * ---------
  86. */
  87. #else /* CONFIG_JFS_DEBUG */
  88. #define dump_mem(label,data,length) do {} while (0)
  89. #define ASSERT(p) do {} while (0)
  90. #define jfs_info(fmt, arg...) do {} while (0)
  91. #define jfs_debug(fmt, arg...) do {} while (0)
  92. #define jfs_warn(fmt, arg...) do {} while (0)
  93. #define jfs_err(fmt, arg...) do {} while (0)
  94. #endif /* CONFIG_JFS_DEBUG */
  95. /*
  96. * statistics
  97. * ----------
  98. */
  99. #ifdef CONFIG_JFS_STATISTICS
  100. #define INCREMENT(x) ((x)++)
  101. #define DECREMENT(x) ((x)--)
  102. #define HIGHWATERMARK(x,y) ((x) = max((x), (y)))
  103. #else
  104. #define INCREMENT(x)
  105. #define DECREMENT(x)
  106. #define HIGHWATERMARK(x,y)
  107. #endif /* CONFIG_JFS_STATISTICS */
  108. #endif /* _H_JFS_DEBUG */