From: Arnd Bergmann Date: Tue, 25 Oct 2016 02:00:56 +0000 (-0400) Subject: LU-4423 lnet: use 64-bit time for selftest X-Git-Tag: 2.9.52~52 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=31aa2bcc2bf65d79fbdc551870c0999596bb2eeb;ds=sidebyside LU-4423 lnet: use 64-bit time for selftest The lustre selftest code has multiple time stamps that are kept as 'time_t' or 'unsigned long' and can therefore overflow on 32-bit systems. This changes the code to use time64_t instead. Linux-commit: d9f79e6bf02c109f117132163239bfffa6475ccb Signed-off-by: Arnd Bergmann Change-Id: I74d704d104e7398af411e73180fac57c0b943eb7 Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/23352 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Frank Zago Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- diff --git a/lnet/selftest/brw_test.c b/lnet/selftest/brw_test.c index 96451ae..bfabc6c 100644 --- a/lnet/selftest/brw_test.c +++ b/lnet/selftest/brw_test.c @@ -139,13 +139,14 @@ brw_client_init (sfw_test_instance_t *tsi) int brw_inject_one_error(void) { - struct timeval tv; + struct timespec64 ts; if (brw_inject_errors <= 0) return 0; - do_gettimeofday(&tv); + ktime_get_ts64(&ts); - if ((tv.tv_usec & 1) == 0) return 0; + if (((ts.tv_nsec / NSEC_PER_USEC) & 1) == 0) + return 0; return brw_inject_errors--; } diff --git a/lnet/selftest/conrpc.c b/lnet/selftest/conrpc.c index ce8e833..014fe58 100644 --- a/lnet/selftest/conrpc.c +++ b/lnet/selftest/conrpc.c @@ -1176,7 +1176,7 @@ lstcon_rpc_pinger(void *arg) srpc_debug_reqst_t *drq; lstcon_ndlink_t *ndl; lstcon_node_t *nd; - time_t intv; + int intv; int count = 0; int rc; @@ -1248,9 +1248,8 @@ lstcon_rpc_pinger(void *arg) if (nd->nd_state != LST_NODE_ACTIVE) continue; - intv = cfs_duration_sec(cfs_time_sub(cfs_time_current(), - nd->nd_stamp)); - if (intv < (time_t)nd->nd_timeout / 2) + intv = cfs_duration_sec(jiffies - nd->nd_stamp); + if (intv < nd->nd_timeout / 2) continue; rc = lstcon_rpc_init(nd, SRPC_SERVICE_DEBUG, diff --git a/lnet/selftest/framework.c b/lnet/selftest/framework.c index 1e26566..e5e302a 100644 --- a/lnet/selftest/framework.c +++ b/lnet/selftest/framework.c @@ -174,8 +174,7 @@ sfw_add_session_timer (void) LASSERT (!sn->sn_timer_active); sn->sn_timer_active = 1; - timer->stt_expires = cfs_time_add(sn->sn_timeout, - ktime_get_real_seconds()); + timer->stt_expires = ktime_get_real_seconds()+ sn->sn_timeout; stt_add_timer(timer); return; } diff --git a/lnet/selftest/rpc.c b/lnet/selftest/rpc.c index 090956f..4079698 100644 --- a/lnet/selftest/rpc.c +++ b/lnet/selftest/rpc.c @@ -1091,8 +1091,7 @@ srpc_add_client_rpc_timer(srpc_client_rpc_t *rpc) INIT_LIST_HEAD(&timer->stt_list); timer->stt_data = rpc; timer->stt_func = srpc_client_rpc_expired; - timer->stt_expires = cfs_time_add(rpc->crpc_timeout, - ktime_get_real_seconds()); + timer->stt_expires = ktime_get_real_seconds() + rpc->crpc_timeout; stt_add_timer(timer); return; } diff --git a/lnet/selftest/timer.c b/lnet/selftest/timer.c index 404542f..ff016e9 100644 --- a/lnet/selftest/timer.c +++ b/lnet/selftest/timer.c @@ -74,13 +74,13 @@ stt_add_timer(stt_timer_t *timer) LASSERT(!stt_data.stt_shuttingdown); LASSERT(timer->stt_func != NULL); LASSERT(list_empty(&timer->stt_list)); - LASSERT(cfs_time_after(timer->stt_expires, ktime_get_real_seconds())); + LASSERT(timer->stt_expires > ktime_get_real_seconds()); /* a simple insertion sort */ list_for_each_prev(pos, STTIMER_SLOT(timer->stt_expires)) { stt_timer_t *old = list_entry(pos, stt_timer_t, stt_list); - if (cfs_time_aftereq(timer->stt_expires, old->stt_expires)) + if (timer->stt_expires >= old->stt_expires) break; } list_add(&timer->stt_list, pos); @@ -126,7 +126,7 @@ stt_expire_list(struct list_head *slot, time64_t now) while (!list_empty(slot)) { timer = list_entry(slot->next, stt_timer_t, stt_list); - if (cfs_time_after(timer->stt_expires, now)) + if (timer->stt_expires > now) break; list_del_init(&timer->stt_list);