mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
tools: add common lv_change_activate
Move common code for changing activation state from vgchange and lvchange to one function. Fix the order of checks - so we always implicitelly activate snapshots and thin volumes in exclusive mode, and we do not allow local deactivation for them.
This commit is contained in:
parent
698137ec38
commit
a81a2406f1
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.99 -
|
Version 2.02.99 -
|
||||||
===================================
|
===================================
|
||||||
|
Add lv_change_activate() for common activation code in vg/lvchange.
|
||||||
Revert change that allowed identical table reload for RAID.
|
Revert change that allowed identical table reload for RAID.
|
||||||
New lvchange arg, '--syncaction' allows scrubbing of RAID LVs.
|
New lvchange arg, '--syncaction' allows scrubbing of RAID LVs.
|
||||||
Improve RAID kernel status retrieval to include sync_action/mismatch_cnt.
|
Improve RAID kernel status retrieval to include sync_action/mismatch_cnt.
|
||||||
|
@ -219,44 +219,12 @@ static int _lvchange_activate(struct cmd_context *cmd, struct logical_volume *lv
|
|||||||
if (lv_is_cow(lv) && !lv_is_virtual_origin(origin_from_cow(lv)))
|
if (lv_is_cow(lv) && !lv_is_virtual_origin(origin_from_cow(lv)))
|
||||||
lv = origin_from_cow(lv);
|
lv = origin_from_cow(lv);
|
||||||
|
|
||||||
if (activate == CHANGE_AAY) {
|
if ((activate == CHANGE_AAY) &&
|
||||||
if (!lv_passes_auto_activation_filter(cmd, lv))
|
!lv_passes_auto_activation_filter(cmd, lv))
|
||||||
return 1;
|
return 1;
|
||||||
activate = CHANGE_ALY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (activate == CHANGE_ALN) {
|
if (!lv_change_activate(cmd, lv, activate))
|
||||||
log_verbose("Deactivating logical volume \"%s\" locally",
|
return_0;
|
||||||
lv->name);
|
|
||||||
if (!deactivate_lv_local(cmd, lv))
|
|
||||||
return_0;
|
|
||||||
} else if (activate == CHANGE_AN) {
|
|
||||||
log_verbose("Deactivating logical volume \"%s\"", lv->name);
|
|
||||||
if (!deactivate_lv(cmd, lv))
|
|
||||||
return_0;
|
|
||||||
} else {
|
|
||||||
if ((activate == CHANGE_AE) ||
|
|
||||||
lv_is_origin(lv) ||
|
|
||||||
lv_is_thin_type(lv)) {
|
|
||||||
log_verbose("Activating logical volume \"%s\" "
|
|
||||||
"exclusively", lv->name);
|
|
||||||
if (!activate_lv_excl(cmd, lv))
|
|
||||||
return_0;
|
|
||||||
} else if (activate == CHANGE_ALY) {
|
|
||||||
log_verbose("Activating logical volume \"%s\" locally",
|
|
||||||
lv->name);
|
|
||||||
if (!activate_lv_local(cmd, lv))
|
|
||||||
return_0;
|
|
||||||
} else {
|
|
||||||
log_verbose("Activating logical volume \"%s\"",
|
|
||||||
lv->name);
|
|
||||||
if (!activate_lv(cmd, lv))
|
|
||||||
return_0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (background_polling())
|
|
||||||
lv_spawn_background_polling(cmd, lv);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1296,6 +1296,51 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Shared code for changing activation state for vgchange/lvchange */
|
||||||
|
int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
|
||||||
|
activation_change_t activate)
|
||||||
|
{
|
||||||
|
if (activate == CHANGE_AN) {
|
||||||
|
log_verbose("Deactivating logical volume \"%s\"", lv->name);
|
||||||
|
if (!deactivate_lv(cmd, lv))
|
||||||
|
return_0;
|
||||||
|
return 1;
|
||||||
|
} else if ((activate == CHANGE_AE) ||
|
||||||
|
lv_is_origin(lv) ||
|
||||||
|
lv_is_thin_type(lv)) {
|
||||||
|
if (activate == CHANGE_ALN) {
|
||||||
|
/* origin or thin, all others have _AE */
|
||||||
|
/* other types of activation are implicitly exclusive */
|
||||||
|
/* Note: the order of tests is mandatory */
|
||||||
|
log_error("Cannot deactivate \"%s\" locally.", lv->name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
log_verbose("Activating logical volume \"%s\" exclusively.", lv->name);
|
||||||
|
if (!activate_lv_excl(cmd, lv))
|
||||||
|
return_0;
|
||||||
|
} else if (activate == CHANGE_ALN) {
|
||||||
|
log_verbose("Deactivating logical volume \"%s\" locally.", lv->name);
|
||||||
|
if (!deactivate_lv_local(cmd, lv))
|
||||||
|
return_0;
|
||||||
|
return 1;
|
||||||
|
} else if ((activate == CHANGE_ALY) || (activate == CHANGE_AAY)) {
|
||||||
|
log_verbose("Activating logical volume \"%s\" locally.", lv->name);
|
||||||
|
if (!activate_lv_local(cmd, lv))
|
||||||
|
return_0;
|
||||||
|
} else { /* CHANGE_AY */
|
||||||
|
log_verbose("Activating logical volume \"%s\".", lv->name);
|
||||||
|
if (!activate_lv(cmd, lv))
|
||||||
|
return_0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* CHANGE_AN/ALN is not getting here */
|
||||||
|
if (background_polling() &&
|
||||||
|
(lv->status & (PVMOVE|CONVERTING|MERGING)))
|
||||||
|
lv_spawn_background_polling(cmd, lv);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv)
|
int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv)
|
||||||
{
|
{
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
@ -101,6 +101,8 @@ void vgcreate_params_set_defaults(struct vgcreate_params *vp_def,
|
|||||||
int vgcreate_params_set_from_args(struct cmd_context *cmd,
|
int vgcreate_params_set_from_args(struct cmd_context *cmd,
|
||||||
struct vgcreate_params *vp_new,
|
struct vgcreate_params *vp_new,
|
||||||
struct vgcreate_params *vp_def);
|
struct vgcreate_params *vp_def);
|
||||||
|
int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
|
||||||
|
activation_change_t activate);
|
||||||
int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv);
|
int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv);
|
||||||
int vg_refresh_visible(struct cmd_context *cmd, struct volume_group *vg);
|
int vg_refresh_visible(struct cmd_context *cmd, struct volume_group *vg);
|
||||||
void lv_spawn_background_polling(struct cmd_context *cmd,
|
void lv_spawn_background_polling(struct cmd_context *cmd,
|
||||||
|
@ -131,44 +131,17 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activate == CHANGE_AAY && !lv_passes_auto_activation_filter(cmd, lv))
|
if ((activate == CHANGE_AAY) &&
|
||||||
|
!lv_passes_auto_activation_filter(cmd, lv))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
expected_count++;
|
expected_count++;
|
||||||
|
|
||||||
if (activate == CHANGE_AN) {
|
if (!lv_change_activate(cmd, lv, activate)) {
|
||||||
if (!deactivate_lv(cmd, lv)) {
|
|
||||||
stack;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else if (activate == CHANGE_ALN) {
|
|
||||||
if (!deactivate_lv_local(cmd, lv)) {
|
|
||||||
stack;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else if ((activate == CHANGE_AE) ||
|
|
||||||
lv_is_origin(lv) ||
|
|
||||||
lv_is_thin_type(lv)) {
|
|
||||||
/* FIXME: duplicated test code with lvchange */
|
|
||||||
if (!activate_lv_excl(cmd, lv)) {
|
|
||||||
stack;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else if (activate == CHANGE_AAY || activate == CHANGE_ALY) {
|
|
||||||
if (!activate_lv_local(cmd, lv)) {
|
|
||||||
stack;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else if (!activate_lv(cmd, lv)) {
|
|
||||||
stack;
|
stack;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (background_polling() &&
|
|
||||||
activate != CHANGE_AN && activate != CHANGE_ALN &&
|
|
||||||
(lv->status & (PVMOVE|CONVERTING|MERGING)))
|
|
||||||
lv_spawn_background_polling(cmd, lv);
|
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user