cluster: RHEL6 - cpglockd: use standard logging infrastructure
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 7f97877bb418014bfe9bc3fb6fff554ad98c22aa
Parent: 9757156c569b05517cdc6173e334f22829e07854
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue Apr 24 15:21:34 2012 +0200
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Tue May 1 10:58:44 2012 -0400
cpglockd: use standard logging infrastructure
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
Reviewed-by: Lon Hohberger <lhh(a)redhat.com>
Reviewed-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/include/cpglock-internal.h | 7 --
rgmanager/src/clulib/libcpglock.c | 4 -
rgmanager/src/daemons/Makefile | 2 +-
rgmanager/src/daemons/cpglockd.c | 171 ++++++++++++++++++++--------------
4 files changed, 104 insertions(+), 80 deletions(-)
diff --git a/rgmanager/include/cpglock-internal.h b/rgmanager/include/cpglock-internal.h
index 904df37..e05b90a 100644
--- a/rgmanager/include/cpglock-internal.h
+++ b/rgmanager/include/cpglock-internal.h
@@ -1,12 +1,6 @@
#ifndef _CPGLOCK_INT_H
#define _CPGLOCK_INT_H
-#ifdef CPGLOCK_DEBUG
-# define cpgl_debug(format, args...) do { printf(format, ##args); } while (0)
-#else
-# define cpgl_debug(format, args...) do { } while (0)
-#endif
-
#ifndef CPG_LOCKD_SOCK
#define CPG_LOCKD_SOCK "/var/run/cpglockd.sk"
#endif
@@ -25,7 +19,6 @@ typedef enum {
MSG_HALT = 999
} cpg_lock_req_t;
-/* Mixed architecture not supported yet */
struct cpg_lock_msg {
int32_t request;
uint32_t owner_nodeid;
diff --git a/rgmanager/src/clulib/libcpglock.c b/rgmanager/src/clulib/libcpglock.c
index d554281..f99edd4 100644
--- a/rgmanager/src/clulib/libcpglock.c
+++ b/rgmanager/src/clulib/libcpglock.c
@@ -145,8 +145,6 @@ cpg_lock(void *handle, const char *resource, lock_flag_t flags, struct cpg_lock
}
if (strcmp(r.resource, l.resource)) {
- cpgl_debug("NOTE: msg for wrong lock want: %s got: %s\n",
- l.resource, r.resource);
add_pending(&h->pending, &r);
pthread_mutex_unlock(&h->mutex);
usleep(random() & 16383);
@@ -154,8 +152,6 @@ cpg_lock(void *handle, const char *resource, lock_flag_t flags, struct cpg_lock
continue;
}
if (r.owner_tid != l.owner_tid) {
- cpgl_debug("NOTE: msg for wrong seq want: %d got: %d\n",
- l.owner_tid, r.owner_tid );
add_pending(&h->pending, &r);
pthread_mutex_unlock(&h->mutex);
usleep(random() & 16383);
diff --git a/rgmanager/src/daemons/Makefile b/rgmanager/src/daemons/Makefile
index d125eaa..a178523 100644
--- a/rgmanager/src/daemons/Makefile
+++ b/rgmanager/src/daemons/Makefile
@@ -107,7 +107,7 @@ ${TARGET3}: ${TARGET1}
${TARGET4}: ${OBJS4} ${LDDEPS}
$(CC) -o $@ $^ $(CPG_LDFLAGS) $(CMAN_LDFLAGS) $(CCS_LDFLAGS) \
- $(FENCED_LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS)
+ $(FENCED_LDFLAGS) $(LOGSYS_LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS)
${TARGET5}: ${OBJS5} ${LDDEPS}
$(CC) -o $@ $^ $(CPG_LDFLAGS)
diff --git a/rgmanager/src/daemons/cpglockd.c b/rgmanager/src/daemons/cpglockd.c
index 9f9f635..47cbcdc 100644
--- a/rgmanager/src/daemons/cpglockd.c
+++ b/rgmanager/src/daemons/cpglockd.c
@@ -18,6 +18,7 @@
#include <ccs.h>
#include <libcman.h>
#include <libfenced.h>
+#include <liblogthread.h>
#include "daemon_init.h"
#include "sock.h"
@@ -75,6 +76,7 @@ static int joined = 0;
static int cluster_quorate = 0;
static int cman_shutdown_requested = 0;
static int shutdown_pending = 0;
+static int nofork = 0;
static cman_node_t cman_nodes[CPG_MEMBERS_MAX];
static int cman_node_count;
@@ -82,6 +84,8 @@ static int cman_node_count;
static cman_node_t old_cman_nodes[CPG_MEMBERS_MAX];
static int old_cman_node_count;
+static void init_logging(int reconf);
+
static void
flag_shutdown(int __attribute__ ((unused)) sig)
{
@@ -100,7 +104,7 @@ cman_nodes_lost(cman_node_t *old_nodes,
size_t lost_nodes_len = 0;
if (lost_nodes_size < old_node_len) {
- cpgl_debug("Lost nodes array smaller than old nodes array");
+ logt_print(LOG_DEBUG, "Lost nodes array smaller than old nodes array");
return -1;
}
@@ -140,7 +144,7 @@ node_has_fencing(int nodeid)
ccs_desc = ccs_connect();
if (ccs_desc < 0) {
- cpgl_debug("Unable to connect to ccsd\n");
+ logt_print(LOG_DEBUG, "Unable to connect to ccsd\n");
/* Assume node has fencing */
return 1;
}
@@ -164,7 +168,7 @@ fence_domain_joined(void) {
ret = fenced_node_info(FENCED_NODEID_US, &fn);
if (ret < 0) {
- cpgl_debug("Unable to determine fence domain membership\n");
+ logt_print(LOG_DEBUG, "Unable to determine fence domain membership\n");
return 0;
}
@@ -192,14 +196,14 @@ cman_callback(cman_handle_t ch, void *privdata, int reason, int arg)
ret = cman_get_nodes(ch, nodes_elem, &cman_node_count, cman_nodes);
if (ret < 0) {
- cpgl_debug("Unable to get cman nodes list\n");
+ logt_print(LOG_DEBUG, "Unable to get cman nodes list\n");
return;
}
nl = cman_nodes_lost(old_cman_nodes, old_cman_node_count,
cman_nodes, cman_node_count, lost_nodes, nodes_elem);
if (nl < 0) {
- cpgl_debug("Unable to get list of lost nodes");
+ logt_print(LOG_DEBUG, "Unable to get list of lost nodes");
return;
}
@@ -209,18 +213,20 @@ cman_callback(cman_handle_t ch, void *privdata, int reason, int arg)
if (node_has_fencing(cur_nodeid)) {
struct pending_fence_node *pf;
- cpgl_debug("Lost node %d\n", cur_nodeid);
+ logt_print(LOG_DEBUG, "Lost node %d\n", cur_nodeid);
pf = do_alloc(sizeof(*pf));
pf->nodeid = cur_nodeid;
pf->fail_time = cur_time;
list_append(&pending_fencing, pf);
} else {
- cpgl_debug("Lost node %d but fencing not configured\n",
+ logt_print(LOG_DEBUG, "Lost node %d but fencing not configured\n",
cur_nodeid);
}
}
} else if (reason == CMAN_REASON_TRY_SHUTDOWN) {
cman_shutdown_requested = 1;
+ } else if (reason == CMAN_REASON_CONFIG_UPDATE) {
+ init_logging(1);
}
}
@@ -228,20 +234,20 @@ static void
wait_for_fencing_join(int nodeid)
{
if (node_has_fencing(nodeid)) {
- cpgl_debug("Waiting for fence domain join operation to complete\n");
+ logt_print(LOG_DEBUG, "Waiting for fence domain join operation to complete\n");
while (!shutdown_pending && !fence_domain_joined())
sleep(1);
- cpgl_debug("Fence domain joined\n");
+ logt_print(LOG_DEBUG, "Fence domain joined\n");
} else
- cpgl_debug("No fencing is configured, not waiting\n");
+ logt_print(LOG_DEBUG, "No fencing is configured, not waiting\n");
}
static void
wait_for_quorum_formation(cman_handle_t ch) {
- cpgl_debug("Waiting for quorum to form\n");
+ logt_print(LOG_DEBUG, "Waiting for quorum to form\n");
while (!shutdown_pending && !(cluster_quorate = cman_is_quorate(ch)))
sleep(1);
- cpgl_debug("Quorum formed\n");
+ logt_print(LOG_DEBUG, "Quorum formed\n");
}
static int
@@ -251,10 +257,10 @@ cman_connect(cman_handle_t *ch)
*ch = cman_init(NULL);
if (!*ch) {
- cpgl_debug("Waiting for CMAN to start\n");
+ logt_print(LOG_DEBUG, "Waiting for CMAN to start\n");
while (!shutdown_pending && !(*ch = cman_init(NULL)))
sleep(1);
- cpgl_debug("CMAN started\n");
+ logt_print(LOG_DEBUG, "CMAN started\n");
}
return 0;
@@ -425,7 +431,7 @@ send_lock_msg(struct cpg_lock_msg *m)
do {
ret = cpg_mcast_joined(cpg, CPG_TYPE_AGREED, &iov, 1);
if (ret != CPG_OK) {
- cpgl_debug("send_lock_msg() failed\n");
+ logt_print(LOG_DEBUG, "send_lock_msg() failed\n");
usleep(250000);
}
} while (ret != CPG_OK && !shutdown_pending);
@@ -449,7 +455,7 @@ send_grant(struct request_node *n)
{
struct cpg_lock_msg m;
- cpgl_debug("-> sending grant %s to %d:%d:%d\n",
+ logt_print(LOG_DEBUG, "-> sending grant %s to %d:%d:%d\n",
n->l.resource, n->l.owner_nodeid, n->l.owner_pid, n->l.owner_tid);
memset(&m, 0, sizeof(m));
@@ -508,7 +514,7 @@ grant_next(struct cpg_lock_msg *m)
/* Send grant */
if (r->l.state == LOCK_PENDING) {
- cpgl_debug("LOCK %s: grant to %d:%d:%d\n", m->resource,
+ logt_print(LOG_DEBUG, "LOCK %s: grant to %d:%d:%d\n", m->resource,
r->l.owner_nodeid, r->l.owner_pid, r->l.owner_tid);
/* don't send dup grants */
r->l.state = LOCK_HELD;
@@ -545,9 +551,9 @@ purge_requests(uint32_t nodeid, uint32_t pid)
if (count) {
if (pid) {
- cpgl_debug("RECOVERY: purged %d requests from %d:%d\n", count, nodeid, pid);
+ logt_print(LOG_DEBUG, "RECOVERY: purged %d requests from %d:%d\n", count, nodeid, pid);
} else {
- cpgl_debug("RECOVERY: purged %d requests from node %d\n", count, nodeid);
+ logt_print(LOG_DEBUG, "RECOVERY: purged %d requests from node %d\n", count, nodeid);
}
}
}
@@ -575,7 +581,7 @@ del_client(int fd)
if (!pid)
return;
- cpgl_debug("RECOVERY: Looking for locks held by PID %d\n", pid);
+ logt_print(LOG_DEBUG, "RECOVERY: Looking for locks held by PID %d\n", pid);
/* This may not be needed */
purge_requests(my_node_id, pid);
@@ -593,7 +599,7 @@ del_client(int fd)
l->l.state != LOCK_HELD)
continue;
- cpgl_debug("RECOVERY: Releasing %s \n", l->l.resource);
+ logt_print(LOG_DEBUG, "RECOVERY: Releasing %s \n", l->l.resource);
l->l.state = LOCK_FREE;
strncpy(m.resource, l->l.resource, sizeof(m.resource));
@@ -602,9 +608,9 @@ del_client(int fd)
}
if (recovered) {
- cpgl_debug("RECOVERY: %d locks from local PID %d\n", recovered, pid);
+ logt_print(LOG_DEBUG, "RECOVERY: %d locks from local PID %d\n", recovered, pid);
}
- cpgl_debug("RECOVERY: Complete\n");
+ logt_print(LOG_DEBUG, "RECOVERY: Complete\n");
}
@@ -622,7 +628,7 @@ del_node(uint32_t nodeid)
*/
list_for(&locks, l, x) {
if (l->l.owner_nodeid == nodeid) {
- cpgl_debug("RECOVERY: LOCK UPDATED: %s [%d:%d]=>[%d:%d]\n",
+ logt_print(LOG_DEBUG, "RECOVERY: LOCK UPDATED: %s [%d:%d]=>[%d:%d]\n",
l->l.resource,
l->l.owner_nodeid, l->l.owner_pid,
group_members->nodeid, group_members->pid);
@@ -633,7 +639,7 @@ del_node(uint32_t nodeid)
return;
}
- cpgl_debug("RECOVERY: I am oldest node in the group, recovering locks\n");
+ logt_print(LOG_DEBUG, "RECOVERY: I am oldest node in the group, recovering locks\n");
/* pass 1: purge outstanding requests from this node. */
@@ -649,13 +655,13 @@ del_node(uint32_t nodeid)
list_for(&locks, l, x) {
if (l->l.owner_nodeid == nodeid && l->l.state == LOCK_HELD) {
- cpgl_debug("RECOVERY: Releasing %s held by dead node %d\n",
+ logt_print(LOG_DEBUG, "RECOVERY: Releasing %s held by dead node %d\n",
l->l.resource, nodeid);
l->l.state = LOCK_FREE;
strncpy(m.resource, l->l.resource, sizeof(m.resource));
if (grant_next(&m) == 0) {
- cpgl_debug("RECOVERY: HELD LOCK UPDATED: %s [%d:%d]=>[%d:%d]\n",
+ logt_print(LOG_DEBUG, "RECOVERY: HELD LOCK UPDATED: %s [%d:%d]=>[%d:%d]\n",
l->l.resource,
l->l.owner_nodeid, l->l.owner_pid,
my_node_id, getpid());
@@ -669,7 +675,7 @@ del_node(uint32_t nodeid)
} else if (l->l.owner_nodeid == nodeid && l->l.state == LOCK_FREE) {
strncpy(m.resource, l->l.resource, sizeof(m.resource));
if (grant_next(&m) == 0) {
- cpgl_debug("RECOVERY: FREE LOCK UPDATED: %s [%d:%d]=>[%d:%d]\n",
+ logt_print(LOG_DEBUG, "RECOVERY: FREE LOCK UPDATED: %s [%d:%d]=>[%d:%d]\n",
l->l.resource,
l->l.owner_nodeid, l->l.owner_pid,
my_node_id, getpid());
@@ -681,13 +687,13 @@ del_node(uint32_t nodeid)
}
if (recovered) {
- cpgl_debug("RECOVERY: %d locks from node %d\n", recovered, nodeid);
+ logt_print(LOG_DEBUG, "RECOVERY: %d locks from node %d\n", recovered, nodeid);
}
if (granted) {
- cpgl_debug("RECOVERY: %d pending locks granted\n", granted);
+ logt_print(LOG_DEBUG, "RECOVERY: %d pending locks granted\n", granted);
}
- cpgl_debug("RECOVERY: Complete\n");
+ logt_print(LOG_DEBUG, "RECOVERY: Complete\n");
}
@@ -760,19 +766,19 @@ grant_client(struct lock_node *l)
c = find_client(l->l.owner_pid);
if (!c) {
- cpgl_debug("can't find client for pid %d\n", l->l.owner_pid);
+ logt_print(LOG_DEBUG, "can't find client for pid %d\n", l->l.owner_pid);
return 1;
}
if (c->fd < 0) {
- cpgl_debug(" Client has bad fd\n");
+ logt_print(LOG_DEBUG, " Client has bad fd\n");
return -1;
}
if (write_retry(c->fd, &m, sizeof(m), NULL) < 0) {
/* no client anymore; drop and send to next guy XXX */
/* This should be handled by our main loop */
- //cpgl_debug("Failed to notify client!\n");
+ //logt_print(LOG_DEBUG, "Failed to notify client!\n");
}
return 0;
@@ -794,19 +800,19 @@ nak_client(struct request_node *l)
c = find_client(l->l.owner_pid);
if (!c) {
- cpgl_debug("can't find client for pid %d\n", l->l.owner_pid);
+ logt_print(LOG_DEBUG, "can't find client for pid %d\n", l->l.owner_pid);
return 1;
}
if (c->fd < 0) {
- cpgl_debug(" Client has bad fd\n");
+ logt_print(LOG_DEBUG, " Client has bad fd\n");
return -1;
}
if (write_retry(c->fd, &m, sizeof(m), NULL) < 0) {
/* no client anymore; drop and send to next guy XXX */
/* This should be handled by our main loop */
- //cpgl_debug("Failed to notify client!\n");
+ //logt_print(LOG_DEBUG, "Failed to notify client!\n");
}
return 0;
@@ -838,7 +844,7 @@ process_lock(struct cpg_lock_msg *m)
if (!joined)
return 0;
- cpgl_debug("LOCK %s: queue for %d:%d:%d\n", m->resource,
+ logt_print(LOG_DEBUG, "LOCK %s: queue for %d:%d:%d\n", m->resource,
m->owner_nodeid, m->owner_pid, m->owner_tid);
queue_request(m);
@@ -914,14 +920,14 @@ process_grant(struct cpg_lock_msg *m, uint32_t nodeid)
if (l->l.state == LOCK_HELD) {
if (m->owner_pid == 0 ||
m->owner_nodeid == 0) {
- cpgl_debug("GRANT averted\n");
+ logt_print(LOG_DEBUG, "GRANT averted\n");
return 0;
}
} else {
l->l.state = LOCK_HELD;
}
- cpgl_debug("GRANT %s: to %d:%d:%d\n",
+ logt_print(LOG_DEBUG, "GRANT %s: to %d:%d:%d\n",
m->resource, m->owner_nodeid,
m->owner_pid, m->owner_tid);
@@ -962,7 +968,7 @@ process_grant(struct cpg_lock_msg *m, uint32_t nodeid)
if (group_members->nodeid == my_node_id &&
!is_member(l->l.owner_nodeid)) {
- cpgl_debug("GRANT to non-member %d; giving to next requestor\n",
+ logt_print(LOG_DEBUG, "GRANT to non-member %d; giving to next requestor\n",
l->l.owner_nodeid);
l->l.state = LOCK_FREE;
@@ -1037,7 +1043,7 @@ process_unlock(struct cpg_lock_msg *m, uint32_t nodeid)
GRANT to the first node on the request queue */
if (l->l.owner_nodeid == m->owner_nodeid &&
l->l.owner_pid == m->owner_pid) {
- cpgl_debug("UNLOCK %s: %d:%d:%d\n",
+ logt_print(LOG_DEBUG, "UNLOCK %s: %d:%d:%d\n",
m->resource, m->owner_nodeid, m->owner_pid, m->owner_tid);
l->l.state = LOCK_FREE;
if (l->l.owner_nodeid == my_node_id) {
@@ -1063,7 +1069,7 @@ find_lock(struct cpg_lock_msg *m)
list_for(&locks, l, x) {
if (m->lockid == l->l.local_id) {
strncpy(m->resource, l->l.resource, sizeof(m->resource));
- cpgl_debug("LOCK %d -> %s\n", m->lockid, m->resource);
+ logt_print(LOG_DEBUG, "LOCK %d -> %s\n", m->lockid, m->resource);
m->owner_nodeid = l->l.owner_nodeid;
m->owner_pid = l->l.owner_pid;
m->owner_tid = l->l.owner_tid;
@@ -1084,7 +1090,7 @@ process_join(struct cpg_lock_msg *m, uint32_t nodeid, uint32_t pid)
list_for(&group_members, n, x) {
if (n->nodeid == nodeid) {
- cpgl_debug("IGNORING JOIN from existing member %d.%d (%d.%d)\n",
+ logt_print(LOG_DEBUG, "IGNORING JOIN from existing member %d.%d (%d.%d)\n",
nodeid, pid, nodeid, n->pid);
return 0;
}
@@ -1093,13 +1099,13 @@ process_join(struct cpg_lock_msg *m, uint32_t nodeid, uint32_t pid)
n = do_alloc(sizeof(*n));
n->nodeid = nodeid;
n->pid = pid;
- cpgl_debug("JOIN: node %d.%u", n->nodeid, n->pid);
+ logt_print(LOG_DEBUG, "JOIN: node %d.%u", n->nodeid, n->pid);
if (nodeid == my_node_id) {
- cpgl_debug(" (self)");
+ logt_print(LOG_DEBUG, " (self)");
joined = 1;
}
total_members++;
- cpgl_debug("\n");
+ logt_print(LOG_DEBUG, "\n");
list_insert(&group_members, n);
return 0;
@@ -1112,7 +1118,7 @@ process_request(struct cpg_lock_msg *m, uint32_t nodeid, uint32_t pid)
swab_cpg_lock_msg(m);
if (m->request == MSG_HALT) {
- cpgl_debug("FAULT: Halting operations; see node %d\n", m->owner_nodeid);
+ logt_print(LOG_DEBUG, "FAULT: Halting operations; see node %d\n", m->owner_nodeid);
while (1)
sleep(30);
}
@@ -1154,7 +1160,7 @@ cpg_deliver_func(cpg_handle_t h,
{
if (msglen != sizeof(struct cpg_lock_msg)) {
- cpgl_debug("Invalid message size %d\n", (int)msglen);
+ logt_print(LOG_DEBUG, "Invalid message size %d\n", (int)msglen);
}
process_request((struct cpg_lock_msg *)msg, nodeid, pid);
@@ -1180,7 +1186,7 @@ cpg_config_change(cpg_handle_t h,
old_msg(&m);
if (total_members == 0) {
- cpgl_debug("JOIN: Setting up initial node list\n");
+ logt_print(LOG_DEBUG, "JOIN: Setting up initial node list\n");
for (x = 0; x < memberlen; x++) {
for (y = 0; y < joinlen; y++) {
if (join[y].nodeid == members[x].nodeid)
@@ -1191,16 +1197,16 @@ cpg_config_change(cpg_handle_t h,
n = do_alloc(sizeof(*n));
n->nodeid = members[x].nodeid;
n->pid = members[x].pid;
- cpgl_debug("JOIN: node %d.%u\n", n->nodeid, n->pid);
+ logt_print(LOG_DEBUG, "JOIN: node %d.%u\n", n->nodeid, n->pid);
list_insert(&group_members, n);
}
}
- cpgl_debug("JOIN: Done\n");
+ logt_print(LOG_DEBUG, "JOIN: Done\n");
total_members = memberlen;
}
- //cpgl_debug("members %d now, %d joined, %d left\n", memberlen, joinlen, leftlen);
+ //logt_print(LOG_DEBUG, "members %d now, %d joined, %d left\n", memberlen, joinlen, leftlen);
#if 0
/* XXX process join on receipt of JOIN message rather than here
@@ -1209,7 +1215,7 @@ cpg_config_change(cpg_handle_t h,
for (x = 0; x < joinlen; x++) {
n = do_alloc(sizeof(*n));
n->nodeid = join[x].nodeid;
- cpgl_debug("ADD: node %d\n", n->nodeid);
+ logt_print(LOG_DEBUG, "ADD: node %d\n", n->nodeid);
list_insert(&group_members, n);
}
#endif
@@ -1219,17 +1225,17 @@ cpg_config_change(cpg_handle_t h,
if (n->nodeid == left[x].nodeid) {
if (n->pid == left[x].pid) {
if (n->nodeid == my_node_id) {
- cpgl_debug("Received DELETE message for self. Exiting.");
+ logt_print(LOG_DEBUG, "Received DELETE message for self. Exiting.");
exit(0);
}
list_remove(&group_members, n);
- cpgl_debug("DELETE: node %d.%u\n", n->nodeid, n->pid);
+ logt_print(LOG_DEBUG, "DELETE: node %d.%u\n", n->nodeid, n->pid);
del_node(n->nodeid);
cpglock_members_removed++;
free(n);
break;
} else {
- cpgl_debug("DUPE NODE %d LEFT (%u != %u)\n",
+ logt_print(LOG_DEBUG, "DUPE NODE %d LEFT (%u != %u)\n",
n->nodeid, n->pid, left[x].pid);
}
}
@@ -1241,11 +1247,11 @@ cpg_config_change(cpg_handle_t h,
total_members = 0;
#if 0
- cpgl_debug("MEMBERS:");
+ logt_print(LOG_DEBUG, "MEMBERS:");
list_for(&group_members, n, y) {
- cpgl_debug(" %d.%u", n->nodeid, n->pid);
+ logt_print(LOG_DEBUG, " %d.%u", n->nodeid, n->pid);
}
- cpgl_debug("\n");
+ logt_print(LOG_DEBUG, "\n");
#endif
return;
@@ -1336,6 +1342,35 @@ cpg_init(void)
return 0;
}
+static void init_logging(int reconf)
+{
+ int ccs_handle;
+ int mode = LOG_MODE_OUTPUT_FILE | LOG_MODE_OUTPUT_SYSLOG;
+ int syslog_facility = SYSLOGFACILITY;
+ int syslog_priority = SYSLOGLEVEL;
+ char logfile[PATH_MAX];
+ int logfile_priority = SYSLOGLEVEL;
+ int debug = 0;
+
+ memset(logfile, 0, PATH_MAX);
+ snprintf(logfile, sizeof(logfile) - 1, LOGDIR "/cpglockd.log");
+
+ ccs_handle = ccs_connect();
+ if (ccs_handle > 0) {
+ ccs_read_logging(ccs_handle, "cpglockd", &debug, &mode,
+ &syslog_facility, &syslog_priority, &logfile_priority, logfile);
+ ccs_disconnect(ccs_handle);
+ }
+
+ if (nofork)
+ mode |= LOG_MODE_OUTPUT_STDERR;
+
+ if (!reconf)
+ logt_init("cpglockd", mode, syslog_facility, syslog_priority, logfile_priority, logfile);
+ else
+ logt_conf("cpglockd", mode, syslog_facility, syslog_priority, logfile_priority, logfile);
+}
+
int
main(int argc, char **argv)
{
@@ -1345,7 +1380,6 @@ main(int argc, char **argv)
int afd = -1;
int cman_fd;
int n,x;
- int nofork = 0;
int wait_for_quorum = 1;
int wait_for_fencing = 1;
int opt;
@@ -1391,6 +1425,7 @@ main(int argc, char **argv)
}
update_pidfile((char *) "cpglockd");
}
+ init_logging(0);
setup_signal(SIGPIPE, SIG_IGN);
setup_signal(SIGTERM, flag_shutdown);
@@ -1520,7 +1555,7 @@ main(int argc, char **argv)
ret = fenced_node_info(pf_node->nodeid, &fn);
if (ret < 0) {
- cpgl_debug("Unable to get last fenced time for node %d\n",
+ logt_print(LOG_DEBUG, "Unable to get last fenced time for node %d\n",
pf_node->nodeid);
victim = 1;
lft = 0;
@@ -1530,7 +1565,7 @@ main(int argc, char **argv)
}
if (lft > pf_node->fail_time) {
- cpgl_debug("Fencing for node %d finished at %ld (>%ld)\n",
+ logt_print(LOG_DEBUG, "Fencing for node %d finished at %ld (>%ld)\n",
pf_node->nodeid, lft, pf_node->fail_time);
list_remove(&pending_fencing, pf_node);
free(pf_node);
@@ -1554,18 +1589,18 @@ main(int argc, char **argv)
do {
usleep(250000);
if (fenced_node_info(pf_node->nodeid, &fn) < 0) {
- cpgl_debug("Unable to get fenced data for node %d\n",
+ logt_print(LOG_DEBUG, "Unable to get fenced data for node %d\n",
pf_node->nodeid);
} else
victim = fn.victim;
} while (!victim && retries++ < 4);
if (!victim) {
- cpgl_debug("First entry in list and victim == 0, removing %d from pending fencing\n", pf_node->nodeid);
+ logt_print(LOG_DEBUG, "First entry in list and victim == 0, removing %d from pending fencing\n", pf_node->nodeid);
list_remove(&pending_fencing, pf_node);
free(pf_node);
} else {
- cpgl_debug("fenced_node.victim flipped to 1 for %d\n",
+ logt_print(LOG_DEBUG, "fenced_node.victim flipped to 1 for %d\n",
pf_node->nodeid);
}
goto fence_check;
@@ -1604,7 +1639,7 @@ main(int argc, char **argv)
continue;
--n;
if (read_retry(client->fd, &m, sizeof(m), NULL) < 0) {
- cpgl_debug("Closing client fd %d pid %d: %d\n",
+ logt_print(LOG_DEBUG, "Closing client fd %d pid %d: %d\n",
client->fd, client->pid, errno);
del_client(client->fd);
@@ -1619,7 +1654,7 @@ main(int argc, char **argv)
}
if (m.request == MSG_UNLOCK) {
- //cpgl_debug("Unlock from fd %d\n", client->fd);
+ //logt_print(LOG_DEBUG, "Unlock from fd %d\n", client->fd);
find_lock(&m);
if (grant_next(&m) == 0)
send_unlock(&m);
12 years, 1 month
cluster: RHEL6 - cpglockd: make network comm endian free
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 1e1c4989fcb4e3a447deed560cda823be7535296
Parent: 5234c99004f03016aeade7ab3c950fd7bd450f31
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue Apr 24 14:55:01 2012 +0200
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Tue May 1 10:58:25 2012 -0400
cpglockd: make network comm endian free
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
Reviewed-by: Lon Hohberger <lhh(a)redhat.com>
Reviewed-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/include/cpglock-internal.h | 6 +++---
rgmanager/src/daemons/cpglockd.c | 15 +++++++++++++++
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/rgmanager/include/cpglock-internal.h b/rgmanager/include/cpglock-internal.h
index 25725c6..904df37 100644
--- a/rgmanager/include/cpglock-internal.h
+++ b/rgmanager/include/cpglock-internal.h
@@ -26,16 +26,16 @@ typedef enum {
} cpg_lock_req_t;
/* Mixed architecture not supported yet */
-struct __attribute__((packed)) cpg_lock_msg {
- char resource[96];
+struct cpg_lock_msg {
int32_t request;
uint32_t owner_nodeid;
uint32_t owner_pid;
uint32_t flags;
uint32_t lockid;
uint32_t owner_tid;
+ char resource[96];
char pad[8];
-}; /* 128 */
+} __attribute__((packed)); /* 128 */
#define CPG_LOCKD_NAME "cpglockd"
diff --git a/rgmanager/src/daemons/cpglockd.c b/rgmanager/src/daemons/cpglockd.c
index 1bd53d3..aa052b3 100644
--- a/rgmanager/src/daemons/cpglockd.c
+++ b/rgmanager/src/daemons/cpglockd.c
@@ -24,6 +24,7 @@
#include "cpglock.h"
#include "cpglock-internal.h"
#include "list.h"
+#include "platform.h"
struct request_node {
list_head();
@@ -398,6 +399,16 @@ insert_client(int fd)
list_append(&clients, n);
}
+static void
+swab_cpg_lock_msg(struct cpg_lock_msg *m)
+{
+ swab32(m->request);
+ swab32(m->owner_nodeid);
+ swab32(m->owner_pid);
+ swab32(m->flags);
+ swab32(m->lockid);
+ swab32(m->owner_tid);
+}
/* forward request from client */
static int
@@ -406,6 +417,8 @@ send_lock_msg(struct cpg_lock_msg *m)
struct iovec iov;
int ret;
+ swab_cpg_lock_msg(m);
+
iov.iov_base = m;
iov.iov_len = sizeof (*m);
@@ -1096,6 +1109,8 @@ process_join(struct cpg_lock_msg *m, uint32_t nodeid, uint32_t pid)
static int
process_request(struct cpg_lock_msg *m, uint32_t nodeid, uint32_t pid)
{
+ swab_cpg_lock_msg(m);
+
if (m->request == MSG_HALT) {
cpgl_debug("FAULT: Halting operations; see node %d\n", m->owner_nodeid);
while (1)
12 years, 1 month
cluster: RHEL6 - Clean up the pid file when exiting after running with -f
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 9757156c569b05517cdc6173e334f22829e07854
Parent: 1e1c4989fcb4e3a447deed560cda823be7535296
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Tue Apr 24 09:16:31 2012 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Tue May 1 10:58:33 2012 -0400
Clean up the pid file when exiting after running with -f
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
Reviewed-by: Lon Hohberger <lhh(a)redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
rgmanager/src/daemons/cpglockd.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/rgmanager/src/daemons/cpglockd.c b/rgmanager/src/daemons/cpglockd.c
index aa052b3..9f9f635 100644
--- a/rgmanager/src/daemons/cpglockd.c
+++ b/rgmanager/src/daemons/cpglockd.c
@@ -1649,7 +1649,6 @@ out2:
out3:
cman_finish(cman_handle);
out4:
- if (!nofork)
- daemon_cleanup();
+ daemon_cleanup();
return exit_status;
}
12 years, 1 month
cluster: RHEL6 - cpglock: drop unused define
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 5234c99004f03016aeade7ab3c950fd7bd450f31
Parent: d03d3719d96f2c2a36d53e08e32e38aa830d8672
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue Apr 24 14:36:50 2012 +0200
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Tue May 1 10:58:16 2012 -0400
cpglock: drop unused define
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
Reviewed-by: Lon Hohberger <lhh(a)redhat.com>
Reviewed-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/include/cpglock-internal.h | 2 --
rgmanager/src/clulib/libcpglock.c | 1 -
2 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/rgmanager/include/cpglock-internal.h b/rgmanager/include/cpglock-internal.h
index d6734eb..25725c6 100644
--- a/rgmanager/include/cpglock-internal.h
+++ b/rgmanager/include/cpglock-internal.h
@@ -37,8 +37,6 @@ struct __attribute__((packed)) cpg_lock_msg {
char pad[8];
}; /* 128 */
-pid_t _gettid (void);
-
#define CPG_LOCKD_NAME "cpglockd"
#endif
diff --git a/rgmanager/src/clulib/libcpglock.c b/rgmanager/src/clulib/libcpglock.c
index 9fe5ead..d554281 100644
--- a/rgmanager/src/clulib/libcpglock.c
+++ b/rgmanager/src/clulib/libcpglock.c
@@ -226,7 +226,6 @@ cpg_unlock(void *handle, struct cpg_lock *lock)
l.owner_nodeid = lock->owner_nodeid;
l.owner_pid = lock->owner_pid;
l.lockid = lock->local_id;
- //l.owner_tid = _gettid();
l.owner_tid = 0;
lock->state = LOCK_FREE;
12 years, 1 month
cluster: RHEL6 - rgmanager: cleanup binary linking and include dirs
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: d03d3719d96f2c2a36d53e08e32e38aa830d8672
Parent: e114e9ad6579674555bfa019a29189b0a771bfe0
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue Apr 24 13:51:36 2012 +0200
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Tue May 1 10:58:04 2012 -0400
rgmanager: cleanup binary linking and include dirs
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
Reviewed-by: Lon Hohberger <lhh(a)redhat.com>
Reviewed-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/daemons/Makefile | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/rgmanager/src/daemons/Makefile b/rgmanager/src/daemons/Makefile
index 336b6cf..d125eaa 100644
--- a/rgmanager/src/daemons/Makefile
+++ b/rgmanager/src/daemons/Makefile
@@ -49,7 +49,8 @@ OBJS5= cpglockdump.o
CFLAGS += -DSHAREDIR=\"${sharedir}\" -D_GNU_SOURCE
CFLAGS += -fPIC
-CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${dlmincdir} -I${logtincdir}
+CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${corosyncincdir}
+CFLAGS += -I${dlmincdir} -I${fencedincdir} -I${logtincdir}
CFLAGS += `xml2-config --cflags` -I${slangincdir}
CFLAGS += -I$(S)/../../include
CFLAGS += -I${incdir}
@@ -63,8 +64,8 @@ CCS_LDFLAGS += -L${ccslibdir} -lccs
CMAN_LDFLAGS += -L${cmanlibdir} -lcman
LOGSYS_LDFLAGS += -L${logtlibdir} -llogthread
DLM_LDFLAGS += -L${dlmlibdir} -ldlm
-CPG_LDFLAGS += -lcpg
-FENCED_LDFLAGS += -lfenced
+CPG_LDFLAGS += -L${corosynclibdir} -lcpg
+FENCED_LDFLAGS += -L${fencedlibdir} -lfenced
XML2_LDFLAGS += `xml2-config --libs`
SLANG_LDFLAGS += -L${slanglibdir} -lslang
EXTRA_LDFLAGS += -lpthread
12 years, 1 month
cluster: RHEL6 - cpglockd: fix a startup race condition
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: e114e9ad6579674555bfa019a29189b0a771bfe0
Parent: 66c89c1bbedd2217b199e76814960aae97d6b0fe
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue Apr 24 12:07:25 2012 +0200
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Tue May 1 10:57:48 2012 -0400
cpglockd: fix a startup race condition
[root@clusternet-node1 shm]# cpglockd -f
nodeid 1 already in group with PID 8126 8126
Unable to join CPG group
in some cases the cpg membership is updated between
cpglockd joining and cpglockd requesting current membership,
triggering the above error incorrectly.
check if the pids are the same, we can be rather sure
that it's us (given previous fix for startup pid/lock check)
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
Reviewed-by: Lon Hohberger <lhh(a)redhat.com>
Reviewed-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/daemons/cpglockd.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/rgmanager/src/daemons/cpglockd.c b/rgmanager/src/daemons/cpglockd.c
index 5b6ea79..1bd53d3 100644
--- a/rgmanager/src/daemons/cpglockd.c
+++ b/rgmanager/src/daemons/cpglockd.c
@@ -1309,10 +1309,12 @@ cpg_init(void)
for (i = 0 ; i < cpg_member_list_len ; i++) {
if (member_list[i].nodeid == my_node_id) {
- fprintf(stderr, "nodeid %d already in group with PID %u\n",
- member_list[i].nodeid, member_list[i].pid);
- cpg_fin();
- return -1;
+ if (member_list[i].pid != getpid()) {
+ fprintf(stderr, "nodeid %d already in group with PID %u %u\n",
+ member_list[i].nodeid, member_list[i].pid, getpid());
+ cpg_fin();
+ return -1;
+ }
}
}
12 years, 1 month
cluster: RHEL6 - cpglockd: fix pid file creation and check if daemon is already running
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 66c89c1bbedd2217b199e76814960aae97d6b0fe
Parent: 682b27fe673efc20b65e0ea97ea23f72574eb81b
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue Apr 24 12:03:37 2012 +0200
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Tue May 1 10:57:40 2012 -0400
cpglockd: fix pid file creation and check if daemon is already running
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
Reviewed-by: Lon Hohberger <lhh(a)redhat.com>
Reviewed-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/include/daemon_init.h | 1 +
rgmanager/src/clulib/daemon_init.c | 3 +--
rgmanager/src/daemons/cpglockd.c | 11 ++++++++++-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/rgmanager/include/daemon_init.h b/rgmanager/include/daemon_init.h
index 0252386..99e87c2 100644
--- a/rgmanager/include/daemon_init.h
+++ b/rgmanager/include/daemon_init.h
@@ -3,6 +3,7 @@
int check_pid_valid(pid_t pid, char *prog);
int check_process_running(char *prog, pid_t * pid);
+void update_pidfile(char *prog);
void daemon_init(char *prog);
void daemon_cleanup(void);
diff --git a/rgmanager/src/clulib/daemon_init.c b/rgmanager/src/clulib/daemon_init.c
index e9adeed..1a495d2 100644
--- a/rgmanager/src/clulib/daemon_init.c
+++ b/rgmanager/src/clulib/daemon_init.c
@@ -30,7 +30,6 @@
/*
* Local prototypes.
*/
-static void update_pidfile(char *prog);
static int setup_sigmask(void);
static char pid_filename[PATH_MAX];
@@ -139,7 +138,7 @@ check_process_running(char *prog, pid_t * pid)
}
-static void
+void
update_pidfile(char *prog)
{
FILE *fp = NULL;
diff --git a/rgmanager/src/daemons/cpglockd.c b/rgmanager/src/daemons/cpglockd.c
index 0cba6f3..5b6ea79 100644
--- a/rgmanager/src/daemons/cpglockd.c
+++ b/rgmanager/src/daemons/cpglockd.c
@@ -1363,8 +1363,17 @@ main(int argc, char **argv)
}
}
- if (!nofork)
+ if (!nofork) {
daemon_init((char *) "cpglockd");
+ } else {
+ pid_t pid;
+ if (check_process_running((char *) "cpglockd", &pid) && (pid != getpid())) {
+ fprintf(stderr,
+ "cpglockd is already running\n");
+ return -1;
+ }
+ update_pidfile((char *) "cpglockd");
+ }
setup_signal(SIGPIPE, SIG_IGN);
setup_signal(SIGTERM, flag_shutdown);
12 years, 1 month
cluster: RHEL6 - cpglockd: cleanup startup init scripts and drop code from rgmanager
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 682b27fe673efc20b65e0ea97ea23f72574eb81b
Parent: 5df73c4e049f3cc4f808e435e3c52668db28ec5a
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue Apr 24 11:38:50 2012 +0200
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Tue May 1 10:57:32 2012 -0400
cpglockd: cleanup startup init scripts and drop code from rgmanager
also fix conditionals to require or not cpglockd within rgmanager
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
Reviewed-by: Lon Hohberger <lhh(a)redhat.com>
Reviewed-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/include/cpglock-internal.h | 4 --
rgmanager/init.d/rgmanager.in | 18 +++++++-
rgmanager/src/daemons/main.c | 79 ++++++++++++----------------------
3 files changed, 44 insertions(+), 57 deletions(-)
diff --git a/rgmanager/include/cpglock-internal.h b/rgmanager/include/cpglock-internal.h
index 27917c7..d6734eb 100644
--- a/rgmanager/include/cpglock-internal.h
+++ b/rgmanager/include/cpglock-internal.h
@@ -11,10 +11,6 @@
#define CPG_LOCKD_SOCK "/var/run/cpglockd.sk"
#endif
-#ifndef CPGLOCKD_BIN_PATH
-# define CPGLOCKD_BIN_PATH "/usr/sbin/cpglockd"
-#endif
-
#include <stdint.h>
typedef enum {
diff --git a/rgmanager/init.d/rgmanager.in b/rgmanager/init.d/rgmanager.in
index 9e5a050..fcf7698 100644
--- a/rgmanager/init.d/rgmanager.in
+++ b/rgmanager/init.d/rgmanager.in
@@ -6,8 +6,8 @@
#
### BEGIN INIT INFO
# Provides: rgmanager
-# Required-Start: cman
-# Required-Stop: cman
+# Required-Start: cman cpglockd
+# Required-Stop: cman cpglockd
# Default-Start:
# Default-Stop:
# Short-Description: Starts and stops Red Hat Service (resource group) Manager
@@ -72,6 +72,15 @@ stop_cluster()
done
}
+#
+# start cpglock if necessary
+#
+start_cpglockd()
+{
+ rings="$(corosync-objctl 2>/dev/null |grep ringnumber | wc -l)"
+ [ "$rings" -gt "1" ] && service cpglockd start
+}
+
rtrn=0
if [ "$EUID" != "0" ]; then
@@ -89,6 +98,11 @@ start)
# required subdirectories for proper operations
mkdir -p /var/run/cluster
+ # failure to start cpglockd should not be fatal here
+ # rgmanager will take care to report the correct errors
+ # later
+ start_cpglockd || true
+
if status $RGMGRD > /dev/null 2>&1; then
success
else
diff --git a/rgmanager/src/daemons/main.c b/rgmanager/src/daemons/main.c
index 3dc0e8a..e55e15e 100644
--- a/rgmanager/src/daemons/main.c
+++ b/rgmanager/src/daemons/main.c
@@ -794,73 +794,43 @@ statedump(int __attribute__ ((unused)) sig)
signalled++;
}
+/*
+ * return -1 on error
+ * 0 cpglock is not needed
+ * 1 cpglock is needed
+ */
static int
cpglockd_needed(void)
{
char *v;
int ccsfd;
- int start_cpglockd = 0;
-
+ int need = 0;
ccsfd = ccs_force_connect(NULL, 0);
if (ccsfd < 0)
return -1;
- if (ccs_get(ccsfd, "/cluster/cman/altmulticast/@addr", &v) == 0) {
- if (v != NULL) {
- int ret;
- free(v);
- ret = ccs_get(ccsfd,
- "/cluster/clusternodes/clusternode/altname/@name", &v);
- if (ret == 0) {
- if (v != NULL) {
- free(v);
- start_cpglockd = 1;
- }
- }
+ if (ccs_get(ccsfd,
+ "/cluster/clusternodes/clusternode/altname/@name", &v) == 0) {
+ if (v) {
+ need = 1;
+ free(v);
}
}
- if (start_cpglockd) {
+ if (need) {
if (ccs_get(ccsfd, "/cluster/totem/@rrp_mode", &v) == 0) {
if (v != NULL) {
- if (!strcasecmp(v, "none"))
- start_cpglockd = 0;
+ if (!strcasecmp(v, "none")) {
+ need = 0;
+ }
free(v);
}
}
}
ccs_disconnect(ccsfd);
- return start_cpglockd;
-}
-
-static int
-cpglockd_start(void) {
- int pid;
- int status;
-
- pid = fork();
- if (pid == -1)
- return -1;
-
- if (pid) {
- waitpid(pid, &status, 0);
- if (!WIFEXITED(status) || WEXITSTATUS(status)) {
- logt_print(LOG_NOTICE, "Unable to start cpglockd\n");
- return -1;
- }
- } else {
- int i;
-
- for (i = 3 ; i < __FD_SETSIZE ; i++)
- close(i);
-
- execl(CPGLOCKD_BIN_PATH, "cpglockd", NULL);
- exit(-1);
- }
-
- return 0;
+ return need;
}
static int
@@ -1143,11 +1113,18 @@ main(int argc, char **argv)
}
xmlInitParser();
- if (cpg_lock_opt == 1 || (cpg_lock_opt != -1 && cpglockd_needed() == 1)) {
- cpglockd_start();
+
+ cpg_locks = 0;
+ if (cpg_lock_opt == 1) { /* force enable */
cpg_locks = 1;
- } else
- cpg_locks = 0;
+ } else if (cpg_lock_opt == 0) { /* autodetect */
+ cpg_locks = cpglockd_needed();
+ if (cpg_locks < 0) {
+ printf("Unable to determine if cpglock is required!\n");
+ cman_finish(clu);
+ return -1;
+ }
+ }
if (!cpg_locks) {
if (clu_lock_init(rgmanager_lsname) != 0) {
@@ -1156,12 +1133,12 @@ main(int argc, char **argv)
return -1;
}
} else {
+ logt_print(LOG_INFO, "Using CPG for locking (EXPERIMENTAL)\n");
if (cpg_lock_initialize() != 0) {
printf("Locks not working!\n");
cman_finish(clu);
return -1;
}
- logt_print(LOG_INFO, "Using CPG for locking (EXPERIMENTAL)\n");
}
memset(&me, 0, sizeof(me));
12 years, 1 month
cluster: RHEL6 - Cleanup the Makefile and add support to the cpglockd init script for options set in /etc/sysconfig/cpglockd
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 5df73c4e049f3cc4f808e435e3c52668db28ec5a
Parent: 79b02f3654e438a216cdb86ccda735b83563fe00
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Mon Apr 23 22:09:44 2012 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Tue May 1 10:57:28 2012 -0400
Cleanup the Makefile and add support to the cpglockd init script for options set in /etc/sysconfig/cpglockd
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
Reviewed-by: Lon Hohberger <lhh(a)redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
rgmanager/init.d/Makefile | 19 ++++++-------------
rgmanager/init.d/cpglockd.in | 5 +++++
rgmanager/init.d/cpglockd.init.defaults.in | 7 +++++++
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/rgmanager/init.d/Makefile b/rgmanager/init.d/Makefile
index 7346884..959ddb3 100644
--- a/rgmanager/init.d/Makefile
+++ b/rgmanager/init.d/Makefile
@@ -1,26 +1,19 @@
-TARGET1=rgmanager
-TARGET2=cpglockd
+TARGET=rgmanager cpglockd cpglockd.init.defaults
-INITDT=$(TARGET1) $(TARGET2)
+INITDT=rgmanager cpglockd
-all: $(TARGET1) $(TARGET2)
+all: $(TARGET)
include ../../make/defines.mk
include $(OBJDIR)/make/clean.mk
include $(OBJDIR)/make/install.mk
include $(OBJDIR)/make/uninstall.mk
-$(TARGET1): $(S)/$(TARGET1).in
- cat $(S)/$(TARGET1).in | sed \
+%: $(S)/%.in
+ cat $^ | sed \
-e 's#@SBINDIR@#${sbindir}#g' \
-e 's#@INITDDIR@#${initddir}#g' \
- > $(TARGET1)
-
-$(TARGET2): $(S)/$(TARGET2).in
- cat $(S)/$(TARGET2).in | sed \
- -e 's#@SBINDIR@#${sbindir}#g' \
- -e 's#@INITDDIR@#${initddir}#g' \
- > $(TARGET2)
+ > $@
clean: generalclean
diff --git a/rgmanager/init.d/cpglockd.in b/rgmanager/init.d/cpglockd.in
index 9fbb43c..772e0e8 100644
--- a/rgmanager/init.d/cpglockd.in
+++ b/rgmanager/init.d/cpglockd.in
@@ -59,6 +59,9 @@ if [ -d /etc/default ]; then
[ -z "$LOCK_FILE" ] && LOCK_FILE="/var/lock/cpglockd"
fi
+[ -z "$CPGLOCKD_WAIT_FOR_QUORUM" ] && CPGLOCKD_WAIT_FOR_QUORUM="yes"
+[ -z "$CPGLOCKD_WAIT_FOR_FENCE_JOIN" ] && CPGLOCKD_WAIT_FOR_FENCE_JOIN="yes"
+
#
# Stop cpglockd
#
@@ -83,6 +86,8 @@ start)
# they also assume that init scripts will create
# required subdirectories for proper operations
mkdir -p /var/run/cluster
+ [ "$CPGLOCKD_WAIT_FOR_QUORUM" = "no" ] && CPGLOCKD_OPTS+=" -Q"
+ [ "$CPGLOCKD_WAIT_FOR_FENCE_JOIN" = "no" ] && CPGLOCKD_OPTS+=" -F"
if status $CPGLOCKD > /dev/null 2>&1; then
success
diff --git a/rgmanager/init.d/cpglockd.init.defaults.in b/rgmanager/init.d/cpglockd.init.defaults.in
new file mode 100644
index 0000000..29caf27
--- /dev/null
+++ b/rgmanager/init.d/cpglockd.init.defaults.in
@@ -0,0 +1,7 @@
+# CPGLOCKD_WAIT_FOR_QUORUM -- Wait for cluster quorum formation
+# at startup.
+#CPGLOCKD_WAIT_FOR_QUORUM=yes
+#
+# CPGLOCKD_WAIT_FOR_FENCE_JOIN -- Wait for the current node to join the
+# fence domain at startup.
+#CPGLOCKD_WAIT_FOR_FENCE_JOIN=yes
12 years, 1 month
cluster: RHEL6 - Update Makefile for cpglockd init script
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 79b02f3654e438a216cdb86ccda735b83563fe00
Parent: a3efdc591c273acde2e790241b3200d79eb711f1
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Mon Apr 23 18:27:55 2012 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Tue May 1 10:57:18 2012 -0400
Update Makefile for cpglockd init script
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
Reviewed-by: Lon Hohberger <lhh(a)redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
rgmanager/init.d/Makefile | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/rgmanager/init.d/Makefile b/rgmanager/init.d/Makefile
index 4c9a44f..7346884 100644
--- a/rgmanager/init.d/Makefile
+++ b/rgmanager/init.d/Makefile
@@ -1,19 +1,26 @@
-TARGET= rgmanager
+TARGET1=rgmanager
+TARGET2=cpglockd
-INITDT=$(TARGET)
+INITDT=$(TARGET1) $(TARGET2)
-all: $(TARGET)
+all: $(TARGET1) $(TARGET2)
include ../../make/defines.mk
include $(OBJDIR)/make/clean.mk
include $(OBJDIR)/make/install.mk
include $(OBJDIR)/make/uninstall.mk
-$(TARGET): $(S)/$(TARGET).in
- cat $(S)/$(TARGET).in | sed \
+$(TARGET1): $(S)/$(TARGET1).in
+ cat $(S)/$(TARGET1).in | sed \
-e 's#@SBINDIR@#${sbindir}#g' \
-e 's#@INITDDIR@#${initddir}#g' \
- > $(TARGET)
+ > $(TARGET1)
+
+$(TARGET2): $(S)/$(TARGET2).in
+ cat $(S)/$(TARGET2).in | sed \
+ -e 's#@SBINDIR@#${sbindir}#g' \
+ -e 's#@INITDDIR@#${initddir}#g' \
+ > $(TARGET2)
clean: generalclean
12 years, 1 month