From a3a02a2f42ff490c8ae55205fa6ee217ffc4c59f Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 23 Oct 2009 01:24:17 +0000 Subject: [PATCH] Cleanup mimagetmp LV if allocation fails for new lvconvert mimage. --- WHATS_NEW | 1 + tools/lvconvert.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 1401be7fa..c4c65c5f9 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.54 - ===================================== + Cleanup mimagetmp LV if allocation fails for new lvconvert mimage. Fix clvmd segfault when refresh_toolcontext fails. Remember to clear 'global lock held during cache refresh' state after use. Use udev flags support in LVM. diff --git a/tools/lvconvert.c b/tools/lvconvert.c index af78c36fd..7a3e7abe6 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -532,7 +532,7 @@ static int _lvconvert_mirrors(struct cmd_context *cmd, struct logical_volume *lv const char *mirrorlog; unsigned corelog = 0; int r = 0; - struct logical_volume *log_lv; + struct logical_volume *log_lv, *layer_lv; int failed_mirrors = 0, failed_log = 0; struct dm_list *old_pvh = NULL, *remove_pvs = NULL; @@ -733,8 +733,21 @@ static int _lvconvert_mirrors(struct cmd_context *cmd, struct logical_volume *lv lv->le_count, lp->region_size), 0U, lp->pvh, lp->alloc, - MIRROR_BY_LV)) + MIRROR_BY_LV)) { + layer_lv = seg_lv(first_seg(lv), 0); + if (!remove_layer_from_lv(lv, layer_lv) || + !deactivate_lv(cmd, layer_lv) || + !lv_remove(layer_lv) || !vg_write(lv->vg) || + !vg_commit(lv->vg)) { + log_error("ABORTING: Failed to remove " + "temporary mirror layer %s.", + layer_lv->name); + log_error("Manual cleanup with vgcfgrestore " + "and dmsetup may be required."); + return 0; + } return_0; + } lv->status |= CONVERTING; lp->need_polling = 1; }