dlm: master - dlm_controld: use monotonic times
David Teigland
teigland at fedoraproject.org
Fri Oct 7 20:47:28 UTC 2011
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=d4cf6836ee60d12d07841b44986cf443a8b4f2ce
Commit: d4cf6836ee60d12d07841b44986cf443a8b4f2ce
Parent: d218916fd8a4132d2b4df8b7853ad419b3538637
Author: David Teigland <teigland at redhat.com>
AuthorDate: Fri Oct 7 15:46:12 2011 -0500
Committer: David Teigland <teigland at redhat.com>
CommitterDate: Fri Oct 7 15:46:12 2011 -0500
dlm_controld: use monotonic times
except for value compared to time from fenced
which is still real time
Signed-off-by: David Teigland <teigland at redhat.com>
---
dlm_controld/cpg.c | 26 +++++++++++++++-----------
dlm_controld/member_cman.c | 2 +-
dlm_controld/plock.c | 12 ++++++------
3 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/dlm_controld/cpg.c b/dlm_controld/cpg.c
index 4dc2bc2..4bf7d1d 100644
--- a/dlm_controld/cpg.c
+++ b/dlm_controld/cpg.c
@@ -72,7 +72,8 @@ struct node {
int fs_notified;
int check_fencing;
- uint64_t fence_time; /* for debug */
+ uint64_t fail_realtime;
+ uint64_t fence_realtime;
uint32_t fence_queries; /* for debug */
};
@@ -525,7 +526,7 @@ static void node_history_lockspace_fail(struct lockspace *ls, int nodeid,
if (cfgd_enable_fencing && node->start_time) {
node->check_fencing = 1;
- node->fence_time = 0;
+ node->fence_realtime = 0;
node->fence_queries = 0;
}
@@ -540,6 +541,7 @@ static void node_history_lockspace_fail(struct lockspace *ls, int nodeid,
node->lockspace_fail_time = now;
node->lockspace_fail_seq = node->lockspace_rem_seq;
node->lockspace_fail_reason = reason; /* for queries */
+ node->fail_realtime = time(NULL);
}
static void node_history_start(struct lockspace *ls, int nodeid)
@@ -552,7 +554,7 @@ static void node_history_start(struct lockspace *ls, int nodeid)
return;
}
- node->start_time = time(NULL);
+ node->start_time = monotime();
}
/* wait for cluster ringid and cpg ringid to be the same so we know our
@@ -596,31 +598,33 @@ static int check_fencing_done(struct lockspace *ls)
if (rv < 0)
log_error("fenced_node_info error %d", rv);
+ /* fenced gives us real time */
+
/* need >= not just > because in at least one case
we've seen fenced_time within the same second as
fail_time: with external fencing, e.g. fence_node */
- if (last_fenced_time >= node->lockspace_fail_time) {
+ if (last_fenced_time >= node->fail_realtime) {
log_group(ls, "check_fencing %d done "
"start %llu fail %llu last %llu",
node->nodeid,
(unsigned long long)node->start_time,
- (unsigned long long)node->lockspace_fail_time,
+ (unsigned long long)node->fail_realtime,
(unsigned long long)last_fenced_time);
node->check_fencing = 0;
node->start_time = 0;
- node->fence_time = last_fenced_time;
+ node->fence_realtime = last_fenced_time;
} else {
if (!node->fence_queries ||
- node->fence_time != last_fenced_time) {
+ node->fence_realtime != last_fenced_time) {
log_group(ls, "check_fencing %d wait "
"start %llu fail %llu last %llu",
node->nodeid,
(unsigned long long)node->start_time,
- (unsigned long long)node->lockspace_fail_time,
+ (unsigned long long)node->fail_realtime,
(unsigned long long)last_fenced_time);
node->fence_queries++;
- node->fence_time = last_fenced_time;
+ node->fence_realtime = last_fenced_time;
}
wait_count++;
}
@@ -1415,7 +1419,7 @@ static int add_change(struct lockspace *ls,
struct change *cg;
struct member *memb;
int i, error;
- uint64_t now = time(NULL);
+ uint64_t now = monotime();
cg = malloc(sizeof(struct change));
if (!cg)
@@ -2418,7 +2422,7 @@ static void confchg_cb_daemon(cpg_handle_t handle,
size_t joined_list_entries)
{
struct node_daemon *node;
- uint64_t now = time(NULL);
+ uint64_t now = monotime();
int i;
log_config(group_name, member_list, member_list_entries,
diff --git a/dlm_controld/member_cman.c b/dlm_controld/member_cman.c
index f7a099c..6bfb2a9 100644
--- a/dlm_controld/member_cman.c
+++ b/dlm_controld/member_cman.c
@@ -110,7 +110,7 @@ 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);
+ uint64_t now = monotime();
if (!cluster_quorate && quorate)
quorate_time = now;
diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index d475cf4..3e48267 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -813,11 +813,11 @@ static void __receive_plock(struct lockspace *ls, struct dlm_plock_info *in,
{
switch (in->optype) {
case DLM_PLOCK_OP_LOCK:
- ls->last_plock_time = time(NULL);
+ ls->last_plock_time = monotime();
do_lock(ls, in, r);
break;
case DLM_PLOCK_OP_UNLOCK:
- ls->last_plock_time = time(NULL);
+ ls->last_plock_time = monotime();
do_unlock(ls, in, r);
break;
case DLM_PLOCK_OP_GET:
@@ -1132,7 +1132,7 @@ static void _receive_own(struct lockspace *ls, struct dlm_header *hd, int len)
int from = hd->nodeid;
int rv;
- ls->last_plock_time = time(NULL);
+ ls->last_plock_time = monotime();
memcpy(&info, (char *)hd + sizeof(struct dlm_header), sizeof(info));
info_bswap_in(&info);
@@ -1305,7 +1305,7 @@ static void _receive_sync(struct lockspace *ls, struct dlm_header *hd, int len)
int from = hd->nodeid;
int rv;
- ls->last_plock_time = time(NULL);
+ ls->last_plock_time = monotime();
memcpy(&info, (char *)hd + sizeof(struct dlm_header), sizeof(info));
info_bswap_in(&info);
@@ -1352,7 +1352,7 @@ static void _receive_drop(struct lockspace *ls, struct dlm_header *hd, int len)
int from = hd->nodeid;
int rv;
- ls->last_plock_time = time(NULL);
+ ls->last_plock_time = monotime();
memcpy(&info, (char *)hd + sizeof(struct dlm_header), sizeof(info));
info_bswap_in(&info);
@@ -2072,7 +2072,7 @@ void purge_plocks(struct lockspace *ls, int nodeid, int unmount)
}
if (purged)
- ls->last_plock_time = time(NULL);
+ ls->last_plock_time = monotime();
log_dlock(ls, "purged %d plocks for %d", purged, nodeid);
}
More information about the cluster-commits
mailing list