1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

lvmlockd: automatically remove the dlm global lockspace

The dlm global lockspace is automatically added when the
first dlm VG lockspace is added.  Reverse this by removing
the dlm global lockspace after the last dlm VG lockspace
is removed.  (Remove old non-working code that did this
based on an old command that could explicitly add/remove
the dlm global lockspace.)
This commit is contained in:
David Teigland 2015-07-31 16:45:43 -05:00
parent 71dbe47619
commit d11f8d4228
3 changed files with 14 additions and 41 deletions

View File

@ -2506,18 +2506,8 @@ static int add_dlm_global_lockspace(struct action *act)
if (gl_running_dlm)
return -EEXIST;
gl_running_dlm = 1;
/* Keep track of whether we automatically added
the global ls, so we know to automatically
remove it. */
if (act)
gl_auto_dlm = 0;
else
gl_auto_dlm = 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
@ -2526,11 +2516,9 @@ static int add_dlm_global_lockspace(struct action *act)
*/
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;
gl_auto_dlm = 0;
}
return rv;
@ -2583,28 +2571,12 @@ out:
}
/*
* When the first dlm lockspace is added for a vg,
* automatically add a separate dlm lockspace for the
* global lock if it hasn't been done explicitly.
* This is to make the dlm global lockspace work similarly to
* the sanlock global lockspace, which is "automatic" by
* nature of being one of the vg lockspaces.
* When the first dlm lockspace is added for a vg, automatically add a separate
* dlm lockspace for the global lock.
*
* For sanlock, a separate lockspace is not used for
* the global lock, but the gl lock lives in a vg
* lockspace, (although it's recommended to create a
* For sanlock, a separate lockspace is not used for the global lock, but the
* gl lock lives in a vg lockspace, (although it's recommended to create a
* special vg dedicated to holding the gl).
*
* N.B. for dlm, if this is an add+WAIT action for a vg
* lockspace, and this triggered the automatic addition
* of the global lockspace, then the action may complete
* for the vg ls add, while the gl ls add is still in
* progress. If the caller wants to ensure that the
* gl ls add is complete, they should explicitly add+WAIT
* the gl ls.
*
* If this function returns and error, the caller
* will queue the act with that error for the client.
*/
static int add_lockspace(struct action *act)
@ -2614,6 +2586,11 @@ static int add_lockspace(struct action *act)
memset(ls_name, 0, sizeof(ls_name));
/*
* FIXME: I don't think this is used any more.
* Remove it, or add the ability to start the global
* dlm lockspace using lvmlockctl?
*/
if (act->rt == LD_RT_GL) {
if (gl_use_dlm) {
rv = add_dlm_global_lockspace(act);
@ -2697,13 +2674,13 @@ static int rem_lockspace(struct action *act)
pthread_mutex_unlock(&lockspaces_mutex);
/*
* If the dlm global lockspace was automatically added when
* the first dlm vg lockspace was added, then reverse that
* The dlm global lockspace was automatically added when
* the first dlm vg lockspace was added, now reverse that
* by automatically removing the dlm global lockspace when
* the last dlm vg lockspace is removed.
*/
if (rt == LD_RT_VG && gl_use_dlm && gl_auto_dlm)
if (rt == LD_RT_VG && gl_use_dlm)
rem_dlm_global_lockspace();
return 0;

View File

@ -247,10 +247,8 @@ int lm_rem_lockspace_dlm(struct lockspace *ls, int free_vg)
free(lmd);
ls->lm_data = NULL;
if (!strcmp(ls->name, gl_lsname_dlm)) {
if (!strcmp(ls->name, gl_lsname_dlm))
gl_running_dlm = 0;
gl_auto_dlm = 0;
}
return 0;
}

View File

@ -307,6 +307,7 @@ static inline int list_empty(const struct list_head *head)
* or when disable_gl matches.
*/
EXTERN int gl_running_dlm;
EXTERN int gl_type_static;
EXTERN int gl_use_dlm;
EXTERN int gl_use_sanlock;
@ -315,9 +316,6 @@ 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 gl_running_dlm;
EXTERN int gl_auto_dlm;
EXTERN int daemon_test; /* run as much as possible without a live lock manager */
EXTERN int daemon_debug;
EXTERN int daemon_host_id;