xfs_message.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __XFS_MESSAGE_H
  3. #define __XFS_MESSAGE_H 1
  4. struct xfs_mount;
  5. extern __printf(2, 3)
  6. void xfs_emerg(const struct xfs_mount *mp, const char *fmt, ...);
  7. extern __printf(2, 3)
  8. void xfs_alert(const struct xfs_mount *mp, const char *fmt, ...);
  9. extern __printf(3, 4)
  10. void xfs_alert_tag(const struct xfs_mount *mp, int tag, const char *fmt, ...);
  11. extern __printf(2, 3)
  12. void xfs_crit(const struct xfs_mount *mp, const char *fmt, ...);
  13. extern __printf(2, 3)
  14. void xfs_err(const struct xfs_mount *mp, const char *fmt, ...);
  15. extern __printf(2, 3)
  16. void xfs_warn(const struct xfs_mount *mp, const char *fmt, ...);
  17. extern __printf(2, 3)
  18. void xfs_notice(const struct xfs_mount *mp, const char *fmt, ...);
  19. extern __printf(2, 3)
  20. void xfs_info(const struct xfs_mount *mp, const char *fmt, ...);
  21. #ifdef DEBUG
  22. extern __printf(2, 3)
  23. void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...);
  24. #else
  25. static inline __printf(2, 3)
  26. void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...)
  27. {
  28. }
  29. #endif
  30. #define xfs_printk_ratelimited(func, dev, fmt, ...) \
  31. do { \
  32. static DEFINE_RATELIMIT_STATE(_rs, \
  33. DEFAULT_RATELIMIT_INTERVAL, \
  34. DEFAULT_RATELIMIT_BURST); \
  35. if (__ratelimit(&_rs)) \
  36. func(dev, fmt, ##__VA_ARGS__); \
  37. } while (0)
  38. #define xfs_printk_once(func, dev, fmt, ...) \
  39. ({ \
  40. static bool __section(".data.once") __print_once; \
  41. bool __ret_print_once = !__print_once; \
  42. \
  43. if (!__print_once) { \
  44. __print_once = true; \
  45. func(dev, fmt, ##__VA_ARGS__); \
  46. } \
  47. unlikely(__ret_print_once); \
  48. })
  49. #define xfs_emerg_ratelimited(dev, fmt, ...) \
  50. xfs_printk_ratelimited(xfs_emerg, dev, fmt, ##__VA_ARGS__)
  51. #define xfs_alert_ratelimited(dev, fmt, ...) \
  52. xfs_printk_ratelimited(xfs_alert, dev, fmt, ##__VA_ARGS__)
  53. #define xfs_crit_ratelimited(dev, fmt, ...) \
  54. xfs_printk_ratelimited(xfs_crit, dev, fmt, ##__VA_ARGS__)
  55. #define xfs_err_ratelimited(dev, fmt, ...) \
  56. xfs_printk_ratelimited(xfs_err, dev, fmt, ##__VA_ARGS__)
  57. #define xfs_warn_ratelimited(dev, fmt, ...) \
  58. xfs_printk_ratelimited(xfs_warn, dev, fmt, ##__VA_ARGS__)
  59. #define xfs_notice_ratelimited(dev, fmt, ...) \
  60. xfs_printk_ratelimited(xfs_notice, dev, fmt, ##__VA_ARGS__)
  61. #define xfs_info_ratelimited(dev, fmt, ...) \
  62. xfs_printk_ratelimited(xfs_info, dev, fmt, ##__VA_ARGS__)
  63. #define xfs_debug_ratelimited(dev, fmt, ...) \
  64. xfs_printk_ratelimited(xfs_debug, dev, fmt, ##__VA_ARGS__)
  65. #define xfs_warn_once(dev, fmt, ...) \
  66. xfs_printk_once(xfs_warn, dev, fmt, ##__VA_ARGS__)
  67. #define xfs_notice_once(dev, fmt, ...) \
  68. xfs_printk_once(xfs_notice, dev, fmt, ##__VA_ARGS__)
  69. void assfail(struct xfs_mount *mp, char *expr, char *f, int l);
  70. void asswarn(struct xfs_mount *mp, char *expr, char *f, int l);
  71. extern void xfs_hex_dump(const void *p, int length);
  72. void xfs_buf_alert_ratelimited(struct xfs_buf *bp, const char *rlmsg,
  73. const char *fmt, ...);
  74. #endif /* __XFS_MESSAGE_H */