Whamcloud - gitweb
LU-4423 lnet: use 64-bit time for selftest 52/23352/2
authorArnd Bergmann <arnd@arndb.de>
Tue, 25 Oct 2016 02:00:56 +0000 (22:00 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 1 Jan 2017 02:02:25 +0000 (02:02 +0000)
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 <arnd@arndb.de>
Change-Id: I74d704d104e7398af411e73180fac57c0b943eb7
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/23352
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Frank Zago <fzago@cray.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lnet/selftest/brw_test.c
lnet/selftest/conrpc.c
lnet/selftest/framework.c
lnet/selftest/rpc.c
lnet/selftest/timer.c

index 96451ae..bfabc6c 100644 (file)
@@ -139,13 +139,14 @@ brw_client_init (sfw_test_instance_t *tsi)
 
 int brw_inject_one_error(void)
 {
 
 int brw_inject_one_error(void)
 {
-       struct timeval tv;
+       struct timespec64 ts;
 
        if (brw_inject_errors <= 0) return 0;
 
 
        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--;
 }
 
        return brw_inject_errors--;
 }
index ce8e833..014fe58 100644 (file)
@@ -1176,7 +1176,7 @@ lstcon_rpc_pinger(void *arg)
         srpc_debug_reqst_t *drq;
         lstcon_ndlink_t    *ndl;
         lstcon_node_t      *nd;
         srpc_debug_reqst_t *drq;
         lstcon_ndlink_t    *ndl;
         lstcon_node_t      *nd;
-        time_t              intv;
+       int intv;
         int                 count = 0;
         int                 rc;
 
         int                 count = 0;
         int                 rc;
 
@@ -1248,9 +1248,8 @@ lstcon_rpc_pinger(void *arg)
                 if (nd->nd_state != LST_NODE_ACTIVE)
                         continue;
 
                 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,
                         continue;
 
                rc = lstcon_rpc_init(nd, SRPC_SERVICE_DEBUG,
index 1e26566..e5e302a 100644 (file)
@@ -174,8 +174,7 @@ sfw_add_session_timer (void)
         LASSERT (!sn->sn_timer_active);
 
         sn->sn_timer_active = 1;
         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;
 }
         stt_add_timer(timer);
         return;
 }
index 090956f..4079698 100644 (file)
@@ -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;
        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;
 }
        stt_add_timer(timer);
        return;
 }
index 404542f..ff016e9 100644 (file)
@@ -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(!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);
 
 
        /* 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);
                        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);
 
        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);
                        break;
 
                list_del_init(&timer->stt_list);