@@ -24,6 +24,9 @@
#define DM_MSG_PREFIX "core"
+unsigned int dm_logging_level;
+EXPORT_SYMBOL(dm_logging_level);
+
/*
* Cookies are numeric values sent with CHANGE and REMOVE
* uevents while resuming, removing or renaming the device.
@@ -205,6 +208,8 @@ static struct kmem_cache *_tio_cache;
static struct kmem_cache *_rq_tio_cache;
static struct kmem_cache *_rq_bio_info_cache;
+char *dm_gendisk_device_name(struct mapped_device *md);
+
static int __init local_init(void)
{
int r = -ENOMEM;
@@ -2045,6 +2050,18 @@ const char *dm_device_name(struct mapped
}
EXPORT_SYMBOL_GPL(dm_device_name);
+char *dm_gendisk_device_name(struct mapped_device *md)
+{
+ struct gendisk *disk = dm_disk(md);
+ return disk->disk_name;
+}
+
+struct mapped_device *dm_target_get_md(struct dm_target *ti)
+{
+ return dm_table_get_md(ti->table);
+}
+EXPORT_SYMBOL_GPL(dm_target_get_md);
+
void dm_put(struct mapped_device *md)
{
struct dm_table *map;
@@ -2679,6 +2696,10 @@ EXPORT_SYMBOL(dm_get_mapinfo);
module_init(dm_init);
module_exit(dm_exit);
+module_param(dm_logging_level, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(dm_logging_level, "a bit mask of logging levels");
+
+
module_param(major, uint, 0);
MODULE_PARM_DESC(major, "The major number of the device mapper");
MODULE_DESCRIPTION(DM_NAME " driver");
@@ -50,6 +50,7 @@ static struct list_head _name_buckets[NU
static struct list_head _uuid_buckets[NUM_BUCKETS];
static void dm_hash_remove_all(int keep_open_devices);
+char *dm_gendisk_device_name(struct mapped_device *md);
/*
* Guards access to both hash tables.
@@ -115,7 +115,6 @@ static void trigger_event(struct work_st
static void activate_path(struct work_struct *work);
static void deactivate_path(struct work_struct *work);
-
/*-----------------------------------------------
* Allocation routines
*-----------------------------------------------*/
@@ -15,6 +15,8 @@
#include <linux/slab.h>
+#define DM_MSG_PREFIX "dm-path-selector"
+
struct ps_internal {
struct path_selector_type pst;
struct list_head list;
@@ -70,6 +70,9 @@ struct dm_table {
struct dm_md_mempools *mempools;
};
+
+char *dm_gendisk_device_name(struct mapped_device *md);
+
/*
* Similar to ceiling(log_size(n))
*/
@@ -308,6 +308,8 @@ void *dm_vcalloc(unsigned long nmemb, un
*---------------------------------------------------------------*/
#define DM_NAME "device-mapper"
+extern unsigned int dm_logging_level;
+
#define DMCRIT(f, arg...) \
printk(KERN_CRIT DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
@@ -339,17 +341,75 @@ void *dm_vcalloc(unsigned long nmemb, un
} while (0)
#ifdef CONFIG_DM_DEBUG
-# define DMDEBUG(f, arg...) \
- printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX " DEBUG: " f "\n", ## arg)
-# define DMDEBUG_LIMIT(f, arg...) \
- do { \
- if (printk_ratelimit()) \
- printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX ": " f \
- "\n", ## arg); \
+/* DM Logging level */
+ #define DMLOG_CRIT 0
+ #define DMLOG_ERR 1
+ #define DMLOG_WARN 2
+ #define DMLOG_INFO 3
+
+ #define DMLOG_BITS 2
+
+ /*DM Logging types */
+ enum {
+ DMLOG_INIT = 0,
+ DMLOG_ADD_DEV,
+ DMLOG_REMOVE_DEV,
+ DMLOG_IOCTL,
+ DMLOG_IO,
+ DMLOG_UEVENT,
+ DMLOG_TABLE,
+
+ DMLOG_FAILOVER,
+ DMLOG_PATH_ACTIVATE,
+ DMLOG_PATH_DEACTIVATE,
+ };
+
+
+
+ # define DMLOG_LEVEL(SHIFT) \
+ ((dm_logging_level >> (SHIFT * DMLOG_BITS)) & ((1 << (DMLOG_BITS)) - 1))
+
+ # define DMLOG(SHIFT, LEVEL, f, arg...) \
+ do { \
+ if ((DMLOG_LEVEL(SHIFT)) >= (LEVEL)) \
+ do { \
+ printk(KERN_INFO DM_NAME ": " \
+ DM_MSG_PREFIX ": " f "\n", ## arg); \
+ } while (0); \
+ } while (0)
+
+ # define DMLOG1(SHIFT, LEVEL, MAPPED_DEVICE, f, arg...) \
+ do { \
+ if ((DMLOG_LEVEL(SHIFT)) >= (LEVEL)) \
+ do { \
+ printk(KERN_INFO DM_NAME ": " \
+ DM_MSG_PREFIX ": "); \
+ if (MAPPED_DEVICE) \
+ printk("[%s]", dm_gendisk_device_name \
+ (MAPPED_DEVICE)); \
+ printk(" " f "\n", ## arg); \
+ } while (0); \
+ } while (0)
+ # define DMLOG2(SHIFT, LEVEL, DM_TARGET, f, arg...) \
+ do { \
+ if ((DMLOG_LEVEL(SHIFT)) >= (LEVEL)) \
+ do { \
+ struct mapped_device *md = \
+ dm_target_get_md(DM_TARGET); \
+ printk(KERN_INFO DM_NAME ": " \
+ DM_MSG_PREFIX ": "); \
+ if (md) { \
+ printk("[%s]", dm_gendisk_device_name \
+ (md)); \
+ dm_put(md); \
+ } \
+ printk(" " f "\n", ## arg); \
+ } while (0); \
} while (0)
#else
-# define DMDEBUG(f, arg...) do {} while (0)
-# define DMDEBUG_LIMIT(f, arg...) do {} while (0)
+#define DMLOG(SHIFT, LEVEL, f, arg...) do {); } while (0)
+#define DMLOG1(SHIFT, LEVEL, MAPPED_DEVICE, f, arg...) do {); } while (0)
+#define DMLOG2(SHIFT, LEVEL, DM_TARGET, f, arg...) do {); } while (0)
#endif
#define DMEMIT(x...) sz += ((sz >= maxlen) ? \
@@ -409,4 +469,8 @@ void dm_requeue_unmapped_request(struct
void dm_kill_unmapped_request(struct request *rq, int error);
int dm_underlying_device_busy(struct request_queue *q);
+struct mapped_device *dm_target_get_md(struct dm_target *ti);
+char *dm_gendisk_device_name(struct mapped_device *md);
+void dm_put(struct mapped_device *md);
+
#endif /* _LINUX_DEVICE_MAPPER_H */