mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
lv: lv_active_change add needs_exclusive flag
Let's use this function for more activations in the code. 'needs_exlusive' will enforce exlusive type for any given LV. We may want to activate LV in exlusive mode, even when we know the LV (as is) supports non-exlusive activation as well. lvcreate -ay -> exclusive & local lvcreate -aay -> exclusive & local lvcreate -aly -> exclusive & local lvcreate -aey -> exclusive (might be on any node).
This commit is contained in:
parent
a82dcadf66
commit
a3a2c792a8
@ -866,7 +866,7 @@ static int _lv_is_exclusive(struct logical_volume *lv)
|
||||
}
|
||||
|
||||
int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
enum activation_change activate)
|
||||
enum activation_change activate, int needs_exclusive)
|
||||
{
|
||||
switch (activate) {
|
||||
case CHANGE_AN:
|
||||
@ -876,7 +876,7 @@ deactivate:
|
||||
return_0;
|
||||
break;
|
||||
case CHANGE_ALN:
|
||||
if (vg_is_clustered(lv->vg) && _lv_is_exclusive(lv)) {
|
||||
if (vg_is_clustered(lv->vg) && (needs_exclusive || _lv_is_exclusive(lv))) {
|
||||
if (!lv_is_active_locally(lv)) {
|
||||
log_error("Cannot deactivate remotely exclusive device locally.");
|
||||
return 0;
|
||||
@ -891,7 +891,7 @@ deactivate:
|
||||
break;
|
||||
case CHANGE_ALY:
|
||||
case CHANGE_AAY:
|
||||
if (_lv_is_exclusive(lv)) {
|
||||
if (needs_exclusive || _lv_is_exclusive(lv)) {
|
||||
log_verbose("Activating logical volume \"%s\" exclusively locally.",
|
||||
lv->name);
|
||||
if (!activate_lv_excl_local(cmd, lv))
|
||||
@ -911,7 +911,7 @@ exclusive:
|
||||
return_0;
|
||||
break;
|
||||
default: /* CHANGE_AY */
|
||||
if (_lv_is_exclusive(lv))
|
||||
if (needs_exclusive || _lv_is_exclusive(lv))
|
||||
goto exclusive;
|
||||
log_verbose("Activating logical volume \"%s\".", lv->name);
|
||||
if (!activate_lv(cmd, lv))
|
||||
|
@ -94,7 +94,7 @@ int lv_set_creation(struct logical_volume *lv,
|
||||
const char *hostname, uint64_t timestamp);
|
||||
const char *lv_layer(const struct logical_volume *lv);
|
||||
int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
enum activation_change activate);
|
||||
enum activation_change activate, int needs_exlusive);
|
||||
char *lv_active_dup(struct dm_pool *mem, const struct logical_volume *lv);
|
||||
const struct logical_volume *lv_lock_holder(const struct logical_volume *lv);
|
||||
const struct logical_volume *lv_ondisk(const struct logical_volume *lv);
|
||||
|
@ -7051,7 +7051,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
|
||||
|
||||
backup(vg);
|
||||
|
||||
if (!lv_active_change(cmd, lv, lp->activate)) {
|
||||
if (!lv_active_change(cmd, lv, lp->activate, 0)) {
|
||||
log_error("Failed to activate thin %s.", lv->name);
|
||||
goto deactivate_and_revert_new_lv;
|
||||
}
|
||||
@ -7070,7 +7070,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
|
||||
"exception store.");
|
||||
goto revert_new_lv;
|
||||
}
|
||||
} else if (!lv_active_change(cmd, lv, lp->activate)) {
|
||||
} else if (!lv_active_change(cmd, lv, lp->activate, 0)) {
|
||||
log_error("Failed to activate new LV.");
|
||||
goto deactivate_and_revert_new_lv;
|
||||
}
|
||||
|
@ -593,7 +593,7 @@ static int lvchange_persistent(struct cmd_context *cmd,
|
||||
|
||||
if (activate != CHANGE_AN) {
|
||||
log_verbose("Re-activating logical volume %s", display_lvname(lv));
|
||||
if (!lv_active_change(cmd, lv, activate)) {
|
||||
if (!lv_active_change(cmd, lv, activate, 0)) {
|
||||
log_error("%s: reactivation failed", display_lvname(lv));
|
||||
backup(lv->vg);
|
||||
return 0;
|
||||
|
@ -731,7 +731,7 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
}
|
||||
}
|
||||
|
||||
if (!lv_active_change(cmd, lv, activate))
|
||||
if (!lv_active_change(cmd, lv, activate, 0))
|
||||
return_0;
|
||||
|
||||
if (background_polling() &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user