diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c index f741940f9..2bc34c88e 100644 --- a/lib/locking/lvmlockd.c +++ b/lib/locking/lvmlockd.c @@ -2561,7 +2561,7 @@ int lockd_rename_vg_final(struct cmd_context *cmd, struct volume_group *vg, int return 1; } -const char *lockd_running_lock_type(struct cmd_context *cmd) +const char *lockd_running_lock_type(struct cmd_context *cmd, int *found_multiple) { daemon_reply reply; const char *lock_type = NULL; @@ -2583,10 +2583,9 @@ const char *lockd_running_lock_type(struct cmd_context *cmd) switch (result) { case -EXFULL: - log_error("lvmlockd found multiple lock managers, use --lock-type to select one."); + *found_multiple = 1; break; case -ENOLCK: - log_error("lvmlockd found no lock manager running."); break; case LOCK_TYPE_SANLOCK: log_debug("lvmlockd found sanlock"); diff --git a/lib/locking/lvmlockd.h b/lib/locking/lvmlockd.h index 7e6505de9..8b282d8c6 100644 --- a/lib/locking/lvmlockd.h +++ b/lib/locking/lvmlockd.h @@ -89,7 +89,7 @@ int lockd_init_lv_args(struct cmd_context *cmd, struct volume_group *vg, int lockd_free_lv(struct cmd_context *cmd, struct volume_group *vg, const char *lv_name, struct id *lv_id, const char *lock_args); -const char *lockd_running_lock_type(struct cmd_context *cmd); +const char *lockd_running_lock_type(struct cmd_context *cmd, int *found_multiple); int handle_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg); @@ -223,7 +223,7 @@ static inline int lockd_free_lv(struct cmd_context *cmd, struct volume_group *vg return 1; } -static inline const char *lockd_running_lock_type(struct cmd_context *cmd) +static inline const char *lockd_running_lock_type(struct cmd_context *cmd, int *found_multiple) { log_error("Using a shared lock type requires lvmlockd."); return NULL; diff --git a/tools/toollib.c b/tools/toollib.c index cf5e236bd..dfb2b87e2 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -931,9 +931,14 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd, } } else if (arg_is_set(cmd, shared_ARG)) { + int found_multiple = 0; + if (use_lvmlockd) { - if (!(lock_type = lockd_running_lock_type(cmd))) { - log_error("Failed to detect a running lock manager to select lock type."); + if (!(lock_type = lockd_running_lock_type(cmd, &found_multiple))) { + if (found_multiple) + log_error("Found multiple lock managers, select one with --lock-type."); + else + log_error("Failed to detect a running lock manager to select lock type."); return 0; }