[multipath] handle alias changes in config file 0.4.5-pre4
authorroot <root@xa-s05.(none)>
Thu, 28 Jul 2005 14:31:10 +0000 (16:31 +0200)
committerroot <root@xa-s05.(none)>
Thu, 28 Jul 2005 14:31:10 +0000 (16:31 +0200)
Now initiate a remove / add sequence upon alias change in the config file.
The daemon catches on.

libmultipath/devmapper.c
libmultipath/devmapper.h
libmultipath/dmparser.c
multipath/main.c

index ec20142..acfcfa1 100644 (file)
@@ -717,3 +717,31 @@ out:
        dm_task_destroy (dmt);
        return r;
 }
+
+#if 0
+int
+dm_rename (char * old, char * new)
+{
+       int r = 1;
+       struct dm_task *dmt;
+
+       if (!(dmt = dm_task_create(DM_DEVICE_RENAME)))
+               return 0;
+
+       if (!dm_task_set_name(dmt, old))
+               goto out;
+
+       if (!dm_task_set_newname(dmt, new))
+               goto out;
+       
+       dm_task_no_open_count(dmt);
+
+       if (!dm_task_run(dmt))
+               goto out;
+
+       r = 0;
+out:
+       dm_task_destroy(dmt);
+       return r;
+}
+#endif
index 224b93e..48bb268 100644 (file)
@@ -17,3 +17,7 @@ int dm_geteventnr (char *name);
 int dm_get_minor (char *name);
 char * dm_mapname(int major, int minor);
 int dm_remove_partmaps (char * mapname);
+
+#if 0
+int dm_rename (char * old, char * new);
+#endif
index b3fbd01..a794885 100644 (file)
@@ -217,7 +217,7 @@ disassemble_map (vector pathvec, char * params, struct multipath * mpp)
                                goto out;
 
                        /*
-                        * Update wwid for multipaths which are not set
+                        * Update wwid for multipaths which are not setup
                         * in the get_dm_mpvec() code path
                         */
                        if (!strlen(mpp->wwid))
index 3d24ce4..4941236 100644 (file)
@@ -497,6 +497,13 @@ select_action (struct multipath * mpp, vector curmp)
        cmpp = find_mp(curmp, mpp->alias);
 
        if (!cmpp) {
+               cmpp = find_mp_by_wwid(curmp, mpp->wwid);
+
+               if (cmpp && !conf->dry_run) {
+                       condlog(2, "remove: %s (dup of %s)",
+                               cmpp->alias, mpp->alias);
+                       dm_flush_map(cmpp->alias, DEFAULT_TARGET);
+               }
                mpp->action = ACT_CREATE;
                return;
        }
@@ -582,10 +589,14 @@ domap (struct multipath * mpp)
        /*
         * last chance to quit before touching the devmaps
         */
-       if (conf->dry_run || mpp->action == ACT_NOTHING)
+       if (conf->dry_run)
                return 0;
 
-       if (mpp->action == ACT_SWITCHPG) {
+       switch (mpp->action) {
+       case ACT_NOTHING:
+               return 0;
+
+       case ACT_SWITCHPG:
                dm_switchgroup(mpp->alias, mpp->nextpg);
                /*
                 * we may have avoided reinstating paths because there where in
@@ -594,12 +605,18 @@ domap (struct multipath * mpp)
                 */
                reinstate_paths(mpp);
                return 0;
-       }
-       if (mpp->action == ACT_CREATE)
+
+       case ACT_CREATE:
                op = DM_DEVICE_CREATE;
+               break;
 
-       if (mpp->action == ACT_RELOAD)
+       case ACT_RELOAD:
                op = DM_DEVICE_RELOAD;
+               break;
+
+       default:
+               break;
+       }
 
                
        /*
@@ -782,16 +799,16 @@ get_dm_mpvec (vector curmp, vector pathvec, char * refwwid)
                wwid = get_mpe_wwid(mpp->alias);
 
                if (wwid) {
-                       strncpy(mpp->wwid, wwid, WWID_SIZE);
+                       /* out of specified scope */
+                       if (refwwid && strncmp(wwid, refwwid, WWID_SIZE))
+                               continue;
                        wwid = NULL;
-               } else
-                       strncpy(mpp->wwid, mpp->alias, WWID_SIZE);
-
-               if (refwwid && strncmp(mpp->wwid, refwwid, WWID_SIZE))
-                       continue;
+               }
 
                condlog(3, "params = %s", mpp->params);
                condlog(3, "status = %s", mpp->status);
+
+               /* will set mpp->wwid */
                disassemble_map(pathvec, mpp->params, mpp);
 
                /*