From 99113cc588d14b6c692bb1cb65a0891e575d9861 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Wed, 27 May 2009 18:19:21 +0000 Subject: [PATCH] Suppress 'removed' messages displayed when internal LVs are removed. Fix lvchange -a and -p for sparse LVs. Fix lvcreate --virtualsize to activate the new device immediately. --- WHATS_NEW | 5 ++++- lib/metadata/lv_manip.c | 5 ++++- tools/lvchange.c | 8 +++++++- tools/lvcreate.c | 10 +++++++--- tools/toollib.c | 2 +- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index b5ba17d45..9a3446ef5 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,8 +1,11 @@ Version 2.02.48 - =============================== + Suppress 'removed' messages displayed when internal LVs are removed. + Fix lvchange -a and -p for sparse LVs. + Fix lvcreate --virtualsize to activate the new device immediately. Make --snapshot optional with lvcreate --virtualsize. Generalise --virtualoriginsize to --virtualsize. - Skip virtual origins in process_each_lv_in_vg(). + Skip virtual origins in process_each_lv_in_vg() without --all. Fix counting of virtual origin LVs in vg_validate. Attempt to load dm-zero module if zero target needed but not present. diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index eeb471015..3f770996e 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -2037,6 +2037,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv, } if (lv_is_active(lv) && (force == PROMPT) && + lv_is_visible(lv) && yes_no_prompt("Do you really want to remove active " "%slogical volume %s? [y/n]: ", vg_is_clustered(vg) ? "clustered " : "", @@ -2083,7 +2084,9 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv, log_error("Failed to resume %s.", origin->name); } - log_print("Logical volume \"%s\" successfully removed", lv->name); + if (lv_is_visible(lv)) + log_print("Logical volume \"%s\" successfully removed", lv->name); + return 1; } diff --git a/tools/lvchange.c b/tools/lvchange.c index 4a314a3b1..bbeca5bd7 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -540,6 +540,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv, { int doit = 0, docmds = 0; int archived = 0; + struct logical_volume *origin; if (!(lv->vg->status & LVM_WRITE) && (arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) || @@ -584,7 +585,12 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv, return ECMD_FAILED; } - if (!(lv_is_visible(lv))) { + /* If LV is sparse, activate origin instead */ + if (arg_count(cmd, available_ARG) && lv_is_cow(lv) && + lv_is_virtual_origin(origin = origin_from_cow(lv))) + lv = origin; + + if (!(lv_is_visible(lv)) && !lv_is_virtual_origin(lv)) { log_error("Unable to change internal LV %s directly", lv->name); return ECMD_FAILED; diff --git a/tools/lvcreate.c b/tools/lvcreate.c index b7dce37b5..208299d28 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -910,12 +910,16 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg, return 0; } + /* A virtual origin must be activated explicitly. */ if (lp->voriginsize && - !(org = _create_virtual_origin(cmd, vg, lv->name, - lp->permission, - lp->voriginextents))) { + (!(org = _create_virtual_origin(cmd, vg, lv->name, + lp->permission, + lp->voriginextents)) || + !activate_lv(cmd, org))) { log_error("Couldn't create virtual origin for LV %s", lv->name); + if (org && !lv_remove(org)) + stack; goto deactivate_and_revert_new_lv; } diff --git a/tools/toollib.c b/tools/toollib.c index fed240658..7c9ff447b 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -122,7 +122,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, if (lvl->lv->status & SNAPSHOT) continue; - if (lv_is_virtual_origin(lvl->lv)) + if (lv_is_virtual_origin(lvl->lv) && !arg_count(cmd, all_ARG)) continue; /* Should we process this LV? */