From 85b711caae6f87b535cdbcfdaecf2cf58ebf6942 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 19 Apr 2024 10:48:19 -0500 Subject: [PATCH] lvmlockd: check for multiple lock managers running When no lock manager for the global lock had been set yet, and the first global lock request was received, and both dlm and sanlock were running, lvmlockd would assume it should use the dlm for the global lock, and would start the "lvm_global" dlm lockspace automatically. That's not always correct, so don't assume the dlm should be used, fail the lock request, and wait until a VG with a specific lock type is started to determine the lock manager to use. --- daemons/lvmlockd/lvmlockd-core.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c index 65055290b..73dfa17b3 100644 --- a/daemons/lvmlockd/lvmlockd-core.c +++ b/daemons/lvmlockd/lvmlockd-core.c @@ -4154,12 +4154,26 @@ static int add_lock_action(struct action *act) vg_ls_name(act->vg_name, ls_name); } else { if (!gl_use_dlm && !gl_use_sanlock && !gl_use_idm) { - if (lm_is_running_dlm()) - gl_use_dlm = 1; - else if (lm_is_running_sanlock()) - gl_use_sanlock = 1; - else if (lm_is_running_idm()) - gl_use_idm = 1; + int run_sanlock = lm_is_running_sanlock(); + int run_dlm = lm_is_running_dlm(); + int run_idm = lm_is_running_idm(); + + if (run_sanlock + run_dlm + run_idm >= 2) { + log_error("global lock op %s mode %s: multiple lock managers running sanlock=%d dlm=%d idm=%d", + op_str(act->op), mode_str(act->mode), run_sanlock, run_dlm, run_idm); + } else if (!run_sanlock && !run_dlm && !run_idm) { + log_debug("global lock op %s mode %s: no lock manager running", + op_str(act->op), mode_str(act->mode)); + } else { + if (run_dlm) + gl_use_dlm = 1; + else if (run_sanlock) + gl_use_sanlock = 1; + else if (run_idm) + gl_use_idm = 1; + log_debug("global lock op %s mode %s: gl_use_sanlock %d gl_use_dlm %d gl_use_idm %d", + op_str(act->op), mode_str(act->mode), gl_use_sanlock, gl_use_dlm, gl_use_idm); + } } gl_ls_name(ls_name); }