1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 10:25:13 +03:00

lvmlockd: optimize dlm global lockspace creation

Set a flag indicating that the dlm global lockspace
exists to avoid going through the entire process of
trying to add it before finding it exists.
This commit is contained in:
David Teigland 2015-09-10 10:31:25 -05:00
parent 0a26c20b88
commit 18dfbbb150
2 changed files with 17 additions and 4 deletions

View File

@ -2546,6 +2546,8 @@ out_act:
ls->thread_done = 1;
ls->free_vg = free_vg;
ls->drop_vg = drop_vg;
if (ls->lm_type == LD_LM_DLM && !strcmp(ls->name, gl_lsname_dlm))
global_dlm_lockspace_exists = 0;
pthread_mutex_unlock(&lockspaces_mutex);
/* worker_thread will join this thread, and free the ls */
@ -2702,6 +2704,8 @@ static int add_lockspace_thread(const char *ls_name,
if (act)
list_add(&act->list, &ls->actions);
if (ls->lm_type == LD_LM_DLM && !strcmp(ls->name, gl_lsname_dlm))
global_dlm_lockspace_exists = 1;
list_add_tail(&ls->list, &lockspaces);
pthread_mutex_unlock(&lockspaces_mutex);
@ -2729,15 +2733,25 @@ static int add_dlm_global_lockspace(struct action *act)
{
int rv;
if (global_dlm_lockspace_exists)
return 0;
/*
* FIXME: optimize this by setting a flag to indicate that the
* dlm global lockspace is running so we can quit here.
* FIXME: if the dlm global lockspace is started without a global
* lock request, insert an internal gl sh lock request?
*/
rv = add_lockspace_thread(gl_lsname_dlm, NULL, NULL, LD_LM_DLM, NULL, act);
if (rv < 0)
log_debug("add_dlm_global_lockspace add_lockspace_thread %d", rv);
/*
* EAGAIN may be returned for a short period because
* global_dlm_lockspace_exists is set to 0 before the
* ls is removed from the lockspaces list by the
* worker_thread.
*/
return rv;
}

View File

@ -316,10 +316,9 @@ static inline int list_empty(const struct list_head *head)
EXTERN int gl_type_static;
EXTERN int gl_use_dlm;
EXTERN int gl_use_sanlock;
EXTERN pthread_mutex_t gl_type_mutex;
EXTERN char gl_lsname_dlm[MAX_NAME+1];
EXTERN char gl_lsname_sanlock[MAX_NAME+1];
EXTERN int global_dlm_lockspace_exists;
EXTERN int daemon_test; /* run as much as possible without a live lock manager */
EXTERN int daemon_debug;