/* This is a member of a container. Try starting the array. */
int err;
err = assemble_container_content(st, mdfd, content, c,
- chosen_name);
+ chosen_name, NULL);
close(mdfd);
return err;
}
#ifndef MDASSEMBLE
int assemble_container_content(struct supertype *st, int mdfd,
struct mdinfo *content, struct context *c,
- char *chosen_name)
+ char *chosen_name, int *result)
{
struct mdinfo *dev, *sra;
int working = 0, preexist = 0;
if (enough(content->array.level, content->array.raid_disks,
content->array.layout, content->array.state & 1, avail) == 0) {
- if (c->verbose >= 0) {
+ if (c->export && result)
+ *result |= INCR_NO;
+ else if (c->verbose >= 0) {
pr_err("%s assembled with %d device%s",
chosen_name, preexist + working,
preexist + working == 1 ? "":"s");
if (c->runstop <= 0 &&
(working + preexist + expansion) <
content->array.working_disks) {
- if (c->verbose >= 0) {
+ if (c->export && result)
+ *result |= INCR_UNSAFE;
+ else if (c->verbose >= 0) {
pr_err("%s assembled with %d device%s",
chosen_name, preexist + working,
preexist + working == 1 ? "":"s");
!start_reshape)
block_subarray(content);
- if (c->verbose >= 0) {
+ if (c->export && result) {
+ if (err)
+ *result |= INCR_NO;
+ else
+ *result |= INCR_YES;
+ } else if (c->verbose >= 0) {
if (err)
pr_err("array %s now has %d device%s",
chosen_name, working + preexist,
struct mdinfo *sra = NULL, *d;
struct mddev_ident *match;
char chosen_name[1024];
+ char *md_devname;
int rv = 1;
struct map_ent *mp, *map = NULL;
int dfd = -1, mdfd = -1;
if (map_lock(&map))
pr_err("failed to get "
"exclusive lock on mapfile\n");
+ if (c->export)
+ printf("MD_DEVNAME=%s\n", devname);
rv = Incremental_container(st, devname, c, NULL);
map_unlock(&map);
return rv;
info.array.working_disks ++;
}
+ if (strncmp(chosen_name, "/dev/md/", 8) == 0)
+ md_devname = chosen_name+8;
+ else
+ md_devname = chosen_name;
+ if (c->export) {
+ printf("MD_DEVICE=%s\n", fd2devnm(mdfd));
+ printf("MD_DEVNAME=%s\n", md_devname);
+ printf("MD_FOREIGN=%s\n", trustworthy == FOREIGN ? "yes" : "no");
+ }
/* 7/ Is there enough devices to possibly start the array? */
/* 7a/ if not, finish with success. */
char devnm[32];
/* Try to assemble within the container */
sysfs_uevent(sra, "change");
- if (c->verbose >= 0)
+ if (!c->export && c->verbose >= 0)
pr_err("container %s now has %d device%s\n",
chosen_name, info.array.working_disks,
info.array.working_disks == 1?"":"s");
if (enough(info.array.level, info.array.raid_disks,
info.array.layout, info.array.state & 1,
avail) == 0) {
- if (c->verbose >= 0)
+ if (c->export) {
+ printf("MD_STARTED=no\n");
+ } else if (c->verbose >= 0)
pr_err("%s attached to %s, not enough to start (%d).\n",
devname, chosen_name, active_disks);
rv = 0;
/* + start the array (auto-readonly). */
if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0) {
- if (c->verbose >= 0)
+ if (c->export) {
+ printf("MD_STARTED=already\n");
+ } else if (c->verbose >= 0)
pr_err("%s attached to %s which is already active.\n",
devname, chosen_name);
rv = 0;
rv = sysfs_set_str(sra, NULL,
"array_state", "read-auto");
if (rv == 0) {
- if (c->verbose >= 0)
+ if (c->export) {
+ printf("MD_STARTED=yes\n");
+ } else if (c->verbose >= 0)
pr_err("%s attached to %s, which has been started.\n",
devname, chosen_name);
rv = 0;
rv = 1;
}
} else {
- if (c->verbose >= 0)
+ if (c->export) {
+ printf("MD_STARTED=unsafe\n");
+ } else if (c->verbose >= 0)
pr_err("%s attached to %s, not enough to start safely.\n",
devname, chosen_name);
rv = 0;
int sfd;
int ra_blocked = 0;
int ra_all = 0;
+ int result = 0;
st->ss->getinfo_super(st, &info, NULL);
info.container_enough > 0)
/* pass */;
else {
- if (c->verbose)
+ if (c->export) {
+ printf("MD_STARTED=no\n");
+ } else if (c->verbose)
pr_err("not enough devices to start the container\n");
return 0;
}
list = st->ss->container_content(st, NULL);
/* when nothing to activate - quit */
- if (list == NULL)
+ if (list == NULL) {
+ if (c->export) {
+ printf("MD_STARTED=nothing\n");
+ }
return 0;
+ }
for (ra = list ; ra ; ra = ra->next) {
int mdfd;
char chosen_name[1024];
}
assemble_container_content(st, mdfd, ra, c,
- chosen_name);
+ chosen_name, &result);
close(mdfd);
}
+ if (c->export && result) {
+ char sep = '=';
+ printf("MD_STARTED");
+ if (result & INCR_NO) {
+ printf("%cno", sep);
+ sep = ',';
+ }
+ if (result & INCR_UNSAFE) {
+ printf("%cunsafe", sep);
+ sep = ',';
+ }
+ if (result & INCR_ALREADY) {
+ printf("%calready", sep);
+ sep = ',';
+ }
+ if (result & INCR_YES) {
+ printf("%cyes", sep);
+ sep = ',';
+ }
+ printf("\n");
+ }
/* don't move spares to container with volume being activated
when all volumes are blocked */