[libmultipath] don't re-select when not necessary in path discovery
authorroot <root@xa-s05.(none)>
Tue, 23 Aug 2005 14:16:00 +0000 (16:16 +0200)
committerroot <root@xa-s05.(none)>
Tue, 23 Aug 2005 14:16:00 +0000 (16:16 +0200)
.getprio, .getuid and .checkfn were needlessly re-selected each time the
corresponding value was updated through discovery.c:pathinfo().

Now that we are more selective, we need to :
- flush the cached values for multipath(8)
- re-select them in case of multipathd(8) "reconfigure" CLI command

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

index 3f2c399..81fc613 100644 (file)
@@ -14,6 +14,9 @@ revoke_cache_info(struct path * pp)
        pp->checker_context = NULL;
        pp->fd = 0;
        pp->mpp = NULL;
+       pp->getuid = NULL;
+       pp->getprio = NULL;
+       pp->checkfn = NULL;
 }
 
 int
index 316549d..a111f7c 100644 (file)
@@ -202,7 +202,11 @@ opennode (char * dev, int mode)
        while (--loop) {
                fd = open(devpath, mode);
 
-               if (fd > 0 || errno != ENOENT)
+               if (fd <= 0 && errno != ENOENT) {
+                       condlog(3, "open error (%s)\n", strerror(errno));
+                       return fd;
+               }
+               if (fd > 0)
                        return fd;
 
                usleep(1000 * 1000 / WAIT_LOOP_PER_SECOND);
@@ -609,9 +613,10 @@ pathinfo (struct path *pp, vector hwtable, int mask)
        /*
         * get path state, no message collection, no context
         */
-       select_checkfn(pp);
-
        if (mask & DI_CHECKER) {
+               if (!pp->checkfn)
+                       select_checkfn(pp);
+
                pp->state = pp->checkfn(pp->fd, NULL, NULL);
                condlog(3, "state = %i", pp->state);
        }
@@ -620,7 +625,8 @@ pathinfo (struct path *pp, vector hwtable, int mask)
         * get path prio
         */
        if (mask & DI_PRIO) {
-               select_getprio(pp);
+               if (!pp->getprio)
+                       select_getprio(pp);
 
                if (!pp->getprio) {
                        pp->priority = 1;
@@ -640,7 +646,8 @@ pathinfo (struct path *pp, vector hwtable, int mask)
         * get path uid
         */
        if (mask & DI_WWID && !strlen(pp->wwid)) {
-               select_getuid(pp);
+               if (!pp->getuid)
+                       select_getuid(pp);
 
                if (apply_format(pp->getuid, &buff[0], pp)) {
                        condlog(0, "error formatting uid callout command");
index 338c375..7ebba36 100644 (file)
@@ -794,6 +794,7 @@ reconfigure (struct paths * allpaths)
 {
        struct config * old = conf;
        struct multipath * mpp;
+       struct path * pp;
        int i;
 
        conf = NULL;
@@ -810,6 +811,11 @@ reconfigure (struct paths * allpaths)
                mpp->mpe = find_mpe(mpp->wwid);
                set_paths_owner(allpaths, mpp);
        }
+       vector_foreach_slot (allpaths->pathvec, pp, i) {
+               select_checkfn(pp);
+               select_getuid(pp);
+               select_getprio(pp);
+       }
        condlog(2, "reconfigured");
        return 0;
 }