Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Dave Chinner | 10e3839 | 2011-03-02 14:20:59 +1100 | [diff] [blame] | 2 | #ifndef __XFS_MESSAGE_H |
| 3 | #define __XFS_MESSAGE_H 1 |
| 4 | |
Tanner Love | a358f40 | 2021-06-28 09:50:06 -0400 | [diff] [blame] | 5 | #include <linux/once_lite.h> |
| 6 | |
Dave Chinner | 10e3839 | 2011-03-02 14:20:59 +1100 | [diff] [blame] | 7 | struct xfs_mount; |
| 8 | |
Joe Perches | b9075fa | 2011-10-31 17:11:33 -0700 | [diff] [blame] | 9 | extern __printf(2, 3) |
| 10 | void xfs_emerg(const struct xfs_mount *mp, const char *fmt, ...); |
| 11 | extern __printf(2, 3) |
| 12 | void xfs_alert(const struct xfs_mount *mp, const char *fmt, ...); |
| 13 | extern __printf(3, 4) |
| 14 | void xfs_alert_tag(const struct xfs_mount *mp, int tag, const char *fmt, ...); |
| 15 | extern __printf(2, 3) |
| 16 | void xfs_crit(const struct xfs_mount *mp, const char *fmt, ...); |
| 17 | extern __printf(2, 3) |
| 18 | void xfs_err(const struct xfs_mount *mp, const char *fmt, ...); |
| 19 | extern __printf(2, 3) |
| 20 | void xfs_warn(const struct xfs_mount *mp, const char *fmt, ...); |
| 21 | extern __printf(2, 3) |
| 22 | void xfs_notice(const struct xfs_mount *mp, const char *fmt, ...); |
| 23 | extern __printf(2, 3) |
| 24 | void xfs_info(const struct xfs_mount *mp, const char *fmt, ...); |
Dave Chinner | 10e3839 | 2011-03-02 14:20:59 +1100 | [diff] [blame] | 25 | |
| 26 | #ifdef DEBUG |
Joe Perches | b9075fa | 2011-10-31 17:11:33 -0700 | [diff] [blame] | 27 | extern __printf(2, 3) |
| 28 | void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...); |
Dave Chinner | 10e3839 | 2011-03-02 14:20:59 +1100 | [diff] [blame] | 29 | #else |
Joe Perches | b9075fa | 2011-10-31 17:11:33 -0700 | [diff] [blame] | 30 | static inline __printf(2, 3) |
| 31 | void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...) |
Christoph Hellwig | 957935d | 2011-04-02 18:13:40 +0000 | [diff] [blame] | 32 | { |
| 33 | } |
Dave Chinner | 10e3839 | 2011-03-02 14:20:59 +1100 | [diff] [blame] | 34 | #endif |
| 35 | |
Eric Sandeen | ec43f6d | 2020-04-27 11:00:42 -0700 | [diff] [blame] | 36 | #define xfs_printk_ratelimited(func, dev, fmt, ...) \ |
Rich Johnston | 3d6e036 | 2013-03-27 09:26:49 -0500 | [diff] [blame] | 37 | do { \ |
| 38 | static DEFINE_RATELIMIT_STATE(_rs, \ |
| 39 | DEFAULT_RATELIMIT_INTERVAL, \ |
| 40 | DEFAULT_RATELIMIT_BURST); \ |
| 41 | if (__ratelimit(&_rs)) \ |
Eric Sandeen | ec43f6d | 2020-04-27 11:00:42 -0700 | [diff] [blame] | 42 | func(dev, fmt, ##__VA_ARGS__); \ |
Rich Johnston | 3d6e036 | 2013-03-27 09:26:49 -0500 | [diff] [blame] | 43 | } while (0) |
| 44 | |
Eric Sandeen | ec43f6d | 2020-04-27 11:00:42 -0700 | [diff] [blame] | 45 | #define xfs_printk_once(func, dev, fmt, ...) \ |
Tanner Love | a358f40 | 2021-06-28 09:50:06 -0400 | [diff] [blame] | 46 | DO_ONCE_LITE(func, dev, fmt, ##__VA_ARGS__) |
Eric Sandeen | ec43f6d | 2020-04-27 11:00:42 -0700 | [diff] [blame] | 47 | |
Rich Johnston | 3d6e036 | 2013-03-27 09:26:49 -0500 | [diff] [blame] | 48 | #define xfs_emerg_ratelimited(dev, fmt, ...) \ |
| 49 | xfs_printk_ratelimited(xfs_emerg, dev, fmt, ##__VA_ARGS__) |
| 50 | #define xfs_alert_ratelimited(dev, fmt, ...) \ |
| 51 | xfs_printk_ratelimited(xfs_alert, dev, fmt, ##__VA_ARGS__) |
| 52 | #define xfs_crit_ratelimited(dev, fmt, ...) \ |
| 53 | xfs_printk_ratelimited(xfs_crit, dev, fmt, ##__VA_ARGS__) |
| 54 | #define xfs_err_ratelimited(dev, fmt, ...) \ |
| 55 | xfs_printk_ratelimited(xfs_err, dev, fmt, ##__VA_ARGS__) |
| 56 | #define xfs_warn_ratelimited(dev, fmt, ...) \ |
| 57 | xfs_printk_ratelimited(xfs_warn, dev, fmt, ##__VA_ARGS__) |
| 58 | #define xfs_notice_ratelimited(dev, fmt, ...) \ |
| 59 | xfs_printk_ratelimited(xfs_notice, dev, fmt, ##__VA_ARGS__) |
| 60 | #define xfs_info_ratelimited(dev, fmt, ...) \ |
| 61 | xfs_printk_ratelimited(xfs_info, dev, fmt, ##__VA_ARGS__) |
| 62 | #define xfs_debug_ratelimited(dev, fmt, ...) \ |
| 63 | xfs_printk_ratelimited(xfs_debug, dev, fmt, ##__VA_ARGS__) |
| 64 | |
Eric Sandeen | ec43f6d | 2020-04-27 11:00:42 -0700 | [diff] [blame] | 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__) |
Darrick J. Wong | 603f000 | 2021-05-12 12:51:26 -0700 | [diff] [blame] | 69 | #define xfs_info_once(dev, fmt, ...) \ |
| 70 | xfs_printk_once(xfs_info, dev, fmt, ##__VA_ARGS__) |
Eric Sandeen | ec43f6d | 2020-04-27 11:00:42 -0700 | [diff] [blame] | 71 | |
Darrick J. Wong | 9842b56 | 2019-11-02 09:41:19 -0700 | [diff] [blame] | 72 | void assfail(struct xfs_mount *mp, char *expr, char *f, int l); |
| 73 | void asswarn(struct xfs_mount *mp, char *expr, char *f, int l); |
Dave Chinner | 9130090 | 2011-03-07 10:09:35 +1100 | [diff] [blame] | 74 | |
Darrick J. Wong | d243b89 | 2019-11-02 09:40:36 -0700 | [diff] [blame] | 75 | extern void xfs_hex_dump(const void *p, int length); |
Dave Chinner | 9130090 | 2011-03-07 10:09:35 +1100 | [diff] [blame] | 76 | |
Brian Foster | f9bccfc | 2020-05-06 13:25:21 -0700 | [diff] [blame] | 77 | void xfs_buf_alert_ratelimited(struct xfs_buf *bp, const char *rlmsg, |
| 78 | const char *fmt, ...); |
| 79 | |
Dave Chinner | 10e3839 | 2011-03-02 14:20:59 +1100 | [diff] [blame] | 80 | #endif /* __XFS_MESSAGE_H */ |