struct map_ent target_array;
int have_target;
char *devname = devlist->devname;
+ int journal_device_missing = 0;
struct createinfo *ci = conf_get_create_info();
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);
NULL, c->verbose);
goto out;
}
- st->ignore_hw_compat = 1;
+ st->ignore_hw_compat = 0;
+
if (st->ss->compare_super == NULL ||
- st->ss->load_super(st, dfd, NULL)) {
+ st->ss->load_super(st, dfd, c->verbose >= 0 ? devname : NULL)) {
if (c->verbose >= 0)
pr_err("no RAID superblock on %s.\n",
devname);
devname);
goto out;
}
- /* Skip the clustered ones. This should be started by
- * clustering resource agents
- */
- if (info.array.state & (1 << MD_SB_CLUSTERED))
- goto out;
/* 3a/ if not, check for homehost match. If no match, continue
* but don't trust the 'name' in the array. Thus a 'random' minor
if (mdfd < 0) {
+ /* Skip the clustered ones. This should be started by
+ * clustering resource agents
+ */
+ if (info.array.state & (1 << MD_SB_CLUSTERED))
+ goto out;
+
/* Couldn't find an existing array, maybe make a new one */
mdfd = create_mddev(match ? match->devname : NULL,
name_to_use, c->autof, trustworthy, chosen_name);
/* add disk needs to know about containers */
if (st->ss->external)
sra->array.level = LEVEL_CONTAINER;
+
+ if (info.array.state & (1 << MD_SB_CLUSTERED))
+ info.disk.state |= (1 << MD_DISK_CLUSTER_ADD);
+
err = add_disk(mdfd, st, sra, &info);
if (err < 0 && errno == EBUSY) {
/* could be another device present with the same
sra = sysfs_read(mdfd, NULL, (GET_DEVS | GET_STATE |
GET_OFFSET | GET_SIZE));
active_disks = count_active(st, sra, mdfd, &avail, &info);
+
+ journal_device_missing = (info.journal_device_required) && (info.journal_clean == 0);
+
if (enough(info.array.level, info.array.raid_disks,
info.array.layout, info.array.state & 1,
avail) == 0) {
}
map_unlock(&map);
- if (c->runstop > 0 || active_disks >= info.array.working_disks) {
+ if (c->runstop > 0 || (!journal_device_missing && active_disks >= info.array.working_disks)) {
struct mdinfo *dsk;
/* Let's try to start it */
+ if (journal_device_missing)
+ pr_err("Trying to run with missing journal device\n");
if (info.reshape_active && !(info.reshape_active & RESHAPE_NO_BACKUP)) {
pr_err("%s: This array is being reshaped and cannot be started\n",
chosen_name);
} else {
if (c->export) {
printf("MD_STARTED=unsafe\n");
+ } else if (journal_device_missing) {
+ pr_err("Journal device is missing, not safe to start yet.\n");
} else if (c->verbose >= 0)
pr_err("%s attached to %s, not enough to start safely.\n",
devname, chosen_name);
close(mdfd);
if (policy)
dev_policy_free(policy);
- if (sra)
- sysfs_free(sra);
+ sysfs_free(sra);
return rv;
out_unlock:
map_unlock(&map);
* without thinking more */
for (d = sra->devs; d ; d = d->next) {
- char dn[10];
+ char dn[24]; // 2*11 bytes for ints (including sign) + colon + null byte
int dfd;
struct mdinfo info;
sprintf(dn, "%d:%d", d->disk.major, d->disk.minor);
close(dfd);
if (ok != 0)
continue;
+
info.array.raid_disks = raid_disks;
st->ss->getinfo_super(st, &info, devmap + raid_disks * devnum);
+ if (info.disk.raid_disk == MD_DISK_ROLE_JOURNAL)
+ bestinfo->journal_clean = 1;
if (!avail) {
raid_disks = info.array.raid_disks;
avail = xcalloc(raid_disks, 1);
replcnt++;
st->ss->free_super(st);
}
+
if (!avail)
return 0;
/* We need to reject any device that thinks the best device is
sizeof(target->uuid)) == 0 &&
sra->array.failed_disks > 0) {
/* This is our target!! */
- if (chosen)
- sysfs_free(chosen);
+ sysfs_free(chosen);
chosen = sra;
sra = NULL;
/* skip to end so we don't check any more */
sra = NULL;
}
next:
- if (sra)
- sysfs_free(sra);
+ sysfs_free(sra);
if (st != st2)
free(st2);
if (dl)
int mdfd = open_dev(chosen->sys_name);
if (mdfd >= 0) {
struct mddev_dev devlist;
- char devname[20];
+ char chosen_devname[24]; // 2*11 for int (including signs) + colon + null
devlist.next = NULL;
devlist.used = 0;
- devlist.writemostly = 0;
- devlist.devname = devname;
- sprintf(devname, "%d:%d", major(stb.st_rdev),
+ devlist.writemostly = FlagDefault;
+ devlist.failfast = FlagDefault;
+ devlist.devname = chosen_devname;
+ sprintf(chosen_devname, "%d:%d", major(stb.st_rdev),
minor(stb.st_rdev));
devlist.disposition = 'a';
close(dfd);
if (st2 == NULL ||
st2->ss->load_super(st2, fd, NULL) < 0)
goto next;
+ st2->ignore_hw_compat = 0;
if (!st) {
/* Check domain policy again, this time referring to metadata */
if (devnm && strcmp(devnm, me->devnm) != 0)
continue;
- if (devnm && me->metadata[0] == '/') {
+ if (me->metadata[0] == '/') {
char *sl;
+
+ if (!devnm)
+ continue;
+
/* member array, need to work on container */
strncpy(container, me->metadata+1, 32);
container[31] = 0;
struct supertype *st = super_by_fd(mdfd, NULL);
int ret = 0;
struct map_ent *map = NULL;
- if (st)
- st->ignore_hw_compat = 1;
+
if (st && st->ss->load_container)
ret = st->ss->load_container(st, mdfd, NULL);
close(mdfd);