[dm-devel] [patch 0/1][RESEND] New Logging approach for Device Mapper

Chauhan, Vijay Vijay.Chauhan at lsi.com
Mon Nov 9 11:07:02 UTC 2009


Hi,

I have modified the previous dm logging patch to print logs in more user friendly format. 

Ex :
Nov  9 16:45:04 localhost kernel: device-mapper: multipath: [dm-1] Switching to pathgroup index 1
Nov  9 16:45:04 localhost kernel: device-mapper: multipath: [dm-1] Selecting path sdc for I/O


This new patch includes following changes:
 - printing "[dm-*]" instead of "major:minor"
 - Added 3 macro functions for logging 
	# define DMLOG(..)
		* It should be used when  we just want to print message without device name.
		Prototype : #define DMLOG(SHIFT, LEVEL, f, arg...)
		Usage ex: DMLOG(DMLOG_INIT, DMLOG_INFO, "cleaned up");
		 
	# define DMLOG1(..)
		* prints device name with messages
		* (struct mapped_device * ) needs to be passed as 3rd argument to this macro function
		Prototype : #define DMLOG1(SHIFT, LEVEL, MAPPED_DEVICE, f, arg...)
		Usage ex: DMLOG1(DMLOG_IOCTL, DMLOG_INFO, md, " Setting DMF_NOFLUSH_SUSPENDING flag");

	# define DMLOG2(..)
		* prints device name with messages
		* (struct dm_target * ) needs to be passed as 3rd argument to this macro function. 
		  (Typically to be used by target)
		Prototype : #define DMLOG2(SHIFT, LEVEL, DM_TARGET, f, arg...)
		Usage ex: DMLOG2(DMLOG_IOCTL, ti, "Unrecognised multipath message received.");


How to set logging level :
---------------------------
[copy paste from my previous mail]

1) On-the-fly by setting /sys/module/dm_mod/parameters/dm_logging_level. 

For example: To enable DMLOG_INIT logs for all ERROR (i.e DMLOG_ERR level) and DMLOG_ADD_DEV logs at DMLOG_INFO level, we can set as 
               follows:
	4   2   0       	 
	|_|_|_|_|
       1 1 0 1   -->0x0d or 13	 
	
	echo 0x0000000d > >/sys/module/dm_mod/parameters/dm_logging_level
			or
	echo 13 >/sys/module/dm_mod/parameters/dm_logging_level


2) At boot time using modprobe.conf:
		options dm-mod dm_logging_level=13
	

------------------------------------------------------------------------------
dm_logging_level bitwise representation (2 bit reserved for each logging type)
------------------------------------------------------------------------------

  	  20  18  16  14  12  10  8   6   4   2   0	
      ......|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|         
            \   \   \   \   \   \   \   \   \   \_DMLOG_INIT   
          	 \   \   \   \   \   \   \   \   \_DMLOG_ADD_DEV    
              \   \   \   \   \   \   \   \_DMLOG_REMOVE_DEV
               \   \   \   \   \   \   \_DMLOG_IOCTL
                \   \   \   \   \   \_DMLOG_IO   
                 \   \   \   \   \_DMLOG_UEVENT   
                  \   \   \   \_DMLOG_TABLE
                   \   \   \_DMLOG_FAILOVER         
                    \   \_DMLOG_PATH_ACTIVATE
	               \_DMLOG_PATH_DEACTIVATE



snippet of syslog with new logging patch:
===============================================
Nov  9 21:33:29 localhost kernel: device-mapper: multipath: version 1.1.0 loaded
Nov  9 21:33:29 localhost kernel: device-mapper: dm-path-selector: path selector round-robin registered successfully
Nov  9 21:33:29 localhost kernel: device-mapper: multipath round-robin: version 1.0.0 loaded
Nov  9 21:33:29 localhost kernel: device-mapper: dm-path-selector: path selector module round-robin Loaded successfully
Nov  9 21:33:29 localhost kernel: device-mapper: ioctl: 3600a0b80003908f9000047ec4a10b680: Creating dm device
Nov  9 21:33:29 localhost kernel: device-mapper: ioctl: [dm-0] Inserting in hash table
Nov  9 21:33:29 localhost kernel: device-mapper: ioctl: [dm-0] Successfully inserted in hash table
Nov  9 21:33:29 localhost multipathd: 3600a0b80003908f9000047ec4a10b680: load table [0 2097152 multipath 2 pg_init_retries 49 1 rdac 2 1 round-robin 0 1 1 8:16 1000
Nov  9 21:33:29 localhost kernel: device-mapper: ioctl: 3600a0b80003910f3000058264a7e46cb: Creating dm device
Nov  9 21:33:29 localhost kernel: device-mapper: ioctl: [dm-1] Inserting in hash table
Nov  9 21:33:29 localhost kernel: device-mapper: ioctl: [dm-1] Successfully inserted in hash table
Nov  9 21:33:29 localhost multipathd: 3600a0b80003910f3000058264a7e46cb: load table [0 20971520 multipath 2 pg_init_retries 49 1 rdac 2 1 round-robin 0 1 1 8:32 1000
Nov  9 21:33:29 localhost multipathd: 3600a0b80003908f9000047ec4a10b680: event checker started
Nov  9 21:33:29 localhost multipathd: 3600a0b80003910f3000058264a7e46cb: event checker started
Nov  9 21:33:29 localhost multipathd: path checkers start up
Nov  9 21:33:29 localhost kernel: device-mapper: multipath: [dm-1] Switching to pathgroup index 1
Nov  9 21:33:29 localhost kernel: device-mapper: multipath: [dm-1] Selecting path sdc for I/O
Nov  9 21:33:29 localhost kernel: device-mapper: multipath: [dm-1] pg_init_done: failover status = 0
Nov  9 21:33:30 localhost kernel: device-mapper: multipath: [dm-0] Switching to pathgroup index 1
Nov  9 21:33:30 localhost kernel: device-mapper: multipath: [dm-0] Selecting path sdb for I/O
Nov  9 21:33:30 localhost kernel: device-mapper: multipath: [dm-0] pg_init_done: failover status = 0



Please give your comments.

Thanks,
Vijay


On September 07, 2009 12:59 PM, Chauhan, Vijay wrote :
 > 
 > On Sun, Sep 6, 2009 at 5:03 AM, Alasdair G Kergon 
 > <agk at redhat.com> wrote:
 > > > Each logging type is represented with 2 bits in 
 > > dm_logging_level. Following are the logging types 
 > currently defined :
 > > 
 > > Does that mean there's a limit we'll soon exceed?
 > 
 > Yes true. In that case we can further split the logging 
 > across the targets , such as multipath, linear so on. Your 
 > thoughts please.
 > 
 > > 
 > > > Sep  5 18:32:02 localhost kernel: device-mapper: core: 
 > > DEBUG: dm_resume: Unsetting DMF_SUSPENDED flag for 253:1
 > > 
 > > I was hoping the next extension to the macro code would 
 > > somehow add info
 > > like '253:1' (and maybe corresponding device name) automatically to
 > > every message related to a device.
 > > 




More information about the dm-devel mailing list