[libmultipath] don't re-select the getprio fn when not needed
authorChristophe Varoqui <root@xa-s05.(none)>
Wed, 16 Nov 2005 15:26:10 +0000 (16:26 +0100)
committerChristophe Varoqui <root@xa-s05.(none)>
Wed, 16 Nov 2005 15:26:10 +0000 (16:26 +0100)
The pp->getprio was used
1) to store the prioritizer function pointer
2) to determine if the prioritizer was already selected

But NULL is a valid value for already selected getprio.
Which causes uneeded re-selection.

So introduce a pp->getprio_selected flag to straight this out.

Edward Goggin, EMC

libmultipath/cache.c
libmultipath/discovery.c
libmultipath/structs.h
multipathd/main.c

index d646bc7..a90b617 100644 (file)
@@ -21,6 +21,7 @@ revoke_cache_info(struct path * pp)
        pp->getuid = NULL;
        pp->getprio = NULL;
        pp->checkfn = NULL;
+       pp->getprio_selected = 0;
 }
 
 int
index a1b7a09..41ad512 100644 (file)
@@ -629,9 +629,10 @@ pathinfo (struct path *pp, vector hwtable, int mask)
         * get path prio
         */
        if (mask & DI_PRIO) {
-               if (!pp->getprio)
+               if (!pp->getprio_selected) {
                        select_getprio(pp);
-
+                       pp->getprio_selected = 1;
+               }
                if (!pp->getprio) {
                        pp->priority = 1;
                } else if (apply_format(pp->getprio, &buff[0], pp)) {
index 183e790..3bcb5b9 100644 (file)
@@ -99,6 +99,7 @@ struct path {
        int pgindex;
        char * getuid;
        char * getprio;
+       int getprio_selected;
        int (*checkfn) (int, char *, void **);
        void * checker_context;
        struct multipath * mpp;
index af3fabc..e1130f0 100644 (file)
@@ -168,6 +168,7 @@ orphan_path (struct path * pp)
        pp->checker_context = NULL;
        pp->getuid = NULL;
        pp->getprio = NULL;
+       pp->getprio_selected = 0;
 
        if (pp->fd >= 0)
                close(pp->fd);