diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 1d341eea2..6fc7afbac 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -6823,13 +6823,10 @@ static int _lv_remove_segs_using_this_lv(struct cmd_context *cmd, struct logical yes_no_prompt("Removing %s \"%s\" will remove %u dependent volume(s). " "Proceed? [y/n]: ", lv_type, lv->name, dm_list_size(&lv->segs_using_this_lv)) == 'n') { - log_error("Logical volume \"%s\" not removed.", lv->name); - return 0; - } - - /* Make aware users of this LV, it's going to be removed, so they - * can skip any updates of itself */ - lv->to_remove = 1; + lv->to_remove = 0; + log_error("Logical volume \"%s\" not removed.", lv->name); + return 0; + } /* * Not using _safe iterator here - since we may delete whole subtree @@ -6859,6 +6856,10 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume * struct lv_list *lvl; struct logical_volume *origin; + /* Make aware users of this LV, it's going to be removed, so they + * can skip any updates of itself */ + lv->to_remove = 1; + if (!level && lv_is_cow(lv)) { /* * A merging snapshot cannot be removed directly unless diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c index 3ee5f4a86..463bb291b 100644 --- a/lib/metadata/snapshot_manip.c +++ b/lib/metadata/snapshot_manip.c @@ -325,6 +325,16 @@ int vg_remove_snapshot(struct logical_volume *cow) cow->snapshot = NULL; lv_set_visible(cow); + /* When origin with all its snapshots is going to be remove + * don't bother with individual manipulation with COWs + * Note: removal proceeds only when origin is inactive */ + if (is_origin_active && origin->to_remove) { + origin->vg->needs_write_and_commit = 1; + log_debug_metadata("Postponing write and commit for remove of snapshot %s.", + display_lvname(cow)); + return 1; + } + if (!vg_write(origin->vg)) return_0;