From cf814617a3151e53c30204fea07afad595b8eddc Mon Sep 17 00:00:00 2001 From: maxim Date: Tue, 25 Dec 2007 16:40:40 +0000 Subject: [PATCH] b=14300 i=isaac i=liang Fix for "prediction from the future" bug. Cleanup of gmlnd and qswlnd to ensure that they use cfs_time_t uniformly. --- lnet/klnds/gmlnd/gmlnd.h | 3 ++- lnet/klnds/gmlnd/gmlnd_comm.c | 10 +++++----- lnet/klnds/qswlnd/qswlnd.h | 3 ++- lnet/klnds/qswlnd/qswlnd_cb.c | 8 ++++---- lnet/klnds/socklnd/socklnd.c | 4 +++- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lnet/klnds/gmlnd/gmlnd.h b/lnet/klnds/gmlnd/gmlnd.h index be0f404..8373a73 100644 --- a/lnet/klnds/gmlnd/gmlnd.h +++ b/lnet/klnds/gmlnd/gmlnd.h @@ -145,7 +145,8 @@ typedef struct gmnal_tx { struct iovec *iov; /* mapped frags */ lnet_kiov_t *kiov; /* page frags */ } tx_large_frags; - unsigned long tx_launchtime; /* when (in jiffies) the transmit was launched */ + cfs_time_t tx_launchtime; /* when (in jiffies) the + * transmit was launched */ struct gmnal_tx *tx_next; /* stash on gmni_txs */ } gmnal_tx_t; diff --git a/lnet/klnds/gmlnd/gmlnd_comm.c b/lnet/klnds/gmlnd/gmlnd_comm.c index 4a66906..cb03c03 100644 --- a/lnet/klnds/gmlnd/gmlnd_comm.c +++ b/lnet/klnds/gmlnd/gmlnd_comm.c @@ -29,12 +29,12 @@ void gmnal_notify_peer_down(gmnal_tx_t *tx) { - struct timeval now; time_t then; - do_gettimeofday (&now); - then = now.tv_sec - (jiffies - tx->tx_launchtime)/HZ; - + then = cfs_time_current_sec() - + cfs_duration_sec(cfs_time_current() - + tx->tx_launchtime); + lnet_notify(tx->tx_gmni->gmni_ni, tx->tx_nid, 0, then); } @@ -339,7 +339,7 @@ gmnal_check_txqueues_locked (gmnal_ni_t *gmni) LASSERT(!tx->tx_credit); tx->tx_credit = 1; - tx->tx_launchtime = jiffies; + tx->tx_launchtime = cfs_time_current(); if (tx->tx_msgnob <= gmni->gmni_small_msgsize) { LASSERT (tx->tx_ltxb == NULL); diff --git a/lnet/klnds/qswlnd/qswlnd.h b/lnet/klnds/qswlnd/qswlnd.h index ba08e16..bf3adc5 100644 --- a/lnet/klnds/qswlnd/qswlnd.h +++ b/lnet/klnds/qswlnd/qswlnd.h @@ -205,7 +205,8 @@ typedef struct kqswnal_tx lnet_nid_t ktx_nid; /* destination node */ void *ktx_args[3]; /* completion passthru */ char *ktx_buffer; /* pre-allocated contiguous buffer for hdr + small payloads */ - unsigned long ktx_launchtime; /* when (in jiffies) the transmit was launched */ + cfs_time_t ktx_launchtime; /* when (in jiffies) the transmit + * was launched */ int ktx_status; /* completion status */ #if KQSW_CKSUM __u32 ktx_cksum; /* optimized GET payload checksum */ diff --git a/lnet/klnds/qswlnd/qswlnd_cb.c b/lnet/klnds/qswlnd/qswlnd_cb.c index eaa890e..c509d10 100644 --- a/lnet/klnds/qswlnd/qswlnd_cb.c +++ b/lnet/klnds/qswlnd/qswlnd_cb.c @@ -26,11 +26,11 @@ void kqswnal_notify_peer_down(kqswnal_tx_t *ktx) { - struct timeval now; time_t then; - do_gettimeofday (&now); - then = now.tv_sec - (jiffies - ktx->ktx_launchtime)/HZ; + then = cfs_time_current_sec() - + cfs_duration_sec(cfs_time_current() - + ktx->ktx_launchtime); lnet_notify(kqswnal_data.kqn_ni, ktx->ktx_nid, 0, then); } @@ -607,7 +607,7 @@ kqswnal_launch (kqswnal_tx_t *ktx) unsigned long flags; int rc; - ktx->ktx_launchtime = jiffies; + ktx->ktx_launchtime = cfs_time_current(); if (kqswnal_data.kqn_shuttingdown) return (-ESHUTDOWN); diff --git a/lnet/klnds/socklnd/socklnd.c b/lnet/klnds/socklnd/socklnd.c index fc105f3..00a260a 100644 --- a/lnet/klnds/socklnd/socklnd.c +++ b/lnet/klnds/socklnd/socklnd.c @@ -1464,7 +1464,9 @@ ksocknal_peer_failed (ksock_peer_t *peer) peer->ksnp_accepting == 0 && ksocknal_find_connecting_route_locked(peer) == NULL) { notify = 1; - last_alive = cfs_time_seconds(peer->ksnp_last_alive); + last_alive = cfs_time_current_sec() - + cfs_duration_sec(cfs_time_current() - + peer->ksnp_last_alive); } read_unlock (&ksocknal_data.ksnd_global_lock); -- 1.8.3.1