]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
printk_ratelimit() shares global ratelimiting state with all
authorNamhyung Kim <namhyung@gmail.com>
Tue, 9 Aug 2011 00:49:58 +0000 (10:49 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 9 Aug 2011 00:49:58 +0000 (10:49 +1000)
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>
drivers/md/dm.c
include/linux/device-mapper.h

index 52b39f335bb38549045f46eae8cad3714c867c5d..52a8fd8eb17f08c3a02632ea57901d7c5041d7d6 100644 (file)
 
 #define DM_MSG_PREFIX "core"
 
+#ifdef CONFIG_PRINTK
+/*
+ * ratelimit state to be used in DMXXX_LIMIT().
+ */
+DEFINE_RATELIMIT_STATE(dm_ratelimit_state,
+                      DEFAULT_RATELIMIT_INTERVAL,
+                      DEFAULT_RATELIMIT_BURST);
+EXPORT_SYMBOL(dm_ratelimit_state);
+#endif
+
 /*
  * Cookies are numeric values sent with CHANGE and REMOVE
  * uevents while resuming, removing or renaming the device.
index 3fa1f3d90ce0e21cb3ba27fa98d3201252f91f8e..7a39be6b746f5971907b22e644ce87e841137d2e 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/bio.h>
 #include <linux/blkdev.h>
+#include <linux/ratelimit.h>
 
 struct dm_dev;
 struct dm_target;
@@ -370,6 +371,14 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
  *---------------------------------------------------------------*/
 #define DM_NAME "device-mapper"
 
+#ifdef CONFIG_PRINTK
+extern struct ratelimit_state dm_ratelimit_state;
+
+#define dm_ratelimit() __ratelimit(&dm_ratelimit_state)
+#else
+#define dm_ratelimit() 0
+#endif
+
 #define DMCRIT(f, arg...) \
        printk(KERN_CRIT DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
 
@@ -377,7 +386,7 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
        printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
 #define DMERR_LIMIT(f, arg...) \
        do { \
-               if (printk_ratelimit()) \
+               if (dm_ratelimit())     \
                        printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " \
                               f "\n", ## arg); \
        } while (0)
@@ -386,7 +395,7 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
        printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
 #define DMWARN_LIMIT(f, arg...) \
        do { \
-               if (printk_ratelimit()) \
+               if (dm_ratelimit())     \
                        printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " \
                               f "\n", ## arg); \
        } while (0)
@@ -395,7 +404,7 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
        printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
 #define DMINFO_LIMIT(f, arg...) \
        do { \
-               if (printk_ratelimit()) \
+               if (dm_ratelimit())     \
                        printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f \
                               "\n", ## arg); \
        } while (0)
@@ -405,7 +414,7 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
        printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX " DEBUG: " f "\n", ## arg)
 #  define DMDEBUG_LIMIT(f, arg...) \
        do { \
-               if (printk_ratelimit()) \
+               if (dm_ratelimit())     \
                        printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX ": " f \
                               "\n", ## arg); \
        } while (0)