mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
cleanup: use is_change_activating
Use a single inline function to detect activation/deactivation
This commit is contained in:
parent
fb519c35bb
commit
e6fd16f8ea
@ -6088,10 +6088,9 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (lv_is_active(lvl->lv) ||
|
||||
((lp->activate != CHANGE_AN) && (lp->activate != CHANGE_ALN)))
|
||||
if (!update_pool_lv(lvl->lv, 1))
|
||||
return_NULL;
|
||||
if ((lv_is_active(lvl->lv) || is_change_activating(lp->activate)) &&
|
||||
!update_pool_lv(lvl->lv, 1))
|
||||
return_NULL;
|
||||
|
||||
/* For thin snapshot we must have matching pool */
|
||||
if (org && lv_is_thin_volume(org) && (!lp->pool ||
|
||||
|
@ -724,7 +724,7 @@ static int _read_activation_params(struct lvcreate_params *lp,
|
||||
lp->activate = (activation_change_t)
|
||||
arg_uint_value(cmd, activate_ARG, CHANGE_AY);
|
||||
|
||||
if (lp->activate == CHANGE_AN || lp->activate == CHANGE_ALN) {
|
||||
if (!is_change_activating(lp->activate)) {
|
||||
if (lp->zero && !seg_is_thin(lp)) {
|
||||
log_error("--activate n requires --zero n");
|
||||
return 0;
|
||||
|
@ -1404,7 +1404,7 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
* deactivation of origin, which is the only visible LV
|
||||
*/
|
||||
if (!deactivate_lv(cmd, find_snapshot(lv)->lv)) {
|
||||
if ((activate != CHANGE_AN) && (activate != CHANGE_ALN)) {
|
||||
if (is_change_activating(activate)) {
|
||||
log_error("Refusing to activate merging \"%s\" while snapshot \"%s\" is still active.",
|
||||
lv->name, find_snapshot(lv)->lv->name);
|
||||
return 0;
|
||||
@ -1420,8 +1420,7 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return_0;
|
||||
|
||||
if (background_polling() &&
|
||||
(activate != CHANGE_AN) &&
|
||||
(activate != CHANGE_ALN) &&
|
||||
is_change_activating(activate) &&
|
||||
(lv->status & (PVMOVE|CONVERTING|MERGING)))
|
||||
lv_spawn_background_polling(cmd, lv);
|
||||
|
||||
|
@ -117,8 +117,7 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
|
||||
/* Can't deactivate a pvmove LV */
|
||||
/* FIXME There needs to be a controlled way of doing this */
|
||||
if (((activate == CHANGE_AN) || (activate == CHANGE_ALN)) &&
|
||||
((lv->status & PVMOVE) ))
|
||||
if ((lv->status & PVMOVE) && !is_change_activating(activate))
|
||||
continue;
|
||||
|
||||
if (lv_activation_skip(lv, activate, arg_count(cmd, ignoreactivationskip_ARG), 0))
|
||||
@ -152,8 +151,8 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
|
||||
if (expected_count)
|
||||
log_verbose("%s %d logical volumes in volume group %s",
|
||||
(activate == CHANGE_AN || activate == CHANGE_ALN)?
|
||||
"Deactivated" : "Activated", count, vg->name);
|
||||
is_change_activating(activate) ?
|
||||
"Activated" : "Deactivated", count, vg->name);
|
||||
|
||||
return (expected_count != count) ? 0 : 1;
|
||||
}
|
||||
@ -193,12 +192,10 @@ static int _vgchange_background_polling(struct cmd_context *cmd, struct volume_g
|
||||
int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
|
||||
activation_change_t activate)
|
||||
{
|
||||
int lv_open, active, monitored = 0, r = 1, do_activate = 1;
|
||||
int lv_open, active, monitored = 0, r = 1;
|
||||
const struct lv_list *lvl;
|
||||
struct lvinfo info;
|
||||
|
||||
if ((activate == CHANGE_AN) || (activate == CHANGE_ALN))
|
||||
do_activate = 0;
|
||||
int do_activate = is_change_activating(activate);
|
||||
|
||||
/*
|
||||
* Safe, since we never write out new metadata here. Required for
|
||||
@ -589,8 +586,7 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
if (arg_count(cmd, activate_ARG) &&
|
||||
(arg_count(cmd, monitor_ARG) || arg_count(cmd, poll_ARG))) {
|
||||
int activate = arg_uint_value(cmd, activate_ARG, 0);
|
||||
if (activate == CHANGE_AN || activate == CHANGE_ALN) {
|
||||
if (!is_change_activating(arg_uint_value(cmd, activate_ARG, 0))) {
|
||||
log_error("Only -ay* allowed with --monitor or --poll.");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user