Incremental: restore assembly for inactive containers, block active

GET_ARRAY_INFO always succeeds on an inactive container, so we need to
be a bit more diligent about adding a disk to an active container.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
Dan Williams 2010-07-19 14:59:25 -07:00
parent 569cc43ffb
commit 1dccfff910
3 changed files with 17 additions and 2 deletions

View File

@ -376,7 +376,16 @@ int Incremental(char *devname, int verbose, int runstop,
* statement about this.
*/
if (runstop < 1) {
if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0) {
int active = 0;
if (st->ss->external) {
char *devname = devnum2devname(fd2devnum(mdfd));
active = devname && is_container_active(devname);
free(devname);
} else if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0)
active = 1;
if (active) {
fprintf(stderr, Name
": not adding %s to active array (without --run) %s\n",
devname, chosen_name);

View File

@ -930,6 +930,7 @@ extern int open_mddev(char *dev, int report_errors);
extern int open_container(int fd);
extern int is_container_member(struct mdstat_ent *ent, char *devname);
extern int is_subarray_active(char *subarray, char *devname);
int is_container_active(char *devname);
extern int open_subarray(char *dev, struct supertype *st, int quiet);
extern struct superswitch *version_to_superswitch(char *vers);

7
util.c
View File

@ -1427,7 +1427,7 @@ int is_subarray_active(char *subarray, char *container)
if (is_container_member(ent, container)) {
char *inst = &ent->metadata_version[10+strlen(container)+1];
if (strcmp(inst, subarray) == 0)
if (!subarray || strcmp(inst, subarray) == 0)
break;
}
}
@ -1437,6 +1437,11 @@ int is_subarray_active(char *subarray, char *container)
return ent != NULL;
}
int is_container_active(char *container)
{
return is_subarray_active(NULL, container);
}
/* open_subarray - opens a subarray in a container
* @dev: container device name
* @st: supertype with only ->subarray set