Remove shared snapshots when origin or the snapshot store is being removed. Signed-off-by: Mikulas Patocka --- lib/metadata/lv_manip.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) Index: LVM2.2.02.54/lib/metadata/lv_manip.c =================================================================== --- LVM2.2.02.54.orig/lib/metadata/lv_manip.c 2009-12-16 04:11:18.000000000 +0100 +++ LVM2.2.02.54/lib/metadata/lv_manip.c 2009-12-16 04:11:34.000000000 +0100 @@ -2189,7 +2189,22 @@ int lv_remove_with_dependencies(struct c { struct dm_list *snh, *snht; - if (lv_is_origin(lv)) { + if (lv_is_cow(lv) && lv_is_multisnap_origin(lv->snapshot->origin)) { + /* if this is shared snapshot, remove its virtual snapshots */ + struct logical_volume *origin = lv->snapshot->origin; + struct lv_list *lvl; + dm_list_iterate_items(lvl, &lv->vg->lvs) { + struct logical_volume *snap_l = lvl->lv; + struct lv_segment *snap_s; + if (lv_is_multisnap_cow(snap_l) && + (snap_s = first_seg(snap_l)) && + snap_s->origin == origin) + if (!lv_remove_with_dependencies(cmd, snap_l, force)) + return 0; + } + } + + if (lv_is_origin(lv)) { /* remove snapshot LVs first */ dm_list_iterate_safe(snh, snht, &lv->snapshot_segs) { if (!lv_remove_with_dependencies(cmd, dm_list_struct_base(snh, struct lv_segment,