Skip to contentSkip to conversation

Improvement: new logging library for mdadm/mdmon

PATCH In review Artur Wojcik 5 participants 7 messages Jan 28, 2010 – Jan 30, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Improvement: new logging library for mdadm/mdmon

The following two patches contains the new method of logging messages in mdadm and mdmon applications. The first patch is just the library, and the second patch is the proposal on how to use the library in the applications.

As for the library, please let me know if detailed explanation is required.

---

Artur Wojcik (2):
Improvement: new logging facility.
Improvement: Replace fprintf functions with log_* functions.

 Assemble.c    |  382 +++++++++++++++--------------------
 Build.c       |   65 +++---
 Create.c      |  206 ++++++++-----------
 Detail.c      |   39 ++--
 Examine.c     |   11 +
 Grow.c        |  333 +++++++++++++++++-------------
 Incremental.c |  229 ++++++++-------------
 Kill.c        |   21 +-
 Makefile      |    6 -
 Manage.c      |  163 ++++++---------
 Monitor.c     |  107 +++++-----
 Query.c       |    2
 ReadMe.c      |   18 ++
 bitmap.c      |   35 +--
 config.c      |  142 ++++++-------
 log.c         |  625 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 log.h         |  148 +++++++++++++
 managemon.c   |   10 -
 mdadm.c       |  556 +++++++++++++++++++++++++++++++++++----------------
 mdadm.h       |   78 ++++---
 mdmon.c       |   45 ++--
 mdopen.c      |   39 ++--
 mdstat.c      |    2
 monitor.c     |   29 +--
 super-ddf.c   |  185 +++++++----------
 super-intel.c |  366 ++++++++++++++-------------------
 super0.c      |   68 ++----
 super1.c      |   53 ++---
 sysfs.c       |   24 +-
 test          |    0
 util.c        |   22 +-
 31 files changed, 2396 insertions(+), 1613 deletions(-)
 create mode 100644 log.c
 create mode 100644 log.h
 mode change 100644 => 100755 test

---
Artur Wojcik

#1 lore raw

PATCH 1/2 Improvement: new logging facility.

This patch introduces the new method of message logging for mdadm and mdmon applications.

The new logging library allows redirecting log messages to terminal console, log file and syslog, simultaneously with a single function call. The library defines 6 log levels and 10 log hives. The log levels are: ALERT, FATAL, ERROR, WARNING, NOTICE, INFO and DEBUG. The log hive is an object to ease operations on group of log messages e.g. form a module of an application or from a certain functionality.

Each hive has verbosity level and a mask determining where to redirect the log messages. The mask is useful, for example, in quiet mode: an application will stop logging messages on terminal console but it will keep logging to a file and/or syslog. The log hive is similar to facility parameter of syslog.

The default location of a log file is /var/log/<binname>.log. The format of log messages differs depending on output. Sylog and log file outputs have messages prefixed with timestamp and pid information. Additionally debug logs have messages prefixed with file name, function name and line in source code. Terminal console output has message format as close as it is possible to original format.

Debug messages can be redirected to different log file then rest of log messages.

---
 Makefile |    6 -
 log.c    |  625 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 log.h    |  148 +++++++++++++++
 3 files changed, 776 insertions(+), 3 deletions(-)
 create mode 100644 log.c
 create mode 100644 log.h
Makefile +3 -3
index 901b3e0..ae9f95c 100644
@@ -81,19 +81,19 @@ OBJS =  mdadm.o config.o mdstat.o  ReadMe.o util.o Manage.o Assemble.o Build.o \
 	Incremental.o \
 	mdopen.o super0.o super1.o super-ddf.o super-intel.o bitmap.o \
 	restripe.o sysfs.o sha1.o mapfile.o crc32.o sg_io.o msg.o \
-	platform-intel.o probe_roms.o
+	platform-intel.o probe_roms.o log.o
 
 SRCS =  mdadm.c config.c mdstat.c  ReadMe.c util.c Manage.c Assemble.c Build.c \
 	Create.c Detail.c Examine.c Grow.c Monitor.c dlink.c Kill.c Query.c \
 	Incremental.c \
 	mdopen.c super0.c super1.c super-ddf.c super-intel.c bitmap.c \
 	restripe.c sysfs.c sha1.c mapfile.c crc32.c sg_io.c msg.c \
-	platform-intel.c probe_roms.c
+	platform-intel.c probe_roms.c log.c
 
 MON_OBJS = mdmon.o monitor.o managemon.o util.o mdstat.o sysfs.o config.o \
 	Kill.o sg_io.o dlink.o ReadMe.o super0.o super1.o super-intel.o \
 	super-ddf.o sha1.o crc32.o msg.o bitmap.o \
-	platform-intel.o probe_roms.o
+	platform-intel.o probe_roms.o log.o
 
 
 STATICSRC = pwgr.c
log.c new file +625 -0

625 lines not on this page · raw message

log.h new file +148 -0

148 lines not on this page · raw message

#2 lore raw
In reply to Artur Wojcik
Quoted 7 lines · On Thu, 28 Jan 2010 17:04:04 +0100 Artur Wojcik <[email protected]> wrote:

