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