Skip to contentSkip to conversation

master - vgchange: separate change locktype and allow recovery

PATCH David Teigland 1 participant 1 message Jul 24, 2017

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f611b68f3c02b9af2521d7ea61061af3709fe87c
Commit:        f611b68f3c02b9af2521d7ea61061af3709fe87c
Parent:        876c4a1b3bdf2d2f9202438a406a803efa01bf9a
Author:        David Teigland <[email protected]>
AuthorDate:    Wed Jul 12 16:03:41 2017 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Mon Jul 24 14:12:08 2017 -0500

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.

---
 man/lvmlockd.8_main    |   24 ++-
 tools/command-lines.in |    7 +-
 tools/lvmcmdline.c     |    2 +
 tools/tools.h          |    2 +
 tools/vgchange.c       |  531 +++++++++++++++++++++++++++---------------------
 5 files changed, 329 insertions(+), 237 deletions(-)
man/lvmlockd.8_main +19 -5
index 552eb94..1dbdaf9 100644
@@ -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:
tools/command-lines.in +6 -1
index 7f9c31f..da097af 100644
@@ -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
tools/lvmcmdline.c +2 -0
index a952c8c..f23e994 100644
@@ -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 },
tools/tools.h +2 -0
index 9543147..8255cdc 100644
@@ -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);
tools/vgchange.c +300 -231

566 lines not on this page · raw message