diff --git a/WHATS_NEW b/WHATS_NEW index c72561a15..5b3ff48cd 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.00.17 - ============================= + Add local activation support. Tidy relative paths in makefile includes. fsadm support for fsck and resizing - needs testing. Add read-only GFS pool support. diff --git a/lib/locking/locking.h b/lib/locking/locking.h index afe0e0d20..2a5a12224 100644 --- a/lib/locking/locking.h +++ b/lib/locking/locking.h @@ -63,6 +63,7 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname); */ #define LCK_NONBLOCK 0x00000010 /* Don't block waiting for lock? */ #define LCK_HOLD 0x00000020 /* Hold lock when lock_vol returns? */ +#define LCK_LOCAL 0x00000040 /* Don't propagate to other nodes */ /* * Common combinations @@ -85,9 +86,14 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname); #define activate_lv(cmd, vol) lock_vol(cmd, vol, LCK_LV_ACTIVATE | LCK_HOLD) #define activate_lv_excl(cmd, vol) \ lock_vol(cmd, vol, LCK_LV_EXCLUSIVE | LCK_HOLD) +#define activate_lv_local(cmd, vol) \ + lock_vol(cmd, vol, LCK_LV_ACTIVATE | LCK_HOLD | LCK_LOCAL) +#define deactivate_lv_local(cmd, vol) \ + lock_vol(cmd, vol, LCK_LV_DEACTIVATE | LCK_LOCAL) /* Process list of LVs */ int suspend_lvs(struct cmd_context *cmd, struct list *lvs); int resume_lvs(struct cmd_context *cmd, struct list *lvs); int activate_lvs_excl(struct cmd_context *cmd, struct list *lvs); + diff --git a/tools/lvchange.c b/tools/lvchange.c index e0ef53652..e9ec8d2a7 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -80,28 +80,49 @@ static int lvchange_availability(struct cmd_context *cmd, activate = arg_uint_value(cmd, available_ARG, 0); - if (activate) { - log_verbose("Activating logical volume \"%s\"", lv->name); - if (lv_is_origin(lv) || (activate == 2)) { - if (!activate_lv_excl(cmd, lv->lvid.s)) { - stack; - return 0; - } - } else if (!activate_lv(cmd, lv->lvid.s)) { + if (activate == CHANGE_ALN) { + log_verbose("Deactivating logical volume \"%s\" locally", + lv->name); + if (!deactivate_lv_local(cmd, lv->lvid.s)) { stack; return 0; } - if ((lv->status & LOCKED) && (pvname = get_pvmove_pvname_from_lv(lv))) { - log_verbose("Spawning background pvmove process for %s", - pvname); - pvmove_poll(cmd, pvname, 1); - } - } else { + } else if (activate == CHANGE_AN) { log_verbose("Deactivating logical volume \"%s\"", lv->name); if (!deactivate_lv(cmd, lv->lvid.s)) { stack; return 0; } + } else { + if (lv_is_origin(lv) || (activate == CHANGE_AE)) { + log_verbose("Activating logical volume \"%s\" " + "exclusively", lv->name); + if (!activate_lv_excl(cmd, lv->lvid.s)) { + stack; + return 0; + } + } else if (activate == CHANGE_ALY) { + log_verbose("Activating logical volume \"%s\" locally", + lv->name); + if (!activate_lv_local(cmd, lv->lvid.s)) { + stack; + return 0; + } + } else { + log_verbose("Activating logical volume \"%s\"", + lv->name); + if (!activate_lv(cmd, lv->lvid.s)) { + stack; + return 0; + } + } + + if ((lv->status & LOCKED) && + (pvname = get_pvmove_pvname_from_lv(lv))) { + log_verbose("Spawning background pvmove process for %s", + pvname); + pvmove_poll(cmd, pvname, 1); + } } return 1; diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 695c4ad8e..3264d67ce 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -90,18 +90,28 @@ int yes_no_excl_arg(struct cmd_context *cmd, struct arg *a) a->sign = SIGN_NONE; if (!strcmp(a->value, "e")) { - a->i_value = 2; - a->ui_value = 2; + a->i_value = CHANGE_AE; + a->ui_value = CHANGE_AE; } else if (!strcmp(a->value, "y")) { - a->i_value = 1; - a->ui_value = 1; + a->i_value = CHANGE_AY; + a->ui_value = CHANGE_AY; } else if (!strcmp(a->value, "n")) { - a->i_value = 0; - a->ui_value = 0; + a->i_value = CHANGE_AN; + a->ui_value = CHANGE_AN; + } + + else if (!strcmp(a->value, "ln") || !strcmp(a->value, "nl")) { + a->i_value = CHANGE_ALN; + a->ui_value = CHANGE_ALN; + } + + else if (!strcmp(a->value, "ly") || !strcmp(a->value, "yl")) { + a->i_value = CHANGE_ALY; + a->ui_value = CHANGE_ALY; } else diff --git a/tools/tools.h b/tools/tools.h index fcee3ddc0..acab0380e 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -78,6 +78,14 @@ typedef enum { SIGN_MINUS = 2 } sign_t; +enum { + CHANGE_AY = 0, + CHANGE_AN = 1, + CHANGE_AE = 2, + CHANGE_ALY = 3, + CHANGE_ALN = 4 +}; + /* a global table of possible arguments */ struct arg { const char short_arg; diff --git a/tools/vgchange.c b/tools/vgchange.c index ec30e6d8a..20d49d939 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -31,15 +31,23 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, continue; /* Can't deactive a pvmove LV */ - if (!activate && (lv->status & PVMOVE)) + /* FIXME There needs to be a controlled way of doing this */ + if (((activate == CHANGE_AN) || (activate == CHANGE_ALN)) && + (lv->status & PVMOVE)) continue; - if (!activate) { + if (activate == CHANGE_AN) { if (!deactivate_lv(cmd, lv->lvid.s)) continue; - } else if (lv_is_origin(lv) || (activate == 2)) { + } else if (activate == CHANGE_ALN) { + if (!deactivate_lv_local(cmd, lv->lvid.s)) + continue; + } else if (lv_is_origin(lv) || (activate == CHANGE_AE)) { if (!activate_lv_excl(cmd, lv->lvid.s)) continue; + } else if (activate == CHANGE_ALY) { + if (!activate_lv_local(cmd, lv->lvid.s)) + continue; } else if (!activate_lv(cmd, lv->lvid.s)) continue; @@ -96,7 +104,7 @@ static int _vgchange_alloc(struct cmd_context *cmd, struct volume_group *vg) if (alloc == ALLOC_INHERIT) { log_error("Volume Group allocation policy cannot inherit " - "from anything"); + "from anything"); return EINVALID_CMD_LINE; } @@ -121,7 +129,6 @@ static int _vgchange_alloc(struct cmd_context *cmd, struct volume_group *vg) return ECMD_PROCESSED; } - static int _vgchange_resizeable(struct cmd_context *cmd, struct volume_group *vg) {