mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
lvchange: deactivate is always possible in foreign vgs
The only realistic way for a host to have active LVs in a foreign VG is if the host's system_id (or system_id_source) is changed while LVs are active. In this case, the active LVs produce an warning, and access to the VG is implicitly allowed (without requiring --foreign.) This allows the active LVs to be deactivated. In this case, rescanning PVs for the VG offers no benefit. It is not possible that rescanning would reveal an LV that is active but wasn't previously in the VG metadata.
This commit is contained in:
parent
dd0ee35378
commit
dd6a202831
@ -98,6 +98,7 @@ struct cmd_context {
|
||||
unsigned independent_metadata_areas:1; /* Active formats have MDAs outside PVs */
|
||||
unsigned unknown_system_id:1;
|
||||
unsigned include_foreign_vgs:1;
|
||||
unsigned include_active_foreign_vgs:1;
|
||||
unsigned error_foreign_vgs:1;
|
||||
|
||||
struct dev_types *dev_types;
|
||||
|
@ -4418,7 +4418,9 @@ static int _access_vg_systemid(struct cmd_context *cmd, struct volume_group *vg)
|
||||
if (lvs_in_vg_activated(vg)) {
|
||||
log_warn("WARNING: Found LVs active in VG %s with foreign system ID \"%s\". Possible data corruption.",
|
||||
vg->name, vg->system_id);
|
||||
if (cmd->include_active_foreign_vgs)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -170,6 +170,18 @@ static int _lvchange_activate(struct cmd_context *cmd, struct logical_volume *lv
|
||||
|
||||
activate = (activation_change_t) arg_uint_value(cmd, activate_ARG, CHANGE_AY);
|
||||
|
||||
/*
|
||||
* We can get here in the odd case where an LV is already active in
|
||||
* a foreign VG, which allows the VG to be accessed by lvchange -a
|
||||
* so the LV can be deactivated.
|
||||
*/
|
||||
if (lv->vg->system_id && cmd->system_id &&
|
||||
strcmp(lv->vg->system_id, cmd->system_id) &&
|
||||
is_change_activating(activate)) {
|
||||
log_error("Cannot activate LVs in a foreign VG.");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (lv_activation_skip(lv, activate, arg_count(cmd, ignoreactivationskip_ARG)))
|
||||
return 1;
|
||||
|
||||
@ -1178,11 +1190,6 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (!update && !arg_count(cmd, refresh_ARG) && !arg_count(cmd, monitor_ARG) && !arg_count(cmd, poll_ARG) &&
|
||||
arg_count(cmd, activate_ARG) &&
|
||||
!is_change_activating((activation_change_t) arg_uint_value(cmd, activate_ARG, CHANGE_AY)))
|
||||
cmd->include_foreign_vgs = 1;
|
||||
|
||||
/*
|
||||
* If --sysinit -aay is used and at the same time lvmetad is used,
|
||||
* we want to rely on autoactivation to take place. Also, we
|
||||
@ -1212,6 +1219,9 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (arg_is_set(cmd, activate_ARG))
|
||||
cmd->include_active_foreign_vgs = 1;
|
||||
|
||||
return process_each_lv(cmd, argc, argv,
|
||||
update ? READ_FOR_UPDATE : 0, NULL,
|
||||
&_lvchange_single);
|
||||
|
@ -1077,6 +1077,7 @@ static int _get_settings(struct cmd_context *cmd)
|
||||
cmd->ignore_clustered_vgs = arg_is_set(cmd, ignoreskippedcluster_ARG);
|
||||
cmd->error_foreign_vgs = cmd->command->flags & ENABLE_FOREIGN_VGS ? 0 : 1;
|
||||
cmd->include_foreign_vgs = arg_is_set(cmd, foreign_ARG) ? 1 : 0;
|
||||
cmd->include_active_foreign_vgs = cmd->command->flags & ENABLE_FOREIGN_VGS ? 1 : 0;
|
||||
|
||||
if (!arg_count(cmd, sysinit_ARG))
|
||||
lvmetad_connect_or_warn();
|
||||
|
Loading…
Reference in New Issue
Block a user