401 lines
11 KiB
Diff
401 lines
11 KiB
Diff
|
diff --git a/dlm_controld/action.c b/dlm_controld/action.c
|
||
|
index ae3f6cd..d4bf11d 100644
|
||
|
--- a/dlm_controld/action.c
|
||
|
+++ b/dlm_controld/action.c
|
||
|
@@ -67,14 +67,14 @@ static int detect_cluster_name(void)
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
- rv = cmap_get_string(handle, "cluster.name", &str);
|
||
|
+ rv = cmap_get_string(handle, "totem.cluster_name", &str);
|
||
|
if (rv != CS_OK) {
|
||
|
- log_error("cmap_get_string cluster.name error %d", rv);
|
||
|
+ log_error("cmap_get_string totem.cluster_name error %d", rv);
|
||
|
goto out;
|
||
|
} else
|
||
|
err = 0;
|
||
|
|
||
|
- log_debug("cmap cluster.name = '%s'", str);
|
||
|
+ log_debug("cmap totem.cluster_name = '%s'", str);
|
||
|
|
||
|
strncpy(cluster_name, str, DLM_LOCKSPACE_LEN);
|
||
|
out:
|
||
|
@@ -848,10 +848,12 @@ int setup_configfs_options(void)
|
||
|
|
||
|
detect_cluster_name();
|
||
|
|
||
|
- if (cluster_name[0])
|
||
|
+ if (cluster_name[0]) {
|
||
|
set_configfs_cluster("cluster_name", cluster_name, 0);
|
||
|
- else
|
||
|
+ } else {
|
||
|
log_error("no cluster name");
|
||
|
+ return -1;
|
||
|
+ }
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
diff --git a/dlm_controld/cpg.c b/dlm_controld/cpg.c
|
||
|
index f490cf5..ced912f 100644
|
||
|
--- a/dlm_controld/cpg.c
|
||
|
+++ b/dlm_controld/cpg.c
|
||
|
@@ -280,7 +280,7 @@ const char *msg_name(int type)
|
||
|
static int _send_message(cpg_handle_t h, void *buf, int len, int type)
|
||
|
{
|
||
|
struct iovec iov;
|
||
|
- cpg_error_t error;
|
||
|
+ cs_error_t error;
|
||
|
int retries = 0;
|
||
|
|
||
|
iov.iov_base = buf;
|
||
|
@@ -288,7 +288,7 @@ static int _send_message(cpg_handle_t h, void *buf, int len, int type)
|
||
|
|
||
|
retry:
|
||
|
error = cpg_mcast_joined(h, CPG_TYPE_AGREED, &iov, 1);
|
||
|
- if (error == CPG_ERR_TRY_AGAIN) {
|
||
|
+ if (error == CS_ERR_TRY_AGAIN) {
|
||
|
retries++;
|
||
|
usleep(1000);
|
||
|
if (!(retries % 100))
|
||
|
@@ -296,7 +296,7 @@ static int _send_message(cpg_handle_t h, void *buf, int len, int type)
|
||
|
retries, msg_name(type));
|
||
|
goto retry;
|
||
|
}
|
||
|
- if (error != CPG_OK) {
|
||
|
+ if (error != CS_OK) {
|
||
|
log_error("cpg_mcast_joined error %d handle %llx %s",
|
||
|
error, (unsigned long long)h, msg_name(type));
|
||
|
return -1;
|
||
|
@@ -686,6 +686,11 @@ static int need_fencing(struct lockspace *ls)
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
+/* we don't need to ask fenced to initiate fencing; it does
|
||
|
+ so itself when it sees a fence domain member fail. Without
|
||
|
+ fenced we'll probably need to ask another daemon to initiate
|
||
|
+ fencing, then check with it above, like we check libfenced. */
|
||
|
+
|
||
|
static void request_fencing(struct lockspace *ls)
|
||
|
{
|
||
|
struct node *node;
|
||
|
@@ -693,12 +698,7 @@ static void request_fencing(struct lockspace *ls)
|
||
|
list_for_each_entry(node, &ls->node_history, list) {
|
||
|
if (!node->request_fencing)
|
||
|
continue;
|
||
|
-
|
||
|
- /* we don't need to ask fenced to initiate fencing; it does
|
||
|
- so itself when it sees a fence domain member fail. Without
|
||
|
- fenced we'll probably need to ask another daemon to initiate
|
||
|
- fencing, then check with it above, like we check libfenced. */
|
||
|
-
|
||
|
+ fence_request(node->nodeid);
|
||
|
node->request_fencing = 0;
|
||
|
}
|
||
|
}
|
||
|
@@ -1886,11 +1886,11 @@ static cpg_model_v1_data_t cpg_callbacks = {
|
||
|
void update_flow_control_status(void)
|
||
|
{
|
||
|
cpg_flow_control_state_t flow_control_state;
|
||
|
- cpg_error_t error;
|
||
|
+ cs_error_t error;
|
||
|
|
||
|
error = cpg_flow_control_state_get(cpg_handle_daemon,
|
||
|
&flow_control_state);
|
||
|
- if (error != CPG_OK) {
|
||
|
+ if (error != CS_OK) {
|
||
|
log_error("cpg_flow_control_state_get %d", error);
|
||
|
return;
|
||
|
}
|
||
|
@@ -1911,7 +1911,7 @@ void update_flow_control_status(void)
|
||
|
static void process_cpg_lockspace(int ci)
|
||
|
{
|
||
|
struct lockspace *ls;
|
||
|
- cpg_error_t error;
|
||
|
+ cs_error_t error;
|
||
|
|
||
|
ls = find_ls_ci(ci);
|
||
|
if (!ls) {
|
||
|
@@ -1919,8 +1919,8 @@ static void process_cpg_lockspace(int ci)
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
- error = cpg_dispatch(ls->cpg_handle, CPG_DISPATCH_ALL);
|
||
|
- if (error != CPG_OK) {
|
||
|
+ error = cpg_dispatch(ls->cpg_handle, CS_DISPATCH_ALL);
|
||
|
+ if (error != CS_OK) {
|
||
|
log_error("cpg_dispatch error %d", error);
|
||
|
return;
|
||
|
}
|
||
|
@@ -1932,7 +1932,7 @@ static void process_cpg_lockspace(int ci)
|
||
|
|
||
|
int dlm_join_lockspace(struct lockspace *ls)
|
||
|
{
|
||
|
- cpg_error_t error;
|
||
|
+ cs_error_t error;
|
||
|
cpg_handle_t h;
|
||
|
struct cpg_name name;
|
||
|
int i = 0, fd, ci, rv;
|
||
|
@@ -1947,7 +1947,7 @@ int dlm_join_lockspace(struct lockspace *ls)
|
||
|
|
||
|
error = cpg_model_initialize(&h, CPG_MODEL_V1,
|
||
|
(cpg_model_data_t *)&cpg_callbacks, NULL);
|
||
|
- if (error != CPG_OK) {
|
||
|
+ if (error != CS_OK) {
|
||
|
log_error("cpg_model_initialize error %d", error);
|
||
|
rv = -1;
|
||
|
goto fail_free;
|
||
|
@@ -1976,13 +1976,13 @@ int dlm_join_lockspace(struct lockspace *ls)
|
||
|
log_group(ls, "cpg_join %s ...", name.value);
|
||
|
retry:
|
||
|
error = cpg_join(h, &name);
|
||
|
- if (error == CPG_ERR_TRY_AGAIN) {
|
||
|
+ if (error == CS_ERR_TRY_AGAIN) {
|
||
|
sleep(1);
|
||
|
if (!(++i % 10))
|
||
|
log_error("cpg_join error retrying");
|
||
|
goto retry;
|
||
|
}
|
||
|
- if (error != CPG_OK) {
|
||
|
+ if (error != CS_OK) {
|
||
|
log_error("cpg_join error %d", error);
|
||
|
cpg_finalize(h);
|
||
|
rv = -1;
|
||
|
@@ -2005,7 +2005,7 @@ int dlm_join_lockspace(struct lockspace *ls)
|
||
|
|
||
|
int dlm_leave_lockspace(struct lockspace *ls)
|
||
|
{
|
||
|
- cpg_error_t error;
|
||
|
+ cs_error_t error;
|
||
|
struct cpg_name name;
|
||
|
int i = 0;
|
||
|
|
||
|
@@ -2017,13 +2017,13 @@ int dlm_leave_lockspace(struct lockspace *ls)
|
||
|
|
||
|
retry:
|
||
|
error = cpg_leave(ls->cpg_handle, &name);
|
||
|
- if (error == CPG_ERR_TRY_AGAIN) {
|
||
|
+ if (error == CS_ERR_TRY_AGAIN) {
|
||
|
sleep(1);
|
||
|
if (!(++i % 10))
|
||
|
log_error("cpg_leave error retrying");
|
||
|
goto retry;
|
||
|
}
|
||
|
- if (error != CPG_OK)
|
||
|
+ if (error != CS_OK)
|
||
|
log_error("cpg_leave error %d", error);
|
||
|
|
||
|
return 0;
|
||
|
@@ -2563,16 +2563,16 @@ static cpg_model_v1_data_t cpg_callbacks_daemon = {
|
||
|
|
||
|
void process_cpg_daemon(int ci)
|
||
|
{
|
||
|
- cpg_error_t error;
|
||
|
+ cs_error_t error;
|
||
|
|
||
|
- error = cpg_dispatch(cpg_handle_daemon, CPG_DISPATCH_ALL);
|
||
|
- if (error != CPG_OK)
|
||
|
+ error = cpg_dispatch(cpg_handle_daemon, CS_DISPATCH_ALL);
|
||
|
+ if (error != CS_OK)
|
||
|
log_error("daemon cpg_dispatch error %d", error);
|
||
|
}
|
||
|
|
||
|
int setup_cpg_daemon(void)
|
||
|
{
|
||
|
- cpg_error_t error;
|
||
|
+ cs_error_t error;
|
||
|
struct cpg_name name;
|
||
|
int i = 0;
|
||
|
|
||
|
@@ -2597,7 +2597,7 @@ int setup_cpg_daemon(void)
|
||
|
error = cpg_model_initialize(&cpg_handle_daemon, CPG_MODEL_V1,
|
||
|
(cpg_model_data_t *)&cpg_callbacks_daemon,
|
||
|
NULL);
|
||
|
- if (error != CPG_OK) {
|
||
|
+ if (error != CS_OK) {
|
||
|
log_error("daemon cpg_initialize error %d", error);
|
||
|
return -1;
|
||
|
}
|
||
|
@@ -2611,13 +2611,13 @@ int setup_cpg_daemon(void)
|
||
|
log_debug("cpg_join %s ...", name.value);
|
||
|
retry:
|
||
|
error = cpg_join(cpg_handle_daemon, &name);
|
||
|
- if (error == CPG_ERR_TRY_AGAIN) {
|
||
|
+ if (error == CS_ERR_TRY_AGAIN) {
|
||
|
sleep(1);
|
||
|
if (!(++i % 10))
|
||
|
log_error("daemon cpg_join error retrying");
|
||
|
goto retry;
|
||
|
}
|
||
|
- if (error != CPG_OK) {
|
||
|
+ if (error != CS_OK) {
|
||
|
log_error("daemon cpg_join error %d", error);
|
||
|
goto fail;
|
||
|
}
|
||
|
@@ -2633,7 +2633,7 @@ int setup_cpg_daemon(void)
|
||
|
void close_cpg_daemon(void)
|
||
|
{
|
||
|
struct lockspace *ls;
|
||
|
- cpg_error_t error;
|
||
|
+ cs_error_t error;
|
||
|
struct cpg_name name;
|
||
|
int i = 0;
|
||
|
|
||
|
@@ -2649,13 +2649,13 @@ void close_cpg_daemon(void)
|
||
|
log_debug("cpg_leave %s ...", name.value);
|
||
|
retry:
|
||
|
error = cpg_leave(cpg_handle_daemon, &name);
|
||
|
- if (error == CPG_ERR_TRY_AGAIN) {
|
||
|
+ if (error == CS_ERR_TRY_AGAIN) {
|
||
|
sleep(1);
|
||
|
if (!(++i % 10))
|
||
|
log_error("daemon cpg_leave error retrying");
|
||
|
goto retry;
|
||
|
}
|
||
|
- if (error != CPG_OK)
|
||
|
+ if (error != CS_OK)
|
||
|
log_error("daemon cpg_leave error %d", error);
|
||
|
fin:
|
||
|
list_for_each_entry(ls, &lockspaces, list) {
|
||
|
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
|
||
|
index 497e6e8..3899550 100644
|
||
|
--- a/dlm_controld/dlm_daemon.h
|
||
|
+++ b/dlm_controld/dlm_daemon.h
|
||
|
@@ -348,6 +348,7 @@ void process_cluster_cfg(int ci);
|
||
|
void kick_node_from_cluster(int nodeid);
|
||
|
|
||
|
/* fence.c */
|
||
|
+void fence_request(int nodeid);
|
||
|
int fence_node_time(int nodeid, uint64_t *last_fenced_time);
|
||
|
int fence_in_progress(int *count);
|
||
|
|
||
|
diff --git a/dlm_controld/fence.c b/dlm_controld/fence.c
|
||
|
index 95a8bc1..f91d9de 100644
|
||
|
--- a/dlm_controld/fence.c
|
||
|
+++ b/dlm_controld/fence.c
|
||
|
@@ -7,38 +7,30 @@
|
||
|
*/
|
||
|
|
||
|
#include "dlm_daemon.h"
|
||
|
-//#include "libfenced.h"
|
||
|
+#ifdef STONITH
|
||
|
+#include <pacemaker/crm/stonith-ng.h>
|
||
|
+#endif
|
||
|
|
||
|
-int fence_node_time(int nodeid, uint64_t *last_fenced_time)
|
||
|
+void fence_request(int nodeid)
|
||
|
{
|
||
|
-/*
|
||
|
- struct fenced_node nodeinfo;
|
||
|
+#ifdef STONITH
|
||
|
int rv;
|
||
|
+ rv = stonith_api_kick_cs_helper(nodeid, 300, 1);
|
||
|
+ if (rv)
|
||
|
+ log_error("stonith_api_kick_cs_helper %d error %d", nodeid, rv);
|
||
|
+#endif
|
||
|
+}
|
||
|
|
||
|
- memset(&nodeinfo, 0, sizeof(nodeinfo));
|
||
|
-
|
||
|
- rv = fenced_node_info(nodeid, &nodeinfo);
|
||
|
- if (rv < 0)
|
||
|
- return rv;
|
||
|
-
|
||
|
- *last_fenced_time = nodeinfo.last_fenced_time;
|
||
|
-*/
|
||
|
+int fence_node_time(int nodeid, uint64_t *last_fenced_time)
|
||
|
+{
|
||
|
+#ifdef STONITH
|
||
|
+ *last_fenced_time = stonith_api_time_cs_helper(nodeid, 0);
|
||
|
+#endif
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int fence_in_progress(int *count)
|
||
|
{
|
||
|
-/* struct fenced_domain domain;
|
||
|
- int rv;
|
||
|
-
|
||
|
- memset(&domain, 0, sizeof(domain));
|
||
|
-
|
||
|
- rv = fenced_domain_info(&domain);
|
||
|
- if (rv < 0)
|
||
|
- return rv;
|
||
|
-
|
||
|
- *count = domain.victim_count;
|
||
|
-*/
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
diff --git a/dlm_controld/member.c b/dlm_controld/member.c
|
||
|
index 4a445c8..7af581c 100644
|
||
|
--- a/dlm_controld/member.c
|
||
|
+++ b/dlm_controld/member.c
|
||
|
@@ -265,7 +265,6 @@ static void shutdown_callback(corosync_cfg_handle_t h,
|
||
|
static corosync_cfg_callbacks_t cfg_callbacks =
|
||
|
{
|
||
|
.corosync_cfg_shutdown_callback = shutdown_callback,
|
||
|
- .corosync_cfg_state_track_callback = NULL,
|
||
|
};
|
||
|
|
||
|
void process_cluster_cfg(int ci)
|
||
|
@@ -302,9 +301,16 @@ int setup_cluster_cfg(void)
|
||
|
corosync_cfg_finalize(ch);
|
||
|
return -1;
|
||
|
}
|
||
|
+
|
||
|
our_nodeid = nodeid;
|
||
|
log_debug("our_nodeid %d", our_nodeid);
|
||
|
|
||
|
+ if (our_nodeid < 0) {
|
||
|
+ log_error("negative nodeid, set corosync totem.clear_node_high_bit");
|
||
|
+ corosync_cfg_finalize(ch);
|
||
|
+ return -1;
|
||
|
+ }
|
||
|
+
|
||
|
return fd;
|
||
|
}
|
||
|
|
||
|
diff --git a/init/dlm.init b/init/dlm.init
|
||
|
index db8f17f..7f3da2d 100644
|
||
|
--- a/init/dlm.init
|
||
|
+++ b/init/dlm.init
|
||
|
@@ -26,7 +26,7 @@ progdir="cluster"
|
||
|
lockfile="/var/run/$progdir/$prog.pid"
|
||
|
exec="/usr/sbin/$prog"
|
||
|
|
||
|
-[ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
|
||
|
+[ -f /etc/sysconfig/dlm ] && . /etc/sysconfig/dlm
|
||
|
|
||
|
setup() {
|
||
|
modprobe dlm > /dev/null 2>&1
|
||
|
diff --git a/init/dlm.service b/init/dlm.service
|
||
|
index e275843..d7cf9c7 100644
|
||
|
--- a/init/dlm.service
|
||
|
+++ b/init/dlm.service
|
||
|
@@ -4,7 +4,10 @@ After=syslog.target network.target corosync.service
|
||
|
|
||
|
[Service]
|
||
|
Type=forking
|
||
|
-ExecStart=/usr/sbin/dlm_controld $OPTIONS
|
||
|
+EnvironmentFile=/etc/sysconfig/dlm
|
||
|
+ExecStartPre=/sbin/modprobe dlm
|
||
|
+ExecStart=/usr/sbin/dlm_controld $DLM_CONTROLD_OPTS
|
||
|
+#ExecStopPost=/sbin/modprobe -r dlm
|
||
|
|
||
|
[Install]
|
||
|
WantedBy=multi-user.target
|
||
|
diff --git a/libdlm/51-dlm.rules b/libdlm/51-dlm.rules
|
||
|
index f71e79d..9d21fc0 100644
|
||
|
--- a/libdlm/51-dlm.rules
|
||
|
+++ b/libdlm/51-dlm.rules
|
||
|
@@ -1,5 +1,4 @@
|
||
|
-KERNEL=="dlm-control", NAME="misc/dlm-control", MODE="0666"
|
||
|
-KERNEL=="dlm-monitor", NAME="misc/dlm-monitor", MODE="0666"
|
||
|
-KERNEL=="dlm_default", NAME="misc/dlm_default", MODE="0666"
|
||
|
-KERNEL=="dlm_*", NAME="misc/%k", MODE="0660"
|
||
|
-
|
||
|
+KERNEL=="dlm-control", MODE="0666", SYMLINK+="misc/dlm-control"
|
||
|
+KERNEL=="dlm-monitor", MODE="0666", SYMLINK+="misc/dlm-monitor"
|
||
|
+KERNEL=="dlm_plock", MODE="0666", SYMLINK+="misc/dlm_plock"
|
||
|
+KERNEL=="dlm_*", MODE="0660", SYMLINK+="misc/%k"
|