From 3c1924c9c0d45cbce67aa3c1dad70737a6956cc3 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 27 Aug 2015 16:00:24 -0500 Subject: [PATCH] lvmlockd: fix starting dlm global lockspace lvmlockd would fail to recognize that the global lockspace failed to start if the dlm wasn't running, so future attempts to start the dlm global lockspace would do nothing, thinking it was already running. --- daemons/lvmlockd/lvmlockd-core.c | 13 ++++++++----- daemons/lvmlockd/lvmlockd-dlm.c | 4 ---- daemons/lvmlockd/lvmlockd-internal.h | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c index c2c3fefe4..14705b0df 100644 --- a/daemons/lvmlockd/lvmlockd-core.c +++ b/daemons/lvmlockd/lvmlockd-core.c @@ -2403,6 +2403,9 @@ out_act: ls->drop_vg = drop_vg; pthread_mutex_unlock(&lockspaces_mutex); + if (gl_use_dlm && !strcmp(ls->name, gl_lsname_dlm)) + dlm_gl_lockspace_running = 0; + /* worker_thread will join this thread, and free the ls */ pthread_mutex_lock(&worker_mutex); worker_wake = 1; @@ -2584,21 +2587,21 @@ static int add_dlm_global_lockspace(struct action *act) { int rv; - if (gl_running_dlm) + if (dlm_gl_lockspace_running) return -EEXIST; - gl_running_dlm = 1; + dlm_gl_lockspace_running = 1; /* * There's a short period after which a previous gl lockspace thread - * has set gl_running_dlm = 0, but before its ls struct has been - * deleted, during which this add_lockspace_thread() can fail with + * has set dlm_gl_lockspace_running = 0, but before its ls struct has + * been deleted, during which this add_lockspace_thread() can fail with * -EAGAIN. */ rv = add_lockspace_thread(gl_lsname_dlm, NULL, NULL, LD_LM_DLM, NULL, act); if (rv < 0) { log_error("add_dlm_global_lockspace add_lockspace_thread %d", rv); - gl_running_dlm = 0; + dlm_gl_lockspace_running = 0; } return rv; diff --git a/daemons/lvmlockd/lvmlockd-dlm.c b/daemons/lvmlockd/lvmlockd-dlm.c index 676c94477..664082123 100644 --- a/daemons/lvmlockd/lvmlockd-dlm.c +++ b/daemons/lvmlockd/lvmlockd-dlm.c @@ -260,10 +260,6 @@ int lm_rem_lockspace_dlm(struct lockspace *ls, int free_vg) out: free(lmd); ls->lm_data = NULL; - - if (!strcmp(ls->name, gl_lsname_dlm)) - gl_running_dlm = 0; - return 0; } diff --git a/daemons/lvmlockd/lvmlockd-internal.h b/daemons/lvmlockd/lvmlockd-internal.h index efb04f96e..9d360ed09 100644 --- a/daemons/lvmlockd/lvmlockd-internal.h +++ b/daemons/lvmlockd/lvmlockd-internal.h @@ -313,7 +313,7 @@ static inline int list_empty(const struct list_head *head) * or when disable_gl matches. */ -EXTERN int gl_running_dlm; +EXTERN int dlm_gl_lockspace_running; EXTERN int gl_type_static; EXTERN int gl_use_dlm; EXTERN int gl_use_sanlock;