dlm: master - dlm_controld: move cluster times out of lockspace structs
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=d218916f...
Commit: d218916fd8a4132d2b4df8b7853ad419b3538637
Parent: 1409a84a8a56ce77c86cbc1458aa44ea43844e98
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Oct 7 15:22:48 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Oct 7 15:22:48 2011 -0500
dlm_controld: move cluster times out of lockspace structs
more sense to keep it in a single spot
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/cpg.c | 81 +++++++++++++------------------------------
dlm_controld/dlm_daemon.h | 4 +--
dlm_controld/member_cman.c | 71 +++++++++++++++++++++++++++++++++++++--
3 files changed, 94 insertions(+), 62 deletions(-)
diff --git a/dlm_controld/cpg.c b/dlm_controld/cpg.c
index 24e82b5..4dc2bc2 100644
--- a/dlm_controld/cpg.c
+++ b/dlm_controld/cpg.c
@@ -57,10 +57,6 @@ struct node {
struct list_head list;
int nodeid;
- uint64_t cluster_add_time;
- uint64_t cluster_rem_time;
- int cluster_member;
-
uint64_t lockspace_add_time;
uint64_t lockspace_rem_time;
uint64_t lockspace_fail_time;
@@ -481,40 +477,8 @@ static struct node *get_node_history_create(struct lockspace *ls, int nodeid)
return node;
}
-void node_history_cluster_add(int nodeid)
-{
- struct lockspace *ls;
- struct node *node;
-
- list_for_each_entry(ls, &lockspaces, list) {
- node = get_node_history_create(ls, nodeid);
- if (!node) {
- log_error("node_history_cluster_add no nodeid %d", nodeid);
- return;
- }
- node->cluster_add_time = time(NULL);
- node->cluster_member = 1;
- }
-}
-
-void node_history_cluster_rem(int nodeid)
-{
- struct lockspace *ls;
- struct node *node;
-
- list_for_each_entry(ls, &lockspaces, list) {
- node = get_node_history(ls, nodeid);
- if (!node) {
- log_error("node_history_cluster_rem no nodeid %d", nodeid);
- return;
- }
- node->cluster_rem_time = time(NULL);
- node->cluster_member = 0;
- }
-}
-
static void node_history_lockspace_add(struct lockspace *ls, int nodeid,
- struct change *cg)
+ struct change *cg, uint64_t now)
{
struct node *node;
@@ -524,13 +488,13 @@ static void node_history_lockspace_add(struct lockspace *ls, int nodeid,
return;
}
- node->lockspace_add_time = time(NULL);
+ node->lockspace_add_time = now;
node->lockspace_add_seq = cg->seq;
node->lockspace_member = 1;
}
static void node_history_lockspace_left(struct lockspace *ls, int nodeid,
- struct change *cg)
+ struct change *cg, uint64_t now)
{
struct node *node;
@@ -542,13 +506,14 @@ static void node_history_lockspace_left(struct lockspace *ls, int nodeid,
node->start_time = 0;
- node->lockspace_rem_time = time(NULL);
+ node->lockspace_rem_time = now;
node->lockspace_rem_seq = cg->seq; /* for queries */
node->lockspace_member = 0;
}
static void node_history_lockspace_fail(struct lockspace *ls, int nodeid,
- struct change *cg, int reason)
+ struct change *cg, int reason,
+ uint64_t now)
{
struct node *node;
@@ -569,10 +534,10 @@ static void node_history_lockspace_fail(struct lockspace *ls, int nodeid,
node->check_fs = 1;
}
- node->lockspace_rem_time = time(NULL);
+ node->lockspace_rem_time = now;
node->lockspace_rem_seq = cg->seq; /* for queries */
node->lockspace_member = 0;
- node->lockspace_fail_time = node->lockspace_rem_time;
+ node->lockspace_fail_time = now;
node->lockspace_fail_seq = node->lockspace_rem_seq;
node->lockspace_fail_reason = reason; /* for queries */
}
@@ -596,13 +561,13 @@ static void node_history_start(struct lockspace *ls, int nodeid)
static int check_ringid_done(struct lockspace *ls)
{
if (cluster_ringid_seq != (uint32_t)ls->cpg_ringid.seq) {
- log_debug("check_ringid cluster %u cpg %u:%llu",
+ log_group(ls, "check_ringid cluster %u cpg %u:%llu",
cluster_ringid_seq, ls->cpg_ringid.nodeid,
(unsigned long long)ls->cpg_ringid.seq);
return 0;
}
- log_debug("check_ringid done cluster %u cpg %u:%llu",
+ log_group(ls, "check_ringid done cluster %u cpg %u:%llu",
cluster_ringid_seq, ls->cpg_ringid.nodeid,
(unsigned long long)ls->cpg_ringid.seq);
return 1;
@@ -967,6 +932,7 @@ static int match_change(struct lockspace *ls, struct change *cg,
struct id_info *id;
struct member *memb;
struct node *node;
+ uint64_t t;
uint32_t seq = hd->msgdata;
int i, members_mismatch;
@@ -1012,11 +978,12 @@ static int match_change(struct lockspace *ls, struct change *cg,
return 0;
}
- if (node->cluster_add_time > cg->create_time) {
+ t = cluster_add_time(node->nodeid);
+ if (t > cg->create_time) {
log_group(ls, "match_change %d:%u skip cg %u created %llu "
"cluster add %llu", hd->nodeid, seq, cg->seq,
(unsigned long long)cg->create_time,
- (unsigned long long)node->cluster_add_time);
+ (unsigned long long)t);
return 0;
}
@@ -1448,6 +1415,7 @@ static int add_change(struct lockspace *ls,
struct change *cg;
struct member *memb;
int i, error;
+ uint64_t now = time(NULL);
cg = malloc(sizeof(struct change));
if (!cg)
@@ -1456,7 +1424,7 @@ static int add_change(struct lockspace *ls,
INIT_LIST_HEAD(&cg->members);
INIT_LIST_HEAD(&cg->removed);
cg->state = CGST_WAIT_CONDITIONS;
- cg->create_time = time(NULL);
+ cg->create_time = now;
cg->seq = ++ls->change_seq;
if (!cg->seq)
cg->seq = ++ls->change_seq;
@@ -1489,9 +1457,9 @@ static int add_change(struct lockspace *ls,
if (memb->failed) {
node_history_lockspace_fail(ls, memb->nodeid, cg,
- left_list[i].reason);
+ left_list[i].reason, now);
} else {
- node_history_lockspace_left(ls, memb->nodeid, cg);
+ node_history_lockspace_left(ls, memb->nodeid, cg, now);
}
log_group(ls, "add_change cg %u remove nodeid %d reason %d",
@@ -1513,7 +1481,7 @@ static int add_change(struct lockspace *ls,
if (memb->nodeid == our_nodeid) {
cg->we_joined = 1;
} else {
- node_history_lockspace_add(ls, memb->nodeid, cg);
+ node_history_lockspace_add(ls, memb->nodeid, cg, now);
}
log_group(ls, "add_change cg %u joined nodeid %d", cg->seq,
@@ -1523,7 +1491,7 @@ static int add_change(struct lockspace *ls,
if (cg->we_joined) {
log_group(ls, "add_change cg %u we joined", cg->seq);
list_for_each_entry(memb, &cg->members, list) {
- node_history_lockspace_add(ls, memb->nodeid, cg);
+ node_history_lockspace_add(ls, memb->nodeid, cg, now);
}
}
@@ -2005,12 +1973,12 @@ static void add_node_daemon(int nodeid)
if (get_node_daemon(nodeid))
return;
- node = malloc(sizeof(struct node));
+ node = malloc(sizeof(struct node_daemon));
if (!node) {
log_error("add_node_daemon no mem");
return;
}
- memset(node, 0, sizeof(struct node));
+ memset(node, 0, sizeof(struct node_daemon));
node->nodeid = nodeid;
list_add_tail(&node->list, &daemon_nodes);
}
@@ -2450,6 +2418,7 @@ static void confchg_cb_daemon(cpg_handle_t handle,
size_t joined_list_entries)
{
struct node_daemon *node;
+ uint64_t now = time(NULL);
int i;
log_config(group_name, member_list, member_list_entries,
@@ -2475,7 +2444,7 @@ static void confchg_cb_daemon(cpg_handle_t handle,
/* node joined daemon cpg */
node->daemon_member = 1;
- node->daemon_add_time = time(NULL);
+ node->daemon_add_time = now;
} else {
if (!node->daemon_member)
continue;
@@ -2484,7 +2453,7 @@ static void confchg_cb_daemon(cpg_handle_t handle,
node->daemon_member = 0;
node->killed = 0;
memset(&node->proto, 0, sizeof(struct protocol));
- node->daemon_rem_time = time(NULL);
+ node->daemon_rem_time = now;
}
}
}
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 61bd78d..6129477 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -199,7 +199,6 @@ enum {
#define DLM_MFLG_HAVEPLOCK 2 /* accompanies start, we have plock state */
#define DLM_MFLG_NACK 4 /* accompanies start, prevent wrong match when
two outstanding changes are the same */
-#define DLM_MFLG_PLOCK_SIG 8 /* msgdata2 is a plock signature */
struct dlm_header {
uint16_t version[3];
@@ -294,8 +293,6 @@ int dlm_join_lockspace(struct lockspace *ls);
int dlm_leave_lockspace(struct lockspace *ls);
const char *msg_name(int type);
void update_flow_control_status(void);
-void node_history_cluster_add(int nodeid);
-void node_history_cluster_rem(int nodeid);
int set_node_info(struct lockspace *ls, int nodeid, struct dlmc_node *node);
int set_lockspace_info(struct lockspace *ls, struct dlmc_lockspace *lockspace);
int set_lockspaces(int *count, struct dlmc_lockspace **lss_out);
@@ -338,6 +335,7 @@ int setup_cluster(void);
void close_cluster(void);
void process_cluster(int ci);
void update_cluster(void);
+uint64_t cluster_add_time(int nodeid);
int is_cluster_member(uint32_t nodeid);
int setup_cluster_cfg(void);
void close_cluster_cfg(void);
diff --git a/dlm_controld/member_cman.c b/dlm_controld/member_cman.c
index ec005c3..f7a099c 100644
--- a/dlm_controld/member_cman.c
+++ b/dlm_controld/member_cman.c
@@ -18,6 +18,68 @@ static uint32_t old_nodes[MAX_NODES];
static int old_node_count;
static uint32_t quorum_nodes[MAX_NODES];
static int quorum_node_count;
+static struct list_head cluster_nodes;
+
+struct node_cluster {
+ struct list_head list;
+ int nodeid;
+
+ uint64_t cluster_add_time;
+ uint64_t cluster_rem_time;
+};
+
+static struct node_cluster *get_cluster_node(int nodeid, int create)
+{
+ struct node_cluster *node;
+
+ list_for_each_entry(node, &cluster_nodes, list) {
+ if (node->nodeid == nodeid)
+ return node;
+ }
+
+ if (!create)
+ return NULL;
+
+ node = malloc(sizeof(struct node_cluster));
+ if (!node)
+ return NULL;
+
+ memset(node, 0, sizeof(struct node_cluster));
+ node->nodeid = nodeid;
+ list_add(&node->list, &cluster_nodes);
+ return node;
+}
+
+static void add_cluster_node(int nodeid, uint64_t now)
+{
+ struct node_cluster *node;
+
+ node = get_cluster_node(nodeid, 1);
+ if (!node)
+ return;
+ node->cluster_add_time = now;
+}
+
+static void rem_cluster_node(int nodeid, uint64_t now)
+{
+ struct node_cluster *node;
+
+ node = get_cluster_node(nodeid, 0);
+ if (!node)
+ return;
+ node->cluster_rem_time = now;
+}
+
+uint64_t cluster_add_time(int nodeid)
+{
+ struct node_cluster *node;
+
+ node = get_cluster_node(nodeid, 0);
+ if (!node)
+ return 0;
+
+ return node->cluster_add_time;
+}
static int is_member(uint32_t *node_list, int count, uint32_t nodeid)
{
@@ -48,9 +110,10 @@ static void quorum_callback(quorum_handle_t h, uint32_t quorate,
corosync_cfg_node_address_t *addrptr = addrs;
cs_error_t err;
int i, j, num_addrs;
+ uint64_t now = time(NULL);
if (!cluster_quorate && quorate)
- quorate_time = time(NULL);
+ quorate_time = now;
cluster_quorate = quorate;
cluster_ringid_seq = (uint32_t)ring_seq;
@@ -71,7 +134,7 @@ static void quorum_callback(quorum_handle_t h, uint32_t quorate,
if (!is_cluster_member(old_nodes[i])) {
log_debug("cluster node %u removed seq %u",
old_nodes[i], cluster_ringid_seq);
- node_history_cluster_rem(old_nodes[i]);
+ rem_cluster_node(old_nodes[i], now);
del_configfs_node(old_nodes[i]);
}
}
@@ -80,7 +143,7 @@ static void quorum_callback(quorum_handle_t h, uint32_t quorate,
if (!is_old_member(quorum_nodes[i])) {
log_debug("cluster node %u added seq %u",
quorum_nodes[i], cluster_ringid_seq);
- node_history_cluster_add(quorum_nodes[i]);
+ add_cluster_node(quorum_nodes[i], now);
err = corosync_cfg_get_node_addrs(ch, quorum_nodes[i],
MAX_NODE_ADDRESSES,
@@ -131,6 +194,8 @@ int setup_cluster(void)
cs_error_t err;
int fd;
+ INIT_LIST_HEAD(&cluster_nodes);
+
err = quorum_initialize(&qh, &quorum_callbacks);
if (err != CS_OK) {
log_error("quorum init error %d", err);
12 years, 7 months
dlm: master - dlm_controld: keep track of ringid and stateful
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=1409a84a...
Commit: 1409a84a8a56ce77c86cbc1458aa44ea43844e98
Parent: 90bf062ed3f8d89f27046ef2c4216bd6e6cc9c49
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Oct 6 17:08:08 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 6 17:08:08 2011 -0500
dlm_controld: keep track of ringid and stateful
copy some code from fenced for keeping track of ringid
and stateful merges
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/cpg.c | 291 +++++++++++++++++++++++++++++++++++---------
dlm_controld/dlm_daemon.h | 4 +-
dlm_controld/member_cman.c | 2 +
3 files changed, 236 insertions(+), 61 deletions(-)
diff --git a/dlm_controld/cpg.c b/dlm_controld/cpg.c
index fa328d0..24e82b5 100644
--- a/dlm_controld/cpg.c
+++ b/dlm_controld/cpg.c
@@ -8,6 +8,8 @@
#include "dlm_daemon.h"
+#define PV_STATEFUL 0x0001
+
struct protocol_version {
uint16_t major;
uint16_t minor;
@@ -40,6 +42,12 @@ struct node_daemon {
struct list_head list;
int nodeid;
+ uint64_t daemon_add_time;
+ uint64_t daemon_rem_time;
+ int daemon_member;
+
+ int killed;
+
struct protocol proto;
};
@@ -58,17 +66,16 @@ struct node {
uint64_t lockspace_fail_time;
uint32_t lockspace_add_seq;
uint32_t lockspace_rem_seq;
+ uint32_t lockspace_fail_seq;
int lockspace_member;
int lockspace_fail_reason;
uint64_t start_time;
- int check_fencing;
- int check_quorum;
int check_fs;
-
int fs_notified;
+ int check_fencing;
uint64_t fence_time; /* for debug */
uint32_t fence_queries; /* for debug */
};
@@ -183,6 +190,32 @@ static void log_config(const struct cpg_name *group_name,
m_buf, j_buf, l_buf);
}
+static void log_ringid(const char *name,
+ struct cpg_ring_id *ringid,
+ const uint32_t *member_list,
+ size_t member_list_entries)
+{
+ char m_buf[128];
+ size_t i, len, pos;
+ int ret;
+
+ memset(m_buf, 0, sizeof(m_buf));
+
+ len = sizeof(m_buf);
+ pos = 0;
+ for (i = 0; i < member_list_entries; i++) {
+ ret = snprintf(m_buf + pos, len - pos, " %u",
+ member_list[i]);
+ if (ret >= len - pos)
+ break;
+ pos += ret;
+ }
+
+ log_debug("%s ring %u:%llu %zu memb%s",
+ name, ringid->nodeid, (unsigned long long)ringid->seq,
+ member_list_entries, m_buf);
+}
+
static void ls_info_in(struct ls_info *li)
{
li->ls_info_size = le32_to_cpu(li->ls_info_size);
@@ -531,12 +564,6 @@ static void node_history_lockspace_fail(struct lockspace *ls, int nodeid,
node->fence_queries = 0;
}
- /* fenced will take care of making sure the quorum value
- is adjusted for all the failures */
-
- if (cfgd_enable_quorum && !cfgd_enable_fencing)
- node->check_quorum = 1;
-
if (ls->fs_registered) {
log_group(ls, "check_fs nodeid %d set", nodeid);
node->check_fs = 1;
@@ -545,8 +572,9 @@ static void node_history_lockspace_fail(struct lockspace *ls, int nodeid,
node->lockspace_rem_time = time(NULL);
node->lockspace_rem_seq = cg->seq; /* for queries */
node->lockspace_member = 0;
- node->lockspace_fail_reason = reason; /* for queries */
node->lockspace_fail_time = node->lockspace_rem_time;
+ node->lockspace_fail_seq = node->lockspace_rem_seq;
+ node->lockspace_fail_reason = reason; /* for queries */
}
static void node_history_start(struct lockspace *ls, int nodeid)
@@ -562,6 +590,24 @@ static void node_history_start(struct lockspace *ls, int nodeid)
node->start_time = time(NULL);
}
+/* wait for cluster ringid and cpg ringid to be the same so we know our
+ information from each service is based on the same node state */
+
+static int check_ringid_done(struct lockspace *ls)
+{
+ if (cluster_ringid_seq != (uint32_t)ls->cpg_ringid.seq) {
+ log_debug("check_ringid cluster %u cpg %u:%llu",
+ cluster_ringid_seq, ls->cpg_ringid.nodeid,
+ (unsigned long long)ls->cpg_ringid.seq);
+ return 0;
+ }
+
+ log_debug("check_ringid done cluster %u cpg %u:%llu",
+ cluster_ringid_seq, ls->cpg_ringid.nodeid,
+ (unsigned long long)ls->cpg_ringid.seq);
+ return 1;
+}
+
static int check_fencing_done(struct lockspace *ls)
{
struct node *node;
@@ -635,42 +681,22 @@ static int check_fencing_done(struct lockspace *ls)
return 1;
}
+/* we know that the quorum value here is consistent with the cpg events
+ because the ringid's are in sync per the previous check_ringid_done */
+
static int check_quorum_done(struct lockspace *ls)
{
- struct node *node;
- int wait_count = 0;
-
if (!cfgd_enable_quorum) {
log_group(ls, "check_quorum disabled");
return 1;
}
- /* wait for quorum system (cman) to see all the same nodes failed, so
- we know that cluster_quorate is adjusted for the same failures we've
- seen (see comment in fenced about the assumption here) */
-
- list_for_each_entry(node, &ls->node_history, list) {
- if (!node->check_quorum)
- continue;
-
- if (!is_cluster_member(node->nodeid)) {
- node->check_quorum = 0;
- } else {
- log_group(ls, "check_quorum nodeid %d is_cluster_member",
- node->nodeid);
- wait_count++;
- }
- }
-
- if (wait_count)
- return 0;
-
if (!cluster_quorate) {
- log_group(ls, "check_quorum not quorate");
+ log_debug("check_quorum not quorate");
return 0;
}
- log_group(ls, "check_quorum done");
+ log_debug("check_quorum done");
return 1;
}
@@ -798,6 +824,11 @@ static void stop_kernel(struct lockspace *ls, uint32_t seq)
static int wait_conditions_done(struct lockspace *ls)
{
+ if (!check_ringid_done(ls)) {
+ poll_ringid++;
+ return 0;
+ }
+
/* the fencing/quorum/fs conditions need to account for all the changes
that have occured since the last change applied to dlm-kernel, not
just the latest change */
@@ -1235,6 +1266,11 @@ static void send_info(struct lockspace *ls, struct change *cg, int type,
free(buf);
}
+/* fenced used the DUPLICATE_CG flag instead of sending nacks like we
+ do here. I think the nacks didn't work for fenced for some reason,
+ but I don't remember why (possibly because the node blocked doing
+ the fencing hadn't created the cg to nack yet). */
+
static void send_start(struct lockspace *ls, struct change *cg)
{
log_group(ls, "send_start %d:%u counts %u %d %d %d %d",
@@ -1373,6 +1409,7 @@ static void apply_changes(struct lockspace *ls)
case CGST_WAIT_MESSAGES:
if (wait_messages_done(ls)) {
+ our_protocol.dr_ver.flags |= PV_STATEFUL;
start_kernel(ls);
prepare_plocks(ls);
cleanup_changes(ls);
@@ -1388,6 +1425,7 @@ void process_lockspace_changes(void)
{
struct lockspace *ls, *safe;
+ poll_ringid = 0;
poll_fencing = 0;
poll_quorum = 0;
poll_fs = 0;
@@ -1767,9 +1805,40 @@ static void deliver_cb(cpg_handle_t handle,
apply_changes(ls);
}
-static cpg_callbacks_t cpg_callbacks = {
+/* save ringid to compare with cman's.
+ also save member_list to double check with cman's member list?
+ they should match */
+
+static void totem_cb(cpg_handle_t handle,
+ struct cpg_ring_id ring_id,
+ uint32_t member_list_entries,
+ const uint32_t *member_list)
+{
+ struct lockspace *ls;
+ char name[128];
+
+ ls = find_ls_handle(handle);
+ if (!ls) {
+ log_error("totem_cb no lockspace for handle");
+ return;
+ }
+
+ memset(&name, 0, sizeof(name));
+ sprintf(name, "dlm:ls:%s", ls->name);
+
+ log_ringid(name, &ring_id, member_list, member_list_entries);
+
+ ls->cpg_ringid.nodeid = ring_id.nodeid;
+ ls->cpg_ringid.seq = ring_id.seq;
+
+ apply_changes(ls);
+}
+
+static cpg_model_v1_data_t cpg_callbacks = {
.cpg_deliver_fn = deliver_cb,
.cpg_confchg_fn = confchg_cb,
+ .cpg_totem_confchg_fn = totem_cb,
+ .flags = CPG_MODEL_V1_DELIVER_INITIAL_TOTEM_CONF,
};
void update_flow_control_status(void)
@@ -1834,9 +1903,10 @@ int dlm_join_lockspace(struct lockspace *ls)
goto fail_free;
}
- error = cpg_initialize(&h, &cpg_callbacks);
+ error = cpg_model_initialize(&h, CPG_MODEL_V1,
+ (cpg_model_data_t *)&cpg_callbacks, NULL);
if (error != CPG_OK) {
- log_error("cpg_initialize error %d", error);
+ log_error("cpg_model_initialize error %d", error);
rv = -1;
goto fail_free;
}
@@ -1861,6 +1931,7 @@ int dlm_join_lockspace(struct lockspace *ls)
/* TODO: allow global_id to be set in cluster.conf? */
ls->global_id = cpgname_to_crc(name.value, name.length);
+ log_debug("cpg_join %s ...", name.value);
retry:
error = cpg_join(h, &name);
if (error == CPG_ERR_TRY_AGAIN) {
@@ -2123,30 +2194,83 @@ static void receive_protocol(struct dlm_header *hd, int len)
return;
}
- /* if we have zero run values, and this msg has non-zero run values,
- then adopt them as ours; otherwise save this proto message */
+ /* save this node's proto so we can tell when we've got all, and
+ use it to select a minimum protocol from all */
- if (our_protocol.daemon_run[0])
+ node = get_node_daemon(hd->nodeid);
+ if (!node) {
+ log_error("receive_protocol no node %d", hd->nodeid);
return;
+ }
- if (p->daemon_run[0]) {
- memcpy(&our_protocol.daemon_run, &p->daemon_run,
- sizeof(struct protocol_version));
- memcpy(&our_protocol.kernel_run, &p->kernel_run,
- sizeof(struct protocol_version));
- log_debug("run protocol from nodeid %d", hd->nodeid);
+ if (!node->daemon_member) {
+ log_error("receive_protocol node %d not member", hd->nodeid);
return;
}
- /* save this node's proto so we can tell when we've got all, and
- use it to select a minimum protocol from all */
+ log_debug("receive_protocol from %d max %u.%u.%u.%x run %u.%u.%u.%x",
+ hd->nodeid,
+ p->daemon_max[0], p->daemon_max[1],
+ p->daemon_max[2], p->daemon_max[3],
+ p->daemon_run[0], p->daemon_run[1],
+ p->daemon_run[2], p->daemon_run[3]);
+ log_debug("daemon node %d max %u.%u.%u.%x run %u.%u.%u.%x",
+ hd->nodeid,
+ node->proto.daemon_max[0], node->proto.daemon_max[1],
+ node->proto.daemon_max[2], node->proto.daemon_max[3],
+ node->proto.daemon_run[0], node->proto.daemon_run[1],
+ node->proto.daemon_run[2], node->proto.daemon_run[3]);
+ log_debug("daemon node %d join %llu left %llu local quorum %llu",
+ hd->nodeid,
+ (unsigned long long)node->daemon_add_time,
+ (unsigned long long)node->daemon_rem_time,
+ (unsigned long long)quorate_time);
+
+ /* checking zero node->daemon_max[0] is a way to tell if we've received
+ an acceptable (non-stateful) proto message from the node since we
+ saw it join the daemon cpg */
+
+ if (hd->nodeid != our_nodeid &&
+ !node->proto.daemon_max[0] &&
+ (p->dr_ver.flags & PV_STATEFUL) &&
+ (our_protocol.dr_ver.flags & PV_STATEFUL)) {
+
+ log_debug("daemon node %d stateful merge", hd->nodeid);
+
+ if (cluster_quorate && node->daemon_rem_time &&
+ quorate_time < node->daemon_rem_time) {
+ log_debug("daemon node %d kill due to stateful merge", hd->nodeid);
+ if (!node->killed)
+ kick_node_from_cluster(hd->nodeid);
+ node->killed = 1;
+ }
+
+ /* don't save p->proto into node->proto; we need to come
+ through here based on zero daemon_max[0] for other proto
+ messages like this one from the same node */
- node = get_node_daemon(hd->nodeid);
- if (!node) {
- log_error("receive_protocol no node %d", hd->nodeid);
return;
}
+
memcpy(&node->proto, p, sizeof(struct protocol));
+
+ /* if we have zero run values, and this msg has non-zero run values,
+ then adopt them as ours; otherwise save this proto message */
+
+ if (our_protocol.daemon_run[0])
+ return;
+
+ if (p->daemon_run[0]) {
+ our_protocol.daemon_run[0] = p->daemon_run[0];
+ our_protocol.daemon_run[1] = p->daemon_run[1];
+ our_protocol.daemon_run[2] = p->daemon_run[2];
+
+ our_protocol.kernel_run[0] = p->kernel_run[0];
+ our_protocol.kernel_run[1] = p->kernel_run[1];
+ our_protocol.kernel_run[2] = p->kernel_run[2];
+
+ log_debug("run protocol from nodeid %d", hd->nodeid);
+ }
}
static void send_protocol(struct protocol *proto)
@@ -2305,6 +2429,17 @@ static void deliver_cb_daemon(cpg_handle_t handle,
}
}
+static int in_daemon_member_list(int nodeid)
+{
+ int i;
+
+ for (i = 0; i < daemon_member_count; i++) {
+ if (daemon_member[i].nodeid == nodeid)
+ return 1;
+ }
+ return 0;
+}
+
static void confchg_cb_daemon(cpg_handle_t handle,
const struct cpg_name *group_name,
const struct cpg_address *member_list,
@@ -2314,6 +2449,7 @@ static void confchg_cb_daemon(cpg_handle_t handle,
const struct cpg_address *joined_list,
size_t joined_list_entries)
{
+ struct node_daemon *node;
int i;
log_config(group_name, member_list, member_list_entries,
@@ -2328,13 +2464,44 @@ static void confchg_cb_daemon(cpg_handle_t handle,
for (i = 0; i < member_list_entries; i++) {
daemon_member[i] = member_list[i];
+ /* add struct for nodes we've not seen before */
add_node_daemon(member_list[i].nodeid);
}
+
+ list_for_each_entry(node, &daemon_nodes, list) {
+ if (in_daemon_member_list(node->nodeid)) {
+ if (node->daemon_member)
+ continue;
+
+ /* node joined daemon cpg */
+ node->daemon_member = 1;
+ node->daemon_add_time = time(NULL);
+ } else {
+ if (!node->daemon_member)
+ continue;
+
+ /* node left daemon cpg */
+ node->daemon_member = 0;
+ node->killed = 0;
+ memset(&node->proto, 0, sizeof(struct protocol));
+ node->daemon_rem_time = time(NULL);
+ }
+ }
+}
+
+static void totem_cb_daemon(cpg_handle_t handle,
+ struct cpg_ring_id ring_id,
+ uint32_t member_list_entries,
+ const uint32_t *member_list)
+{
+ log_ringid("dlm:controld", &ring_id, member_list, member_list_entries);
}
-static cpg_callbacks_t cpg_callbacks_daemon = {
+static cpg_model_v1_data_t cpg_callbacks_daemon = {
.cpg_deliver_fn = deliver_cb_daemon,
.cpg_confchg_fn = confchg_cb_daemon,
+ .cpg_totem_confchg_fn = totem_cb_daemon,
+ .flags = CPG_MODEL_V1_DELIVER_INITIAL_TOTEM_CONF,
};
void process_cpg_daemon(int ci)
@@ -2362,7 +2529,9 @@ int setup_cpg_daemon(void)
our_protocol.kernel_max[1] = 1;
our_protocol.kernel_max[2] = 1;
- error = cpg_initialize(&cpg_handle_daemon, &cpg_callbacks_daemon);
+ error = cpg_model_initialize(&cpg_handle_daemon, CPG_MODEL_V1,
+ (cpg_model_data_t *)&cpg_callbacks_daemon,
+ NULL);
if (error != CPG_OK) {
log_error("daemon cpg_initialize error %d", error);
return -1;
@@ -2374,6 +2543,7 @@ int setup_cpg_daemon(void)
sprintf(name.value, "dlm:controld");
name.length = strlen(name.value) + 1;
+ log_debug("cpg_join %s ...", name.value);
retry:
error = cpg_join(cpg_handle_daemon, &name);
if (error == CPG_ERR_TRY_AGAIN) {
@@ -2411,6 +2581,7 @@ void close_cpg_daemon(void)
sprintf(name.value, "dlm:controld");
name.length = strlen(name.value) + 1;
+ log_debug("cpg_leave %s ...", name.value);
retry:
error = cpg_leave(cpg_handle_daemon, &name);
if (error == CPG_ERR_TRY_AGAIN) {
@@ -2509,13 +2680,15 @@ int set_lockspace_info(struct lockspace *ls, struct dlmc_lockspace *lockspace)
lockspace->cg_next.seq = cg->seq;
if (cg->state == CGST_WAIT_CONDITIONS)
- lockspace->cg_next.wait_condition = 4;
- if (poll_fencing)
+ lockspace->cg_next.wait_condition = 5;
+ if (poll_ringid)
lockspace->cg_next.wait_condition = 1;
- else if (poll_quorum)
+ else if (poll_fencing)
lockspace->cg_next.wait_condition = 2;
- else if (poll_fs)
+ else if (poll_quorum)
lockspace->cg_next.wait_condition = 3;
+ else if (poll_fs)
+ lockspace->cg_next.wait_condition = 4;
if (cg->state == CGST_WAIT_MESSAGES)
lockspace->cg_next.wait_messages = 1;
@@ -2550,8 +2723,6 @@ static int _set_node_info(struct lockspace *ls, struct change *cg, int nodeid,
if (n->check_fencing)
node->flags |= DLMC_NF_CHECK_FENCING;
- if (n->check_quorum)
- node->flags |= DLMC_NF_CHECK_QUORUM;
if (n->check_fs)
node->flags |= DLMC_NF_CHECK_FS;
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 27e5c01..61bd78d 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -118,6 +118,7 @@
EXTERN int daemon_debug_opt;
EXTERN int daemon_quit;
EXTERN int cluster_down;
+EXTERN int poll_ringid;
EXTERN int poll_fencing;
EXTERN int poll_quorum;
EXTERN int poll_fs;
@@ -127,6 +128,7 @@ EXTERN int plock_fd;
EXTERN int plock_ci;
EXTERN struct list_head lockspaces;
EXTERN int cluster_quorate;
+EXTERN uint64_t quorate_time;
EXTERN uint32_t cluster_ringid_seq;
EXTERN int our_nodeid;
EXTERN uint32_t control_minor;
@@ -220,6 +222,7 @@ struct lockspace {
/* lockspace membership stuff */
cpg_handle_t cpg_handle;
+ struct cpg_ring_id cpg_ringid;
int cpg_client;
int cpg_fd;
int joining;
@@ -242,7 +245,6 @@ struct lockspace {
struct list_head saved_messages;
struct list_head plock_resources;
struct rb_root plock_resources_root;
- time_t last_checkpoint_time;
time_t last_plock_time;
struct timeval drop_resources_last;
diff --git a/dlm_controld/member_cman.c b/dlm_controld/member_cman.c
index 279b707..ec005c3 100644
--- a/dlm_controld/member_cman.c
+++ b/dlm_controld/member_cman.c
@@ -49,6 +49,8 @@ static void quorum_callback(quorum_handle_t h, uint32_t quorate,
cs_error_t err;
int i, j, num_addrs;
+ if (!cluster_quorate && quorate)
+ quorate_time = time(NULL);
cluster_quorate = quorate;
cluster_ringid_seq = (uint32_t)ring_seq;
12 years, 7 months
dlm: master - dlm_controld: renaming things
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=90bf062e...
Commit: 90bf062ed3f8d89f27046ef2c4216bd6e6cc9c49
Parent: 264d1b5ea71b3f23c3f249b25f7b19fb9397fb87
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Oct 6 15:26:03 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 6 15:26:03 2011 -0500
dlm_controld: renaming things
rename some functions and struct fields to clarify what
they refer to
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/cpg.c | 215 ++++++++++++++++++++++++++------------------
dlm_controld/dlm_daemon.h | 2 +-
dlm_controld/member_cman.c | 2 +-
3 files changed, 128 insertions(+), 91 deletions(-)
diff --git a/dlm_controld/cpg.c b/dlm_controld/cpg.c
index 49f7d02..fa328d0 100644
--- a/dlm_controld/cpg.c
+++ b/dlm_controld/cpg.c
@@ -34,37 +34,46 @@ struct protocol {
};
};
-struct member {
+/* per dlm_controld cpg: daemon_nodes */
+
+struct node_daemon {
struct list_head list;
int nodeid;
- int start; /* 1 if we received a start message for this change */
- int added; /* 1 if added by this change */
- int failed; /* 1 if failed in this change */
- int disallowed;
- uint32_t start_flags;
+
+ struct protocol proto;
};
+/* per lockspace cpg: ls->node_history */
+
struct node {
struct list_head list;
int nodeid;
+
+ uint64_t cluster_add_time;
+ uint64_t cluster_rem_time;
+ int cluster_member;
+
+ uint64_t lockspace_add_time;
+ uint64_t lockspace_rem_time;
+ uint64_t lockspace_fail_time;
+ uint32_t lockspace_add_seq;
+ uint32_t lockspace_rem_seq;
+ int lockspace_member;
+ int lockspace_fail_reason;
+
+ uint64_t start_time;
+
int check_fencing;
int check_quorum;
int check_fs;
+
int fs_notified;
- uint64_t add_time;
- uint64_t fail_time;
+
uint64_t fence_time; /* for debug */
- uint64_t cluster_add_time;
- uint64_t cluster_remove_time;
uint32_t fence_queries; /* for debug */
- uint32_t added_seq; /* for queries */
- uint32_t removed_seq; /* for queries */
- int failed_reason; /* for queries */
-
- struct protocol proto;
};
-/* One of these change structs is created for every confchg a cpg gets. */
+/* per lockspace confchg: ls->changes */
#define CGST_WAIT_CONDITIONS 1
#define CGST_WAIT_MESSAGES 2
@@ -84,6 +93,18 @@ struct change {
uint64_t create_time;
};
+/* per lockspace change member: cg->members */
+
+struct member {
+ struct list_head list;
+ int nodeid;
+ int start; /* 1 if we received a start message for this change */
+ int added; /* 1 if added by this change */
+ int failed; /* 1 if failed in this change */
+ int disallowed;
+ uint32_t start_flags;
+};
+
struct ls_info {
uint32_t ls_info_size;
uint32_t id_info_size;
@@ -371,7 +392,7 @@ static void free_ls(struct lockspace *ls)
For 1:
- node X fails
- - we see node X fail and X has non-zero add_time,
+ - we see node X fail and X has non-zero start_time,
set check_fencing and record the fail time
- wait for X to be removed from all dlm cpg's (probably not necessary)
- check that the fencing time is later than the recorded time above
@@ -387,15 +408,15 @@ static void free_ls(struct lockspace *ls)
continue running properly once the remerged node is properly reset
ls->node_history
- when we see a node not in this list, add entry for it with zero add_time
- record the time we get a good start message from the node, add_time
- clear add_time if the node leaves
- if node fails with non-zero add_time, set check_fencing
- when a node is fenced, clear add_time and clear check_fencing
- if a node remerges after this, no good start message, no new add_time set
- if a node fails with zero add_time, it doesn't need fencing
+ when we see a node not in this list, add entry for it with zero start_time
+ record the time we get a good start message from the node, start_time
+ clear start_time if the node leaves
+ if node fails with non-zero start_time, set check_fencing
+ when a node is fenced, clear start_time and clear check_fencing
+ if a node remerges after this, no good start message, no new start_time set
+ if a node fails with zero start_time, it doesn't need fencing
if a node remerges before it's been fenced, no good start message, no new
- add_time set
+ start_time set
*/
static struct node *get_node_history(struct lockspace *ls, int nodeid)
@@ -409,26 +430,22 @@ static struct node *get_node_history(struct lockspace *ls, int nodeid)
return NULL;
}
-static void node_history_init(struct lockspace *ls, int nodeid,
- struct change *cg)
+static struct node *get_node_history_create(struct lockspace *ls, int nodeid)
{
struct node *node;
node = get_node_history(ls, nodeid);
if (node)
- goto out;
+ return node;
node = malloc(sizeof(struct node));
if (!node)
- return;
+ return NULL;
memset(node, 0, sizeof(struct node));
node->nodeid = nodeid;
- node->add_time = 0;
list_add_tail(&node->list, &ls->node_history);
- out:
- if (cg)
- node->added_seq = cg->seq; /* for queries */
+ return node;
}
void node_history_cluster_add(int nodeid)
@@ -437,20 +454,17 @@ void node_history_cluster_add(int nodeid)
struct node *node;
list_for_each_entry(ls, &lockspaces, list) {
- node_history_init(ls, nodeid, NULL);
-
- node = get_node_history(ls, nodeid);
+ node = get_node_history_create(ls, nodeid);
if (!node) {
- log_error("node_history_cluster_add no nodeid %d",
- nodeid);
+ log_error("node_history_cluster_add no nodeid %d", nodeid);
return;
}
-
node->cluster_add_time = time(NULL);
+ node->cluster_member = 1;
}
}
-void node_history_cluster_remove(int nodeid)
+void node_history_cluster_rem(int nodeid)
{
struct lockspace *ls;
struct node *node;
@@ -458,59 +472,63 @@ void node_history_cluster_remove(int nodeid)
list_for_each_entry(ls, &lockspaces, list) {
node = get_node_history(ls, nodeid);
if (!node) {
- log_error("node_history_cluster_remove no nodeid %d",
- nodeid);
+ log_error("node_history_cluster_rem no nodeid %d", nodeid);
return;
}
-
- node->cluster_remove_time = time(NULL);
+ node->cluster_rem_time = time(NULL);
+ node->cluster_member = 0;
}
}
-static void node_history_start(struct lockspace *ls, int nodeid)
+static void node_history_lockspace_add(struct lockspace *ls, int nodeid,
+ struct change *cg)
{
struct node *node;
-
- node = get_node_history(ls, nodeid);
+
+ node = get_node_history_create(ls, nodeid);
if (!node) {
- log_error("node_history_start no nodeid %d", nodeid);
+ log_error("node_history_lockspace_add no nodeid %d", nodeid);
return;
}
- node->add_time = time(NULL);
+ node->lockspace_add_time = time(NULL);
+ node->lockspace_add_seq = cg->seq;
+ node->lockspace_member = 1;
}
-static void node_history_left(struct lockspace *ls, int nodeid,
- struct change *cg)
+static void node_history_lockspace_left(struct lockspace *ls, int nodeid,
+ struct change *cg)
{
struct node *node;
node = get_node_history(ls, nodeid);
if (!node) {
- log_error("node_history_left no nodeid %d", nodeid);
+ log_error("node_history_lockspace_left no nodeid %d", nodeid);
return;
}
- node->add_time = 0;
- node->removed_seq = cg->seq; /* for queries */
+ node->start_time = 0;
+
+ node->lockspace_rem_time = time(NULL);
+ node->lockspace_rem_seq = cg->seq; /* for queries */
+ node->lockspace_member = 0;
}
-static void node_history_fail(struct lockspace *ls, int nodeid,
- struct change *cg, int reason)
+static void node_history_lockspace_fail(struct lockspace *ls, int nodeid,
+ struct change *cg, int reason)
{
struct node *node;
node = get_node_history(ls, nodeid);
if (!node) {
- log_error("node_history_fail no nodeid %d", nodeid);
+ log_error("node_history_lockspace_fail no nodeid %d", nodeid);
return;
}
- if (cfgd_enable_fencing && node->add_time) {
+ if (cfgd_enable_fencing && node->start_time) {
node->check_fencing = 1;
node->fence_time = 0;
node->fence_queries = 0;
- node->fail_time = time(NULL);
}
/* fenced will take care of making sure the quorum value
@@ -524,8 +542,24 @@ static void node_history_fail(struct lockspace *ls, int nodeid,
node->check_fs = 1;
}
- node->removed_seq = cg->seq; /* for queries */
- node->failed_reason = reason; /* for queries */
+ node->lockspace_rem_time = time(NULL);
+ node->lockspace_rem_seq = cg->seq; /* for queries */
+ node->lockspace_member = 0;
+ node->lockspace_fail_reason = reason; /* for queries */
+ node->lockspace_fail_time = node->lockspace_rem_time;
+}
+
+static void node_history_start(struct lockspace *ls, int nodeid)
+{
+ struct node *node;
+
+ node = get_node_history(ls, nodeid);
+ if (!node) {
+ log_error("node_history_start no nodeid %d", nodeid);
+ return;
+ }
+
+ node->start_time = time(NULL);
}
static int check_fencing_done(struct lockspace *ls)
@@ -545,7 +579,7 @@ static int check_fencing_done(struct lockspace *ls)
continue;
/* check with fenced to see if the node has been
- fenced since node->add_time */
+ fenced since node->start_time */
rv = fence_node_time(node->nodeid, &last_fenced_time);
if (rv < 0)
@@ -555,24 +589,24 @@ static int check_fencing_done(struct lockspace *ls)
we've seen fenced_time within the same second as
fail_time: with external fencing, e.g. fence_node */
- if (last_fenced_time >= node->fail_time) {
+ if (last_fenced_time >= node->lockspace_fail_time) {
log_group(ls, "check_fencing %d done "
- "add %llu fail %llu last %llu",
+ "start %llu fail %llu last %llu",
node->nodeid,
- (unsigned long long)node->add_time,
- (unsigned long long)node->fail_time,
+ (unsigned long long)node->start_time,
+ (unsigned long long)node->lockspace_fail_time,
(unsigned long long)last_fenced_time);
node->check_fencing = 0;
- node->add_time = 0;
+ node->start_time = 0;
node->fence_time = last_fenced_time;
} else {
if (!node->fence_queries ||
node->fence_time != last_fenced_time) {
log_group(ls, "check_fencing %d wait "
- "add %llu fail %llu last %llu",
+ "start %llu fail %llu last %llu",
node->nodeid,
- (unsigned long long)node->add_time,
- (unsigned long long)node->fail_time,
+ (unsigned long long)node->start_time,
+ (unsigned long long)node->lockspace_fail_time,
(unsigned long long)last_fenced_time);
node->fence_queries++;
node->fence_time = last_fenced_time;
@@ -1415,11 +1449,12 @@ static int add_change(struct lockspace *ls,
}
list_add_tail(&memb->list, &cg->removed);
- if (memb->failed)
- node_history_fail(ls, memb->nodeid, cg,
- left_list[i].reason);
- else
- node_history_left(ls, memb->nodeid, cg);
+ if (memb->failed) {
+ node_history_lockspace_fail(ls, memb->nodeid, cg,
+ left_list[i].reason);
+ } else {
+ node_history_lockspace_left(ls, memb->nodeid, cg);
+ }
log_group(ls, "add_change cg %u remove nodeid %d reason %d",
cg->seq, memb->nodeid, left_list[i].reason);
@@ -1437,10 +1472,11 @@ static int add_change(struct lockspace *ls,
}
memb->added = 1;
- if (memb->nodeid == our_nodeid)
+ if (memb->nodeid == our_nodeid) {
cg->we_joined = 1;
- else
- node_history_init(ls, memb->nodeid, cg);
+ } else {
+ node_history_lockspace_add(ls, memb->nodeid, cg);
+ }
log_group(ls, "add_change cg %u joined nodeid %d", cg->seq,
memb->nodeid);
@@ -1448,8 +1484,9 @@ static int add_change(struct lockspace *ls,
if (cg->we_joined) {
log_group(ls, "add_change cg %u we joined", cg->seq);
- list_for_each_entry(memb, &cg->members, list)
- node_history_init(ls, memb->nodeid, cg);
+ list_for_each_entry(memb, &cg->members, list) {
+ node_history_lockspace_add(ls, memb->nodeid, cg);
+ }
}
log_group(ls, "add_change cg %u counts member %d joined %d remove %d "
@@ -1879,9 +1916,9 @@ int dlm_leave_lockspace(struct lockspace *ls)
return 0;
}
-static struct node *get_node_daemon(int nodeid)
+static struct node_daemon *get_node_daemon(int nodeid)
{
- struct node *node;
+ struct node_daemon *node;
list_for_each_entry(node, &daemon_nodes, list) {
if (node->nodeid == nodeid)
@@ -1892,7 +1929,7 @@ static struct node *get_node_daemon(int nodeid)
static void add_node_daemon(int nodeid)
{
- struct node *node;
+ struct node_daemon *node;
if (get_node_daemon(nodeid))
return;
@@ -1944,7 +1981,7 @@ static void protocol_out(struct protocol *proto)
static int all_protocol_messages(void)
{
- struct node *node;
+ struct node_daemon *node;
int i;
if (!daemon_member_count)
@@ -1968,7 +2005,7 @@ static int pick_min_protocol(struct protocol *proto)
{
uint16_t mind[4];
uint16_t mink[4];
- struct node *node;
+ struct node_daemon *node;
int i;
memset(&mind, 0, sizeof(mind));
@@ -2052,7 +2089,7 @@ static int pick_min_protocol(struct protocol *proto)
static void receive_protocol(struct dlm_header *hd, int len)
{
struct protocol *p;
- struct node *node;
+ struct node_daemon *node;
p = (struct protocol *)((char *)hd + sizeof(struct dlm_header));
protocol_in(p);
@@ -2518,9 +2555,9 @@ static int _set_node_info(struct lockspace *ls, struct change *cg, int nodeid,
if (n->check_fs)
node->flags |= DLMC_NF_CHECK_FS;
- node->added_seq = n->added_seq;
- node->removed_seq = n->removed_seq;
- node->failed_reason = n->failed_reason;
+ node->added_seq = n->lockspace_add_seq;
+ node->removed_seq = n->lockspace_rem_seq;
+ node->failed_reason = n->lockspace_fail_reason;
out:
return 0;
}
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 6f70a17..27e5c01 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -293,7 +293,7 @@ int dlm_leave_lockspace(struct lockspace *ls);
const char *msg_name(int type);
void update_flow_control_status(void);
void node_history_cluster_add(int nodeid);
-void node_history_cluster_remove(int nodeid);
+void node_history_cluster_rem(int nodeid);
int set_node_info(struct lockspace *ls, int nodeid, struct dlmc_node *node);
int set_lockspace_info(struct lockspace *ls, struct dlmc_lockspace *lockspace);
int set_lockspaces(int *count, struct dlmc_lockspace **lss_out);
diff --git a/dlm_controld/member_cman.c b/dlm_controld/member_cman.c
index 41af911..279b707 100644
--- a/dlm_controld/member_cman.c
+++ b/dlm_controld/member_cman.c
@@ -69,7 +69,7 @@ static void quorum_callback(quorum_handle_t h, uint32_t quorate,
if (!is_cluster_member(old_nodes[i])) {
log_debug("cluster node %u removed seq %u",
old_nodes[i], cluster_ringid_seq);
- node_history_cluster_remove(old_nodes[i]);
+ node_history_cluster_rem(old_nodes[i]);
del_configfs_node(old_nodes[i]);
}
}
12 years, 7 months
dlm: master - dlm_tool: remove unused line
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=264d1b5e...
Commit: 264d1b5ea71b3f23c3f249b25f7b19fb9397fb87
Parent: 079325c492e5a5a8c43111fe30f0c09fc6f1019f
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Oct 6 13:08:30 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 6 13:08:30 2011 -0500
dlm_tool: remove unused line
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_tool/main.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/dlm_tool/main.c b/dlm_tool/main.c
index 3523cce..776aa64 100644
--- a/dlm_tool/main.c
+++ b/dlm_tool/main.c
@@ -53,8 +53,6 @@ static int verbose;
static int wide;
static int summarize;
-#define VERSION "master"
-
#define MAX_LS 128
#define MAX_NODES 128
12 years, 7 months
dlm: master - dlm_controld: remove /dev/misc/lock_dlm_plock
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=079325c4...
Commit: 079325c492e5a5a8c43111fe30f0c09fc6f1019f
Parent: 91ba7d83c9468ca3d9c1ca5e65e45347c1d9160b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Oct 6 12:19:34 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 6 12:19:34 2011 -0500
dlm_controld: remove /dev/misc/lock_dlm_plock
compat code which was replaced by dlm_plock
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/action.c | 125 ---------------------------------------------
dlm_controld/dlm_daemon.h | 3 -
dlm_controld/plock.c | 41 ---------------
3 files changed, 0 insertions(+), 169 deletions(-)
diff --git a/dlm_controld/action.c b/dlm_controld/action.c
index 237221a..78500dd 100644
--- a/dlm_controld/action.c
+++ b/dlm_controld/action.c
@@ -15,7 +15,6 @@ static int dir_members[MAX_NODES];
static int dir_members_count;
static int comms_nodes[MAX_NODES];
static int comms_nodes_count;
-static char mg_name[DLM_LOCKSPACE_LEN+1];
#define DLM_SYSFS_DIR "/sys/kernel/dlm"
#define CLUSTER_DIR "/sys/kernel/config/dlm/cluster"
@@ -74,87 +73,6 @@ static int detect_protocol(void)
return proto;
}
-/* look for an id that matches in e.g. /sys/fs/gfs/bull\:x/lock_module/id
- and then extract the "x" as the name */
-
-static int get_mountgroup_name(uint32_t mg_id)
-{
- char path[PATH_MAX];
- char *fsname;
- const char *fsdir;
- DIR *d;
- FILE *file;
- struct dirent *de;
- uint32_t id;
- int retry_gfs2 = 1;
- int rv, error;
-
- fsdir = "/sys/fs/gfs";
- retry:
- rv = -1;
-
- d = opendir(fsdir);
- if (!d) {
- log_debug("%s: opendir failed: %d", path, errno);
- goto out;
- }
-
- while ((de = readdir(d))) {
- if (de->d_name[0] == '.')
- continue;
-
- id = 0;
- memset(path, 0, PATH_MAX);
- snprintf(path, PATH_MAX, "%s/%s/lock_module/id",
- fsdir, de->d_name);
-
- file = fopen(path, "r");
- if (!file) {
- log_error("can't open %s %d", path, errno);
- continue;
- }
-
- error = fscanf(file, "%u", &id);
- fclose(file);
-
- if (error != 1) {
- log_error("bad read %s %d", path, errno);
- continue;
- }
- if (id != mg_id) {
- log_debug("get_mountgroup_name skip %x %s",
- id, de->d_name);
- continue;
- }
-
- /* take the fsname out of clustername:fsname */
- fsname = strstr(de->d_name, ":");
- if (!fsname) {
- log_debug("get_mountgroup_name skip2 %x %s",
- id, de->d_name);
- continue;
- }
- fsname++;
-
- log_debug("get_mountgroup_name found %x %s %s",
- id, de->d_name, fsname);
- strncpy(mg_name, fsname, sizeof(mg_name));
- rv = 0;
- break;
- }
-
- closedir(d);
-
- out:
- if (rv && retry_gfs2) {
- retry_gfs2 = 0;
- fsdir = "/sys/fs/gfs2";
- goto retry;
- }
-
- return rv;
-}
-
/* This is for the case where dlm_controld exits/fails, abandoning dlm
lockspaces in the kernel, and then dlm_controld is restarted. When
dlm_controld exits and abandons lockspaces, that node needs to be
@@ -186,36 +104,6 @@ int check_uncontrolled_lockspaces(void)
return 0;
}
-/* find the mountgroup with "mg_id" in sysfs, get it's name, then look for
- the ls with with the same name in lockspaces list, return its id */
-
-void set_associated_id(uint32_t mg_id)
-{
- struct lockspace *ls;
- int rv;
-
- log_debug("set_associated_id mg_id %x %d", mg_id, mg_id);
-
- memset(&mg_name, 0, sizeof(mg_name));
-
- rv = get_mountgroup_name(mg_id);
- if (rv) {
- log_error("no mountgroup found with id %x", mg_id);
- return;
- }
-
- ls = find_ls(mg_name);
- if (!ls) {
- log_error("no lockspace found with name %s for mg_id %x",
- mg_name, mg_id);
- return;
- }
-
- log_debug("set_associated_id mg %x is ls %x", mg_id, ls->global_id);
-
- ls->associated_mg_id = mg_id;
-}
-
static int do_sysfs(const char *name, const char *file, char *val)
{
char fname[512];
@@ -996,7 +884,6 @@ static void find_minors(void)
control_minor = 0;
monitor_minor = 0;
plock_minor = 0;
- old_plock_minor = 0;
if (!(fl = fopen("/proc/misc", "r"))) {
log_error("/proc/misc fopen failed: %s", strerror(errno));
@@ -1015,9 +902,6 @@ static void find_minors(void)
} else if (!strcmp(name, "dlm_plock")) {
plock_minor = number;
found++;
- } else if (!strcmp(name, "lock_dlm_plock")) {
- old_plock_minor = number;
- found++;
}
} else do {
@@ -1078,15 +962,6 @@ int setup_misc_devices(void)
plock_minor);
}
- if (!plock_minor && old_plock_minor) {
- rv = find_udev_device("/dev/misc/lock_dlm_plock",
- old_plock_minor);
- if (rv < 0)
- return rv;
- log_debug("found /dev/misc/lock_dlm_plock minor %u",
- old_plock_minor);
- }
-
return 0;
}
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 27c9d7a..6f70a17 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -132,7 +132,6 @@ EXTERN int our_nodeid;
EXTERN uint32_t control_minor;
EXTERN uint32_t monitor_minor;
EXTERN uint32_t plock_minor;
-EXTERN uint32_t old_plock_minor;
EXTERN int optk_debug;
EXTERN int optk_timewarn;
@@ -240,7 +239,6 @@ struct lockspace {
int save_plocks;
int disable_plock;
uint32_t recv_plocks_data_count;
- uint32_t associated_mg_id;
struct list_head saved_messages;
struct list_head plock_resources;
struct rb_root plock_resources_root;
@@ -266,7 +264,6 @@ struct lockspace {
};
/* action.c */
-void set_associated_id(uint32_t mg_id);
int set_sysfs_control(char *name, int val);
int set_sysfs_event_done(char *name, int val);
int set_sysfs_id(char *name, uint32_t id);
diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index 4b66904..d475cf4 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -26,7 +26,6 @@ static struct timeval plock_recv_time;
static struct timeval plock_rate_last;
static int plock_device_fd = -1;
-static int need_fsid_translation = 0;
extern int message_flow_control_on;
@@ -163,13 +162,6 @@ static const char *ex_str(int optype, int ex)
return "RD";
}
-/*
- * In kernels before 2.6.26, plocks came from gfs2's lock_dlm module.
- * Reading plocks from there as well should allow us to use cluster3
- * on old (RHEL5) kernels. In this case, the fsid we read in plock_info
- * structs is the mountgroup id, which we need to translate to the ls id.
- */
-
int setup_plocks(void)
{
plock_read_count = 0;
@@ -181,10 +173,6 @@ int setup_plocks(void)
if (plock_minor) {
plock_device_fd = open("/dev/misc/dlm_plock", O_RDWR);
- } else if (old_plock_minor) {
- log_debug("setup_plocks using old lock_dlm interface");
- need_fsid_translation = 1;
- plock_device_fd = open("/dev/misc/lock_dlm_plock", O_RDWR);
}
if (plock_device_fd < 0) {
@@ -193,9 +181,6 @@ int setup_plocks(void)
}
log_debug("plocks %d", plock_device_fd);
- log_debug("plock cpg message size: %u bytes",
- (unsigned int) (sizeof(struct dlm_header) +
- sizeof(struct dlm_plock_info)));
return plock_device_fd;
}
@@ -206,26 +191,6 @@ void close_plocks(void)
close(plock_device_fd);
}
-static uint32_t mg_to_ls_id(uint32_t fsid)
-{
- struct lockspace *ls;
- int do_set = 1;
-
- retry:
- list_for_each_entry(ls, &lockspaces, list) {
- if (ls->associated_mg_id == fsid)
- return ls->global_id;
- }
-
- if (do_set) {
- do_set = 0;
- set_associated_id(fsid);
- goto retry;
- }
-
- return fsid;
-}
-
/* FIXME: unify these two */
static unsigned long time_diff_ms(struct timeval *begin, struct timeval *end)
@@ -724,9 +689,6 @@ static int add_waiter(struct lockspace *ls, struct resource *r,
static void write_result(struct lockspace *ls, struct dlm_plock_info *in,
int rv)
{
- if (need_fsid_translation)
- in->fsid = ls->associated_mg_id;
-
in->rv = rv;
write(plock_device_fd, in, sizeof(struct dlm_plock_info));
}
@@ -1582,9 +1544,6 @@ void process_plocks(int ci)
goto fail;
}
- if (need_fsid_translation)
- info.fsid = mg_to_ls_id(info.fsid);
-
ls = find_ls_id(info.fsid);
if (!ls) {
log_plock(ls, "process_plocks: no ls id %x", info.fsid);
12 years, 7 months
dlm: master - add license/copyright headers
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=91ba7d83...
Commit: 91ba7d83c9468ca3d9c1ca5e65e45347c1d9160b
Parent: 7ca6817d7a4dad7c4d96c41ad548ceccbd167e48
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Oct 6 12:07:45 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 6 12:07:45 2011 -0500
add license/copyright headers
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/action.c | 8 ++++++++
dlm_controld/config.c | 8 ++++++++
dlm_controld/cpg.c | 8 ++++++++
dlm_controld/crc.c | 8 ++++++++
dlm_controld/deadlock.c | 8 ++++++++
dlm_controld/dlm_controld.h | 8 ++++++++
dlm_controld/dlm_daemon.h | 8 ++++++++
dlm_controld/lib.c | 8 ++++++++
dlm_controld/libdlmcontrol.h | 8 ++++++++
dlm_controld/linux_endian.h | 8 ++++++++
dlm_controld/logging.c | 8 ++++++++
dlm_controld/main.c | 8 ++++++++
dlm_controld/member_cman.c | 8 ++++++++
dlm_controld/netlink.c | 8 ++++++++
dlm_controld/plock.c | 8 ++++++++
dlm_tool/main.c | 8 ++++++++
libdlm/libdlm.c | 9 +++++++++
libdlm/libdlm.h | 9 +++++++++
libdlm/libdlm_internal.h | 8 ++++++++
19 files changed, 154 insertions(+), 0 deletions(-)
diff --git a/dlm_controld/action.c b/dlm_controld/action.c
index e9148a1..237221a 100644
--- a/dlm_controld/action.c
+++ b/dlm_controld/action.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#include "dlm_daemon.h"
#include <corosync/corotypes.h>
diff --git a/dlm_controld/config.c b/dlm_controld/config.c
index 6c94fca..7ceea6a 100644
--- a/dlm_controld/config.c
+++ b/dlm_controld/config.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#include "dlm_daemon.h"
#include <libxml/tree.h>
diff --git a/dlm_controld/cpg.c b/dlm_controld/cpg.c
index b3c1454..49f7d02 100644
--- a/dlm_controld/cpg.c
+++ b/dlm_controld/cpg.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#include "dlm_daemon.h"
struct protocol_version {
diff --git a/dlm_controld/crc.c b/dlm_controld/crc.c
index ff8c1d3..1764850 100644
--- a/dlm_controld/crc.c
+++ b/dlm_controld/crc.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#include "dlm_daemon.h"
static const uint32_t crc_32_tab[] = {
diff --git a/dlm_controld/deadlock.c b/dlm_controld/deadlock.c
index 6aaabc5..9a7fd5d 100644
--- a/dlm_controld/deadlock.c
+++ b/dlm_controld/deadlock.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#include "dlm_daemon.h"
#include "libdlm.h"
diff --git a/dlm_controld/dlm_controld.h b/dlm_controld/dlm_controld.h
index 73e4ecc..a802882 100644
--- a/dlm_controld/dlm_controld.h
+++ b/dlm_controld/dlm_controld.h
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#ifndef __DLM_CONTROLD_DOT_H__
#define __DLM_CONTROLD_DOT_H__
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index d0975af..27c9d7a 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#ifndef __DLM_DAEMON_DOT_H__
#define __DLM_DAEMON_DOT_H__
diff --git a/dlm_controld/lib.c b/dlm_controld/lib.c
index e714ff9..311b6e9 100644
--- a/dlm_controld/lib.c
+++ b/dlm_controld/lib.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/dlm_controld/libdlmcontrol.h b/dlm_controld/libdlmcontrol.h
index 64a3814..5a9404f 100644
--- a/dlm_controld/libdlmcontrol.h
+++ b/dlm_controld/libdlmcontrol.h
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#ifndef _LIBDLMCONTROL_H_
#define _LIBDLMCONTROL_H_
diff --git a/dlm_controld/linux_endian.h b/dlm_controld/linux_endian.h
index 43089d2..8736b5b 100644
--- a/dlm_controld/linux_endian.h
+++ b/dlm_controld/linux_endian.h
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#ifndef __LINUX_ENDIAN_DOT_H__
#define __LINUX_ENDIAN_DOT_H__
diff --git a/dlm_controld/logging.c b/dlm_controld/logging.c
index bf1a0eb..803d08a 100644
--- a/dlm_controld/logging.c
+++ b/dlm_controld/logging.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#include "dlm_daemon.h"
static int syslog_facility;
diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index a931aa6..822a6a5 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#define EXTERN
#include "dlm_daemon.h"
#include <pthread.h>
diff --git a/dlm_controld/member_cman.c b/dlm_controld/member_cman.c
index 909c249..41af911 100644
--- a/dlm_controld/member_cman.c
+++ b/dlm_controld/member_cman.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#include "dlm_daemon.h"
#include <corosync/corotypes.h>
#include <corosync/cfg.h>
diff --git a/dlm_controld/netlink.c b/dlm_controld/netlink.c
index 9f1d382..06b6312 100644
--- a/dlm_controld/netlink.c
+++ b/dlm_controld/netlink.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#include "dlm_daemon.h"
#include <linux/dlm.h>
#include <linux/netlink.h>
diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index c38b998..4b66904 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#include "dlm_daemon.h"
#include <linux/dlm_plock.h>
diff --git a/dlm_tool/main.c b/dlm_tool/main.c
index 55593c0..3523cce 100644
--- a/dlm_tool/main.c
+++ b/dlm_tool/main.c
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>
diff --git a/libdlm/libdlm.c b/libdlm/libdlm.c
index a5157e2..134f5a7 100644
--- a/libdlm/libdlm.c
+++ b/libdlm/libdlm.c
@@ -1,3 +1,12 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
#ifdef _REENTRANT
#include <pthread.h>
#endif
diff --git a/libdlm/libdlm.h b/libdlm/libdlm.h
index 17a552c..6a30407 100644
--- a/libdlm/libdlm.h
+++ b/libdlm/libdlm.h
@@ -1,3 +1,12 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
#ifndef __LIBDLM_H
#define __LIBDLM_H
diff --git a/libdlm/libdlm_internal.h b/libdlm/libdlm_internal.h
index c8b270e..c8fded7 100644
--- a/libdlm/libdlm_internal.h
+++ b/libdlm/libdlm_internal.h
@@ -1,3 +1,11 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
/* Needed before we include the kernel libdlm header */
#define __user
12 years, 7 months
dlm: master - dlm_controld: use EXTERN
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=7ca6817d...
Commit: 7ca6817d7a4dad7c4d96c41ad548ceccbd167e48
Parent: 43931c355acc80658345a73c78ca866016938d32
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Oct 6 11:44:06 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 6 11:44:06 2011 -0500
dlm_controld: use EXTERN
to clean up declarations
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/config.h | 47 ------------------------
dlm_controld/deadlock.c | 1 -
dlm_controld/dlm_daemon.h | 86 ++++++++++++++++++++++++++++++++++-----------
dlm_controld/main.c | 68 ++++++++---------------------------
dlm_controld/netlink.c | 1 -
5 files changed, 80 insertions(+), 123 deletions(-)
diff --git a/dlm_controld/config.h b/dlm_controld/config.h
deleted file mode 100644
index ab37eed..0000000
--- a/dlm_controld/config.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef __CONFIG_DOT_H__
-#define __CONFIG_DOT_H__
-
-/* the kernel has default values for debug, timewarn and protocol;
- we only change them if new values are given on command line or in ccs */
-
-#define DEFAULT_DEBUG_LOGFILE 0
-#define DEFAULT_ENABLE_FENCING 1
-#define DEFAULT_ENABLE_QUORUM 0
-#define DEFAULT_ENABLE_PLOCK 1
-#define DEFAULT_PLOCK_DEBUG 0
-#define DEFAULT_PLOCK_RATE_LIMIT 0
-#define DEFAULT_PLOCK_OWNERSHIP 0
-#define DEFAULT_DROP_RESOURCES_TIME 10000 /* 10 sec */
-#define DEFAULT_DROP_RESOURCES_COUNT 10
-#define DEFAULT_DROP_RESOURCES_AGE 10000 /* 10 sec */
-
-extern int optk_debug;
-extern int optk_timewarn;
-extern int optk_protocol;
-extern int optd_debug_logfile;
-extern int optd_enable_fencing;
-extern int optd_enable_quorum;
-extern int optd_enable_plock;
-extern int optd_plock_debug;
-extern int optd_plock_rate_limit;
-extern int optd_plock_ownership;
-extern int optd_drop_resources_time;
-extern int optd_drop_resources_count;
-extern int optd_drop_resources_age;
-
-extern int cfgk_debug;
-extern int cfgk_timewarn;
-extern int cfgk_protocol;
-extern int cfgd_debug_logfile;
-extern int cfgd_enable_fencing;
-extern int cfgd_enable_quorum;
-extern int cfgd_enable_plock;
-extern int cfgd_plock_debug;
-extern int cfgd_plock_rate_limit;
-extern int cfgd_plock_ownership;
-extern int cfgd_drop_resources_time;
-extern int cfgd_drop_resources_count;
-extern int cfgd_drop_resources_age;
-
-#endif
-
diff --git a/dlm_controld/deadlock.c b/dlm_controld/deadlock.c
index bd1d68c..6aaabc5 100644
--- a/dlm_controld/deadlock.c
+++ b/dlm_controld/deadlock.c
@@ -1,5 +1,4 @@
#include "dlm_daemon.h"
-#include "config.h"
#include "libdlm.h"
static SaCkptHandleT global_ckpt_h;
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 5d12296..d0975af 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -38,11 +38,19 @@
#include <linux/dlmconstants.h>
#include "libdlmcontrol.h"
#include "dlm_controld.h"
-#include "config.h"
#include "list.h"
#include "rbtree.h"
#include "linux_endian.h"
+#ifndef EXTERN
+#define EXTERN extern
+#else
+#undef EXTERN
+#define EXTERN
+#endif
+
+#define DAEMON_NAME "dlm_controld"
+
/* TODO: get CONFDIR, LOGDIR, RUNDIR from build */
#define RUNDIR "/var/run/cluster"
@@ -63,8 +71,16 @@
#define DEFAULT_LOGFILE_PRIORITY LOG_INFO
#define DEFAULT_LOGFILE LOG_FILE_PATH
-#define DAEMON_NAME "dlm_controld"
-
+#define DEFAULT_DEBUG_LOGFILE 0
+#define DEFAULT_ENABLE_FENCING 1
+#define DEFAULT_ENABLE_QUORUM 0
+#define DEFAULT_ENABLE_PLOCK 1
+#define DEFAULT_PLOCK_DEBUG 0
+#define DEFAULT_PLOCK_RATE_LIMIT 0
+#define DEFAULT_PLOCK_OWNERSHIP 0
+#define DEFAULT_DROP_RESOURCES_TIME 10000 /* 10 sec */
+#define DEFAULT_DROP_RESOURCES_COUNT 10
+#define DEFAULT_DROP_RESOURCES_AGE 10000 /* 10 sec */
/* DLM_LOCKSPACE_LEN: maximum lockspace name length, from linux/dlmconstants.h.
Copied in libdlm.h so apps don't need to include the kernel header.
@@ -91,24 +107,52 @@
#define PROTO_SCTP 1
#define PROTO_DETECT 2
-extern int daemon_debug_opt;
-extern int daemon_quit;
-extern int cluster_down;
-extern int poll_fencing;
-extern int poll_quorum;
-extern int poll_fs;
-extern int poll_ignore_plock;
-extern int poll_drop_plock;
-extern int plock_fd;
-extern int plock_ci;
-extern struct list_head lockspaces;
-extern int cluster_quorate;
-extern uint32_t cluster_ringid_seq;
-extern int our_nodeid;
-extern uint32_t control_minor;
-extern uint32_t monitor_minor;
-extern uint32_t plock_minor;
-extern uint32_t old_plock_minor;
+EXTERN int daemon_debug_opt;
+EXTERN int daemon_quit;
+EXTERN int cluster_down;
+EXTERN int poll_fencing;
+EXTERN int poll_quorum;
+EXTERN int poll_fs;
+EXTERN int poll_ignore_plock;
+EXTERN int poll_drop_plock;
+EXTERN int plock_fd;
+EXTERN int plock_ci;
+EXTERN struct list_head lockspaces;
+EXTERN int cluster_quorate;
+EXTERN uint32_t cluster_ringid_seq;
+EXTERN int our_nodeid;
+EXTERN uint32_t control_minor;
+EXTERN uint32_t monitor_minor;
+EXTERN uint32_t plock_minor;
+EXTERN uint32_t old_plock_minor;
+
+EXTERN int optk_debug;
+EXTERN int optk_timewarn;
+EXTERN int optk_protocol;
+EXTERN int optd_debug_logfile;
+EXTERN int optd_enable_fencing;
+EXTERN int optd_enable_quorum;
+EXTERN int optd_enable_plock;
+EXTERN int optd_plock_debug;
+EXTERN int optd_plock_rate_limit;
+EXTERN int optd_plock_ownership;
+EXTERN int optd_drop_resources_time;
+EXTERN int optd_drop_resources_count;
+EXTERN int optd_drop_resources_age;
+
+EXTERN int cfgk_debug;
+EXTERN int cfgk_timewarn;
+EXTERN int cfgk_protocol;
+EXTERN int cfgd_debug_logfile;
+EXTERN int cfgd_enable_fencing;
+EXTERN int cfgd_enable_quorum;
+EXTERN int cfgd_enable_plock;
+EXTERN int cfgd_plock_debug;
+EXTERN int cfgd_plock_rate_limit;
+EXTERN int cfgd_plock_ownership;
+EXTERN int cfgd_drop_resources_time;
+EXTERN int cfgd_drop_resources_count;
+EXTERN int cfgd_drop_resources_age;
#define LOG_DUMP_SIZE DLMC_DUMP_SIZE
diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index e940fc0..a931aa6 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -1,3 +1,4 @@
+#define EXTERN
#include "dlm_daemon.h"
#include <pthread.h>
#include <linux/netlink.h>
@@ -1234,6 +1235,20 @@ int main(int argc, char **argv)
{
int fd;
+ cfgk_debug = -1;
+ cfgk_timewarn = -1;
+ cfgk_protocol = PROTO_DETECT;
+ cfgd_debug_logfile = DEFAULT_DEBUG_LOGFILE;
+ cfgd_enable_fencing = DEFAULT_ENABLE_FENCING;
+ cfgd_enable_quorum = DEFAULT_ENABLE_QUORUM;
+ cfgd_enable_plock = DEFAULT_ENABLE_PLOCK;
+ cfgd_plock_debug = DEFAULT_PLOCK_DEBUG;
+ cfgd_plock_rate_limit = DEFAULT_PLOCK_RATE_LIMIT;
+ cfgd_plock_ownership = DEFAULT_PLOCK_OWNERSHIP;
+ cfgd_drop_resources_time = DEFAULT_DROP_RESOURCES_TIME;
+ cfgd_drop_resources_count = DEFAULT_DROP_RESOURCES_COUNT;
+ cfgd_drop_resources_age = DEFAULT_DROP_RESOURCES_AGE;
+
INIT_LIST_HEAD(&lockspaces);
INIT_LIST_HEAD(&fs_register_list);
@@ -1264,56 +1279,3 @@ int main(int argc, char **argv)
return 0;
}
-int daemon_debug_opt;
-int daemon_quit;
-int cluster_down;
-int poll_fencing;
-int poll_quorum;
-int poll_fs;
-int poll_ignore_plock;
-int poll_drop_plock;
-int plock_fd;
-int plock_ci;
-struct list_head lockspaces;
-int cluster_quorate;
-int our_nodeid;
-uint32_t cluster_ringid_seq;
-uint32_t control_minor;
-uint32_t monitor_minor;
-uint32_t plock_minor;
-uint32_t old_plock_minor;
-
-/* was a config value set on command line?, 0 or 1.
- optk is a kernel option, optd is a daemon option */
-
-int optk_debug;
-int optk_timewarn;
-int optk_protocol;
-int optd_debug_logfile;
-int optd_enable_fencing;
-int optd_enable_quorum;
-int optd_enable_plock;
-int optd_plock_debug;
-int optd_plock_rate_limit;
-int optd_plock_ownership;
-int optd_drop_resources_time;
-int optd_drop_resources_count;
-int optd_drop_resources_age;
-
-/* actual config value from command line, cluster.conf, or default.
- cfgk is a kernel config value, cfgd is a daemon config value */
-
-int cfgk_debug = -1;
-int cfgk_timewarn = -1;
-int cfgk_protocol = PROTO_DETECT;
-int cfgd_debug_logfile = DEFAULT_DEBUG_LOGFILE;
-int cfgd_enable_fencing = DEFAULT_ENABLE_FENCING;
-int cfgd_enable_quorum = DEFAULT_ENABLE_QUORUM;
-int cfgd_enable_plock = DEFAULT_ENABLE_PLOCK;
-int cfgd_plock_debug = DEFAULT_PLOCK_DEBUG;
-int cfgd_plock_rate_limit = DEFAULT_PLOCK_RATE_LIMIT;
-int cfgd_plock_ownership = DEFAULT_PLOCK_OWNERSHIP;
-int cfgd_drop_resources_time = DEFAULT_DROP_RESOURCES_TIME;
-int cfgd_drop_resources_count = DEFAULT_DROP_RESOURCES_COUNT;
-int cfgd_drop_resources_age = DEFAULT_DROP_RESOURCES_AGE;
-
diff --git a/dlm_controld/netlink.c b/dlm_controld/netlink.c
index 63122f7..9f1d382 100644
--- a/dlm_controld/netlink.c
+++ b/dlm_controld/netlink.c
@@ -1,5 +1,4 @@
#include "dlm_daemon.h"
-#include "config.h"
#include <linux/dlm.h>
#include <linux/netlink.h>
#include <linux/genetlink.h>
12 years, 7 months
dlm: master - dlm_controld: update logging
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=43931c35...
Commit: 43931c355acc80658345a73c78ca866016938d32
Parent: 9a6125969490e49cd843b02feb23de1fc53c94ad
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Oct 6 11:31:33 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 6 11:31:33 2011 -0500
dlm_controld: update logging
don't bother logging from thread, other cleanups
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/Makefile | 2 +-
dlm_controld/dlm_daemon.h | 2 +-
dlm_controld/logging.c | 54 ++++++++++++++++++++-------------------------
dlm_controld/main.c | 18 ++++++++++++--
4 files changed, 41 insertions(+), 35 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index 25b1ea4..7bd37a1 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -61,7 +61,7 @@ BIN_CFLAGS += -I../include -I../libdlm
BIN_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
BIN_LDFLAGS += `xml2-config --libs`
-BIN_LDFLAGS += -lpthread -llogthread -lcpg -lconfdb -lcfg -lquorum -lfenced
+BIN_LDFLAGS += -lpthread -lrt -lcpg -lconfdb -lcfg -lquorum -lfenced
LIB_CFLAGS += $(BIN_CFLAGS)
LIB_LDFLAGS += -Wl,-z,relro -pie
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 9c180d7..5d12296 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -271,6 +271,7 @@ void deadlk_confchg(struct lockspace *ls,
/* main.c */
int do_read(int fd, void *buf, size_t count);
int do_write(int fd, void *buf, size_t count);
+uint64_t monotime(void);
void client_dead(int ci);
int client_add(int fd, void (*workfn)(int ci), void (*deadfn)(int ci));
int client_fd(int ci);
@@ -319,7 +320,6 @@ void clear_plocks_data(struct lockspace *ls);
/* logging.c */
void init_logging(void);
-void setup_logging(void);
void close_logging(void);
void copy_log_dump(char *buf, int *len);
void copy_log_dump_plock(char *buf, int *len);
diff --git a/dlm_controld/logging.c b/dlm_controld/logging.c
index cb3c7fb..bf1a0eb 100644
--- a/dlm_controld/logging.c
+++ b/dlm_controld/logging.c
@@ -1,14 +1,13 @@
#include "dlm_daemon.h"
-static int log_mode;
static int syslog_facility;
static int syslog_priority;
static int logfile_priority;
static char logfile[PATH_MAX];
+static FILE *logfile_fp;
void init_logging(void)
{
- log_mode = DEFAULT_LOG_MODE;
syslog_facility = DEFAULT_SYSLOG_FACILITY;
syslog_priority = DEFAULT_SYSLOG_PRIORITY;
logfile_priority = DEFAULT_LOGFILE_PRIORITY;
@@ -20,36 +19,22 @@ void init_logging(void)
if (cfgd_debug_logfile)
logfile_priority = LOG_DEBUG;
- log_debug("logging mode %d syslog f %d p %d logfile p %d %s",
- log_mode, syslog_facility, syslog_priority,
- logfile_priority, logfile);
-
- logt_init(DAEMON_NAME, log_mode, syslog_facility, syslog_priority,
- logfile_priority, logfile);
-}
-
-void setup_logging(void)
-{
-
- /* TODO: look for settings for each of these in dlm.conf */
- /*
- ccs_read_logging(ccs_handle, DAEMON_NAME,
- &cfgd_debug_logfile, &log_mode,
- &syslog_facility, &syslog_priority,
- &logfile_priority, logfile);
- */
-
- log_debug("logging mode %d syslog f %d p %d logfile p %d %s",
- log_mode, syslog_facility, syslog_priority,
- logfile_priority, logfile);
+ if (logfile[0]) {
+ logfile_fp = fopen(logfile, "a+");
+ if (logfile_fp != NULL) {
+ int fd = fileno(logfile_fp);
+ fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
+ }
+ }
- logt_conf(DAEMON_NAME, log_mode, syslog_facility, syslog_priority,
- logfile_priority, logfile);
+ openlog(DAEMON_NAME, LOG_CONS | LOG_PID, syslog_facility);
}
void close_logging(void)
{
- logt_exit();
+ closelog();
+ if (logfile_fp)
+ fclose(logfile_fp);
}
#define NAME_ID_SIZE 32
@@ -142,7 +127,7 @@ void log_level(char *name_in, uint32_t level_in, const char *fmt, ...)
snprintf(name, NAME_ID_SIZE, "%s ", name_in);
ret = snprintf(log_str + pos, len - pos, "%llu %s",
- (unsigned long long)time(NULL), name);
+ (unsigned long long)monotime(), name);
pos += ret;
@@ -162,8 +147,17 @@ void log_level(char *name_in, uint32_t level_in, const char *fmt, ...)
log_save_str(level, pos - 1, log_dump, &log_point, &log_wrap);
if (plock)
log_save_str(level, pos - 1, log_dump_plock, &log_point_plock, &log_wrap_plock);
- if (level)
- logt_print(level, "%s", log_str);
+
+ if (level <= syslog_priority)
+ syslog(level, "%s", log_str);
+
+ if (level <= logfile_priority && logfile_fp) {
+ time_t logtime = time(NULL);
+ char tbuf[64];
+ strftime(tbuf, sizeof(tbuf), "%b %d %T", localtime(&logtime));
+ fprintf(logfile_fp, "%s %s", tbuf, log_str);
+ fflush(logfile_fp);
+ }
if (!daemon_debug_opt)
return;
diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index 2be088a..e940fc0 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -62,6 +62,13 @@ int do_write(int fd, void *buf, size_t count)
return 0;
}
+uint64_t monotime(void)
+{
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return ts.tv_sec;
+}
+
static void client_alloc(void)
{
int i;
@@ -871,8 +878,6 @@ static void loop(void)
setup_config(0);
- setup_logging();
-
rv = check_uncontrolled_lockspaces();
if (rv < 0)
goto out;
@@ -1240,10 +1245,17 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
}
- fd = lockfile(RUNDIR, RUN_FILE_NAME);
+
init_logging();
+
+ fd = lockfile(RUNDIR, RUN_FILE_NAME);
+ if (fd < 0)
+ return fd;
+
log_level(NULL, LOG_INFO, "dlm_controld %s started", RELEASE_VERSION);
+
signal(SIGTERM, sigterm_handler);
+
set_scheduler();
loop();
12 years, 7 months
dlm: master - Makefiles: more munging
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=9a612596...
Commit: 9a6125969490e49cd843b02feb23de1fc53c94ad
Parent: c9186e3cf1b9c7aa5305fccdddc82f6bf75a8694
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Oct 5 16:48:07 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Oct 5 16:48:07 2011 -0500
Makefiles: more munging
---
dlm_controld/Makefile | 16 +++++++++-------
dlm_tool/Makefile | 9 +++++----
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index d83ead8..25b1ea4 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -1,3 +1,12 @@
+DESTDIR=
+PREFIX=/usr
+LIBNUM=/lib64
+BINDIR=$(PREFIX)/sbin
+LIBDIR=$(PREFIX)/$(LIBNUM)
+HDRDIR=$(PREFIX)/include
+MANDIR=$(PREFIX)/share/man
+INIDIR=/etc/init.d
+
BIN_TARGET = dlm_controld
MAN_TARGET = dlm_controld.8
@@ -76,13 +85,6 @@ clean:
INSTALL=$(shell which install)
-DESTDIR=
-BINDIR=/usr/sbin
-LIBDIR=/usr/lib64
-HDRDIR=/usr/include
-MANDIR=/usr/share/man
-INIDIR=/etc/init.d
-
.PHONY: install
install: all
$(INSTALL) -d $(DESTDIR)/$(BINDIR)
diff --git a/dlm_tool/Makefile b/dlm_tool/Makefile
index f2cd4b6..b4f65bb 100644
--- a/dlm_tool/Makefile
+++ b/dlm_tool/Makefile
@@ -1,3 +1,8 @@
+DESTDIR=
+PREFIX=/usr
+BINDIR=$(PREFIX)/sbin
+MANDIR=$(PREFIX)/share/man
+
BIN_TARGET = dlm_tool
MAN_TARGET = dlm_tool.8
@@ -41,10 +46,6 @@ clean:
INSTALL=$(shell which install)
-DESTDIR=
-BINDIR=/usr/sbin
-MANDIR=/usr/share/man
-
.PHONY: install
install: all
$(INSTALL) -d $(DESTDIR)/$(BINDIR)
12 years, 7 months
dlm: master - dlm: add init.d file
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=c9186e3c...
Commit: c9186e3cf1b9c7aa5305fccdddc82f6bf75a8694
Parent: bc70e884fdfdbed3cf51091f506be415716982da
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Oct 5 16:44:03 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Oct 5 16:44:03 2011 -0500
dlm: add init.d file
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/Makefile | 34 +++++++++------
dlm_controld/dlm.in | 110 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 131 insertions(+), 13 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index e846b05..d83ead8 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -4,6 +4,8 @@ MAN_TARGET = dlm_controld.8
HDR_TARGET = libdlmcontrol.h
+INI_TARGET = dlm
+
LIB_NAME = libdlmcontrol
LIB_MAJOR = 3
LIB_MINOR = 1
@@ -11,16 +13,17 @@ LIB_SO = $(LIB_NAME).so
LIB_SMAJOR = $(LIB_SO).$(LIB_MAJOR)
LIB_TARGET = $(LIB_SO).$(LIB_MAJOR).$(LIB_MINOR)
-BIN_SOURCE = \
- action.c \
- cpg.c \
- crc.c \
- main.c \
- plock.c \
- config.c \
- member_cman.c \
- logging.c \
- rbtree.c
+BIN_SOURCE = action.c \
+ cpg.c \
+ crc.c \
+ main.c \
+ plock.c \
+ config.c \
+ member_cman.c \
+ logging.c \
+ rbtree.c
+LIB_SOURCE = lib.c
+INI_SOURCE = dlm.in
BIN_CFLAGS += -D_GNU_SOURCE -g \
-Wall \
@@ -51,11 +54,10 @@ BIN_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
BIN_LDFLAGS += `xml2-config --libs`
BIN_LDFLAGS += -lpthread -llogthread -lcpg -lconfdb -lcfg -lquorum -lfenced
-LIB_SOURCE = lib.c
LIB_CFLAGS += $(BIN_CFLAGS)
LIB_LDFLAGS += -Wl,-z,relro -pie
-all: $(LIB_TARGET) $(BIN_TARGET)
+all: $(LIB_TARGET) $(BIN_TARGET) $(INI_TARGET)
$(BIN_TARGET): $(BIN_SOURCE)
$(CC) $(BIN_CFLAGS) $(BIN_LDFLAGS) $(BIN_SOURCE) -o $@ -L.
@@ -64,9 +66,12 @@ $(LIB_TARGET): $(LIB_SOURCE)
$(CC) $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared -fPIC -o $@ -Wl,-soname=$(LIB_SMAJOR) $^
ln -sf $(LIB_TARGET) $(LIB_SO)
ln -sf $(LIB_TARGET) $(LIB_SMAJOR)
+
+$(INI_TARGET): $(INI_SOURCE)
+ cp $(INI_SOURCE) $(INI_TARGET)
clean:
- rm -f *.o *.so *.so.* $(BIN_TARGET)
+ rm -f *.o *.so *.so.* $(BIN_TARGET) $(LIB_TARGET) $(INI_TARGET)
INSTALL=$(shell which install)
@@ -76,16 +81,19 @@ BINDIR=/usr/sbin
LIBDIR=/usr/lib64
HDRDIR=/usr/include
MANDIR=/usr/share/man
+INIDIR=/etc/init.d
.PHONY: install
install: all
$(INSTALL) -d $(DESTDIR)/$(BINDIR)
$(INSTALL) -d $(DESTDIR)/$(LIBDIR)
$(INSTALL) -d $(DESTDIR)/$(HDRDIR)
+ $(INSTALL) -d $(DESTDIR)/$(INIDIR)
$(INSTALL) -d $(DESTDIR)/$(MANDIR)/man8
$(INSTALL) -c -m 755 $(BIN_TARGET) $(DESTDIR)/$(BINDIR)
$(INSTALL) -c -m 755 $(LIB_TARGET) $(DESTDIR)/$(LIBDIR)
cp -a $(LIB_SO) $(DESTDIR)/$(LIBDIR)
$(INSTALL) -c -m 644 $(HDR_TARGET) $(DESTDIR)/$(HDRDIR)
+ $(INSTALL) -m 755 $(INI_TARGET) $(DESTDIR)/$(INIDIR)
$(INSTALL) -m 644 $(MAN_TARGET) $(DESTDIR)/$(MANDIR)/man8/
diff --git a/dlm_controld/dlm.in b/dlm_controld/dlm.in
new file mode 100644
index 0000000..c2eb711
--- /dev/null
+++ b/dlm_controld/dlm.in
@@ -0,0 +1,110 @@
+#!/bin/sh
+#
+# dlm_controld
+#
+# chkconfig: 21 79
+# description: starts and stops dlm_controld
+#
+
+
+### BEGIN INIT INFO
+# Provides: dlm_controld
+# Required-Start: $network $time $syslog corosync
+# Required-Stop: $syslog
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: starts and stops dlm_controld
+# Description: starts and stops dlm_controld
+### END INIT INFO
+
+. /etc/rc.d/init.d/functions
+
+prog="dlm_controld"
+progdir="cluster"
+lockfile="/var/run/$progdir/$prog.pid"
+exec="/usr/sbin/$prog"
+
+[ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+start() {
+ [ -x $exec ] || exit 5
+
+ if [ ! -d /var/run/$progdir ]; then
+ mkdir -p /var/run/$progdir
+ [ -x /usr/sbin/restorecon ] && restorecon /var/run/$progdir
+ fi
+
+ echo -n $"Starting $prog: "
+ daemon $prog $DLM_CONTROLD_OPTS
+ retval=$?
+ echo
+ [ $retval -eq 0 ]
+ return $retval
+}
+
+stop() {
+ echo -n $"Stopping $prog: "
+ killproc -p $lockfile $prog -TERM
+ retval=$?
+ echo
+ [ $retval -eq 0 ]
+}
+
+wait_for_stop() {
+ while [ -e $lockfile ]; do
+ sleep .5
+ done
+}
+
+restart() {
+ stop
+ wait_for_stop
+ start
+}
+
+reload() {
+ restart
+}
+
+rh_status() {
+ status $prog
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+case "$1" in
+ start)
+ rh_status_q && exit 0
+ $1
+ ;;
+ stop)
+ rh_status_q || exit 0
+ $1
+ ;;
+ restart)
+ $1
+ ;;
+ reload)
+ rh_status_q || exit 7
+ $1
+ ;;
+ force-reload)
+ force_reload
+ ;;
+ status)
+ rh_status
+ ;;
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ restart
+ ;;
+ *)
+ echo $"Usage $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
+
12 years, 7 months