aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2010-05-24 17:33:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-25 11:07:03 -0400
commitf40c396a9ab04eae526990e2b2cef875b424ed4e (patch)
tree92b87fb6feb9470f9aa3cacc9344f7907ab2489c
parentd8521fcc5e0ad3e79bbc4231bb20a6cdc2b50164 (diff)
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 <hirofumi@mail.parknet.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/ratelimit.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h
index 668cf1bef030..8f69d09a41a5 100644
--- a/include/linux/ratelimit.h
+++ b/include/linux/ratelimit.h
@@ -2,7 +2,7 @@
2#define _LINUX_RATELIMIT_H 2#define _LINUX_RATELIMIT_H
3 3
4#include <linux/param.h> 4#include <linux/param.h>
5#include <linux/spinlock_types.h> 5#include <linux/spinlock.h>
6 6
7#define DEFAULT_RATELIMIT_INTERVAL (5 * HZ) 7#define DEFAULT_RATELIMIT_INTERVAL (5 * HZ)
8#define DEFAULT_RATELIMIT_BURST 10 8#define DEFAULT_RATELIMIT_BURST 10
@@ -25,6 +25,17 @@ struct ratelimit_state {
25 .burst = burst_init, \ 25 .burst = burst_init, \
26 } 26 }
27 27
28static inline void ratelimit_state_init(struct ratelimit_state *rs,
29 int interval, int burst)
30{
31 spin_lock_init(&rs->lock);
32 rs->interval = interval;
33 rs->burst = burst;
34 rs->printed = 0;
35 rs->missed = 0;
36 rs->begin = 0;
37}
38
28extern int ___ratelimit(struct ratelimit_state *rs, const char *func); 39extern int ___ratelimit(struct ratelimit_state *rs, const char *func);
29#define __ratelimit(state) ___ratelimit(state, __func__) 40#define __ratelimit(state) ___ratelimit(state, __func__)
30 41