else if (homehost == NULL ||
st->ss->match_home(st, homehost) != 1)
trustworthy = FOREIGN;
- name_to_use = strchr(info.name, ':');
- if (name_to_use)
- name_to_use++;
else
- name_to_use = info.name;
+ trustworthy = LOCAL;
/* There are three possible sources for 'autof': command line,
* ARRAY line in mdadm.conf, or CREATE line in mdadm.conf.
return Incremental_container(st, devname, verbose, runstop,
autof, trustworthy);
}
+ name_to_use = strchr(info.name, ':');
+ if (name_to_use)
+ name_to_use++;
+ else
+ name_to_use = info.name;
+
+ if ((!name_to_use || name_to_use[0] == 0) &&
+ info.array.level == LEVEL_CONTAINER &&
+ trustworthy == LOCAL) {
+ name_to_use = info.text_version;
+ trustworthy = METADATA;
+ }
+
/* 4/ Check if array exists.
*/
map_lock(&map);
/* Couldn't find an existing array, maybe make a new one */
mdfd = create_mddev(match ? match->devname : NULL,
- info.name, autof, trustworthy, chosen_name);
-
+ name_to_use, autof, trustworthy, chosen_name);
if (mdfd < 0)
return 1;
": container %s now has %d devices\n",
chosen_name, info.array.working_disks);
wait_for(chosen_name);
+ if (runstop < 0)
+ return 0; /* don't try to assemble */
return Incremental(chosen_name, verbose, runstop,
NULL, homehost, autof);
}
active_disks = count_active(st, mdfd, &avail, &info);
if (enough(info.array.level, info.array.raid_disks,
info.array.layout, info.array.state & 1,
- avail, active_disks) == 0) {
+ avail, active_disks) == 0 ||
+ (runstop < 0 && active_disks < info.array.raid_disks)) {
free(avail);
if (verbose >= 0)
fprintf(stderr, Name
return cnt + cnt1;
}
-void RebuildMap(void)
-{
- struct mdstat_ent *mdstat = mdstat_read(0, 0);
- struct mdstat_ent *md;
- struct map_ent *map = NULL;
- int mdp = get_mdp_major();
-
- for (md = mdstat ; md ; md = md->next) {
- struct mdinfo *sra = sysfs_read(-1, md->devnum, GET_DEVS);
- struct mdinfo *sd;
-
- for (sd = sra->devs ; sd ; sd = sd->next) {
- char dn[30];
- int dfd;
- int ok;
- struct supertype *st;
- char *path;
- struct mdinfo info;
-
- sprintf(dn, "%d:%d", sd->disk.major, sd->disk.minor);
- dfd = dev_open(dn, O_RDONLY);
- if (dfd < 0)
- continue;
- st = guess_super(dfd);
- if ( st == NULL)
- ok = -1;
- else
- ok = st->ss->load_super(st, dfd, NULL);
- close(dfd);
- if (ok != 0)
- continue;
- st->ss->getinfo_super(st, &info);
- if (md->devnum > 0)
- path = map_dev(MD_MAJOR, md->devnum, 0);
- else
- path = map_dev(mdp, (-1-md->devnum)<< 6, 0);
- map_add(&map, md->devnum,
- info.text_version,
- info.uuid, path ? : "/unknown");
- st->ss->free_super(st);
- break;
- }
- sysfs_free(sra);
- }
- map_write(map);
- map_free(map);
- for (md = mdstat ; md ; md = md->next) {
- struct mdinfo *sra = sysfs_read(-1, md->devnum, GET_VERSION);
- sysfs_uevent(sra, "change");
- sysfs_free(sra);
- }
-}
-
int IncrementalScan(int verbose)
{
/* look at every device listed in the 'map' file.
err = assemble_container_content(st, mdfd, ra, runstop,
chosen_name, verbose);
- close(mdfd);
if (err)
return err;
}