summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2016-02-22 09:32:39 -0600
committerDavid Teigland <teigland@redhat.com>2016-02-22 09:36:35 -0600
commitc716813651c2691c44bc709040cd16fbf363a74e (patch)
tree45dca4327d575ef59d498f1caead22889c5f21f6
parent161ae36363f5fa1b1469fd3a42c096c878002b31 (diff)
downloadlvm2-c716813651c2691c44bc709040cd16fbf363a74e.tar.gz
lvmlockd: invalidate name in lockspace struct after remove
After the lockspace has been successfully removed, invalidate the name field in the lockspace struct. The struct remains on the list of lockspaces until the struct can be freed later. Until the struct is freed, its name will prevent another new lockspace from being created with the same name.
-rw-r--r--daemons/lvmlockd/lvmlockd-core.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 76a7650b1..c273d257b 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -2269,6 +2269,7 @@ static void *lockspace_thread_main(void *arg_in)
struct action *act_op_free = NULL;
struct list_head tmp_act;
struct list_head act_close;
+ char tmp_name[MAX_NAME+1];
int free_vg = 0;
int drop_vg = 0;
int error = 0;
@@ -2634,6 +2635,10 @@ out_act:
ls->drop_vg = drop_vg;
if (ls->lm_type == LD_LM_DLM && !strcmp(ls->name, gl_lsname_dlm))
global_dlm_lockspace_exists = 0;
+ /* Avoid a name collision of the same lockspace is added again before this thread is cleaned up. */
+ memset(tmp_name, 0, sizeof(tmp_name));
+ snprintf(tmp_name, MAX_NAME, "REM:%s", ls->name);
+ memcpy(ls->name, tmp_name, MAX_NAME);
pthread_mutex_unlock(&lockspaces_mutex);
/* worker_thread will join this thread, and free the ls */
@@ -3113,6 +3118,8 @@ static int for_each_lockspace(int do_stop, int do_free, int do_force)
/* FIXME: will free_vg ever not be set? */
+ log_debug("free ls %s", ls->name);
+
if (ls->free_vg) {
/* In future we may need to free ls->actions here */
free_ls_resources(ls);