Parse the 'instance' part of external:/mdXX/INST in metadata handler.

This give more flexability.
This commit is contained in:
Neil Brown 2008-05-27 09:18:57 +10:00
parent dd15dc4a4d
commit cba0191bad
4 changed files with 24 additions and 19 deletions

View File

@ -203,8 +203,7 @@ static void manage_new(struct mdstat_ent *mdstat,
struct active_array *new;
struct mdinfo *mdi, *di;
char *n;
int inst;
char *inst;
int i;
new = malloc(sizeof(*new));
@ -218,10 +217,7 @@ static void manage_new(struct mdstat_ent *mdstat,
new->container = container;
n = &mdstat->metadata_version[10+strlen(container->devname)+1];
inst = atoi(n);
if (inst < 0)
abort();//FIXME
inst = &mdstat->metadata_version[10+strlen(container->devname)+1];
mdi = sysfs_read(-1, new->devnum,
GET_LEVEL|GET_CHUNK|GET_DISKS|

View File

@ -413,7 +413,8 @@ extern struct superswitch {
struct mdinfo *(*container_content)(struct supertype *st);
/* for mdmon */
int (*open_new)(struct supertype *c, struct active_array *a, int inst);
int (*open_new)(struct supertype *c, struct active_array *a,
char *inst);
/* Tell the metadata handler the current state of the array.
* This covers whether it is known to be consistent (no pending writes)

View File

@ -1201,14 +1201,19 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info)
info->disk.major = 0;
info->disk.minor = 0;
info->disk.number = __be32_to_cpu(ddf->dlist->disk.refnum);
// info->disk.raid_disk = find refnum in the table and use index;
info->disk.raid_disk = -1;
for (i = 0; i < __be16_to_cpu(ddf->phys->max_pdes) ; i++)
if (ddf->phys->entries[i].refnum == ddf->dlist->disk.refnum) {
info->disk.raid_disk = i;
break;
}
if (ddf->dlist) {
info->disk.number = __be32_to_cpu(ddf->dlist->disk.refnum);
info->disk.raid_disk = -1;
for (i = 0; i < __be16_to_cpu(ddf->phys->max_pdes) ; i++)
if (ddf->phys->entries[i].refnum ==
ddf->dlist->disk.refnum) {
info->disk.raid_disk = i;
break;
}
} else {
info->disk.number = -1;
// info->disk.raid_disk = find refnum in the table and use index;
}
info->disk.state = (1 << MD_DISK_SYNC);
info->reshape_active = 0;
@ -2516,9 +2521,10 @@ static int compare_super_ddf(struct supertype *st, struct supertype *tst)
* We need to confirm that the array matches the metadata in 'c' so
* that we don't corrupt any metadata.
*/
static int ddf_open_new(struct supertype *c, struct active_array *a, int inst)
static int ddf_open_new(struct supertype *c, struct active_array *a, char *inst)
{
fprintf(stderr, "ddf: open_new %d\n", inst);
fprintf(stderr, "ddf: open_new %s\n", inst);
a->info.container_member = atoi(inst);
return 0;
}

View File

@ -1128,9 +1128,11 @@ static struct mdinfo *container_content_imsm(struct supertype *st)
}
static int imsm_open_new(struct supertype *c, struct active_array *a, int inst)
static int imsm_open_new(struct supertype *c, struct active_array *a,
char *inst)
{
fprintf(stderr, "imsm: open_new %d\n", inst);
fprintf(stderr, "imsm: open_new %s\n", inst);
a->info.container_member = atoi(inst);
return 0;
}