From a0776fe40921a47018de9b014191cb5090cb6b3d Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 4 Mar 2024 11:58:32 +0100 Subject: [PATCH] thin: remove stack external origins Ensure external origin is deactivated during removal. Only unused external origins can be deactivated. --- lib/metadata/lv_manip.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index bd70fdaa1..904348af3 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -7932,9 +7932,18 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume * return 1; } - if (lv_is_external_origin(lv) && - !_lv_remove_segs_using_this_lv(cmd, lv, force, level, "external origin")) - return_0; + if (lv_is_external_origin(lv)) { + if (!_lv_remove_check_in_use(lv, force)) + return_0; + + if (!deactivate_lv(cmd, lv)) + goto no_remove; + + log_verbose("Removing external origin logical volume %s.", display_lvname(lv)); + + if (!_lv_remove_segs_using_this_lv(cmd, lv, force, level, "external origin")) + return_0; + } if (lv_is_used_thin_pool(lv) && !_lv_remove_segs_using_this_lv(cmd, lv, force, level, "pool"))