summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Assemble.c19
-rw-r--r--Examine.c2
-rw-r--r--Grow.c6
-rw-r--r--mdadm.c8
-rw-r--r--mdadm.h6
-rw-r--r--super0.c10
-rw-r--r--super1.c4
7 files changed, 36 insertions, 19 deletions
diff --git a/Assemble.c b/Assemble.c
index 29bf059..30cb1aa 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -33,7 +33,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
mddev_ident_t ident, char *conffile,
mddev_dev_t devlist, char *backup_file,
int readonly, int runstop,
- char *update,
+ char *update, char *homehost,
int verbose, int force)
{
/*
@@ -294,11 +294,16 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
*(__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);
-
+ strcpy(info.name, ident->name);
+ st->ss->update_super(&info, super, update, devname, verbose,
+ ident->uuid_set, homehost);
+ if (strcmp(update, "uuid")==0 &&
+ !ident->uuid_set) {
+ ident->uuid_set = 1;
+ memcpy(ident->uuid, info.uuid, 16);
+ }
dfd = dev_open(devname, O_RDWR|O_EXCL);
if (dfd < 0)
fprintf(stderr, Name ": Cannot open %s for superblock update\n",
@@ -451,7 +456,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
continue;
}
info.events = devices[most_recent].events;
- st->ss->update_super(&info, super, "force", devices[chosen_drive].devname, verbose);
+ st->ss->update_super(&info, super, "force", devices[chosen_drive].devname, verbose, 0, NULL);
if (st->ss->store_super(st, fd, super)) {
close(fd);
@@ -522,7 +527,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
info.disk.state = desired_state;
if (devices[j].uptodate &&
- st->ss->update_super(&info, super, "assemble", NULL, verbose)) {
+ st->ss->update_super(&info, super, "assemble", NULL, verbose, 0, NULL)) {
if (force) {
if (verbose >= 0)
fprintf(stderr, Name ": "
@@ -547,7 +552,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
if (force && okcnt == info.array.raid_disks-1) {
/* FIXME check event count */
change += st->ss->update_super(&info, super, "force",
- devices[chosen_drive].devname, verbose);
+ devices[chosen_drive].devname, verbose, 0, NULL);
}
if (change) {
diff --git a/Examine.c b/Examine.c
index 16b1b9b..8a8f8f4 100644
--- a/Examine.c
+++ b/Examine.c
@@ -98,7 +98,7 @@ int Examine(mddev_dev_t devlist, int brief, int scan,
}
if (SparcAdjust)
- st->ss->update_super(NULL, super, "sparc2.2", devlist->devname, 0);
+ st->ss->update_super(NULL, super, "sparc2.2", devlist->devname, 0, 0, NULL);
/* Ok, its good enough to try, though the checksum could be wrong */
if (brief) {
struct array *ap;
diff --git a/Grow.c b/Grow.c
index 9b98e9f..8c8aa28 100644
--- a/Grow.c
+++ b/Grow.c
@@ -121,7 +121,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
info.disk.minor = minor(stb.st_rdev);
info.disk.raid_disk = d;
info.disk.state = (1 << MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE);
- st->ss->update_super(&info, super, "grow", newdev, 0);
+ st->ss->update_super(&info, super, "grow", newdev, 0, 0, NULL);
if (st->ss->store_super(st, nfd, super)) {
fprintf(stderr, Name ": Cannot store new superblock on %s\n", newdev);
@@ -179,7 +179,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
info.disk.minor = minor(stb.st_rdev);
info.disk.raid_disk = nd;
info.disk.state = (1 << MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE);
- st->ss->update_super(&info, super, "grow", dv, 0);
+ st->ss->update_super(&info, super, "grow", dv, 0, 0, NULL);
if (st->ss->store_super(st, fd2, super)) {
fprintf(stderr, Name ": Cannot store new superblock on %s\n", dv);
@@ -948,7 +948,7 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt
continue;
st->ss->getinfo_super(&dinfo, super);
dinfo.reshape_progress = __le64_to_cpu(bsb.length);
- st->ss->update_super(&dinfo, super, "_reshape_progress",NULL,0);
+ st->ss->update_super(&dinfo, super, "_reshape_progress",NULL,0, 0, NULL);
st->ss->store_super(st, fdlist[j], super);
free(super);
}
diff --git a/mdadm.c b/mdadm.c
index dc3e282..880fa94 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -939,14 +939,14 @@ int main(int argc, char *argv[])
else {
rv |= Assemble(ss, devlist->devname, mdfd, array_ident, configfile,
NULL, backup_file,
- readonly, runstop, update, verbose-quiet, force);
+ readonly, runstop, update, homehost, verbose-quiet, force);
close(mdfd);
}
}
} else if (!scan)
rv = Assemble(ss, devlist->devname, mdfd, &ident, configfile,
devlist->next, backup_file,
- readonly, runstop, update, verbose-quiet, force);
+ readonly, runstop, update, homehost, verbose-quiet, force);
else if (devs_found>0) {
if (update && devs_found > 1) {
fprintf(stderr, Name ": can only update a single array at a time\n");
@@ -972,7 +972,7 @@ int main(int argc, char *argv[])
}
rv |= Assemble(ss, dv->devname, mdfd, array_ident, configfile,
NULL, backup_file,
- readonly, runstop, update, verbose-quiet, force);
+ readonly, runstop, update, homehost, verbose-quiet, force);
close(mdfd);
}
} else {
@@ -1004,7 +1004,7 @@ int main(int argc, char *argv[])
rv |= Assemble(ss, array_list->devname, mdfd,
array_list, configfile,
NULL, NULL,
- readonly, runstop, NULL, verbose-quiet, force);
+ readonly, runstop, NULL, homehost, verbose-quiet, force);
close(mdfd);
}
}
diff --git a/mdadm.h b/mdadm.h
index 25c8b8f..ecaacd4 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -278,7 +278,9 @@ extern struct superswitch {
void (*brief_detail_super)(void *sbv);
void (*uuid_from_super)(int uuid[4], void *sbv);
void (*getinfo_super)(struct mdinfo *info, void *sbv);
- int (*update_super)(struct mdinfo *info, void *sbv, char *update, char *devname, int verbose);
+ int (*update_super)(struct mdinfo *info, void *sbv, char *update,
+ char *devname, int verbose,
+ int uuid_set, char *homehost);
__u64 (*event_super)(void *sbv);
int (*init_super)(struct supertype *st, void **sbp, mdu_array_info_t *info, unsigned long long size, char *name, char *homehost);
void (*add_to_super)(void *sbv, mdu_disk_info_t *dinfo);
@@ -342,7 +344,7 @@ extern int Assemble(struct supertype *st, char *mddev, int mdfd,
char *conffile,
mddev_dev_t devlist, char *backup_file,
int readonly, int runstop,
- char *update,
+ char *update, char *homehost,
int verbose, int force);
extern int Build(char *mddev, int mdfd, int chunk, int level, int layout,
diff --git a/super0.c b/super0.c
index dbf59c8..d21032f 100644
--- a/super0.c
+++ b/super0.c
@@ -334,7 +334,9 @@ static void getinfo_super0(struct mdinfo *info, void *sbv)
}
-static int update_super0(struct mdinfo *info, void *sbv, char *update, char *devname, int verbose)
+static int update_super0(struct mdinfo *info, void *sbv, char *update,
+ char *devname, int verbose,
+ int uuid_set, char *homehost)
{
/* NOTE: for 'assemble' and 'force' we need to return non-zero if any change was made.
* For others, the return value is ignored.
@@ -441,6 +443,12 @@ static int update_super0(struct mdinfo *info, void *sbv, char *update, char *dev
sb->recovery_cp = 0;
}
if (strcmp(update, "uuid") == 0) {
+ if (!uuid_set && homehost) {
+ unsigned char *hash = SHA1((unsigned char*)homehost,
+ strlen(homehost),
+ NULL);
+ memcpy(info->uuid+2, hash, 8);
+ }
sb->set_uuid0 = info->uuid[0];
sb->set_uuid1 = info->uuid[1];
sb->set_uuid2 = info->uuid[2];
diff --git a/super1.c b/super1.c
index b1ea298..533929a 100644
--- a/super1.c
+++ b/super1.c
@@ -434,7 +434,9 @@ static void getinfo_super1(struct mdinfo *info, void *sbv)
info->array.working_disks = working;
}
-static int update_super1(struct mdinfo *info, void *sbv, char *update, char *devname, int verbose)
+static int update_super1(struct mdinfo *info, void *sbv, char *update,
+ char *devname, int verbose,
+ int uuid_set, char *homehost)
{
/* NOTE: for 'assemble' and 'force' we need to return non-zero if any change was made.
* For others, the return value is ignored.