Whamcloud - gitweb
LU-4423 selftest: use jiffies_to_*() instead of cfs_duration_usec 19/27019/3
authorArnd Bergmann <arnd@arndb.de>
Tue, 9 May 2017 19:06:43 +0000 (15:06 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 20 May 2017 18:46:24 +0000 (18:46 +0000)
The cfs_duration_usec() function has a timeval as its output, which we
want to avoid in general because of the y2038 problem.

There are only two locations remaining in lustre, so we can for now
eplace one with jiffies_to_timeval(), which is a generic kernel function
that does the same thing, the other can just use jiffies_to_usecs()
and completely avoid the timeval.

This is not a full solution yet, but it's a small step that lets us
build a larger portion of lustre without this reference to timeval in
a header file, and avoid triggering automated checking tools that wants
to warn about timeval.

Linux-commit: 70513c5d17b9812cc218e8b4c7826ebb5f375d9a

Test-Parameters: trivial testlist=lnet-selftest

Change-Id: If39f4d4857a2b3210bb0dc634b8bb42530df83dc
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
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/27019
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Doug Oucharek <doug.s.oucharek@intel.com>
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/include/libcfs/linux/linux-time.h
lnet/selftest/conrpc.c
lnet/selftest/framework.c

index 2dd750f..dc84385 100644 (file)
@@ -237,31 +237,6 @@ static inline time_t cfs_duration_sec(cfs_duration_t d)
        return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-static inline void cfs_duration_usec(cfs_duration_t d, struct timeval *s)
-{
-#if (BITS_PER_LONG == 32)
-       if (msecs_to_jiffies(MSEC_PER_SEC) > 4096) {
-               __u64 t;
-
-               s->tv_sec = d / msecs_to_jiffies(MSEC_PER_SEC);
-               t = (d - (cfs_duration_t)s->tv_sec *
-                    msecs_to_jiffies(MSEC_PER_SEC)) * USEC_PER_SEC;
-               do_div(t, msecs_to_jiffies(MSEC_PER_SEC));
-               s->tv_usec = t;
-       } else {
-               s->tv_sec = d / msecs_to_jiffies(MSEC_PER_SEC);
-               s->tv_usec = ((d - (cfs_duration_t)s->tv_sec *
-                              msecs_to_jiffies(MSEC_PER_SEC)) *
-                              USEC_PER_SEC) / msecs_to_jiffies(MSEC_PER_SEC);
-       }
-#else
-       s->tv_sec = d / msecs_to_jiffies(MSEC_PER_SEC);
-       s->tv_usec = ((d - (cfs_duration_t)s->tv_sec *
-                      msecs_to_jiffies(MSEC_PER_SEC)) *
-                      USEC_PER_SEC) / msecs_to_jiffies(MSEC_PER_SEC);
-#endif
-}
-
 static inline void cfs_duration_nsec(cfs_duration_t d, struct timespec *s)
 {
 #if (BITS_PER_LONG == 32)
index b445183..749714a 100644 (file)
@@ -503,7 +503,7 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
 
                 dur = (cfs_duration_t)cfs_time_sub(crpc->crp_stamp,
                       (cfs_time_t)console_session.ses_id.ses_stamp);
-                cfs_duration_usec(dur, &tv);
+               jiffies_to_timeval(dur, &tv);
 
                if (copy_to_user(&ent->rpe_peer,
                                 &nd->nd_id, sizeof(struct lnet_process_id)) ||
index da0c012..032d95e 100644 (file)
@@ -376,7 +376,6 @@ sfw_get_stats (srpc_stat_reqst_t *request, srpc_stat_reply_t *reply)
         sfw_session_t  *sn = sfw_data.fw_session;
        struct sfw_counters *cnt = &reply->str_fw;
         sfw_batch_t    *bat;
-        struct timeval  tv;
 
         reply->str_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
 
@@ -395,10 +394,7 @@ sfw_get_stats (srpc_stat_reqst_t *request, srpc_stat_reply_t *reply)
 
         /* send over the msecs since the session was started
          - with 32 bits to send, this is ~49 days */
-        cfs_duration_usec(cfs_time_sub(cfs_time_current(),
-                                       sn->sn_started), &tv);
-
-        cnt->running_ms      = (__u32)(tv.tv_sec * 1000 + tv.tv_usec / 1000);
+       cnt->running_ms      = jiffies_to_msecs(jiffies - sn->sn_started);
        cnt->brw_errors      = atomic_read(&sn->sn_brw_errors);
        cnt->ping_errors     = atomic_read(&sn->sn_ping_errors);
        cnt->zombie_sessions = atomic_read(&sfw_data.fw_nzombies);