jfs_debug.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 void dump_mem(char *label, void *data, int length);
  59. extern int jfs_txanchor_read(char *, char **, off_t, int, int *, void *);
  60. /* information message: e.g., configuration, major event */
  61. #define jfs_info(fmt, arg...) do { \
  62. if (jfsloglevel >= JFS_LOGLEVEL_INFO) \
  63. printk(KERN_INFO fmt "\n", ## arg); \
  64. } while (0)
  65. /* debug message: ad hoc */
  66. #define jfs_debug(fmt, arg...) do { \
  67. if (jfsloglevel >= JFS_LOGLEVEL_DEBUG) \
  68. printk(KERN_DEBUG fmt "\n", ## arg); \
  69. } while (0)
  70. /* warn message: */
  71. #define jfs_warn(fmt, arg...) do { \
  72. if (jfsloglevel >= JFS_LOGLEVEL_WARN) \
  73. printk(KERN_WARNING fmt "\n", ## arg); \
  74. } while (0)
  75. /* error event message: e.g., i/o error */
  76. #define jfs_err(fmt, arg...) do { \
  77. if (jfsloglevel >= JFS_LOGLEVEL_ERR) \
  78. printk(KERN_ERR fmt "\n", ## arg); \
  79. } while (0)
  80. /*
  81. * debug OFF
  82. * ---------
  83. */
  84. #else /* CONFIG_JFS_DEBUG */
  85. #define dump_mem(label,data,length) do {} while (0)
  86. #define ASSERT(p) do {} while (0)
  87. #define jfs_info(fmt, arg...) do {} while (0)
  88. #define jfs_debug(fmt, arg...) do {} while (0)
  89. #define jfs_warn(fmt, arg...) do {} while (0)
  90. #define jfs_err(fmt, arg...) do {} while (0)
  91. #endif /* CONFIG_JFS_DEBUG */
  92. /*
  93. * statistics
  94. * ----------
  95. */
  96. #ifdef CONFIG_JFS_STATISTICS
  97. extern int jfs_lmstats_read(char *, char **, off_t, int, int *, void *);
  98. extern int jfs_txstats_read(char *, char **, off_t, int, int *, void *);
  99. extern int jfs_mpstat_read(char *, char **, off_t, int, int *, void *);
  100. extern int jfs_xtstat_read(char *, char **, off_t, int, int *, void *);
  101. #define INCREMENT(x) ((x)++)
  102. #define DECREMENT(x) ((x)--)
  103. #define HIGHWATERMARK(x,y) ((x) = max((x), (y)))
  104. #else
  105. #define INCREMENT(x)
  106. #define DECREMENT(x)
  107. #define HIGHWATERMARK(x,y)
  108. #endif /* CONFIG_JFS_STATISTICS */
  109. #endif /* _H_JFS_DEBUG */