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