From 46a29c021214e6bc4cf2d7aa8d78815eb57ead70 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Tue, 6 May 2003 12:14:36 +0000 Subject: [PATCH] Check for locked LVs/pvmoves. --- tools/lvchange.c | 13 +++++++++++++ tools/vgchange.c | 15 ++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/lvchange.c b/tools/lvchange.c index e42641a77..42ab1f083 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -76,6 +76,7 @@ static int lvchange_availability(struct cmd_context *cmd, struct logical_volume *lv) { int activate = 0; + struct physical_volume *pv; if (strcmp(arg_str_value(cmd, available_ARG, "n"), "n")) activate = 1; @@ -85,6 +86,11 @@ static int lvchange_availability(struct cmd_context *cmd, log_verbose("Activating logical volume \"%s\"", lv->name); if (!lock_vol(cmd, lv->lvid.s, LCK_LV_ACTIVATE)) return 0; + if ((lv->status & LOCKED) && (pv = get_pvmove_pv_from_lv(lv))) { + log_verbose("Spawning background pvmove process for %s", + dev_name(pv->dev)); + pvmove_poll(cmd, dev_name(pv->dev), 1); + } } else { log_verbose("Deactivating logical volume \"%s\"", lv->name); if (!lock_vol(cmd, lv->lvid.s, LCK_LV_DEACTIVATE)) @@ -289,6 +295,13 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv, return ECMD_FAILED; } + if (lv->status & PVMOVE) { + log_error("Unable to change pvmove LV %s", lv->name); + if (arg_count(cmd, available_ARG)) + log_error("Use 'pvmove --abort' to abandon a pvmove"); + return ECMD_FAILED; + } + /* access permission change */ if (arg_count(cmd, permission_ARG)) { if (!archive(lv->vg)) diff --git a/tools/vgchange.c b/tools/vgchange.c index 4c6e6085f..2e9ed17f3 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -25,18 +25,31 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, { struct list *lvh; struct logical_volume *lv; + struct physical_volume *pv; int count = 0; list_iterate(lvh, &vg->lvs) { lv = list_item(lvh, struct lv_list)->lv; - /* Only request activatation of snapshot origin devices */ + /* Only request activation of snapshot origin devices */ if (lv_is_cow(lv)) continue; + /* Can't deactive a pvmove LV */ + if ((lock == LCK_LV_DEACTIVATE) && (lv->status & PVMOVE)) + continue; + if (!lock_vol(cmd, lv->lvid.s, lock | LCK_NONBLOCK)) continue; + if ((lv->status & PVMOVE) && + (pv = get_pvmove_pv_from_lv_mirr(lv))) { + log_verbose("Spawning background process for %s %s", + lv->name, dev_name(pv->dev)); + pvmove_poll(cmd, dev_name(pv->dev), 1); + continue; + } + count++; }