1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

Add local activation support.

This commit is contained in:
Alasdair Kergon 2004-06-16 17:13:41 +00:00
parent 2818520bd1
commit 150b350d31
6 changed files with 78 additions and 25 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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)
{