1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

[lv|vg]change: Allow limited metadata changes when PVs are missing

A while back, the behavior of LVM changed from allowing metadata changes
when PVs were missing to not allowing changes.  Until recently, this
change was tolerated by HA-LVM by forcing a 'vgreduce --removemissing'
before trying (again) to add tags to an LV and then activate it.  LVM
mirroring requires that failed devices are removed anyway, so this was
largely harmless.  However, RAID LVs do not require devices to be removed
from the array in order to be activated.  In fact, in an HA-LVM
environment this would be very undesirable.  Device failures in such an
environment can often be transient and it would be much better to restore
the device to the array than synchronize an entirely new device.

There are two methods that can be used to setup an HA-LVM environment:
"clvm" or "tagging".  For RAID LVs, "clvm" is out of the question because
RAID LVs are not supported in clustered VGs - not even in an exclusively
activated manner.  That leaves "tagging".  HA-LVM uses tagging - coupled
with 'volume_list' - to ensure that only one machine can have an LV active
at a time.  If updates are not allowed when a PV is missing, it is
impossible to add or remove tags to allow for activation.  This removes
one of the most basic functionalities of HA-LVM - site redundancy.  If
mirroring or RAID is used to replicate the storage in two data centers
and one of them goes down, a server and a storage device are lost.  When
the service fails-over to the alternate site, the VG will be "partial".
Unable to add a tag to the VG/LV, the RAID device will be unable to
activate.

The solution is to allow vgchange and lvchange to alter the LVM metadata
for a limited set of options - --[add|del]tag included.  The set of
allowable options are ones that do not cause changes to the DM kernel
target (like --resync would) or could alter the structure of the LV
(like allocation or conversion).
This commit is contained in:
Jonathan Brassow 2012-10-10 11:33:10 -05:00
parent 3af43af493
commit 3501f17fd0
3 changed files with 28 additions and 10 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.98 - Version 2.02.98 -
================================= =================================
Allow limited metadata changes when PVs are missing via [vg|lv]change.
Do not start dmeventd for lvchange --resync when monitoring is off. Do not start dmeventd for lvchange --resync when monitoring is off.
Remove ExecStartPost with pvscan --cache from lvm2-lvmetad.service. Remove ExecStartPost with pvscan --cache from lvm2-lvmetad.service.
Report invalid percentage for property snap_percent of non-snaphot LVs. Report invalid percentage for property snap_percent of non-snaphot LVs.

View File

@ -927,12 +927,24 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
int lvchange(struct cmd_context *cmd, int argc, char **argv) int lvchange(struct cmd_context *cmd, int argc, char **argv)
{ {
int update = /* options other than -a, --refresh, --monitor or --poll */ /*
arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) || * Options that update metadata should be listed in one of
arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) || * the two lists below (i.e. options other than -a, --refresh,
arg_count(cmd, addtag_ARG) || arg_count(cmd, deltag_ARG) || * --monitor or --poll).
arg_count(cmd, resync_ARG) || arg_count(cmd, alloc_ARG) || */
arg_count(cmd, discards_ARG) || arg_count(cmd, zero_ARG); int update_partial_safe = /* options safe to update if partial */
arg_count(cmd, contiguous_ARG) ||
arg_count(cmd, permission_ARG) ||
arg_count(cmd, readahead_ARG) ||
arg_count(cmd, persistent_ARG) ||
arg_count(cmd, addtag_ARG) ||
arg_count(cmd, deltag_ARG);
int update_partial_unsafe =
arg_count(cmd, resync_ARG) ||
arg_count(cmd, alloc_ARG) ||
arg_count(cmd, discards_ARG) ||
arg_count(cmd, zero_ARG);
int update = update_partial_safe || update_partial_unsafe;
if (!update && if (!update &&
!arg_count(cmd, activate_ARG) && !arg_count(cmd, refresh_ARG) && !arg_count(cmd, activate_ARG) && !arg_count(cmd, refresh_ARG) &&
@ -954,7 +966,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }
if (!update) if (!update || !update_partial_unsafe)
cmd->handles_missing_pvs = 1; cmd->handles_missing_pvs = 1;
if (!argc) { if (!argc) {

View File

@ -539,17 +539,19 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
int vgchange(struct cmd_context *cmd, int argc, char **argv) int vgchange(struct cmd_context *cmd, int argc, char **argv)
{ {
/* Update commands that can be combined */ /* Update commands that can be combined */
int update = int update_partial_safe =
arg_count(cmd, deltag_ARG) ||
arg_count(cmd, addtag_ARG);
int update_partial_unsafe =
arg_count(cmd, logicalvolume_ARG) || arg_count(cmd, logicalvolume_ARG) ||
arg_count(cmd, maxphysicalvolumes_ARG) || arg_count(cmd, maxphysicalvolumes_ARG) ||
arg_count(cmd, resizeable_ARG) || arg_count(cmd, resizeable_ARG) ||
arg_count(cmd, deltag_ARG) ||
arg_count(cmd, addtag_ARG) ||
arg_count(cmd, uuid_ARG) || arg_count(cmd, uuid_ARG) ||
arg_count(cmd, physicalextentsize_ARG) || arg_count(cmd, physicalextentsize_ARG) ||
arg_count(cmd, clustered_ARG) || arg_count(cmd, clustered_ARG) ||
arg_count(cmd, alloc_ARG) || arg_count(cmd, alloc_ARG) ||
arg_count(cmd, vgmetadatacopies_ARG); arg_count(cmd, vgmetadatacopies_ARG);
int update = update_partial_safe || update_partial_unsafe;
if (!update && if (!update &&
!arg_count(cmd, activate_ARG) && !arg_count(cmd, activate_ARG) &&
@ -613,6 +615,9 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }
if (!update || !update_partial_unsafe)
cmd->handles_missing_pvs = 1;
return process_each_vg(cmd, argc, argv, update ? READ_FOR_UPDATE : 0, return process_each_vg(cmd, argc, argv, update ? READ_FOR_UPDATE : 0,
NULL, &vgchange_single); NULL, &vgchange_single);
} }