jfs_debug.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) International Business Machines Corp., 2000-2002
  4. * Portions Copyright (C) Christoph Hellwig, 2001-2002
  5. */
  6. #ifndef _H_JFS_DEBUG
  7. #define _H_JFS_DEBUG
  8. /*
  9. * jfs_debug.h
  10. *
  11. * global debug message, data structure/macro definitions
  12. * under control of CONFIG_JFS_DEBUG, CONFIG_JFS_STATISTICS;
  13. */
  14. /*
  15. * Create /proc/fs/jfs if procfs is enabled andeither
  16. * CONFIG_JFS_DEBUG or CONFIG_JFS_STATISTICS is defined
  17. */
  18. #if defined(CONFIG_PROC_FS) && (defined(CONFIG_JFS_DEBUG) || defined(CONFIG_JFS_STATISTICS))
  19. #define PROC_FS_JFS
  20. extern void jfs_proc_init(void);
  21. extern void jfs_proc_clean(void);
  22. #endif
  23. /*
  24. * assert with traditional printf/panic
  25. */
  26. #define assert(p) do { \
  27. if (!(p)) { \
  28. printk(KERN_CRIT "BUG at %s:%d assert(%s)\n", \
  29. __FILE__, __LINE__, #p); \
  30. BUG(); \
  31. } \
  32. } while (0)
  33. /*
  34. * debug ON
  35. * --------
  36. */
  37. #ifdef CONFIG_JFS_DEBUG
  38. #define ASSERT(p) assert(p)
  39. /* printk verbosity */
  40. #define JFS_LOGLEVEL_ERR 1
  41. #define JFS_LOGLEVEL_WARN 2
  42. #define JFS_LOGLEVEL_DEBUG 3
  43. #define JFS_LOGLEVEL_INFO 4
  44. extern int jfsloglevel;
  45. int jfs_txanchor_proc_show(struct seq_file *m, void *v);
  46. /* information message: e.g., configuration, major event */
  47. #define jfs_info(fmt, arg...) do { \
  48. if (jfsloglevel >= JFS_LOGLEVEL_INFO) \
  49. printk(KERN_INFO fmt "\n", ## arg); \
  50. } while (0)
  51. /* debug message: ad hoc */
  52. #define jfs_debug(fmt, arg...) do { \
  53. if (jfsloglevel >= JFS_LOGLEVEL_DEBUG) \
  54. printk(KERN_DEBUG fmt "\n", ## arg); \
  55. } while (0)
  56. /* warn message: */
  57. #define jfs_warn(fmt, arg...) do { \
  58. if (jfsloglevel >= JFS_LOGLEVEL_WARN) \
  59. printk(KERN_WARNING fmt "\n", ## arg); \
  60. } while (0)
  61. /* error event message: e.g., i/o error */
  62. #define jfs_err(fmt, arg...) do { \
  63. if (jfsloglevel >= JFS_LOGLEVEL_ERR) \
  64. printk(KERN_ERR fmt "\n", ## arg); \
  65. } while (0)
  66. /*
  67. * debug OFF
  68. * ---------
  69. */
  70. #else /* CONFIG_JFS_DEBUG */
  71. #define ASSERT(p) do {} while (0)
  72. #define jfs_info(fmt, arg...) do {} while (0)
  73. #define jfs_debug(fmt, arg...) do {} while (0)
  74. #define jfs_warn(fmt, arg...) do {} while (0)
  75. #define jfs_err(fmt, arg...) do {} while (0)
  76. #endif /* CONFIG_JFS_DEBUG */
  77. /*
  78. * statistics
  79. * ----------
  80. */
  81. #ifdef CONFIG_JFS_STATISTICS
  82. int jfs_lmstats_proc_show(struct seq_file *m, void *v);
  83. int jfs_txstats_proc_show(struct seq_file *m, void *v);
  84. int jfs_mpstat_proc_show(struct seq_file *m, void *v);
  85. int jfs_xtstat_proc_show(struct seq_file *m, void *v);
  86. #define INCREMENT(x) ((x)++)
  87. #define DECREMENT(x) ((x)--)
  88. #define HIGHWATERMARK(x,y) ((x) = max((x), (y)))
  89. #else
  90. #define INCREMENT(x)
  91. #define DECREMENT(x)
  92. #define HIGHWATERMARK(x,y)
  93. #endif /* CONFIG_JFS_STATISTICS */
  94. #endif /* _H_JFS_DEBUG */