diff options
author | Namhyung Kim <namhyung@gmail.com> | 2011-10-31 16:18:54 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2011-10-31 16:18:54 -0400 |
commit | 71a16736a15e3fd11d283c42aa86bf704f6d25ff (patch) | |
tree | 1c6c54e8229b422756ec775cc04ad0066d1ad0c8 | |
parent | 4693c9668fdcec229825b3763876b4744f9e6d5e (diff) |
dm: use local printk ratelimit
printk_ratelimit() shares global ratelimiting state with all
other subsystems, so its usage is discouraged. Instead,
define and use dm's local state.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r-- | drivers/md/dm.c | 10 | ||||
-rw-r--r-- | include/linux/device-mapper.h | 17 |
2 files changed, 23 insertions, 4 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 52b39f335bb3..52a8fd8eb17f 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -25,6 +25,16 @@ | |||
25 | 25 | ||
26 | #define DM_MSG_PREFIX "core" | 26 | #define DM_MSG_PREFIX "core" |
27 | 27 | ||
28 | #ifdef CONFIG_PRINTK | ||
29 | /* | ||
30 | * ratelimit state to be used in DMXXX_LIMIT(). | ||
31 | */ | ||
32 | DEFINE_RATELIMIT_STATE(dm_ratelimit_state, | ||
33 | DEFAULT_RATELIMIT_INTERVAL, | ||
34 | DEFAULT_RATELIMIT_BURST); | ||
35 | EXPORT_SYMBOL(dm_ratelimit_state); | ||
36 | #endif | ||
37 | |||
28 | /* | 38 | /* |
29 | * Cookies are numeric values sent with CHANGE and REMOVE | 39 | * Cookies are numeric values sent with CHANGE and REMOVE |
30 | * uevents while resuming, removing or renaming the device. | 40 | * uevents while resuming, removing or renaming the device. |
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 99e3e50b5c57..622678ccb5e0 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h | |||
@@ -10,6 +10,7 @@ | |||
10 | 10 | ||
11 | #include <linux/bio.h> | 11 | #include <linux/bio.h> |
12 | #include <linux/blkdev.h> | 12 | #include <linux/blkdev.h> |
13 | #include <linux/ratelimit.h> | ||
13 | 14 | ||
14 | struct dm_dev; | 15 | struct dm_dev; |
15 | struct dm_target; | 16 | struct dm_target; |
@@ -375,6 +376,14 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size); | |||
375 | *---------------------------------------------------------------*/ | 376 | *---------------------------------------------------------------*/ |
376 | #define DM_NAME "device-mapper" | 377 | #define DM_NAME "device-mapper" |
377 | 378 | ||
379 | #ifdef CONFIG_PRINTK | ||
380 | extern struct ratelimit_state dm_ratelimit_state; | ||
381 | |||
382 | #define dm_ratelimit() __ratelimit(&dm_ratelimit_state) | ||
383 | #else | ||
384 | #define dm_ratelimit() 0 | ||
385 | #endif | ||
386 | |||
378 | #define DMCRIT(f, arg...) \ | 387 | #define DMCRIT(f, arg...) \ |
379 | printk(KERN_CRIT DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) | 388 | printk(KERN_CRIT DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) |
380 | 389 | ||
@@ -382,7 +391,7 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size); | |||
382 | printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) | 391 | printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) |
383 | #define DMERR_LIMIT(f, arg...) \ | 392 | #define DMERR_LIMIT(f, arg...) \ |
384 | do { \ | 393 | do { \ |
385 | if (printk_ratelimit()) \ | 394 | if (dm_ratelimit()) \ |
386 | printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " \ | 395 | printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " \ |
387 | f "\n", ## arg); \ | 396 | f "\n", ## arg); \ |
388 | } while (0) | 397 | } while (0) |
@@ -391,7 +400,7 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size); | |||
391 | printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) | 400 | printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) |
392 | #define DMWARN_LIMIT(f, arg...) \ | 401 | #define DMWARN_LIMIT(f, arg...) \ |
393 | do { \ | 402 | do { \ |
394 | if (printk_ratelimit()) \ | 403 | if (dm_ratelimit()) \ |
395 | printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " \ | 404 | printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " \ |
396 | f "\n", ## arg); \ | 405 | f "\n", ## arg); \ |
397 | } while (0) | 406 | } while (0) |
@@ -400,7 +409,7 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size); | |||
400 | printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) | 409 | printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) |
401 | #define DMINFO_LIMIT(f, arg...) \ | 410 | #define DMINFO_LIMIT(f, arg...) \ |
402 | do { \ | 411 | do { \ |
403 | if (printk_ratelimit()) \ | 412 | if (dm_ratelimit()) \ |
404 | printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f \ | 413 | printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f \ |
405 | "\n", ## arg); \ | 414 | "\n", ## arg); \ |
406 | } while (0) | 415 | } while (0) |
@@ -410,7 +419,7 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size); | |||
410 | printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX " DEBUG: " f "\n", ## arg) | 419 | printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX " DEBUG: " f "\n", ## arg) |
411 | # define DMDEBUG_LIMIT(f, arg...) \ | 420 | # define DMDEBUG_LIMIT(f, arg...) \ |
412 | do { \ | 421 | do { \ |
413 | if (printk_ratelimit()) \ | 422 | if (dm_ratelimit()) \ |
414 | printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX ": " f \ | 423 | printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX ": " f \ |
415 | "\n", ## arg); \ | 424 | "\n", ## arg); \ |
416 | } while (0) | 425 | } while (0) |