#ifndef MDASSEMBLE
static int load_super_ddf_all(struct supertype *st, int fd,
- void **sbp, char *devname, int keep_fd);
+ void **sbp, char *devname);
#endif
static void free_super_ddf(struct supertype *st);
struct ddf_super *super;
int rv;
-#ifndef MDASSEMBLE
- /* if 'fd' is a container, load metadata from all the devices */
- if (load_super_ddf_all(st, fd, &st->sb, devname, 1) == 0)
- return 0;
-#endif
- if (st->subarray[0])
- return 1; /* FIXME Is this correct */
-
if (get_dev_size(fd, devname, &dsize) == 0)
return 1;
return rv;
}
- if (st->subarray[0]) {
- unsigned long val;
- struct vcl *v;
- char *ep;
-
- val = strtoul(st->subarray, &ep, 10);
- if (*ep != '\0') {
- free(super);
- return 1;
- }
-
- for (v = super->conflist; v; v = v->next)
- if (v->vcnum == val)
- super->currentconf = v;
- if (!super->currentconf) {
- free(super);
- return 1;
- }
- }
-
/* Should possibly check the sections .... */
st->sb = super;
st->minor_version = 0;
st->max_devs = 512;
}
- st->loaded_container = 0;
return 0;
}
st = malloc(sizeof(*st));
memset(st, 0, sizeof(*st));
+ st->container_dev = NoMdDev;
st->ss = &super_ddf;
st->max_devs = 512;
st->minor_version = 0;
info->array.major_version = -1;
info->array.minor_version = -2;
- sprintf(info->text_version, "/%s/%s",
+ sprintf(info->text_version, "/%s/%d",
devnum2devname(st->container_dev),
- st->subarray);
+ info->container_member);
info->safe_mode_delay = 200;
memcpy(info->name, ddf->virt->entries[info->container_member].name, 16);
// if (info->vendor_is_local)
// strcpy(ddf->controller.vendor_data, homehost);
rv = -1;
- } if (strcmp(update, "name") == 0) {
+ } else if (strcmp(update, "name") == 0) {
/* name is stored in virtual_entry->name */
// memset(ve->name, ' ', 16);
// strncpy(ve->name, info->name, 16);
rv = -1;
- } if (strcmp(update, "_reshape_progress") == 0) {
+ } else if (strcmp(update, "_reshape_progress") == 0) {
/* We don't support reshape yet */
+ } else if (strcmp(update, "assemble") == 0 ) {
+ /* Do nothing, just succeed */
+ rv = 0;
} else
rv = -1;
return 0;
}
+ if (name)
+ for (venum = 0; venum < __be16_to_cpu(ddf->virt->max_vdes); venum++)
+ if (!all_ff(ddf->virt->entries[venum].guid)) {
+ char *n = ddf->virt->entries[venum].name;
+
+ if (strncmp(name, n, 16) == 0) {
+ fprintf(stderr, Name ": This ddf already"
+ " has an array called %s\n",
+ name);
+ return 0;
+ }
+ }
+
for (venum = 0; venum < __be16_to_cpu(ddf->virt->max_vdes); venum++)
if (all_ff(ddf->virt->entries[venum].guid))
break;
}
vcl->lba_offset = (__u64*) &vcl->conf.phys_refnum[ddf->mppe];
vcl->vcnum = venum;
- sprintf(st->subarray, "%d", venum);
vcl->block_sizes = NULL; /* FIXME not for CONCAT */
vc = &vcl->conf;
static unsigned char null_conf[4096+512];
-static int __write_init_super_ddf(struct supertype *st, int do_close)
+static int __write_init_super_ddf(struct supertype *st)
{
struct ddf_super *ddf = st->sb;
successes++;
}
- if (do_close)
- for (d = ddf->dlist; d; d=d->next) {
- close(d->fd);
- d->fd = -1;
- }
-
return attempts != successes;
}
struct dl *d;
for (d = ddf->dlist; d; d=d->next)
while (Kill(d->devname, NULL, 0, 1, 1) == 0);
- return __write_init_super_ddf(st, 1);
+ return __write_init_super_ddf(st);
}
}
* and try to create a bvd
*/
struct ddf_super *ddf;
- if (load_super_ddf_all(st, cfd, (void **)&ddf, NULL, 1) == 0) {
+ if (load_super_ddf_all(st, cfd, (void **)&ddf, NULL) == 0) {
st->sb = ddf;
st->container_dev = fd2devnum(cfd);
close(cfd);
}
static int load_super_ddf_all(struct supertype *st, int fd,
- void **sbp, char *devname, int keep_fd)
+ void **sbp, char *devname)
{
struct mdinfo *sra;
struct ddf_super *super;
int rv;
sprintf(nm, "%d:%d", sd->disk.major, sd->disk.minor);
- dfd = dev_open(nm, keep_fd? O_RDWR : O_RDONLY);
+ dfd = dev_open(nm, O_RDWR);
if (dfd < 0)
return 2;
rv = load_ddf_headers(dfd, super, NULL);
if (rv == 0)
- rv = load_ddf_local(dfd, super, NULL, keep_fd);
- if (!keep_fd) close(dfd);
+ rv = load_ddf_local(dfd, super, NULL, 1);
if (rv)
return 1;
}
- if (st->subarray[0]) {
- unsigned long val;
- struct vcl *v;
- char *ep;
-
- val = strtoul(st->subarray, &ep, 10);
- if (*ep != '\0') {
- free(super);
- return 1;
- }
-
- for (v = super->conflist; v; v = v->next)
- if (v->vcnum == val)
- super->currentconf = v;
- if (!super->currentconf) {
- free(super);
- return 1;
- }
- }
*sbp = super;
if (st->ss == NULL) {
st->ss = &super_ddf;
st->minor_version = 0;
st->max_devs = 512;
- st->container_dev = fd2devnum(fd);
}
- st->loaded_container = 1;
+ st->container_dev = fd2devnum(fd);
return 0;
}
+
+static int load_container_ddf(struct supertype *st, int fd,
+ char *devname)
+{
+ return load_super_ddf_all(st, fd, &st->sb, devname);
+}
+
#endif /* MDASSEMBLE */
static struct mdinfo *container_content_ddf(struct supertype *st, char *subarray)
if (!ddf->updates_pending)
return;
ddf->updates_pending = 0;
- __write_init_super_ddf(st, 0);
+ __write_init_super_ddf(st);
dprintf("ddf: sync_metadata\n");
}
}
}
+static void default_geometry_ddf(struct supertype *st, int *level, int *layout, int *chunk)
+{
+ if (level && *level == UnSet)
+ *level = LEVEL_CONTAINER;
+
+ if (level && layout && *layout == UnSet)
+ *layout = ddf_level_to_layout(*level);
+}
+
struct superswitch super_ddf = {
#ifndef MDASSEMBLE
.examine_super = examine_super_ddf,
.validate_geometry = validate_geometry_ddf,
.write_init_super = write_init_super_ddf,
.add_to_super = add_to_super_ddf,
+ .load_container = load_container_ddf,
#endif
.match_home = match_home_ddf,
.uuid_from_super= uuid_from_super_ddf,
.free_super = free_super_ddf,
.match_metadata_desc = match_metadata_desc_ddf,
.container_content = container_content_ddf,
- .default_layout = ddf_level_to_layout,
+ .default_geometry = default_geometry_ddf,
.external = 1,