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