multipath: add option to change the number of error messages
authorBenjamin Marzinski <bmarzins@redhat.com>
Mon, 19 Dec 2011 21:41:57 +0000 (15:41 -0600)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Fri, 23 Dec 2011 20:04:59 +0000 (21:04 +0100)
This patch adds a new default config parameter, log_checker_err.  It accepts
two values, "once" and "always", and defaults of "always".  It controls
how multipathd logs checker error messages.  If it's set to "once", only the
first checker error message is logged at logging level 2. All future messages
are logged at level 3, until the device is restored or removed. If it's set
to "always", all messages are logged at level 2, like multipathd currently does.

This version actually compiles.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
libmultipath/config.h
libmultipath/dict.c
libmultipath/structs.h
multipath/multipath.conf.5
multipathd/main.c

index 6615e94202ef55899219c7dc7a35f079daf4731b..1bb2a8646e63a101f898ad1afe22af083fb1aa47 100644 (file)
@@ -92,6 +92,7 @@ struct config {
        int attribute_flags;
        int fast_io_fail;
        unsigned int dev_loss;
+       int log_checker_err;
        int allow_queueing;
        uid_t uid;
        gid_t gid;
index 514e589b61fa1ef885440bc75702e7fbaa4028ba..6220141f28e6ec9744a35c8fa86b08bb69851495 100644 (file)
@@ -524,6 +524,25 @@ def_flush_on_last_del_handler(vector strvec)
        return 0;
 }
 
+static int
+def_log_checker_err_handler(vector strvec)
+{
+       char * buff;
+
+       buff = set_value(strvec);
+
+       if (!buff)
+               return 1;
+
+       if (strlen(buff) == 4 && !strcmp(buff, "once"))
+               conf->log_checker_err = LOG_CHKR_ERR_ONCE;
+       else if (strlen(buff) == 6 && !strcmp(buff, "always"))
+               conf->log_checker_err = LOG_CHKR_ERR_ALWAYS;
+
+       free(buff);
+       return 0;
+}
+
 static int
 names_handler(vector strvec)
 {
@@ -2337,6 +2356,14 @@ snprint_def_flush_on_last_del (char * buff, int len, void * data)
        return 0;
 }
 
+static int
+snprint_def_log_checker_err (char * buff, int len, void * data)
+{
+       if (conf->log_checker_err == LOG_CHKR_ERR_ONCE)
+               return snprintf(buff, len, "once");
+       return snprintf(buff, len, "always");
+}
+
 static int
 snprint_def_user_friendly_names (char * buff, int len, void * data)
 {
@@ -2428,6 +2455,7 @@ init_keywords(void)
        install_keyword("fast_io_fail_tmo", &def_fast_io_fail_handler, &snprint_def_fast_io_fail);
        install_keyword("dev_loss_tmo", &def_dev_loss_handler, &snprint_def_dev_loss);
        install_keyword("bindings_file", &bindings_file_handler, &snprint_def_bindings_file);
+       install_keyword("log_checker_err", &def_log_checker_err_handler, &snprint_def_log_checker_err);
        __deprecated install_keyword("default_selector", &def_selector_handler, NULL);
        __deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
        __deprecated install_keyword("default_getuid_callout", &def_getuid_callout_handler, NULL);
index ea0fbf32ccbdc0a73b141044a47f92c4fdd7a12d..97caa31ac23f8947c0c76d5c87967c22cba7d378 100644 (file)
@@ -87,6 +87,11 @@ enum flush_states {
        FLUSH_IN_PROGRESS,
 };
 
+enum log_checker_err_states {
+       LOG_CHKR_ERR_ALWAYS,
+       LOG_CHKR_ERR_ONCE,
+};
+
 struct scsi_idlun {
        int dev_id;
        int host_unique_id;
index 94adee255ed7db984ae26edf74843581cca06476..aed171403ab8f8ab50998a862492f0bd25f20aed 100644 (file)
@@ -316,9 +316,19 @@ cannot be told to stop queueing IO. Setting queue_without_daemon to
 .I no
 , avoids this problem. Default is
 .I yes
+.TP
 .B bindings_file
 The full pathname of the binding file to be used when the user_friendly_names option is set. Defaults to
 .I /var/lib/multipath/bindings
+.TP
+.B log_checker_err
+If set to
+.I once
+, multipathd logs the first path checker error at logging level 2. Any later
+errors are logged at level 3 until the device is restored. If set to
+.I always
+, multipathd always logs the path checker error at logging level 2. Default is
+.I always
 .
 .SH "blacklist section"
 The
index 2e5fe0573057c2e8b1a4b8b112fc2748093254b8..3b686426a56261ddce3515ba701883809504cd2d 100644 (file)
@@ -1193,8 +1193,12 @@ check_path (struct vectors * vecs, struct path * pp)
                                pp->dev_t, pp->tick);
                }
        }
-       else if (newstate == PATH_DOWN)
-               LOG_MSG(2, checker_message(&pp->checker));
+       else if (newstate == PATH_DOWN) {
+               if (conf->log_checker_err == LOG_CHKR_ERR_ONCE)
+                       LOG_MSG(3, checker_message(&pp->checker));
+               else
+                       LOG_MSG(2, checker_message(&pp->checker));
+       }
 
        pp->state = newstate;