[RFC v2 1/2] xfs: create a daily warning mechanism

Brian Foster bfoster at redhat.com
Fri Sep 11 13:53:54 CDT 2015


The warning mechanism in XFS currently uses the default ratelimit time
interval and burst parameters. The default parameters are intended to
avoid flooding the logs and whatnot due to messages within fairly short
timeframes (e.g., 10 messages within 5s). The forthcoming invalid
metadata LSN detection must provide a consistent, but not incessant
warning to the user that a repair is required to reformat the log.

Update the core ratelimit mechanism to allow customized parameters,
continue to pass the ratelimit defaults for existing users, and define a
new xfs_warn_daily() mechanism to fire a message on a 24 hour interval.

Signed-off-by: Brian Foster <bfoster at redhat.com>
---
 fs/xfs/xfs_message.h | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_message.h b/fs/xfs/xfs_message.h
index 8540115..9f1a036 100644
--- a/fs/xfs/xfs_message.h
+++ b/fs/xfs/xfs_message.h
@@ -30,15 +30,22 @@ void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...)
 }
 #endif
 
-#define xfs_printk_ratelimited(func, dev, fmt, ...)		\
+#define __xfs_printk_ratelimited(interval, burst, func, dev, fmt, ...)	\
 do {									\
-	static DEFINE_RATELIMIT_STATE(_rs,				\
-				      DEFAULT_RATELIMIT_INTERVAL,	\
-				      DEFAULT_RATELIMIT_BURST);		\
+	static DEFINE_RATELIMIT_STATE(_rs, interval, burst);		\
 	if (__ratelimit(&_rs))						\
 		func(dev, fmt, ##__VA_ARGS__);			\
 } while (0)
 
+#define xfs_printk_ratelimited(func, dev, fmt, ...)		\
+	__xfs_printk_ratelimited(DEFAULT_RATELIMIT_INTERVAL,	\
+				 DEFAULT_RATELIMIT_BURST,	\
+				 func, dev, fmt, ##__VA_ARGS__)
+
+#define xfs_printk_daily(func, dev, fmt, ...)			\
+	__xfs_printk_ratelimited(86400 * HZ, 1, func, dev, fmt,	\
+				 ##__VA_ARGS__)
+
 #define xfs_emerg_ratelimited(dev, fmt, ...)				\
 	xfs_printk_ratelimited(xfs_emerg, dev, fmt, ##__VA_ARGS__)
 #define xfs_alert_ratelimited(dev, fmt, ...)				\
@@ -56,6 +63,9 @@ do {									\
 #define xfs_debug_ratelimited(dev, fmt, ...)				\
 	xfs_printk_ratelimited(xfs_debug, dev, fmt, ##__VA_ARGS__)
 
+#define xfs_warn_daily(dev, fmt, ...)					\
+	xfs_printk_daily(xfs_warn, dev, fmt, ##__VA_ARGS__)
+
 extern void assfail(char *expr, char *f, int l);
 extern void asswarn(char *expr, char *f, int l);
 
-- 
2.1.0



More information about the xfs mailing list