diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index e4bcd54db..37629a214 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -355,10 +355,17 @@ static int _populate_vanilla(struct dev_manager *dm, static int _populate_origin(struct dev_manager *dm, struct dm_task *dmt, struct dev_layer *dl) { + char *real; char params[PATH_MAX + 32]; + if (!(real = _build_name(dm->mem, dm->vg_name, + dl->lv->name, "real"))) { + stack; + return 0; + } + if (lvm_snprintf(params, sizeof(params), "%s/%s 0", - dm_dir(), dl->name) == -1) { + dm_dir(), real) == -1) { log_err("Couldn't create origin device parameters for '%s'.", dl->name); return 0; @@ -558,6 +565,7 @@ static int _expand_lv(struct dev_manager *dm, struct logical_volume *lv) dl->populate = _populate_vanilla; dl->visible = 0; + /* insert the cow layer */ if (!hash_insert(dm->layers, dl->name, dl)) { stack; return 0; @@ -584,6 +592,21 @@ static int _expand_lv(struct dev_manager *dm, struct logical_volume *lv) list_add(&dl->pre_create, &sl->list); + /* add the dependency on the org device */ + if (!(sl = pool_alloc(dm->mem, sizeof(*sl)))) { + stack; + return 0; + } + + if (!(sl->str = _build_name(dm->mem, dm->vg_name, + s->origin->name, "top"))) { + stack; + return 0; + } + + list_add(&dl->pre_create, &sl->list); + + /* insert the snapshot layer */ if (!hash_insert(dm->layers,dl->name, dl)) { stack; return 0; diff --git a/lib/format1/import-export.c b/lib/format1/import-export.c index a677aebb0..332a75a09 100644 --- a/lib/format1/import-export.c +++ b/lib/format1/import-export.c @@ -546,6 +546,7 @@ int export_lvs(struct disk_list *dl, struct volume_group *vg, org->lv_access |= LV_SNAPSHOT_ORG; cow->lv_access |= LV_SNAPSHOT; cow->lv_snapshot_minor = org->lv_number; + cow->lv_chunk_size = s->chunk_size; } r = 1; @@ -618,7 +619,8 @@ int import_snapshots(struct pool *mem, struct volume_group *vg, continue; /* insert the snapshot */ - if (!vg_add_snapshot(org, cow, 1, lvd->lv_chunk_size)) { + if (!vg_add_snapshot(org, cow, 1, + lvd->lv_chunk_size)) { log_err("Couldn't add snapshot."); return 0; } diff --git a/lib/format_text/import.c b/lib/format_text/import.c index 317f0a633..f7ebfac2e 100644 --- a/lib/format_text/import.c +++ b/lib/format_text/import.c @@ -484,12 +484,14 @@ static int _read_sections(const char *section, section_fn fn, return 1; } -static struct volume_group *_read_vg(struct pool *mem, struct config_file *cf, +static struct volume_group *_read_vg(struct cmd_context *cmd, + struct config_file *cf, struct uuid_map *um) { struct config_node *vgn, *cn; struct volume_group *vg; struct hash_table *pv_hash = NULL; + struct pool *mem = cmd->mem; /* skip any top-level values */ for (vgn = cf->root; (vgn && vgn->v); vgn = vgn->sib) @@ -504,6 +506,7 @@ static struct volume_group *_read_vg(struct pool *mem, struct config_file *cf, stack; return NULL; } + vg->cmd = cmd; if (!(vg->name = pool_strdup(mem, vgn->key))) { stack; @@ -648,7 +651,7 @@ struct volume_group *text_vg_import(struct cmd_context *cmd, goto out; } - if (!(vg = _read_vg(cmd->mem, cf, um))) { + if (!(vg = _read_vg(cmd, cf, um))) { stack; goto out; }