From 5da4feac0eae10302808f42671437fb4e089ea96 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 17 Oct 2008 10:57:15 +0000 Subject: [PATCH] Use temp table to set device size when converting mirrors. (Avoids having same mirror table loaded twice concurrently by first using a 'zero' table to set the size of the device so when mirror table is preloaded it doesn't have to be activated immediately.) --- WHATS_NEW | 1 + lib/metadata/lv_manip.c | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index c30e9ee0f..a46a45dce 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.41 - ===================================== + Use temp table to set device size when converting mirrors. In resume_mirror_images replace activate_lv with resume_lv as workaround. Avoid overwriting in-use on-disk text metadata by forgetting MDA_HEADER_SIZE. Fix snapshot monitoring library to not cancel monitoring invalid snapshot. diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 7724e4847..07d6d23e7 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -2360,11 +2360,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd, struct segment_type *segtype; struct lv_segment *mapseg; - if (!(segtype = get_segtype_from_string(cmd, "striped"))) - return_NULL; - /* create an empty layer LV */ - len = strlen(lv_where->name) + 32; if (!(name = alloca(len))) { log_error("layer name allocation failed. " @@ -2384,12 +2380,43 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd, return NULL; } + if (strstr(name, "_mimagetmp")) { + log_very_verbose("Creating transient 'zero' LV" + " for Mirror -> mirror up-convert."); + + segtype = get_segtype_from_string(cmd, "zero"); + + if (!lv_add_virtual_segment(layer_lv, 0, lv_where->le_count, segtype)) { + log_error("Creation of intermediate layer LV failed."); + return NULL; + } + + if (!vg_write(lv_where->vg)) { + log_error("Failed to write intermediate VG metadata"); + return NULL; + } + + if (!vg_commit(lv_where->vg)) { + log_error("Failed to commit intermediate VG metadata"); + vg_revert(lv_where->vg); + return NULL; + } + + if (!activate_lv(cmd, layer_lv)) { + log_error("Failed to resume intermediate 'zero' LV, %s", name); + return NULL; + } + } + log_very_verbose("Inserting layer %s for %s", layer_lv->name, lv_where->name); if (!_move_lv_segments(layer_lv, lv_where, 0, 0)) return_NULL; + if (!(segtype = get_segtype_from_string(cmd, "striped"))) + return_NULL; + /* allocate a new linear segment */ if (!(mapseg = alloc_lv_segment(cmd->mem, segtype, lv_where, 0, layer_lv->le_count,