From 866b21532a121a142b1c5dcc36fbaf5e24bc30f8 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 19 Oct 2011 16:37:30 +0000 Subject: [PATCH] Drop messages referencing deleted LV lvremove may remove problematic LV for thin target. --- lib/metadata/thin_manip.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c index c66e527a0..ef16d270c 100644 --- a/lib/metadata/thin_manip.c +++ b/lib/metadata/thin_manip.c @@ -46,12 +46,32 @@ int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv) int detach_pool_lv(struct lv_segment *seg) { + struct lv_thin_message *tmsg; + struct dm_list *l, *lt; + if (!lv_is_thin_pool(seg->pool_lv)) { log_error(INTERNAL_ERROR "LV %s is not a thin pool", seg->pool_lv->name); return 0; } + /* Drop any message referencing removed segment */ + dm_list_iterate_safe(l, lt, &first_seg(seg->pool_lv)->thin_messages) { + tmsg = dm_list_item(l, struct lv_thin_message); + switch (tmsg->type) { + case DM_THIN_MESSAGE_CREATE_SNAP: + case DM_THIN_MESSAGE_CREATE_THIN: + case DM_THIN_MESSAGE_TRIM: + if (first_seg(tmsg->u.lv) == seg) { + log_debug("Discarding message for LV %s.", + tmsg->u.lv->name); + dm_list_del(&tmsg->list); + } + default: + break; + } + } + if (!attach_pool_message(first_seg(seg->pool_lv), DM_THIN_MESSAGE_DELETE, NULL, seg->device_id, 0)) -- 2.43.5