[libmultipath] clarify priority values
authorChristophe Varoqui <cvaroqui@zezette.localdomain>
Wed, 15 Nov 2006 23:06:48 +0000 (00:06 +0100)
committerChristophe Varoqui <cvaroqui@zezette.localdomain>
Wed, 15 Nov 2006 23:06:48 +0000 (00:06 +0100)
Define two values :
PRIO_UNDEF: prioritizer not exec yet, or returned an error
PRIO_DEFAULT: no prioritizer set, default value arbitrary set to 1

Changes :
1) 0 is no longer used as a possible priority value.
2) don't exec prioritizer in pathinfo() if path is down and priority is
defined

Edward Goggin, EMC
Dave Wysochanski, Red Hat
& Me

libmultipath/configure.c
libmultipath/discovery.c
libmultipath/structs.c
libmultipath/structs.h
multipath/main.c

index b66cf23..9d17022 100644 (file)
@@ -441,7 +441,7 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid)
                if ((mpp = add_map_with_path(vecs, pp1, 0)) == NULL)
                        return 1;
 
-               if (pp1->priority < 0)
+               if (pp1->priority == PRIO_UNDEF)
                        mpp->action = ACT_REJECT;
 
                if (!mpp->paths) {
@@ -468,7 +468,7 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid)
                                        mpp->size);
                                mpp->action = ACT_REJECT;
                        }
-                       if (pp2->priority < 0)
+                       if (pp2->priority == PRIO_UNDEF)
                                mpp->action = ACT_REJECT;
                }
                verify_paths(mpp, vecs, NULL);
index 69c9bc3..f21e5bc 100644 (file)
@@ -638,14 +638,14 @@ get_prio (struct path * pp)
                pp->getprio_selected = 1;
        }
        if (!pp->getprio) {
-               pp->priority = 1;
+               pp->priority = PRIO_DEFAULT;
        } else if (apply_format(pp->getprio, &buff[0], pp)) {
                condlog(0, "error formatting prio callout command");
-               pp->priority = -1;
+               pp->priority = PRIO_UNDEF;
                return 1;
        } else if (execute_program(buff, prio, 16)) {
                condlog(0, "error calling out %s", buff);
-               pp->priority = -1;
+               pp->priority = PRIO_UNDEF;
                return 1;
        } else
                pp->priority = atoi(prio);
@@ -701,13 +701,12 @@ pathinfo (struct path *pp, vector hwtable, int mask)
        if (mask & DI_CHECKER && get_state(pp))
                goto blank;
        
-       /*
-        * Path state of PATH_DOWN does not necessarily prevent
-        * path priority callout (or getuid callouot) from
-        * succeeding since the path may be being considered
-        * failed for reasons other than transport connectivity.
-        */
-       if (mask & DI_PRIO)
+        /*
+         * Retrieve path priority for even PATH_DOWN paths if it has never
+         * been successfully obtained before.
+         */
+       if (mask & DI_PRIO &&
+           (pp->state != PATH_DOWN || pp->priority != PRIO_UNDEF))
                get_prio(pp);
 
        if (mask & DI_WWID && !strlen(pp->wwid))
index f0564c2..db3f824 100644 (file)
@@ -31,6 +31,7 @@ alloc_path (void)
                pp->sg_id.scsi_id = -1;
                pp->sg_id.lun = -1;
                pp->fd = -1;
+               pp->priority = PRIO_UNDEF;
        }
        return pp;
 }
index faa2b8f..7db7faa 100644 (file)
@@ -18,6 +18,9 @@
 #define NO_PATH_RETRY_FAIL     -1
 #define NO_PATH_RETRY_QUEUE    -2
 
+#define PRIO_UNDEF             -1
+#define PRIO_DEFAULT           1
+
 enum free_path_switch {
        KEEP_PATHS,
        FREE_PATHS
index a5f122e..accb230 100644 (file)
@@ -134,7 +134,7 @@ update_paths (struct multipath * mpp)
                        if (pp->state == PATH_UNCHECKED)
                                pathinfo(pp, conf->hwtable, DI_CHECKER);
 
-                       if (!pp->priority)
+                       if (pp->priority == PRIO_UNDEF)
                                pathinfo(pp, conf->hwtable, DI_PRIO);
                }
        }