if (fd >= 0)
remove_partitions(fd);
if (st->ss->add_to_super(st, &inf->disk,
- fd, dv->devname))
+ fd, dv->devname)) {
+ ioctl(mdfd, STOP_ARRAY, NULL);
goto abort;
+ }
st->ss->getinfo_super(st, inf);
safe_mode_delay = inf->safe_mode_delay;
if (ioctl(mdfd, RUN_ARRAY, ¶m)) {
fprintf(stderr, Name ": RUN_ARRAY failed: %s\n",
strerror(errno));
- Manage_runstop(mddev, mdfd, -1, 0);
+ ioctl(mdfd, STOP_ARRAY, NULL);
goto abort;
}
}
return 0;
abort:
+ map_lock(&map);
+ map_remove(&map, fd2devnum(mdfd));
+ map_unlock(&map);
+
if (mdfd >= 0)
close(mdfd);
return 1;
if (quiet <= 0)
fprintf(stderr, Name ": stopped %s\n", devname);
- if (devnum != NoMdDev) {
- map_delete(&map, devnum);
- map_write(map);
- map_free(map);
- }
+ map_lock(&map);
+ map_remove(&map, devnum);
+ map_unlock(&map);
}
return 0;
}
}
}
+void map_remove(struct map_ent **mapp, int devnum)
+{
+ if (devnum == NoMdDev)
+ return;
+
+ map_delete(mapp, devnum);
+ map_write(*mapp);
+ map_free(*mapp);
+}
+
struct map_ent *map_by_uuid(struct map_ent **map, int uuid[4])
{
struct map_ent *mp;
};
extern int map_update(struct map_ent **mpp, int devnum, char *metadata,
int uuid[4], char *path);
+extern void map_remove(struct map_ent **map, int devnum);
extern struct map_ent *map_by_uuid(struct map_ent **map, int uuid[4]);
extern struct map_ent *map_by_devnum(struct map_ent **map, int devnum);
extern struct map_ent *map_by_name(struct map_ent **map, char *name);
map->num_members = info->raid_disks;
for (i = 0; i < map->num_members; i++) {
/* initialized in add_to_super */
- set_imsm_ord_tbl_ent(map, i, 0);
+ set_imsm_ord_tbl_ent(map, i, IMSM_ORD_REBUILD);
}
mpb->num_raid_devs++;
struct dl *dl;
struct imsm_dev *dev;
struct imsm_map *map;
+ int slot;
dev = get_imsm_dev(super, super->current_vol);
map = get_imsm_map(dev, 0);
dl->index = super->anchor->num_disks;
super->anchor->num_disks++;
}
+ /* Check the device has not already been added */
+ slot = get_imsm_disk_slot(map, dl->index);
+ if (slot >= 0 &&
+ (get_imsm_ord_tbl_ent(dev, slot) & IMSM_ORD_REBUILD) == 0) {
+ fprintf(stderr, Name ": %s has been included in this array twice\n",
+ devname);
+ return 1;
+ }
set_imsm_ord_tbl_ent(map, dk->number, dl->index);
dl->disk.status = CONFIGURED_DISK;