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

xxchange -ae to activation exclusively

This commit is contained in:
Alasdair Kergon 2004-05-24 13:44:10 +00:00
parent d1b26f8e86
commit 3bc930ea7b
6 changed files with 36 additions and 8 deletions

View File

@ -1,5 +1,6 @@
Version 2.00.16 -
=============================
xxchange -ae for exclusive activation.
Don't return non-zero status if there aren't any volume groups.
Add --alloc argument to tools.
Rename allocation policies to contiguous, normal, anywhere, inherit.

View File

@ -51,7 +51,7 @@ arg(allocation_ARG, '\0', "allocation", yes_no_arg)
/*
* ... and now the short args.
*/
arg(available_ARG, 'a', "available", yes_no_arg)
arg(available_ARG, 'a', "available", yes_no_excl_arg)
arg(all_ARG, 'a', "all", NULL)
arg(autobackup_ARG, 'A', "autobackup", yes_no_arg)
arg(activevolumegroups_ARG, 'A', "activevolumegroups", NULL)

View File

@ -75,15 +75,14 @@ static int lvchange_permission(struct cmd_context *cmd,
static int lvchange_availability(struct cmd_context *cmd,
struct logical_volume *lv)
{
int activate = 0;
int activate;
const char *pvname;
if (strcmp(arg_str_value(cmd, available_ARG, "n"), "n"))
activate = 1;
activate = arg_uint_value(cmd, available_ARG, 0);
if (activate) {
log_verbose("Activating logical volume \"%s\"", lv->name);
if (lv_is_origin(lv)) {
if (lv_is_origin(lv) || (activate == 2)) {
if (!activate_lv_excl(cmd, lv->lvid.s)) {
stack;
return 0;

View File

@ -85,6 +85,31 @@ int yes_no_arg(struct cmd_context *cmd, struct arg *a)
return 1;
}
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;
}
else if (!strcmp(a->value, "y")) {
a->i_value = 1;
a->ui_value = 1;
}
else if (!strcmp(a->value, "n")) {
a->i_value = 0;
a->ui_value = 0;
}
else
return 0;
return 1;
}
int metadatatype_arg(struct cmd_context *cmd, struct arg *a)
{
struct format_type *fmt;

View File

@ -109,6 +109,7 @@ void usage(const char *name);
/* the argument verify/normalise functions */
int yes_no_arg(struct cmd_context *cmd, struct arg *a);
int yes_no_excl_arg(struct cmd_context *cmd, struct arg *a);
int size_kb_arg(struct cmd_context *cmd, struct arg *a);
int size_mb_arg(struct cmd_context *cmd, struct arg *a);
int int_arg(struct cmd_context *cmd, struct arg *a);

View File

@ -37,7 +37,7 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd,
if (!activate) {
if (!deactivate_lv(cmd, lv->lvid.s))
continue;
} else if (lv_is_origin(lv)) {
} else if (lv_is_origin(lv) || (activate == 2)) {
if (!activate_lv_excl(cmd, lv->lvid.s))
continue;
} else if (!activate_lv(cmd, lv->lvid.s))
@ -60,7 +60,9 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd,
static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
{
int lv_open, active;
int available = !strcmp(arg_str_value(cmd, available_ARG, "n"), "y");
int available;
available = arg_uint_value(cmd, available_ARG, 0);
/* FIXME: Force argument to deactivate them? */
if (!available && (lv_open = lvs_in_vg_opened(vg))) {
@ -73,7 +75,7 @@ static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
log_verbose("%d logical volume(s) in volume group \"%s\" "
"already active", active, vg->name);
if (available && _activate_lvs_in_vg(cmd, vg, 1))
if (available && _activate_lvs_in_vg(cmd, vg, available))
log_verbose("Activated logical volumes in "
"volume group \"%s\"", vg->name);