From patchwork Mon Nov 23 07:24:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chauhan, Vijay" X-Patchwork-Id: 62109 X-Patchwork-Delegate: agk@redhat.com Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAN7Pftu007067 for ; Mon, 23 Nov 2009 07:25:41 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id B8EC961988B; Mon, 23 Nov 2009 02:25:40 -0500 (EST) Received: from int-mx08.intmail.prod.int.phx2.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id nAN7PdFb008666 for ; Mon, 23 Nov 2009 02:25:39 -0500 Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.14]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nAN7PcO8015386; Mon, 23 Nov 2009 02:25:38 -0500 Received: from na3sys009aog104.obsmtp.com (na3sys009aog104.obsmtp.com [74.125.149.73]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAN7P9W6029806; Mon, 23 Nov 2009 02:25:09 -0500 Received: from source ([147.145.40.20]) by na3sys009aob104.postini.com ([74.125.148.12]) with SMTP ID DSNKSwo41eWM9pToIxJyxYjXnB0yo5l6GVke@postini.com; Sun, 22 Nov 2009 23:25:23 PST Received: from milmhbs0.lsil.com (mhbs.lsil.com [147.145.1.30]) by mail0.lsil.com (8.12.11/8.12.11) with ESMTP id nAN7P6dm029397; Sun, 22 Nov 2009 23:25:07 -0800 (PST) Received: from inbmail01.lsi.com (inbmail01.in.lsil.com [172.28.140.213]) by milmhbs0.lsil.com (8.12.11/8.12.11) with ESMTP id nAN7P94I002578; Sun, 22 Nov 2009 23:25:09 -0800 Received: from inbmail01.lsi.com ([172.28.140.213]) by inbmail01.lsi.com ([172.28.140.213]) with mapi; Mon, 23 Nov 2009 12:55:04 +0530 From: "Chauhan, Vijay" To: "agk@redhat.com" , "hare@suse.de" , "sekharan@linux.vnet.ibm.com" , device-mapper development Date: Mon, 23 Nov 2009 12:54:41 +0530 Thread-Topic: [Patch 1/2][RESEND] New Logging approach for Device Mapper Thread-Index: AcphLNVYoT+LUNgZQ0mHGhtyjAxHyQK3lLjQ Message-ID: <0D1E8821739E724A86F4D16902CE275C1C93C74ED3@inbmail01.lsi.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.14 X-Scanned-By: MIMEDefang 2.39 X-RedHat-Spam-Score: 0 () X-MIME-Autoconverted: from quoted-printable to 8bit by listman.util.phx.redhat.com id nAN7PdFb008666 X-loop: dm-devel@redhat.com Cc: "Dachepalli, Sudhir" , "Chauhan, Vijay" , "Stankey, Robert" , "Moger, Babu" Subject: [dm-devel] RE: [Patch 1/2][RESEND] New Logging approach for Device Mapper X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com diff -uprN linux-2.6.32-rc5-orig/drivers/md/dm.c linux-2.6.32-rc5/drivers/md/dm.c --- linux-2.6.32-rc5-orig/drivers/md/dm.c 2009-11-09 06:09:34.000000000 +0530 +++ linux-2.6.32-rc5/drivers/md/dm.c 2009-11-20 01:11:53.000000000 +0530 @@ -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; +const 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); +const 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"); diff -uprN linux-2.6.32-rc5-orig/drivers/md/dm-ioctl.c linux-2.6.32-rc5/drivers/md/dm-ioctl.c --- linux-2.6.32-rc5-orig/drivers/md/dm-ioctl.c 2009-11-09 06:09:34.000000000 +0530 +++ linux-2.6.32-rc5/drivers/md/dm-ioctl.c 2009-11-20 01:11:41.000000000 +0530 @@ -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); +const char *dm_gendisk_device_name(struct mapped_device *md); /* * Guards access to both hash tables. diff -uprN linux-2.6.32-rc5-orig/drivers/md/dm-mpath.c linux-2.6.32-rc5/drivers/md/dm-mpath.c --- linux-2.6.32-rc5-orig/drivers/md/dm-mpath.c 2009-11-09 06:09:34.000000000 +0530 +++ linux-2.6.32-rc5/drivers/md/dm-mpath.c 2009-11-20 01:07:13.000000000 +0530 @@ -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 *-----------------------------------------------*/ diff -uprN linux-2.6.32-rc5-orig/drivers/md/dm-path-selector.c linux-2.6.32-rc5/drivers/md/dm-path-selector.c --- linux-2.6.32-rc5-orig/drivers/md/dm-path-selector.c 2009-11-09 06:09:34.000000000 +0530 +++ linux-2.6.32-rc5/drivers/md/dm-path-selector.c 2009-11-20 01:07:13.000000000 +0530 @@ -15,6 +15,8 @@ #include +#define DM_MSG_PREFIX "dm-path-selector" + struct ps_internal { struct path_selector_type pst; struct list_head list; diff -uprN linux-2.6.32-rc5-orig/drivers/md/dm-table.c linux-2.6.32-rc5/drivers/md/dm-table.c --- linux-2.6.32-rc5-orig/drivers/md/dm-table.c 2009-11-09 06:09:34.000000000 +0530 +++ linux-2.6.32-rc5/drivers/md/dm-table.c 2009-11-20 01:11:46.000000000 +0530 @@ -70,6 +70,9 @@ struct dm_table { struct dm_md_mempools *mempools; }; + +const char *dm_gendisk_device_name(struct mapped_device *md); + /* * Similar to ceiling(log_size(n)) */ diff -uprN linux-2.6.32-rc5-orig/include/linux/device-mapper.h linux-2.6.32-rc5/include/linux/device-mapper.h --- linux-2.6.32-rc5-orig/include/linux/device-mapper.h 2009-11-09 06:10:02.000000000 +0530 +++ linux-2.6.32-rc5/include/linux/device-mapper.h 2009-11-20 01:20:04.000000000 +0530 @@ -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, MD, f, arg...) \ + do { \ + if ((DMLOG_LEVEL(SHIFT)) >= (LEVEL)) \ + do { \ + printk(KERN_INFO DM_NAME ": " \ + DM_MSG_PREFIX ": "); \ + if (MD) \ + printk("[%s] %s:", dm_device_name(MD), \ + dm_gendisk_device_name(MD)); \ + 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] %s:", dm_device_name(md), \ + 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); +const char *dm_gendisk_device_name(struct mapped_device *md); +void dm_put(struct mapped_device *md); + #endif /* _LINUX_DEVICE_MAPPER_H */