The following two patches contains the new method of logging messages in mdadm and mdmon applications. The first patch is just the library, and the second patch is the proposal on how to use the library in the applications.

As for the library, please let me know if detailed explanation is required.

Detailed explanations are always necessary.

I'd probably need a lot of convincing to add something like this to mdadm.

NeilBrown

#3 lore raw
Quoted 2 lines · Neil Brown

I'd probably need a lot of convincing to add something like this to mdadm.

I did not expect this patch to be accepted without convincing you or at least without a lot of explanations :). What interest you the most?

The reason for this improvement/patch is:

1) to unify the way mdadm and mdmon log messages,
2) to have logs from mdadm and mdmon applications at the same time,
3) to be able to capture log messages when system is booting,
4) to simplify the source code.

This all should improve problem diagnosis/resolution (complete log) and reduce the complexity of source code (one function call, less parameters in parent function) and simpler code is easier to maintain.

This is only the library, the next step would be to clean up the logs i.e. mdmon does not log much. I started this in 2nd patch.

BTW. I have a problem with patch 2/2 - it didn't appear on the list. I tried sending it several times - is it too big?. However you should receive it on your mailbox, if not please let me know.

The second patch is only a proposal on how to incorporate the logging library into mdmon/mdmadm.

At the moment all I can ask you is to try it first. The command line works as before i.e. -v[v[v]] increases the level of verbosity and 'quiet' makes no output on terminal console only (mdadm still will be logging to file and to syslog).

The command line does not work for mdadm yet.

The logs are redirected to terminal console, syslog and log file with a single function call.

There are new command line options, use them to on/off certain group of logs and change verbosity level. The new commands are

--log-alert=[list of hives comma separated; all - for all hives] --log-fatal=[same as above]
--log-error=[same as above]
--log-warn=[same as above]
--log-notice=[same as above]
--log-info=[same as above]
--log-debug=[same as above]

If no argument is given (optarg is null) then verbosity is changed for generic hive only.

There will be command line options options added soon to redirect the log messages.

Here's the list of hives: generic, io, super, ddf, mode, imsm, deamon, all

generic - command line parser and config file parser

io - e.g. file acces errors, file seek errors, etc.

super - log messages related to super0 and super1.

ddf - log messages related to DDF volumes and containers only.

mode - log messages related to mode operations (Assemble, Create, Build, etc) - the logs visualizing the stages of an algorithm.

imsm - the logs from all Intel modules.

deamon - the logs from mdmon deamon process and from monitor proces of mdadm.

all - means 'perform an operation on all hives'

Thanks,
Artur

#4 lore raw
Quoted 3 lines · Artur Wojcik

deamon - the logs from mdmon deamon process and from monitor proces of mdadm.

Just to be pedantic, can I point out that this should be either demon or daemon, but definitely not deamon.

Cheers,
Robin

Signature · 4 lines
     ___        
    ( ' }     |       Robin Hill        <[email protected]> |
   / / )      | Little Jim says ....                            |
  // !!       |      "He fallen in de water !!"                 |
#5 lore raw
In reply to Artur Wojcik
Quoted 10 lines · Artur
Quoted 2 lines · Neil Brown

I'd probably need a lot of convincing to add something like this to mdadm.

I did not expect this patch to be accepted without convincing you or at least without a lot of explanations :). What interest you the most?

The reason for this improvement/patch is:

1) to unify the way mdadm and mdmon log messages,

Unification implies code reduction, this is currently just code movement.

Quoted 2 lines

2) to have logs from mdadm and mdmon applications at the same time
3) to be able to capture log messages when system is booting, 4) to simplify the source code.

The only one that would be interesting from a debug perspective is 3, but syslog is not available in the initramfs and I currently do not see how it would be much better than just redirecting the console to the serial port and logging it there. The dprintf() calls in mdmon are sometimes useful, but I am skeptical of needing those on all the time.

Can you identify debug scenarios that require this level of logging sophistication (versus doing one-off build/configuration changes to dump some diagnostic info)? As it stands this looks like a solution looking for a problem.

--
Dan

#6 lore raw
Quoted 21 lines · Dan Williams
Quoted 7 lines · Artur
Quoted 4 lines · Neil Brown

I'd probably need a lot of convincing to add something like this to mdadm.

Quoted 6 lines

I did not expect this patch to be accepted without convincing you or at least without a lot of explanations :). What interest you the most?

The reason for this improvement/patch is:

1) to unify the way mdadm and mdmon log messages,

Unification implies code reduction, this is currently just code movement.

Quoted 3 lines

2) to have logs from mdadm and mdmon applications at the same time
3) to be able to capture log messages when system is booting, 4) to simplify the source code.

Quoted 6 lines

The only one that would be interesting from a debug perspective is 3, but syslog is not available in the initramfs and I currently do not see how it would be much better than just redirecting the console to the serial port and logging it there.  The dprintf() calls in mdmon are sometimes useful, but I am skeptical of needing those on all the time.

3) If you're worried about the kernel messages look in to netconsole.

If you're worried about where system logs go after startup, isn't that what the various syslog daemons are for (in fact on my 24/7 linux system my syslog /captures/ netconsole logs from any other machine I care to set up sending from)?
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html