devname);
return rv;
}
- dfd = dev_open(devname, O_RDONLY|O_EXCL);
+ dfd = dev_open(devname, O_RDONLY);
if (dfd < 0) {
if (c->verbose >= 0)
pr_err("cannot open %s: %s.\n",
if (must_be_container(dfd)) {
if (!st)
st = super_by_fd(dfd, NULL);
+ if (st)
+ st->ignore_hw_compat = 1;
if (st && st->ss->load_container)
rv = st->ss->load_container(st, dfd, NULL);
st, c->verbose);
goto out;
}
+ st->ignore_hw_compat = 1;
if (st->ss->compare_super == NULL ||
st->ss->load_super(st, dfd, NULL)) {
if (c->verbose >= 0)
if (map_lock(&map))
pr_err("failed to get exclusive lock on "
"mapfile\n");
+ /* Now check we can get O_EXCL. If not, probably "mdadm -A" has
+ * taken over
+ */
+ dfd = dev_open(devname, O_RDONLY|O_EXCL);
+ if (dfd < 0) {
+ if (c->verbose >= 0)
+ pr_err("cannot reopen %s: %s.\n",
+ devname, strerror(errno));
+ goto out_unlock;
+ }
+ /* Cannot hold it open while we add the device to the array,
+ * so we must release the O_EXCL and depend on the map_lock()
+ */
+ close(dfd);
+ dfd = -1;
+
mp = map_by_uuid(&map, info.uuid);
if (mp)
mdfd = open_dev(mp->devnum);
if (c->runstop > 0 || active_disks >= info.array.working_disks) {
struct mdinfo *dsk;
/* Let's try to start it */
+
+ if (info.reshape_active && !(info.reshape_active & RESHAPE_NO_BACKUP)) {
+ fprintf(stderr, Name
+ ": %s: This array is being reshaped and cannot be started\n"
+ " by --incremental. Please use --assemble\n",
+ chosen_name);
+ goto out;
+ }
if (match && match->bitmap_file) {
int bmfd = open(match->bitmap_file, O_RDWR);
if (bmfd < 0) {
/* count how many devices in sra think they are active */
struct mdinfo *d;
int cnt = 0;
+ int replcnt = 0;
__u64 max_events = 0;
char *avail = NULL;
int *best = NULL;
best[info.disk.raid_disk] = devnum;
st->ss->getinfo_super(st, bestinfo, NULL);
}
- }
+ } else if (info.disk.state & (1<<MD_DISK_REPLACEMENT))
+ replcnt++;
st->ss->free_super(st);
}
if (!avail)
}
free(best);
free(devmap);
- return cnt;
+ return cnt + replcnt;
}
/* test if container has degraded member(s) */
close(mdfd);
}
if ((sra->component_size > 0 &&
- st2->ss->avail_size(st2, devsize) < sra->component_size)
+ st2->ss->avail_size(st2, devsize,
+ sra->devs
+ ? sra->devs->data_offset
+ : INVALID_SECTORS)
+ < sra->component_size)
||
(sra->component_size == 0 && devsize < component_size)) {
if (verbose > 1)
me->path, strerror(errno));
}
}
+ /* FIXME check for reshape_active and consider not
+ * starting array.
+ */
sra = sysfs_read(mdfd, 0, 0);
if (sra) {
if (sysfs_set_str(sra, NULL,