From patchwork Mon Nov 9 11:07:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chauhan, Vijay" X-Patchwork-Id: 58686 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 nA9B7xSD002352 for ; Mon, 9 Nov 2009 11:08:00 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 B341C618E49; Mon, 9 Nov 2009 06:07:59 -0500 (EST) Received: from int-mx02.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 nA9B7w5c006721 for ; Mon, 9 Nov 2009 06:07:58 -0500 Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.7]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nA9B7vq3004773; Mon, 9 Nov 2009 06:07:57 -0500 Received: from na3sys009aog112.obsmtp.com (na3sys009aog112.obsmtp.com [74.125.149.207]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nA9B7iuO003368; Mon, 9 Nov 2009 06:07:45 -0500 Received: from source ([147.145.40.20]) by na3sys009aob112.postini.com ([74.125.148.12]) with SMTP ID DSNKSvf4ADyaqeehigif+CJjSgdu11ldG8BD@postini.com; Mon, 09 Nov 2009 03:07:57 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 nA9B7hfK005134; Mon, 9 Nov 2009 03:07:43 -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 nA9B7h84029360; Mon, 9 Nov 2009 03:07:43 -0800 Received: from inbmail01.lsi.com ([172.28.140.213]) by inbmail01.lsi.com ([172.28.140.213]) with mapi; Mon, 9 Nov 2009 16:37:41 +0530 From: "Chauhan, Vijay" To: "agk@redhat.com" , "hare@suse.de" , "sekharan@linux.vnet.ibm.com" , device-mapper development Date: Mon, 9 Nov 2009 16:37:31 +0530 Thread-Topic: [Patch 1/2][RESEND] New Logging approach for Device Mapper Thread-Index: AcphLNVYoT+LUNgZQ0mHGhtyjAxHyQ== Message-ID: <0D1E8821739E724A86F4D16902CE275C1C93C03EA6@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.12 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.7 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 nA9B7w5c006721 X-loop: dm-devel@redhat.com Cc: "Dachepalli, Sudhir" , "Stankey, Robert" , "Moger, Babu" Subject: [dm-devel] [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-09 20:34:05.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; +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"); 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-09 20:34:05.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); +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-09 20:34:05.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-09 20:34:05.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-09 20:34:05.000000000 +0530 @@ -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)) */ 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-09 20:34:40.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, 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 */