87 lines
2.9 KiB
Diff
87 lines
2.9 KiB
Diff
From a6dec74334d5b4c3d0774d8b120930dd6e008844 Mon Sep 17 00:00:00 2001
|
|
From: David Teigland <teigland@redhat.com>
|
|
Date: Thu, 13 Jun 2024 13:34:23 -0500
|
|
Subject: [PATCH 13/13] lvmlockd: allow forced vgchange locktype from none
|
|
|
|
vgchange --locktype sanlock|dlm --lockopt force <vgname>
|
|
can be used to change the lock type without lvmlockd or
|
|
the lock manager involved.
|
|
|
|
(cherry picked from commit 4dc009c87227a137c8be50686b1104cebb9a88e2)
|
|
---
|
|
man/lvmlockd.8_main | 5 +++++
|
|
tools/vgchange.c | 17 +++++++++--------
|
|
2 files changed, 14 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/man/lvmlockd.8_main b/man/lvmlockd.8_main
|
|
index ea967d73d..38f9d958d 100644
|
|
--- a/man/lvmlockd.8_main
|
|
+++ b/man/lvmlockd.8_main
|
|
@@ -729,6 +729,11 @@ vgchange --locktype sanlock|dlm <vgname>
|
|
Start the VG on hosts to use it:
|
|
.br
|
|
vgchange --lockstart <vgname>
|
|
+.P
|
|
+If lvmlockd or the cluster manager are not available, the lock type can
|
|
+be forcibly changed with:
|
|
+.br
|
|
+vgchange --locktype sanlock|dlm \-\-lockopt force <vgname>
|
|
.
|
|
.SS Changing a shared VG to a local VG
|
|
.
|
|
diff --git a/tools/vgchange.c b/tools/vgchange.c
|
|
index 2004d6e92..94c1feb8f 100644
|
|
--- a/tools/vgchange.c
|
|
+++ b/tools/vgchange.c
|
|
@@ -1176,7 +1176,7 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
|
|
return ret;
|
|
}
|
|
|
|
-static int _vgchange_locktype(struct cmd_context *cmd, struct volume_group *vg)
|
|
+static int _vgchange_locktype(struct cmd_context *cmd, struct volume_group *vg, int *no_change)
|
|
{
|
|
const char *lock_type = arg_str_value(cmd, locktype_ARG, NULL);
|
|
const char *lockopt = arg_str_value(cmd, lockopt_ARG, NULL);
|
|
@@ -1206,6 +1206,7 @@ static int _vgchange_locktype(struct cmd_context *cmd, struct volume_group *vg)
|
|
if (lock_type && !strcmp(vg->lock_type, lock_type)) {
|
|
log_warn("WARNING: New lock type %s matches the current lock type %s.",
|
|
lock_type, vg->lock_type);
|
|
+ *no_change = 1;
|
|
return 1;
|
|
}
|
|
|
|
@@ -1344,9 +1345,14 @@ static int _vgchange_locktype_single(struct cmd_context *cmd, const char *vg_nam
|
|
struct volume_group *vg,
|
|
struct processing_handle *handle)
|
|
{
|
|
- if (!_vgchange_locktype(cmd, vg))
|
|
+ int no_change = 0;
|
|
+
|
|
+ if (!_vgchange_locktype(cmd, vg, &no_change))
|
|
return_ECMD_FAILED;
|
|
|
|
+ if (no_change)
|
|
+ return ECMD_PROCESSED;
|
|
+
|
|
if (!vg_write(vg) || !vg_commit(vg))
|
|
return_ECMD_FAILED;
|
|
|
|
@@ -1402,13 +1408,8 @@ int vgchange_locktype_cmd(struct cmd_context *cmd, int argc, char **argv)
|
|
* just return success when they see the disable flag set.
|
|
*/
|
|
if (lockopt && !strcmp(lockopt, "force")) {
|
|
- if (lock_type && strcmp(lock_type, "none")) {
|
|
- log_error("Lock type can only be forced to \"none\" for recovery.");
|
|
- return 0;
|
|
- }
|
|
-
|
|
if (!arg_is_set(cmd, yes_ARG) &&
|
|
- yes_no_prompt("Forcibly change VG lock type to none? [y/n]: ") == 'n') {
|
|
+ yes_no_prompt("Forcibly change VG lock type to %s? [y/n]: ", lock_type) == 'n') {
|
|
log_error("VG lock type not changed.");
|
|
return 0;
|
|
}
|
|
--
|
|
2.45.2
|
|
|