1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

In some versions (RHEL6) dlm_create_lockspace() always

return lockspace reference (even if lockspace already exists)
and thus increases DLM lockspace count. It means that after
clvmd restart the lockspace is still in use.

(The only way to clean environment to enable clean cluster
shutdown is call "dlm_tool leave clvmd" several times.)

Because only one clvmd can run in time, we can use simpler logic,
try to open lockspace with dlm_open_lockspace() and only if it fails
try to create new one. This way the lockspace reference doesn not
increase.

Very easily reproducible with  "clvmd -S" command.

Patch also fixes return code when clvmd_restart fails and fixes
double free if debug option was specified during restart.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=612862
This commit is contained in:
Milan Broz 2011-01-19 23:09:31 +00:00
parent dbc8e5098c
commit 679830cf58
4 changed files with 24 additions and 16 deletions

View File

@ -1,6 +1,7 @@
Version 2.02.82 -
===================================
Add -f (don't fork) option to clvmd and fix clvmd -d<num> description.
Fix possible clvmd DLM lockspace increasing reference count.
Version 2.02.81 - 17th January 2011
===================================

View File

@ -89,16 +89,17 @@ static int _init_cluster(void)
DEBUGLOG("CMAN initialisation complete\n");
/* Create a lockspace for LV & VG locks to live in */
lockspace = dlm_create_lockspace(LOCKSPACE_NAME, 0600);
lockspace = dlm_open_lockspace(LOCKSPACE_NAME);
if (!lockspace) {
if (errno == EEXIST) {
lockspace = dlm_open_lockspace(LOCKSPACE_NAME);
}
lockspace = dlm_create_lockspace(LOCKSPACE_NAME, 0600);
if (!lockspace) {
syslog(LOG_ERR, "Unable to create lockspace for CLVM: %m");
syslog(LOG_ERR, "Unable to create DLM lockspace for CLVM: %m");
return -1;
}
}
DEBUGLOG("Created DLM lockspace for CLVMD.\n");
} else
DEBUGLOG("Opened existing DLM lockspace for CLVMD.\n");
dlm_ls_pthread_init(lockspace);
DEBUGLOG("DLM initialisation complete\n");
return 0;

View File

@ -147,7 +147,7 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen,
break;
case CLVMD_CMD_RESTART:
restart_clvmd();
status = restart_clvmd();
break;
case CLVMD_CMD_GET_CLUSTERNAME:
@ -382,8 +382,14 @@ static int restart_clvmd(void)
dm_snprintf(debug_arg, 16, "-d%d", (int)clvmd_get_debug()) < 0)
goto_out;
argv[argc++] = debug_arg;
debug_arg = NULL;
}
/*
* FIXME: specify used cluster backend
* argv[argc++] = strdup("-Isinglenode");
*/
/* Now add the exclusively-open LVs */
do {
hn = get_next_excl_lock(hn, &lv_name);
@ -402,6 +408,7 @@ static int restart_clvmd(void)
argv[argc++] = NULL;
/* Exec new clvmd */
DEBUGLOG("--- Restarting %s ---\n", CLVMD_PATH);
/* NOTE: This will fail when downgrading! */
execve(CLVMD_PATH, argv, NULL);
out:
@ -413,5 +420,5 @@ out:
free(argv);
free(debug_arg);
return 0;
return EIO;
}

View File

@ -294,19 +294,18 @@ static int _init_cluster(void)
return cs_to_errno(err);
}
/* Create a lockspace for LV & VG locks to live in */
lockspace = dlm_create_lockspace(LOCKSPACE_NAME, 0600);
lockspace = dlm_open_lockspace(LOCKSPACE_NAME);
if (!lockspace) {
if (errno == EEXIST) {
lockspace = dlm_open_lockspace(LOCKSPACE_NAME);
}
lockspace = dlm_create_lockspace(LOCKSPACE_NAME, 0600);
if (!lockspace) {
syslog(LOG_ERR, "Unable to create lockspace for CLVM: %m");
quorum_finalize(quorum_handle);
syslog(LOG_ERR, "Unable to create DLM lockspace for CLVM: %m");
return -1;
}
}
DEBUGLOG("Created DLM lockspace for CLVMD.\n");
} else
DEBUGLOG("Opened existing DLM lockspace for CLVMD.\n");
dlm_ls_pthread_init(lockspace);
DEBUGLOG("DLM initialisation complete\n");