From e1d53a63762141bc497d6e0194bdc288028b2201 Mon Sep 17 00:00:00 2001
From: nikita <nikita>
Date: Thu, 21 Jun 2007 21:31:08 +0000
Subject: [PATCH] landing fix for bug 12227.

---
 lnet/ChangeLog                         | 11 ++++++++++-
 lnet/include/libcfs/linux/linux-time.h |  6 ++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/lnet/ChangeLog b/lnet/ChangeLog
index 959a299ea5..99aeb85155 100644
--- a/lnet/ChangeLog
+++ b/lnet/ChangeLog
@@ -1,4 +1,4 @@
-2007-04-23  Cluster File Systems, Inc. <info@clusterfs.com>
+2006-06-22  Cluster File Systems, Inc. <info@clusterfs.com>
        * version 1.4.11 / 1.6.1
        * Support for networks:
 	socklnd   - kernels up to 2.6.16
@@ -13,6 +13,15 @@
 	ptllnd    - Portals 3.3 / UNICOS/lc 1.5.x, 2.0.x
        * bug fixes
 
+Severity   : minor
+Frequency  : rare
+Bugzilla   : 12227
+Description: cfs_duration_{u,n}sec() wrongly calculate nanosecond part of
+	     struct timeval.
+Details    : do_div() macro is used incorrectly.
+
+2007-04-23  Cluster File Systems, Inc. <info@clusterfs.com>
+
 Severity   : normal
 Bugzilla   : 11680
 Description: make panic on lbug configurable
diff --git a/lnet/include/libcfs/linux/linux-time.h b/lnet/include/libcfs/linux/linux-time.h
index e928387a79..56523e2908 100644
--- a/lnet/include/libcfs/linux/linux-time.h
+++ b/lnet/include/libcfs/linux/linux-time.h
@@ -238,7 +238,8 @@ static inline void cfs_duration_usec(cfs_duration_t d, struct timeval *s)
 
         s->tv_sec = d / HZ;
         t = (d - (cfs_duration_t)s->tv_sec * HZ) * ONE_MILLION;
-        s->tv_usec = do_div (t, HZ);
+        do_div(t, HZ);
+        s->tv_usec = t;
 #else
         s->tv_sec = d / HZ;
         s->tv_usec = ((d - (cfs_duration_t)s->tv_sec * HZ) * ONE_MILLION) / HZ;
@@ -252,7 +253,8 @@ static inline void cfs_duration_nsec(cfs_duration_t d, struct timespec *s)
 
         s->tv_sec = d / HZ;
         t = (d - s->tv_sec * HZ) * ONE_BILLION;
-        s->tv_nsec = do_div (t, HZ);
+        do_div(t, HZ);
+        s->tv_nsec = t;
 #else
         s->tv_sec = d / HZ;
         s->tv_nsec = ((d - s->tv_sec * HZ) * ONE_BILLION) / HZ;
-- 
GitLab