name_to_use = info.name;
if (name_to_use[0] == 0 &&
- info.array.level == LEVEL_CONTAINER &&
- trustworthy == LOCAL) {
+ info.array.level == LEVEL_CONTAINER) {
name_to_use = info.text_version;
trustworthy = METADATA;
}
sprintf(dn, "%d:%d", sra->devs->disk.major,
sra->devs->disk.minor);
dfd2 = dev_open(dn, O_RDONLY);
+ if (dfd2 < 0) {
+ fprintf(stderr, Name
+ ": unable to open %s\n", devname);
+ rv = 2;
+ goto out_unlock;
+ }
st2 = dup_super(st);
if (st2->ss->load_super(st2, dfd2, NULL) ||
st->ss->compare_super(st, st2) != 0) {
if (info.array.level == LEVEL_CONTAINER) {
int devnum = devnum; /* defined and used iff ->external */
/* Try to assemble within the container */
+ sysfs_uevent(sra, "change");
if (verbose >= 0)
fprintf(stderr, Name
- ": container %s now has %d devices\n",
- chosen_name, info.array.working_disks);
+ ": container %s now has %d device%s\n",
+ chosen_name, info.array.working_disks,
+ info.array.working_disks==1?"":"s");
wait_for(chosen_name, mdfd);
if (st->ss->external)
devnum = fd2devnum(mdfd);
* to obtain minimum spare size */
struct supertype *st3 = dup_super(st2);
int mdfd = open_dev(mp->devnum);
- if (!mdfd)
+ if (mdfd < 0) {
+ free(st3);
goto next;
+ }
if (st3->ss->load_container &&
!st3->ss->load_container(st3, mdfd, mp->path)) {
component_size = st3->ss->min_acceptable_spare_size(st3);
close(fd);
}
+ closedir(dir);
+
if (!chosen)
return 1;
strerror(errno));
rv = 1;
}
+ sysfs_free(sra);
}
}
return rv;
/* when nothing to activate - quit */
if (list == NULL)
return 0;
- if (map_lock(&map))
- fprintf(stderr, Name ": failed to get exclusive lock on "
- "mapfile\n");
for (ra = list ; ra ; ra = ra->next) {
int mdfd;
char chosen_name[1024];
/* don't move spares to container with volume being activated
when all volumes are blocked */
- if (ra_all == ra_blocked) {
- map_unlock(&map);
+ if (ra_all == ra_blocked)
return 0;
- }
/* Now move all suitable spares from spare container */
domains = domain_from_array(list, st->ss->name);