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

cleanup: use is_change_activating

Use a single inline function to detect activation/deactivation
This commit is contained in:
Zdenek Kabelac 2014-02-18 20:52:17 +01:00
parent fb519c35bb
commit e6fd16f8ea
4 changed files with 12 additions and 18 deletions

View File

@ -6088,9 +6088,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL; return NULL;
} }
if (lv_is_active(lvl->lv) || if ((lv_is_active(lvl->lv) || is_change_activating(lp->activate)) &&
((lp->activate != CHANGE_AN) && (lp->activate != CHANGE_ALN))) !update_pool_lv(lvl->lv, 1))
if (!update_pool_lv(lvl->lv, 1))
return_NULL; return_NULL;
/* For thin snapshot we must have matching pool */ /* For thin snapshot we must have matching pool */

View File

@ -724,7 +724,7 @@ static int _read_activation_params(struct lvcreate_params *lp,
lp->activate = (activation_change_t) lp->activate = (activation_change_t)
arg_uint_value(cmd, activate_ARG, CHANGE_AY); 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)) { if (lp->zero && !seg_is_thin(lp)) {
log_error("--activate n requires --zero n"); log_error("--activate n requires --zero n");
return 0; return 0;

View File

@ -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 * deactivation of origin, which is the only visible LV
*/ */
if (!deactivate_lv(cmd, find_snapshot(lv)->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.", log_error("Refusing to activate merging \"%s\" while snapshot \"%s\" is still active.",
lv->name, find_snapshot(lv)->lv->name); lv->name, find_snapshot(lv)->lv->name);
return 0; return 0;
@ -1420,8 +1420,7 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
return_0; return_0;
if (background_polling() && if (background_polling() &&
(activate != CHANGE_AN) && is_change_activating(activate) &&
(activate != CHANGE_ALN) &&
(lv->status & (PVMOVE|CONVERTING|MERGING))) (lv->status & (PVMOVE|CONVERTING|MERGING)))
lv_spawn_background_polling(cmd, lv); lv_spawn_background_polling(cmd, lv);

View File

@ -117,8 +117,7 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
/* Can't deactivate a pvmove LV */ /* Can't deactivate a pvmove LV */
/* FIXME There needs to be a controlled way of doing this */ /* FIXME There needs to be a controlled way of doing this */
if (((activate == CHANGE_AN) || (activate == CHANGE_ALN)) && if ((lv->status & PVMOVE) && !is_change_activating(activate))
((lv->status & PVMOVE) ))
continue; continue;
if (lv_activation_skip(lv, activate, arg_count(cmd, ignoreactivationskip_ARG), 0)) 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) if (expected_count)
log_verbose("%s %d logical volumes in volume group %s", log_verbose("%s %d logical volumes in volume group %s",
(activate == CHANGE_AN || activate == CHANGE_ALN)? is_change_activating(activate) ?
"Deactivated" : "Activated", count, vg->name); "Activated" : "Deactivated", count, vg->name);
return (expected_count != count) ? 0 : 1; 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, int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
activation_change_t activate) 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; const struct lv_list *lvl;
struct lvinfo info; struct lvinfo info;
int do_activate = is_change_activating(activate);
if ((activate == CHANGE_AN) || (activate == CHANGE_ALN))
do_activate = 0;
/* /*
* Safe, since we never write out new metadata here. Required for * 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) && if (arg_count(cmd, activate_ARG) &&
(arg_count(cmd, monitor_ARG) || arg_count(cmd, poll_ARG))) { (arg_count(cmd, monitor_ARG) || arg_count(cmd, poll_ARG))) {
int activate = arg_uint_value(cmd, activate_ARG, 0); if (!is_change_activating(arg_uint_value(cmd, activate_ARG, 0))) {
if (activate == CHANGE_AN || activate == CHANGE_ALN) {
log_error("Only -ay* allowed with --monitor or --poll."); log_error("Only -ay* allowed with --monitor or --poll.");
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }