summaryrefslogtreecommitdiff
path: root/lib/metadata/lv_manip.c
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2021-05-24 16:08:27 -0500
committerDavid Teigland <teigland@redhat.com>2021-05-24 16:09:35 -0500
commit4a746f7ffcc8e61c9cb5ce9f9e8a061d1ef6b28e (patch)
tree3996e93ccbb0d356b6948714dcf16ed6dd8931a1 /lib/metadata/lv_manip.c
parenta65f8e0a62b9ab3c2fc909a63abfa0e933619a8c (diff)
downloadlvm2-4a746f7ffcc8e61c9cb5ce9f9e8a061d1ef6b28e.tar.gz
lvremove: fix removing thin pool with writecache on data
Diffstat (limited to 'lib/metadata/lv_manip.c')
-rw-r--r--lib/metadata/lv_manip.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 508f78c13..37dd3611d 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6692,6 +6692,25 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return_0;
}
+ /* if thin pool data lv is writecache, then detach and remove the writecache */
+ if (lv_is_thin_pool(lv)) {
+ struct logical_volume *data_lv = data_lv_from_thin_pool(lv);
+
+ if (data_lv && lv_is_writecache(data_lv)) {
+ struct logical_volume *cachevol_lv = first_seg(data_lv)->writecache;
+
+ if (!lv_detach_writecache_cachevol(data_lv, 1)) {
+ log_error("Failed to detach writecache from %s", display_lvname(data_lv));
+ return 0;
+ }
+
+ if (!lv_remove_single(cmd, cachevol_lv, force, 1)) {
+ log_error("Failed to remove cachevol %s.", display_lvname(cachevol_lv));
+ return 0;
+ }
+ }
+ }
+
if (lv_is_writecache(lv)) {
struct logical_volume *cachevol_lv = first_seg(lv)->writecache;