return 1;
}
-int Assemble(struct supertype *st, char *mddev,
- struct mddev_ident *ident,
- struct mddev_dev *devlist,
- struct context *c)
+int Assemble(char *mddev, struct mddev_ident *ident,
+ struct mddev_dev *devlist, struct context *c)
{
/*
* The task of Assemble is to find a collection of
char chosen_name[1024];
struct map_ent *map = NULL;
struct map_ent *mp;
+ struct supertype *st = NULL;
/*
* If any subdevs are listed, then any that don't
return 1;
}
+ if (c->metadata) {
+ for (i = 0; !st && superlist[i]; i++)
+ st = superlist[i]->match_metadata_desc(c->metadata);
+ if (!st) {
+ pr_err("unrecognised metadata identifier: %s\n", c->metadata);
+ return -EINVAL;
+ }
+ }
+
if (devlist == NULL)
devlist = conf_get_devs();
else if (mddev)
st->ignore_hw_compat = 1;
num_devs = select_devices(devlist, ident, &st, &content, c,
inargv, auto_assem);
- if (num_devs < 0)
- return 1;
+ if (num_devs < 0) {
+ rv = 1;
+ goto free_st;
+ }
- if (!st || !st->sb || !content)
- return 2;
+ if (!st || !st->sb || !content) {
+ rv = 2;
+ goto free_st;
+ }
/* We have a full set of devices - we now need to find the
* array device.
if (content != &info) {
/* This is a member of a container. Try starting the array. */
- int err;
- err = assemble_container_content(st, mdfd, content, c,
+ rv = assemble_container_content(st, mdfd, content, c,
chosen_name, NULL);
close(mdfd);
sysfs_free(pre_exist);
- return err;
+ goto free_st;
}
/* Ok, no bad inconsistancy, we can try updating etc */
/* '2' means 'OK, but not started yet' */
if (rv == -1) {
free(devices);
- return 1;
+ rv = 1;
+ goto free_st;
}
close(mdfd);
- return rv == 2 ? 0 : rv;
+
+ if (rv == 2)
+ rv = 0;
+free_st:
+ if (st) {
+ st->ss->free_super(st);
+ free(st);
+ }
+
+ return rv;
}
int assemble_container_content(struct supertype *st, int mdfd,
int grow_continue = 0;
struct context c = {
.require_homehost = 1,
+ .metadata = NULL,
};
struct shape s = {
.journaldisks = 0,
pr_err("unrecognised metadata identifier: %s\n", optarg);
exit(2);
}
+ c.metadata = optarg;
continue;
case O(MANAGE,'W'):
if (mdfd >= 0)
close(mdfd);
} else {
- rv |= Assemble(ss, ident.devname, array_ident, NULL, &c);
+ rv |= Assemble(ident.devname, array_ident, NULL, &c);
}
} else if (!c.scan)
- rv = Assemble(ss, ident.devname, &ident, devlist->next, &c);
+ rv = Assemble(ident.devname, &ident, devlist->next, &c);
else if (devs_found > 0) {
if (c.update && devs_found > 1) {
pr_err("can only update a single array at a time\n");
rv |= 1;
continue;
}
- rv |= Assemble(ss, dv->devname, array_ident, NULL, &c);
+ rv |= Assemble(dv->devname, array_ident, NULL, &c);
}
} else {
if (c.update) {
if (a->devname && is_devname_ignore(a->devname) == true)
continue;
- r = Assemble(ss, a->devname,
+ r = Assemble(a->devname,
a, NULL, c);
if (r == 0) {
a->assembled = 1;
struct mddev_dev *devlist = conf_get_devs();
acnt = 0;
do {
- rv2 = Assemble(ss, NULL,
+ rv2 = Assemble(NULL,
ident,
devlist, c);
if (rv2 == 0) {
char *action;
int nodes;
char *homecluster;
+ char *metadata;
};
struct shape {
int verbose);
extern int Grow_continue_command(char *devname, int fd, struct context *c);
-extern int Assemble(struct supertype *st, char *mddev,
- struct mddev_ident *ident,
- struct mddev_dev *devlist,
- struct context *c);
+extern int Assemble(char *mddev, struct mddev_ident *ident,
+ struct mddev_dev *devlist, struct context *c);
extern int Build(struct mddev_ident *ident, struct mddev_dev *devlist, struct shape *s,
struct context *c);