diff --git a/Assemble.c b/Assemble.c index c86a165..20c4be7 100644 --- a/Assemble.c +++ b/Assemble.c @@ -320,7 +320,7 @@ int Assemble(struct supertype *st, char *mddev, tmpdev->content = content->next; if (tmpdev->content == NULL) - tmpdev->used = 1; + tmpdev->used = 2; } else if (ident->container || ident->member) { /* No chance of this matching if we don't have @@ -396,12 +396,15 @@ int Assemble(struct supertype *st, char *mddev, * looking. If the chosen member is active, skip. */ if (is_member_busy(content->text_version)) { + if (report_missmatch) + fprintf(stderr, Name ": member %s in %s is already assembled\n", + content->text_version, + devname); + tst->ss->free_super(tst); + tst = NULL; + content = NULL; if (auto_assem) goto loop; - fprintf(stderr, Name ": member %s in %s is already assembled\n", - content->text_version, - devname); - tst->ss->free_super(tst); return 1; } st = tst; tst = NULL; @@ -1202,8 +1205,10 @@ int assemble_container_content(struct supertype *st, int mdfd, sra = sysfs_read(mdfd, 0, GET_VERSION); if (sra == NULL || strcmp(sra->text_version, content->text_version) != 0) - if (sysfs_set_array(content, md_get_version(mdfd)) != 0) + if (sysfs_set_array(content, md_get_version(mdfd)) != 0) { + close(mdfd); return 1; + } if (sra) sysfs_free(sra); @@ -1212,9 +1217,10 @@ int assemble_container_content(struct supertype *st, int mdfd, working++; else if (errno == EEXIST) preexist++; - if (working == 0) - /* Nothing new, don't try to start */ ; - else if (runstop > 0 || + if (working == 0) { + close(mdfd); + return 1;/* Nothing new, don't try to start */ + } else if (runstop > 0 || (working + preexist) >= content->array.working_disks) { map_update(&map, fd2devnum(mdfd), @@ -1246,15 +1252,18 @@ int assemble_container_content(struct supertype *st, int mdfd, fprintf(stderr, "\n"); } wait_for(chosen_name); + close(mdfd); + return 0; /* FIXME should have an O_EXCL and wait for read-auto */ - } else + } else { if (verbose >= 0) fprintf(stderr, Name ": %s assembled with %d devices but " "not started\n", chosen_name, working); - - return 0; + close(mdfd); + return 1; + } } #endif diff --git a/Create.c b/Create.c index da05eed..783ab09 100644 --- a/Create.c +++ b/Create.c @@ -780,11 +780,11 @@ int Create(struct supertype *st, char *mddev, ping_monitor(devnum2devname(st->container_dev)); close(container_fd); } + wait_for(chosen_name); } else { fprintf(stderr, Name ": not starting array - not enough devices.\n"); } close(mdfd); - wait_for(chosen_name); return 0; abort: diff --git a/Incremental.c b/Incremental.c index ff8aa9a..474f78d 100644 --- a/Incremental.c +++ b/Incremental.c @@ -829,7 +829,6 @@ int Incremental_container(struct supertype *st, char *devname, int verbose, err = assemble_container_content(st, mdfd, ra, runstop, chosen_name, verbose); - close(mdfd); if (err) return err; }