From f40c396a9ab04eae526990e2b2cef875b424ed4e Mon Sep 17 00:00:00 2001 From: OGAWA Hirofumi Date: Mon, 24 May 2010 14:33:11 -0700 Subject: ratelimit: add ratelimit_state_init() For now, all users of ratelimit_state allocates it statically, so DEFINE_RATELIMIT_STATE() is enough. But, I want to use ratelimit_state for fs, i.e. per super_block to suppress too many error reports. So, this adds ratelimit_state_init() to initialize ratelimite_state which is dynamically allocated, instead of opencoding. Signed-off-by: OGAWA Hirofumi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/ratelimit.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'include/linux/ratelimit.h') diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h index 668cf1bef03..8f69d09a41a 100644 --- a/include/linux/ratelimit.h +++ b/include/linux/ratelimit.h @@ -2,7 +2,7 @@ #define _LINUX_RATELIMIT_H #include -#include +#include #define DEFAULT_RATELIMIT_INTERVAL (5 * HZ) #define DEFAULT_RATELIMIT_BURST 10 @@ -25,6 +25,17 @@ struct ratelimit_state { .burst = burst_init, \ } +static inline void ratelimit_state_init(struct ratelimit_state *rs, + int interval, int burst) +{ + spin_lock_init(&rs->lock); + rs->interval = interval; + rs->burst = burst; + rs->printed = 0; + rs->missed = 0; + rs->begin = 0; +} + extern int ___ratelimit(struct ratelimit_state *rs, const char *func); #define __ratelimit(state) ___ratelimit(state, __func__) -- cgit v1.2.3-70-g09d2