Commit f40c396a authored by OGAWA Hirofumi's avatar OGAWA Hirofumi Committed by Linus Torvalds

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: default avatarOGAWA Hirofumi <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent d8521fcc
......@@ -2,7 +2,7 @@
#include <linux/param.h>
#include <linux/spinlock_types.h>
#include <linux/spinlock.h>
......@@ -25,6 +25,17 @@ struct ratelimit_state {
.burst = burst_init, \
static inline void ratelimit_state_init(struct ratelimit_state *rs,
int interval, int burst)
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__)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment