* START_ARRAY
*
*/
+ int must_close = 0;
int old_linux = 0;
int vers;
void *first_super = NULL, *super = NULL;
mdu_array_info_t inf;
char *c;
if (!first_super) {
- return 1;
+ return 2;
}
st->ss->getinfo_super(&info, first_super);
c = strchr(info.name, ':');
free(first_super);
return 1;
}
+ must_close = 1;
}
/* Ok, no bad inconsistancy, we can try updating etc */
fprintf(stderr, Name ": no devices found for %s\n",
mddev);
free(first_super);
+ if (must_close) close(mdfd);
return 1;
}
if ((fd=dev_open(devices[j].devname, O_RDONLY|O_EXCL))< 0) {
fprintf(stderr, Name ": Cannot open %s: %s\n",
devices[j].devname, strerror(errno));
+ if (must_close) close(mdfd);
return 1;
}
if (st->ss->load_super(st,fd, &super, NULL)) {
close(fd);
fprintf(stderr, Name ": RAID superblock has disappeared from %s\n",
devices[j].devname);
+ if (must_close) close(mdfd);
return 1;
}
close(fd);
}
if (super == NULL) {
fprintf(stderr, Name ": No suitable drives found for %s\n", mddev);
+ if (must_close) close(mdfd);
return 1;
}
st->ss->getinfo_super(&info, super);
if (fd < 0) {
fprintf(stderr, Name ": Could not open %s for write - cannot Assemble array.\n",
devices[chosen_drive].devname);
+ if (must_close) close(mdfd);
return 1;
}
if (st->ss->store_super(st, fd, super)) {
close(fd);
fprintf(stderr, Name ": Could not re-write superblock on %s\n",
devices[chosen_drive].devname);
+ if (must_close) close(mdfd);
return 1;
}
close(fd);
}
if (err) {
fprintf(stderr, Name ": Failed to restore critical section for reshape, sorry.\n");
+ if (must_close) close(mdfd);
return err;
}
}
if (rv) {
fprintf(stderr, Name ": SET_ARRAY_INFO failed for %s: %s\n",
mddev, strerror(errno));
+ if (must_close) 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");
+ if (must_close) close(mdfd);
return 1;
}
} else if (ident->bitmap_file) {
if (bmfd < 0) {
fprintf(stderr, Name ": Could not open bitmap file %s\n",
ident->bitmap_file);
+ if (must_close) 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);
+ if (must_close) close(mdfd);
return 1;
}
close(bmfd);
fprintf(stderr, " and %d spare%s", sparecnt, sparecnt==1?"":"s");
fprintf(stderr, ".\n");
}
+ if (must_close) close(mdfd);
return 0;
}
fprintf(stderr, Name ": failed to RUN_ARRAY %s: %s\n",
mddev, strerror(errno));
+ if (must_close) close(mdfd);
return 1;
}
if (runstop == -1) {
if (okcnt != info.array.raid_disks)
fprintf(stderr, " (out of %d)", info.array.raid_disks);
fprintf(stderr, ", but not started.\n");
+ if (must_close) close(mdfd);
return 0;
}
if (verbose >= 0) {
fprintf(stderr, " (use --run to insist).\n");
}
}
+ if (must_close) close(mdfd);
return 1;
} else {
/* The "chosen_drive" is a good choice, and if necessary, the superblock has
}
}
+ if (must_close) close(mdfd);
return 0;
}
fprintf(stderr, Name ": --super-minor=dev is incompatible with --auto\n");
exit(2);
}
+ if (mode == MANAGE && runstop < 0)
+ autof=1; /* Don't create */
mdfd = open_mddev(devlist->devname, autof);
if (mdfd < 0)
exit(1);
* until it fails
*/
int rv2;
+ int acnt;
+ ident.autof = autof;
do {
- ident.autof = autof;
- rv2 = Assemble(ss, NULL, -1,
- &ident, configfile,
- devlist, NULL,
- readonly, runstop, NULL, homehost, verbose-quiet, force);
- if (rv2==0)
- cnt++;
- } while (rv2==0);
+ acnt = 0;
+ do {
+ rv2 = Assemble(ss, NULL, -1,
+ &ident, configfile,
+ devlist, NULL,
+ readonly, runstop, NULL, homehost, verbose-quiet, force);
+ if (rv2==0) {
+ cnt++;
+ acnt++;
+ }
+ } while (rv2!=2);
+ /* Incase there are stacked devices, we need to go around again */
+ devlist = conf_get_devs(configfile);
+ } while (acnt);
if (cnt == 0 && rv == 0) {
fprintf(stderr, Name ": No arrays found in config file or automatically\n");
rv = 1;
e->dev);
continue;
}
- mdfd = open_mddev(name, 0);
+ mdfd = open_mddev(name, 1);
if (mdfd >= 0) {
if (Manage_runstop(name, mdfd, -1, !last))
err = 1;
case 'X':
rv |= ExamineBitmap(dv->devname, brief, ss); continue;
}
- mdfd = open_mddev(dv->devname, 0);
+ mdfd = open_mddev(dv->devname, 1);
if (mdfd>=0) {
switch(dv->disposition) {
case 'R':