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);