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 Start the VG on hosts to use it: .br vgchange --lockstart +.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 . .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; }