blob: bb9860ec9a9346610588679de69e53be98ee7371 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Dave Chinner10e38392011-03-02 14:20:59 +11002#ifndef __XFS_MESSAGE_H
3#define __XFS_MESSAGE_H 1
4
Tanner Lovea358f402021-06-28 09:50:06 -04005#include <linux/once_lite.h>
6
Dave Chinner10e38392011-03-02 14:20:59 +11007struct xfs_mount;
8
Joe Perchesb9075fa2011-10-31 17:11:33 -07009extern __printf(2, 3)
10void xfs_emerg(const struct xfs_mount *mp, const char *fmt, ...);
11extern __printf(2, 3)
12void xfs_alert(const struct xfs_mount *mp, const char *fmt, ...);
13extern __printf(3, 4)
14void xfs_alert_tag(const struct xfs_mount *mp, int tag, const char *fmt, ...);
15extern __printf(2, 3)
16void xfs_crit(const struct xfs_mount *mp, const char *fmt, ...);
17extern __printf(2, 3)
18void xfs_err(const struct xfs_mount *mp, const char *fmt, ...);
19extern __printf(2, 3)
20void xfs_warn(const struct xfs_mount *mp, const char *fmt, ...);
21extern __printf(2, 3)
22void xfs_notice(const struct xfs_mount *mp, const char *fmt, ...);
23extern __printf(2, 3)
24void xfs_info(const struct xfs_mount *mp, const char *fmt, ...);
Dave Chinner10e38392011-03-02 14:20:59 +110025
26#ifdef DEBUG
Joe Perchesb9075fa2011-10-31 17:11:33 -070027extern __printf(2, 3)
28void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...);
Dave Chinner10e38392011-03-02 14:20:59 +110029#else
Joe Perchesb9075fa2011-10-31 17:11:33 -070030static inline __printf(2, 3)
31void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...)
Christoph Hellwig957935d2011-04-02 18:13:40 +000032{
33}
Dave Chinner10e38392011-03-02 14:20:59 +110034#endif
35
Eric Sandeenec43f6d2020-04-27 11:00:42 -070036#define xfs_printk_ratelimited(func, dev, fmt, ...) \
Rich Johnston3d6e0362013-03-27 09:26:49 -050037do { \
38 static DEFINE_RATELIMIT_STATE(_rs, \
39 DEFAULT_RATELIMIT_INTERVAL, \
40 DEFAULT_RATELIMIT_BURST); \
41 if (__ratelimit(&_rs)) \
Eric Sandeenec43f6d2020-04-27 11:00:42 -070042 func(dev, fmt, ##__VA_ARGS__); \
Rich Johnston3d6e0362013-03-27 09:26:49 -050043} while (0)
44
Eric Sandeenec43f6d2020-04-27 11:00:42 -070045#define xfs_printk_once(func, dev, fmt, ...) \
Tanner Lovea358f402021-06-28 09:50:06 -040046 DO_ONCE_LITE(func, dev, fmt, ##__VA_ARGS__)
Eric Sandeenec43f6d2020-04-27 11:00:42 -070047
Rich Johnston3d6e0362013-03-27 09:26:49 -050048#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 Sandeenec43f6d2020-04-27 11:00:42 -070065#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. Wong603f0002021-05-12 12:51:26 -070069#define xfs_info_once(dev, fmt, ...) \
70 xfs_printk_once(xfs_info, dev, fmt, ##__VA_ARGS__)
Eric Sandeenec43f6d2020-04-27 11:00:42 -070071
Darrick J. Wong9842b562019-11-02 09:41:19 -070072void assfail(struct xfs_mount *mp, char *expr, char *f, int l);
73void asswarn(struct xfs_mount *mp, char *expr, char *f, int l);
Dave Chinner91300902011-03-07 10:09:35 +110074
Darrick J. Wongd243b892019-11-02 09:40:36 -070075extern void xfs_hex_dump(const void *p, int length);
Dave Chinner91300902011-03-07 10:09:35 +110076
Brian Fosterf9bccfc2020-05-06 13:25:21 -070077void xfs_buf_alert_ratelimited(struct xfs_buf *bp, const char *rlmsg,
78 const char *fmt, ...);
79
Dave Chinner10e38392011-03-02 14:20:59 +110080#endif /* __XFS_MESSAGE_H */