]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Remove update_private
authorNeilBrown <neilb@suse.de>
Mon, 19 Dec 2011 23:30:34 +0000 (10:30 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 19 Dec 2011 23:30:34 +0000 (10:30 +1100)
This fields doesn't work any more as ->getinfo_super clears the info
structure at an awkward time.  So get rid of it and do it differently.

The issue is that the metadata handler cannot tell if the uuid it has
was randomly generated or explicitly requested, except on the first
call.
And we don't want to accept explicit requests for IMSM.
So when it was auto-generated, make it look distinctive by having the
same int copied in all 4 positions.  If someone requests a uuid like
that, I guess they get away with it.

Reported-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Assemble.c
mdadm.h
super-intel.c

index fac2bad676c70c6dfe7871653f90cd98fad45d3f..74fb6a32c6f9032e689c45bfd988c2e237ff1262 100644 (file)
@@ -706,7 +706,6 @@ int Assemble(struct supertype *st, char *mddev,
        bitmap_done = 0;
 #endif
        /* Ok, no bad inconsistancy, we can try updating etc */
-       content->update_private = NULL;
        devices = malloc(num_devs * sizeof(*devices));
        devmap = calloc(num_devs * content->array.raid_disks, 1);
        for (tmpdev = devlist; tmpdev; tmpdev=tmpdev->next) if (tmpdev->used == 1) {
@@ -891,8 +890,6 @@ int Assemble(struct supertype *st, char *mddev,
                }
                devcnt++;
        }
-       free(content->update_private);
-       content->update_private = NULL;
 
        if (devcnt == 0) {
                fprintf(stderr, Name ": no devices found for %s\n",
diff --git a/mdadm.h b/mdadm.h
index 1351d420cffb71c8b4c63bb98d2a5080ffe6caab..4f3533f8d650ac9c6e848ec91757e2ae0081b73f 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -217,11 +217,6 @@ struct mdinfo {
        unsigned long           cache_size; /* size of raid456 stripe cache*/
        int                     mismatch_cnt;
        char                    text_version[50];
-       void                    *update_private; /* for passing metadata-format
-                                                 * specific update data
-                                                 * between successive calls to
-                                                 * update_super()
-                                                 */
 
        int container_member; /* for assembling external-metatdata arrays
                               * This is to be used internally by metadata
index e1073efbf2aec0722a8217715d051c747ecef40c..9074485ab06d5295ea59a33d1a2d0e91985094f5 100644 (file)
@@ -2791,25 +2791,30 @@ static int update_super_imsm(struct supertype *st, struct mdinfo *info,
 
        mpb = super->anchor;
 
-       if (strcmp(update, "uuid") == 0 && uuid_set && !info->update_private)
-               rv = -1;
-       else if (strcmp(update, "uuid") == 0 && uuid_set && info->update_private) {
-               mpb->orig_family_num = *((__u32 *) info->update_private);
-               rv = 0;
-       } else if (strcmp(update, "uuid") == 0) {
-               __u32 *new_family = malloc(sizeof(*new_family));
-
-               /* update orig_family_number with the incoming random
-                * data, report the new effective uuid, and store the
-                * new orig_family_num for future updates.
+       if (strcmp(update, "uuid") == 0) {
+               /* We take this to mean that the family_num should be updated.
+                * However that is much smaller than the uuid so we cannot really
+                * allow an explicit uuid to be given.  And it is hard to reliably
+                * know if one was.
+                * So if !uuid_set we know the current uuid is random and just used
+                * the first 'int' and copy it to the other 3 positions.
+                * Otherwise we require the 4 'int's to be the same as would be the
+                * case if we are using a random uuid.  So an explicit uuid will be
+                * accepted as long as all for ints are the same... which shouldn't hurt
                 */
-               if (new_family) {
-                       memcpy(&mpb->orig_family_num, info->uuid, sizeof(__u32));
-                       uuid_from_super_imsm(st, info->uuid);
-                       *new_family = mpb->orig_family_num;
-                       info->update_private = new_family;
+               if (!uuid_set) {
+                       info->uuid[1] = info->uuid[2] = info->uuid[3] = info->uuid[0];
                        rv = 0;
+               } else {
+                       if (info->uuid[0] != info->uuid[1] ||
+                           info->uuid[1] != info->uuid[2] ||
+                           info->uuid[2] != info->uuid[3])
+                               rv = -1;
+                       else
+                               rv = 0;
                }
+               if (rv == 0)
+                       mpb->orig_family_num = info->uuid[0];
        } else if (strcmp(update, "assemble") == 0)
                rv = 0;
        else