diff options
author | Neil Brown <neilb@suse.de> | 2005-12-05 05:56:33 +0000 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2005-12-05 05:56:33 +0000 |
commit | 7d99579f6a52fbf575e4707121ece51d0672277b (patch) | |
tree | 61745ca11734259875fa35139858875fb9185d79 | |
parent | ee04451c56f5bc39a77515e2e51897ac1fc15104 (diff) | |
download | mdadm-7d99579f6a52fbf575e4707121ece51d0672277b.tar.gz mdadm-7d99579f6a52fbf575e4707121ece51d0672277b.tar.xz mdadm-7d99579f6a52fbf575e4707121ece51d0672277b.zip |
Support updating of uuid during --assemble.
Signed-off-by: Neil Brown <neilb@suse.de>
-rw-r--r-- | Assemble.c | 18 | ||||
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | mdadm.8 | 11 | ||||
-rw-r--r-- | mdadm.c | 4 | ||||
-rw-r--r-- | super0.c | 6 | ||||
-rw-r--r-- | super1.c | 2 |
6 files changed, 38 insertions, 4 deletions
@@ -219,7 +219,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, } if (dfd >= 0) close(dfd); - if (ident->uuid_set && + if (ident->uuid_set && (!update && strcmp(update, "uuid")!= 0) && (!super || same_uuid(info.uuid, ident->uuid, tst->ss->swapuuid)==0)) { if ((inargv && verbose >= 0) || verbose > 0) fprintf(stderr, Name ": %s has wrong uuid.\n", @@ -281,7 +281,21 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, struct stat stb2; fstat(mdfd, &stb2); info.array.md_minor = minor(stb2.st_rdev); - + + if (strcmp(update, "uuid")==0 && + !ident->uuid_set) { + int rfd; + if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 || + read(rfd, ident->uuid, 16) != 16) { + *(__u32*)(ident->uuid) = random(); + *(__u32*)(ident->uuid+1) = random(); + *(__u32*)(ident->uuid+2) = random(); + *(__u32*)(ident->uuid+3) = random(); + } + if (rfd >= 0) close(rfd); + ident->uuid_set = 1; + } + memcpy(info.uuid, ident->uuid, 16); st->ss->update_super(&info, super, update, devname, verbose); dfd = dev_open(devname, O_RDWR|O_EXCL); @@ -18,6 +18,7 @@ Changes Prior to this release mdadm was insisting the event numbers were identical, but this isn't needed, and is a problem if the crash was while the metadata was being updated. + - Support --update==uuid Changes Prior to 2.1 release - Fix assembling of raid10 array when devices are missing. @@ -610,6 +610,7 @@ Update the superblock on each device while assembling the array. The argument given to this flag can be one of .BR sparc2.2 , .BR summaries , +.BR uuid , .BR resync , .BR byteorder , or @@ -617,7 +618,7 @@ or The .B sparc2.2 -option will adjust the superblock of an array what was created on a Sparc +option will adjust the superblock of an array what was created on a Sparc machine running a patched 2.2 Linux kernel. This kernel got the alignment of part of the superblock wrong. You can use the .B "--examine --sparc2.2" @@ -634,6 +635,14 @@ assembled. This is not needed on 2.6 and later kernels as they make this adjustment automatically. The +.B uuid +option will change the uuid of the array. If a UUID is given with the +"--uuid" option that UUID will be used as a new UUID and with +.B NOT +be used to help identify the devices in the array. +If no "--uuid" is given, a random uuid is chosen. + +The .B resync option will cause the array to be marked .I dirty @@ -593,6 +593,8 @@ int main(int argc, char *argv[]) continue; if (strcmp(update, "resync")==0) continue; + if (strcmp(update, "uuid")==0) + continue; if (strcmp(update, "byteorder")==0) { if (ss) { fprintf(stderr, Name ": must not set metadata type with --update=byteorder.\n"); @@ -607,7 +609,7 @@ int main(int argc, char *argv[]) continue; } - fprintf(stderr, Name ": '--update %s' invalid. Only 'sparc2.2', 'super-minor', 'resync' or 'summaries' supported\n",update); + fprintf(stderr, Name ": '--update %s' invalid. Only 'sparc2.2', 'super-minor', 'uuid', 'resync' or 'summaries' supported\n",update); exit(2); case O(ASSEMBLE,'c'): /* config file */ @@ -359,6 +359,12 @@ static int update_super0(struct mdinfo *info, void *sbv, char *update, char *dev sb->state &= ~(1<<MD_SB_CLEAN); sb->recovery_cp = 0; } + if (strcmp(update, "uuid") == 0) { + sb->set_uuid0 = info->uuid[0]; + sb->set_uuid1 = info->uuid[1]; + sb->set_uuid2 = info->uuid[2]; + sb->set_uuid3 = info->uuid[3]; + } sb->sb_csum = calc_sb0_csum(sb); return rv; @@ -381,6 +381,8 @@ static int update_super1(struct mdinfo *info, void *sbv, char *update, char *dev /* make sure resync happens */ sb->resync_offset = ~0ULL; } + if (strcmp(update, "uuid") == 0) + memcmp(sb->set_uuid, info->uuid, 16); sb->sb_csum = calc_sb_1_csum(sb); return rv; |