mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
vgchange: separate change locktype and allow recovery
Add an independent command definition for "vgchange --locktype", and split the implementation out of the set of common metadata changes. It is unlike normal metadata changes, and can only be run by itself. (Changing the lock type is similar in principle to changing the VG name or the VG system ID; it effects the ability of any host to see or access the VG.) At some point this command lost the ability to forcibly change the lock type of a shared VG to "none" (making it a local VG). This can be necessary to repair shared VGs (e.g. recovery steps that occur in vg_read are disabled for shared VGs because they are not locked properly, or recovering sanlock locks when the PV holding them is lost.) "vgchange --locktype none --lockopt force VG" is used as the method of forcing the shared VG to become local so that it can be repaired.
This commit is contained in:
parent
876c4a1b3b
commit
f611b68f3c
@ -610,12 +610,26 @@ The command deactivates the LV. After deactivating the LV, the command
|
||||
uses lvmlockd to release the current lock on the LV.
|
||||
|
||||
|
||||
.SS manually repairing a shared VG
|
||||
|
||||
Some failure conditions may not be repairable while the VG has a shared
|
||||
lock type. In these cases, it may be possible to repair the VG by
|
||||
forcibly changing the lock type to "none". This is done by adding
|
||||
"--lock-opt force" to the normal command for changing the lock type:
|
||||
vgchange --lock-type none VG. The VG lockspace should first be stopped on
|
||||
all hosts, and be certain that no hosts are using the VG before this is
|
||||
done.
|
||||
|
||||
|
||||
.SS recover from lost PV holding sanlock locks
|
||||
|
||||
The general approach is to change the VG lock type to "none", and then
|
||||
change the lock type back to "sanlock". This recreates the internal
|
||||
lvmlock LV and the necessary locks on it. Additional steps may be
|
||||
required to deal with the missing PV.
|
||||
In a sanlock VG, the sanlock locks are held on the hidden "lvmlock" LV.
|
||||
If the PV holding this LV is lost, a new lvmlock LV needs to be created.
|
||||
To do this, ensure no hosts are using the VG, then forcibly change the
|
||||
lock type to "none" (see above). Then change the lock type back to
|
||||
"sanlock" with the normal command for changing the lock type: vgchange
|
||||
--lock-type sanlock VG. This recreates the internal lvmlock LV with the
|
||||
necessary locks.
|
||||
|
||||
|
||||
.SS locking system failures
|
||||
@ -733,7 +747,7 @@ cat /sys/kernel/config/dlm/cluster/cluster_name
|
||||
.IP \[bu] 2
|
||||
Change the VG lock type to none:
|
||||
.br
|
||||
vgchange --lock-type none --force <vgname>
|
||||
vgchange --lock-type none --lock-opt force <vgname>
|
||||
|
||||
.IP \[bu] 2
|
||||
Change the VG lock type back to dlm which sets the new cluster name:
|
||||
|
@ -1474,7 +1474,7 @@ OO_VGCHANGE: --autobackup Bool, --ignoremonitoring, --ignoreskippedcluster,
|
||||
OO_VGCHANGE_META: --addtag Tag, --deltag Tag,
|
||||
--logicalvolume Uint32, --maxphysicalvolumes Uint32, --alloc Alloc, --uuid,
|
||||
--clustered Bool, --pvmetadatacopies MetadataCopiesPV, --vgmetadatacopies MetadataCopiesVG,
|
||||
--physicalextentsize SizeMB, --resizeable Bool, --systemid String, --locktype LockType,
|
||||
--physicalextentsize SizeMB, --resizeable Bool, --systemid String,
|
||||
--profile String, --detachprofile, --metadataprofile String
|
||||
|
||||
vgchange OO_VGCHANGE_META
|
||||
@ -1522,6 +1522,11 @@ OP: VG|Tag|Select ...
|
||||
ID: vgchange_lockstop
|
||||
DESC: Stop the lockspace of a shared VG in lvmlockd.
|
||||
|
||||
vgchange --locktype LockType VG
|
||||
OO: --lockopt String
|
||||
ID: vgchange_locktype
|
||||
DESC: Change the lock type for a shared VG.
|
||||
|
||||
---
|
||||
|
||||
vgck
|
||||
|
@ -103,6 +103,8 @@ static const struct command_function command_functions[CMD_COUNT] = {
|
||||
{ lvchange_poll_CMD, lvchange_monitor_poll_cmd },
|
||||
{ lvchange_persistent_CMD, lvchange_persistent_cmd },
|
||||
|
||||
{ vgchange_locktype_CMD, vgchange_locktype_cmd },
|
||||
|
||||
/* lvconvert utilities related to repair. */
|
||||
{ lvconvert_repair_pvs_or_thinpool_CMD, lvconvert_repair_pvs_or_thinpool_cmd },
|
||||
{ lvconvert_replace_pv_CMD, lvconvert_replace_pv_cmd },
|
||||
|
@ -223,6 +223,8 @@ int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
|
||||
|
||||
int vgchange_background_polling(struct cmd_context *cmd, struct volume_group *vg);
|
||||
|
||||
int vgchange_locktype_cmd(struct cmd_context *cmd, int argc, char **argv);
|
||||
|
||||
struct lv_prop *get_lv_prop(int lvp_enum);
|
||||
struct lv_type *get_lv_type(int lvt_enum);
|
||||
struct command *get_command(int cmd_enum);
|
||||
|
1113
tools/vgchange.c
1113
tools/vgchange.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user