libmultipath: always allocate space for alias
authorHannes Reinecke <hare@suse.de>
Tue, 20 Jul 2010 08:10:14 +0000 (10:10 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Mon, 26 Jul 2010 08:30:17 +0000 (10:30 +0200)
We should always allocating space for alias. This makes
freeing up and allocation tracking far easier.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath/propsel.c
libmultipath/structs.c
libmultipath/structs_vec.c

index ee4109e..3074ce1 100644 (file)
@@ -239,7 +239,7 @@ extern int
 select_alias (struct multipath * mp)
 {
        if (mp->mpe && mp->mpe->alias)
-               mp->alias = mp->mpe->alias;
+               mp->alias = STRDUP(mp->mpe->alias);
        else {
                mp->alias = NULL;
                if (conf->user_friendly_names) {
@@ -257,7 +257,7 @@ select_alias (struct multipath * mp)
                        }
                }
                if (mp->alias == NULL)
-                       mp->alias = mp->wwid;
+                       mp->alias = STRDUP(mp->wwid);
        }
 
        return 0;
@@ -472,7 +472,7 @@ select_pg_timeout(struct multipath *mp)
                return 0;
        }
        mp->pg_timeout = PGTIMEOUT_UNDEF;
-       condlog(3, "pg_timeout = NONE (internal default)");
+       condlog(3, "%s: pg_timeout = NONE (internal default)", mp->alias);
        return 0;
 }
 
index a4b86d2..82df680 100644 (file)
@@ -163,9 +163,7 @@ free_multipath (struct multipath * mpp, int free_paths)
 
        free_multipath_attributes(mpp);
 
-       if (mpp->alias &&
-           (!mpp->mpe || (mpp->mpe && mpp->alias != mpp->mpe->alias)) &&
-           (mpp->wwid && mpp->alias != mpp->wwid)) {
+       if (mpp->alias) {
                FREE(mpp->alias);
                mpp->alias = NULL;
        }
index 699efa1..51c41e8 100644 (file)
@@ -335,8 +335,13 @@ retry:
        condlog(3, "%s: discover", mpp->alias);
 
        if (update_multipath_strings(mpp, vecs->pathvec)) {
-               char new_alias[WWID_SIZE];
+               char *new_alias;
 
+               new_alias = MALLOC(WWID_SIZE);
+               if (!new_alias) {
+                       condlog(0, "%s: failed to allocate alias", mpp->alias);
+                       goto out;
+               }
                /*
                 * detect an external rename of the multipath device
                 */
@@ -344,7 +349,8 @@ retry:
                        condlog(3, "%s multipath mapped device name has "
                                "changed from %s to %s", mpp->wwid,
                                mpp->alias, new_alias);
-                       strcpy(mpp->alias, new_alias);
+                       FREE(mpp->alias);
+                       mpp->alias = new_alias;
 
                        if (mpp->waiter)
                                strncpy(((struct event_thread *)mpp->waiter)->mapname,