jfs_debug.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. extern void jfs_proc_init(void);
  34. extern void jfs_proc_clean(void);
  35. #endif
  36. /*
  37. * assert with traditional printf/panic
  38. */
  39. #ifdef CONFIG_KERNEL_ASSERTS
  40. /* kgdb stuff */
  41. #define assert(p) KERNEL_ASSERT(#p, p)
  42. #else
  43. #define assert(p) do { \
  44. if (!(p)) { \
  45. printk(KERN_CRIT "BUG at %s:%d assert(%s)\n", \
  46. __FILE__, __LINE__, #p); \
  47. BUG(); \
  48. } \
  49. } while (0)
  50. #endif
  51. /*
  52. * debug ON
  53. * --------
  54. */
  55. #ifdef CONFIG_JFS_DEBUG
  56. #define ASSERT(p) assert(p)
  57. /* printk verbosity */
  58. #define JFS_LOGLEVEL_ERR 1
  59. #define JFS_LOGLEVEL_WARN 2
  60. #define JFS_LOGLEVEL_DEBUG 3
  61. #define JFS_LOGLEVEL_INFO 4
  62. extern int jfsloglevel;
  63. extern void dump_mem(char *label, void *data, int length);
  64. extern int jfs_txanchor_read(char *, char **, off_t, int, int *, void *);
  65. /* information message: e.g., configuration, major event */
  66. #define jfs_info(fmt, arg...) do { \
  67. if (jfsloglevel >= JFS_LOGLEVEL_INFO) \
  68. printk(KERN_INFO fmt "\n", ## arg); \
  69. } while (0)
  70. /* debug message: ad hoc */
  71. #define jfs_debug(fmt, arg...) do { \
  72. if (jfsloglevel >= JFS_LOGLEVEL_DEBUG) \
  73. printk(KERN_DEBUG fmt "\n", ## arg); \
  74. } while (0)
  75. /* warn message: */
  76. #define jfs_warn(fmt, arg...) do { \
  77. if (jfsloglevel >= JFS_LOGLEVEL_WARN) \
  78. printk(KERN_WARNING fmt "\n", ## arg); \
  79. } while (0)
  80. /* error event message: e.g., i/o error */
  81. #define jfs_err(fmt, arg...) do { \
  82. if (jfsloglevel >= JFS_LOGLEVEL_ERR) \
  83. printk(KERN_ERR fmt "\n", ## arg); \
  84. } while (0)
  85. /*
  86. * debug OFF
  87. * ---------
  88. */
  89. #else /* CONFIG_JFS_DEBUG */
  90. #define dump_mem(label,data,length) do {} while (0)
  91. #define ASSERT(p) do {} while (0)
  92. #define jfs_info(fmt, arg...) do {} while (0)
  93. #define jfs_debug(fmt, arg...) do {} while (0)
  94. #define jfs_warn(fmt, arg...) do {} while (0)
  95. #define jfs_err(fmt, arg...) do {} while (0)
  96. #endif /* CONFIG_JFS_DEBUG */
  97. /*
  98. * statistics
  99. * ----------
  100. */
  101. #ifdef CONFIG_JFS_STATISTICS
  102. extern int jfs_lmstats_read(char *, char **, off_t, int, int *, void *);
  103. extern int jfs_txstats_read(char *, char **, off_t, int, int *, void *);
  104. extern int jfs_mpstat_read(char *, char **, off_t, int, int *, void *);
  105. extern int jfs_xtstat_read(char *, char **, off_t, int, int *, void *);
  106. #define INCREMENT(x) ((x)++)
  107. #define DECREMENT(x) ((x)--)
  108. #define HIGHWATERMARK(x,y) ((x) = max((x), (y)))
  109. #else
  110. #define INCREMENT(x)
  111. #define DECREMENT(x)
  112. #define HIGHWATERMARK(x,y)
  113. #endif /* CONFIG_JFS_STATISTICS */
  114. #endif /* _H_JFS_DEBUG */