--- lib/activate/dev_manager.c | 23 +++++++++++++++++------ tools/lvcreate.c | 11 +++++++++-- 2 files changed, 26 insertions(+), 8 deletions(-) Index: LVM2.2.02.45/lib/activate/dev_manager.c =================================================================== --- LVM2.2.02.45.orig/lib/activate/dev_manager.c 2009-05-19 21:19:15.000000000 +0200 +++ LVM2.2.02.45/lib/activate/dev_manager.c 2009-05-19 21:27:49.000000000 +0200 @@ -847,16 +847,21 @@ static int _add_origin_target_to_dtree(s "real"))) return_0; - if (!lv->merging_snapshot) { - if (!dm_tree_node_add_snapshot_origin_target(dnode, lv->size, real_dlid)) - return_0; - } else { + if (lv->merging_snapshot) { if (!(cow_dlid = build_dlid(dm, !swap_snap_lvids ? lv->merging_snapshot->cow->lvid.s : lv->merging_snapshot->origin->lvid.s, "cow"))) return_0; if (!dm_tree_node_add_snapshot_merge_target(dnode, lv->size, real_dlid, cow_dlid, lv->merging_snapshot->chunk_size)) return_0; + } else if (lv->shared_snapshot) { + if (!(cow_dlid = build_dlid(dm, lv->shared_snapshot->cow->lvid.s, "cow"))) + return_0; + if (!dm_tree_node_add_snapshot_shared_target(dnode, lv->size, real_dlid, cow_dlid, lv->shared_snapshot->chunk_size)) + return_0; + } else { + if (!dm_tree_node_add_snapshot_origin_target(dnode, lv->size, real_dlid)) + return_0; } return 1; @@ -877,7 +882,7 @@ static int _add_snapshot_target_to_dtree return 0; } - if (snap_seg->status & SNAPSHOT_MERGE) { + if (snap_seg->status & (SNAPSHOT_MERGE | SNAPSHOT_SHARED)) { return 1; } @@ -996,6 +1001,11 @@ static int _add_segment_to_dtree(struct seg->lv->merging_snapshot->cow, seg->lv->name, "real")) return_0; + } else if (seg->lv->shared_snapshot) { + if (!_add_new_lv_to_dtree(dm, dtree, seg->lv->shared_snapshot->cow, seg->lv->name, "cow")) + return_0; + if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, NULL, "real")) + return_0; } else { if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, NULL, "real")) return_0; @@ -1049,7 +1059,8 @@ static int _add_new_lv_to_dtree(struct d if (!lv_name) lv_name = lv->name; - if (lv_is_cow(lv) && find_cow(lv)->status & SNAPSHOT_MERGE && !layer) + if (lv_is_cow(lv) && find_cow(lv)->status & (SNAPSHOT_MERGE | SNAPSHOT_SHARED) + && !layer) return 1; if (!(name = build_dm_name(dm->mem, lv->vg->name, lv_name, layer))) Index: LVM2.2.02.45/tools/lvcreate.c =================================================================== --- LVM2.2.02.45.orig/tools/lvcreate.c 2009-05-19 21:29:29.000000000 +0200 +++ LVM2.2.02.45/tools/lvcreate.c 2009-05-19 21:35:15.000000000 +0200 @@ -850,8 +850,15 @@ static int _lvcreate(struct cmd_context if (!(lp->permission & LVM_WRITE)) lv->status &= ~LVM_WRITE; - /* COW area must be deactivated if origin is not active */ - if (!origin_active && !deactivate_lv(cmd, lv)) { + /* + * COW area must be deactivated if origin is not active + * We also don't want active cow if it is shared store, + * in this case the target is loaded through the origin + * and there's no reason why the user would want to access + * the cow directly. + */ + if ((!origin_active || lp->shared_store) && + !deactivate_lv(cmd, lv)) { log_error("Aborting. Couldn't deactivate snapshot " "COW area. Manual intervention required."); return 0;