Correctly set pgfailback
authorHannes Reinecke <hare@suse.de>
Tue, 16 Jul 2013 07:13:10 +0000 (09:13 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 16 Jul 2013 19:50:42 +0000 (21:50 +0200)
Something weird happened to pgfailback; no default was assigned
when loading the configuration, but then it got set (wrongly)
to the default value when printing the configuration.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath/config.c
libmultipath/dict.c

index cc44244..8013a07 100644 (file)
@@ -556,6 +556,7 @@ load_config (char * file, struct udev *udev)
        conf->reassign_maps = DEFAULT_REASSIGN_MAPS;
        conf->checkint = DEFAULT_CHECKINT;
        conf->max_checkint = MAX_CHECKINT(conf->checkint);
+       conf->pgfailback = DEFAULT_FAILBACK;
        conf->fast_io_fail = DEFAULT_FAST_IO_FAIL;
        conf->retain_hwhandler = DEFAULT_RETAIN_HWHANDLER;
        conf->detect_prio = DEFAULT_DETECT_PRIO;
index 4b840de..0408e03 100644 (file)
@@ -1869,12 +1869,11 @@ snprint_mp_failback (char * buff, int len, void * data)
 {
        struct mpentry * mpe = (struct mpentry *)data;
 
-       if (!mpe->pgfailback)
+       if (mpe->pgfailback == FAILBACK_UNDEF ||
+           mpe->pgfailback == DEFAULT_FAILBACK)
                return 0;
 
        switch(mpe->pgfailback) {
-       case  FAILBACK_UNDEF:
-               break;
        case -FAILBACK_MANUAL:
                return snprintf(buff, len, "\"manual\"");
        case -FAILBACK_IMMEDIATE:
@@ -2247,12 +2246,11 @@ snprint_hw_failback (char * buff, int len, void * data)
 {
        struct hwentry * hwe = (struct hwentry *)data;
 
-       if (!hwe->pgfailback)
+       if (hwe->pgfailback == FAILBACK_UNDEF ||
+           hwe->pgfailback == DEFAULT_FAILBACK)
                return 0;
 
        switch(hwe->pgfailback) {
-       case  FAILBACK_UNDEF:
-               break;
        case -FAILBACK_MANUAL:
                return snprintf(buff, len, "\"manual\"");
        case -FAILBACK_IMMEDIATE:
@@ -2534,13 +2532,9 @@ snprint_def_path_checker (char * buff, int len, void * data)
 static int
 snprint_def_failback (char * buff, int len, void * data)
 {
-       int pgfailback = conf->pgfailback;
-       if (!pgfailback)
-               pgfailback = DEFAULT_FAILBACK;
-
        switch(conf->pgfailback) {
        case  FAILBACK_UNDEF:
-               break;
+               return snprintf(buff, len, "\"undef\"");
        case -FAILBACK_MANUAL:
                return snprintf(buff, len, "\"manual\"");
        case -FAILBACK_IMMEDIATE: