struct createinfo *ci = conf_get_create_info();
- if (autof == 0)
- autof = ci->autof;
/* 1/ Check if device is permitted by mdadm.conf */
match = array_list;
}
- /* 3a/ if not, check for homehost match. If no match, reject. */
+ /* 3a/ if not, check for homehost match. If no match, continue
+ * but don't trust the 'name' in the array. Thus a 'random' minor
+ * number will be assigned, and the device name will be based
+ * on that. */
if (!match) {
if (homehost == NULL ||
st->ss->match_home(st, homehost) != 1)
uuid_for_name = 1;
}
/* 4/ Determine device number. */
- /* - If in mdadm.conf with std name, use that */
- /* - UUID in /var/run/mdadm.map use that */
+ /* - If in mdadm.conf with std name, get number from name. */
+ /* - UUID in /var/run/mdadm.map get number from mapping */
/* - If name is suggestive, use that. unless in use with */
/* different uuid. */
/* - Choose a free, high number. */
} else
name_to_use = info.name;
- if (match && is_standard(match->devname, &devnum))
- /* We have devnum now */;
- else if (mp != NULL)
+ /* There are three possible sources for 'autof': command line,
+ * ARRAY line in mdadm.conf, or CREATE line in mdadm.conf.
+ * ARRAY takes precedence, then command line, then
+ * CREATE.
+ */
+ if (match && match->autof)
+ autof = match->autof;
+ if (autof == 0)
+ autof = ci->autof;
+
+ if (match && (rv = is_standard(match->devname, &devnum))) {
+ devnum = (rv > 0) ? (-1-devnum) : devnum;
+ } else if (mp != NULL)
devnum = mp->devnum;
else {
/* Have to guess a bit. */
devnum = use_partitions ? (-1-devnum) : devnum;
}
- mdfd = open_mddev_devnum(match ? match->devname : mp ? mp->path : NULL,
+ mdfd = create_mddev_devnum(match ? match->devname : mp ? mp->path : NULL,
devnum,
name_to_use,
chosen_name, autof >> 3);
close(bmfd);
}
sra = sysfs_read(mdfd, devnum, 0);
- if (sra == NULL || active_disks >= info.array.working_disks)
+ if ((sra == NULL || active_disks >= info.array.working_disks)
+ && uuid_for_name == 0)
rv = ioctl(mdfd, RUN_ARRAY, NULL);
else
rv = sysfs_set_str(sra, NULL,
if (ok != 0)
continue;
st->ss->getinfo_super(st, &info);
+ if (!avail) {
+ avail = malloc(info.array.raid_disks);
+ if (!avail) {
+ fprintf(stderr, Name ": out of memory.\n");
+ exit(1);
+ }
+ memset(avail, 0, info.array.raid_disks);
+ *availp = avail;
+ }
+
if (info.disk.state & (1<<MD_DISK_SYNC))
{
- if (avail == NULL) {
- avail = malloc(info.array.raid_disks);
- memset(avail, 0, info.array.raid_disks);
- }
if (cnt == 0) {
cnt++;
max_events = info.events;
mdu_array_info_t array;
mdu_bitmap_file_t bmf;
struct mdinfo *sra;
- int mdfd = open_mddev_devnum(me->path, me->devnum,
+ int mdfd = create_mddev_devnum(me->path, me->devnum,
NULL, path, 0);
if (mdfd < 0)
continue;
return rv;
}
-static char *container2devname(char *devname)
-{
- int fd = open(devname, O_RDONLY);
- char *mdname = NULL;
-
- if (fd >= 0) {
- mdname = devnum2devname(fd2devnum(fd));
- close(fd);
- }
-
- return mdname;
-}
-
int Incremental_container(struct supertype *st, char *devname, int verbose,
int runstop, int autof)
{
struct mdinfo *list = st->ss->container_content(st);
struct mdinfo *ra;
- char *mdname = container2devname(devname);
-
- if (!mdname) {
- fprintf(stderr, Name": failed to determine device name\n");
- return 2;
- }
for (ra = list ; ra ; ra = ra->next) {
struct mdinfo *dev, *sra;
continue;
if (strcmp(array_list->member, sub) != 0)
continue;
+ if (array_list->uuid_set &&
+ !same_uuid(ra->uuid, array_list->uuid, st->ss->swapuuid))
+ continue;
fd = open(array_list->container, O_RDONLY);
if (fd < 0)
continue;
free(dn);
/* we have a match */
match = array_list;
+ if (verbose>0)
+ fprintf(stderr, Name ": match found for member %s\n",
+ array_list->member);
break;
}
}
else
devnum = find_free_devnum(usepart);
}
- mdfd = open_mddev_devnum(mp ? mp->path : match ? match->devname : NULL,
+ mdfd = create_mddev_devnum(mp ? mp->path : match ? match->devname : NULL,
devnum, name_to_use,
chosen_name, autof>>3);