summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-12-20 10:30:34 +1100
committerNeilBrown <neilb@suse.de>2011-12-20 10:30:34 +1100
commit81a5b4f52f0697f3c494c7ee2723e5f833b9ec51 (patch)
tree3160324570095e5bbc4fb8beac108e8dddefd18b
parent67a2db324f61326157373117c78a8314c7d220e4 (diff)
Remove update_private
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>
-rw-r--r--Assemble.c3
-rw-r--r--mdadm.h5
-rw-r--r--super-intel.c37
3 files changed, 21 insertions, 24 deletions
diff --git a/Assemble.c b/Assemble.c
index fac2bad6..74fb6a32 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -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 1351d420..4f3533f8 100644
--- 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
diff --git a/super-intel.c b/super-intel.c
index e1073efb..9074485a 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -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