1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __XFS_MESSAGE_H 3 #define __XFS_MESSAGE_H 1 4 5 #include <linux/once_lite.h> 6 7 struct xfs_mount; 8 9 extern __printf(3, 4) 10 void xfs_printk_level(const char *kern_level, const struct xfs_mount *mp, 11 const char *fmt, ...); 12 13 #define xfs_emerg(mp, fmt, ...) \ 14 xfs_printk_level(KERN_EMERG, mp, fmt, ##__VA_ARGS__) 15 #define xfs_alert(mp, fmt, ...) \ 16 xfs_printk_level(KERN_ALERT, mp, fmt, ##__VA_ARGS__) 17 #define xfs_crit(mp, fmt, ...) \ 18 xfs_printk_level(KERN_CRIT, mp, fmt, ##__VA_ARGS__) 19 #define xfs_err(mp, fmt, ...) \ 20 xfs_printk_level(KERN_ERR, mp, fmt, ##__VA_ARGS__) 21 #define xfs_warn(mp, fmt, ...) \ 22 xfs_printk_level(KERN_WARNING, mp, fmt, ##__VA_ARGS__) 23 #define xfs_notice(mp, fmt, ...) \ 24 xfs_printk_level(KERN_NOTICE, mp, fmt, ##__VA_ARGS__) 25 #define xfs_info(mp, fmt, ...) \ 26 xfs_printk_level(KERN_INFO, mp, fmt, ##__VA_ARGS__) 27 #ifdef DEBUG 28 #define xfs_debug(mp, fmt, ...) \ 29 xfs_printk_level(KERN_DEBUG, mp, fmt, ##__VA_ARGS__) 30 #else 31 #define xfs_debug(mp, fmt, ...) do {} while (0) 32 #endif 33 34 extern __printf(3, 4) 35 void xfs_alert_tag(const struct xfs_mount *mp, int tag, const char *fmt, ...); 36 37 #define xfs_printk_ratelimited(func, dev, fmt, ...) \ 38 do { \ 39 static DEFINE_RATELIMIT_STATE(_rs, \ 40 DEFAULT_RATELIMIT_INTERVAL, \ 41 DEFAULT_RATELIMIT_BURST); \ 42 if (__ratelimit(&_rs)) \ 43 func(dev, fmt, ##__VA_ARGS__); \ 44 } while (0) 45 46 #define xfs_printk_once(func, dev, fmt, ...) \ 47 DO_ONCE_LITE(func, dev, fmt, ##__VA_ARGS__) 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 66 #define xfs_warn_once(dev, fmt, ...) \ 67 xfs_printk_once(xfs_warn, dev, fmt, ##__VA_ARGS__) 68 #define xfs_notice_once(dev, fmt, ...) \ 69 xfs_printk_once(xfs_notice, dev, fmt, ##__VA_ARGS__) 70 #define xfs_info_once(dev, fmt, ...) \ 71 xfs_printk_once(xfs_info, dev, fmt, ##__VA_ARGS__) 72 73 void assfail(struct xfs_mount *mp, char *expr, char *f, int l); 74 void asswarn(struct xfs_mount *mp, char *expr, char *f, int l); 75 76 extern void xfs_hex_dump(const void *p, int length); 77 78 void xfs_buf_alert_ratelimited(struct xfs_buf *bp, const char *rlmsg, 79 const char *fmt, ...); 80 81 #endif /* __XFS_MESSAGE_H */ 82