devname);
tmpdev->used = 2;
} else if (auto_assem && st == NULL &&
- !conf_test_metadata(tst->ss->name)) {
+ !conf_test_metadata(tst->ss->name,
+ tst->ss->match_home(tst, homehost) == 1)) {
if (report_missmatch)
fprintf(stderr, Name ": %s has metadata type %s for which "
"auto-assembly is disabled\n",
}
}
st = tst; tst = NULL;
- if (!auto_assem && tmpdev->next != NULL) {
+ if (!auto_assem && inargv && tmpdev->next != NULL) {
fprintf(stderr, Name ": %s is a container, but is not "
"only device given: confused and aborting\n",
devname);
remove_partitions(dfd);
tst = dup_super(st);
- tst->ss->load_super(tst, dfd, NULL);
+ if (dfd < 0 || tst->ss->load_super(tst, dfd, NULL) != 0) {
+ fprintf(stderr, Name ": cannot re-read metadata from %s - aborting\n",
+ devname);
+ if (dfd >= 0)
+ close(dfd);
+ close(mdfd);
+ return 1;
+ }
tst->ss->getinfo_super(tst, content);
memcpy(content->uuid, ident->uuid, 16);
remove_partitions(dfd);
- tst->ss->load_super(tst, dfd, NULL);
+ if (dfd < 0 || tst->ss->load_super(tst, dfd, NULL) != 0) {
+ fprintf(stderr, Name ": cannot re-read metadata from %s - aborting\n",
+ devname);
+ if (dfd >= 0)
+ close(dfd);
+ close(mdfd);
+ return 1;
+ }
tst->ss->getinfo_super(tst, content);
tst->ss->free_super(tst);
close(dfd);
> devices[most_recent].i.events)
most_recent = devcnt;
}
- if (content->array.level == -4)
+ if (content->array.level == LEVEL_MULTIPATH)
/* with multipath, the raid_disk from the superblock is meaningless */
i = devcnt;
else
/* note: we ignore error flags in multipath arrays
* as they don't make sense
*/
- if (content->array.level != -4)
- if (!(devices[j].i.disk.state & (1<<MD_DISK_SYNC))) {
+ if (content->array.level != LEVEL_MULTIPATH)
+ if (!(devices[j].i.disk.state & (1<<MD_DISK_ACTIVE))) {
if (!(devices[j].i.disk.state
& (1<<MD_DISK_FAULTY)))
sparecnt++;
if (devices[j].i.events+event_margin >=
devices[most_recent].i.events) {
devices[j].uptodate = 1;
- if (i < content->array.raid_disks) {
+ if (i < content->array.raid_disks &&
+ devices[j].i.recovery_start == MaxSector) {
okcnt++;
avail[i]=1;
} else
int j = best[i];
if (j>=0 &&
!devices[j].uptodate &&
+ devices[j].i.recovery_start == MaxSector &&
(chosen_drive < 0 ||
devices[j].i.events
> devices[chosen_drive].i.events))
if (content->reshape_active) {
int err = 0;
int *fdlist = malloc(sizeof(int)* bestcnt);
+ if (verbose > 0)
+ fprintf(stderr, Name ":%s has an active reshape - checking "
+ "if critical section needs to be restored\n",
+ chosen_name);
for (i=0; i<bestcnt; i++) {
int j = best[i];
if (j >= 0) {
fdlist[i] = -1;
}
if (!err)
- err = Grow_restart(st, content, fdlist, bestcnt, backup_file);
+ err = Grow_restart(st, content, fdlist, bestcnt, backup_file, verbose > 0);
while (i>0) {
i--;
if (fdlist[i]>=0) close(fdlist[i]);
}
if (err) {
fprintf(stderr, Name ": Failed to restore critical section for reshape, sorry.\n");
+ if (backup_file == NULL)
+ fprintf(stderr," Possibly you needed to specify the --backup-file\n");
close(mdfd);
return err;
}
if (rv) {
fprintf(stderr, Name ": failed to set array info for %s: %s\n",
mddev, strerror(errno));
+ ioctl(mdfd, STOP_ARRAY, NULL);
close(mdfd);
return 1;
}
if (ident->bitmap_fd >= 0) {
if (ioctl(mdfd, SET_BITMAP_FILE, ident->bitmap_fd) != 0) {
fprintf(stderr, Name ": SET_BITMAP_FILE failed.\n");
+ ioctl(mdfd, STOP_ARRAY, NULL);
close(mdfd);
return 1;
}
if (bmfd < 0) {
fprintf(stderr, Name ": Could not open bitmap file %s\n",
ident->bitmap_file);
+ ioctl(mdfd, STOP_ARRAY, NULL);
close(mdfd);
return 1;
}
if (ioctl(mdfd, SET_BITMAP_FILE, bmfd) != 0) {
fprintf(stderr, Name ": Failed to set bitmapfile for %s\n", mddev);
close(bmfd);
+ ioctl(mdfd, STOP_ARRAY, NULL);
close(mdfd);
return 1;
}
content->array.layout, clean, avail, okcnt) &&
(okcnt >= req_cnt || start_partial_ok)
))) {
- if (ioctl(mdfd, RUN_ARRAY, NULL)==0) {
+ /* This array is good-to-go.
+ * If a reshape is in progress then we might need to
+ * continue monitoring it. In that case we start
+ * it read-only and let the grow code make it writable.
+ */
+ int rv;
+#ifndef MDASSEMBLE
+ if (content->reshape_active &&
+ content->delta_disks <= 0)
+ rv = Grow_continue(mdfd, st, content, backup_file);
+ else
+#endif
+ rv = ioctl(mdfd, RUN_ARRAY, NULL);
+ if (rv == 0) {
if (verbose >= 0) {
fprintf(stderr, Name ": %s has been started with %d drive%s",
mddev, okcnt, okcnt==1?"":"s");