]> sourceware.org Git - lvm2.git/commitdiff
lvmlockd: allow forced vgchange locktype from none
authorDavid Teigland <teigland@redhat.com>
Thu, 13 Jun 2024 18:34:23 +0000 (13:34 -0500)
committerDavid Teigland <teigland@redhat.com>
Thu, 27 Jun 2024 18:29:03 +0000 (13:29 -0500)
vgchange --locktype sanlock|dlm --lockopt force <vgname>
can be used to change the lock type without lvmlockd or
the lock manager involved.

man/lvmlockd.8_main
tools/vgchange.c

index ea967d73d94c2a17f8ea6aa95c61cf38edae036a..38f9d958ddf129a2215d2540374053e19f7322bc 100644 (file)
@@ -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
 .
index 80db5ca2dd67cef46e86c9aa5dbb2c3de5695486..8a17cfaecfce5025ba515d67d48515a9216cffab 100644 (file)
@@ -1141,7 +1141,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);
@@ -1171,6 +1171,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;
        }
 
@@ -1309,9 +1310,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;
 
@@ -1367,13 +1373,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;
                }
This page took 0.047934 seconds and 5 git commands to generate.