Whamcloud - gitweb
LU-12931 libcfs: skip cfs_time_seconds() indirection
[fs/lustre-release.git] / libcfs / include / libcfs / linux / linux-time.h
index 5af8134..454f37e 100644 (file)
@@ -98,6 +98,26 @@ static inline struct timespec timespec64_to_timespec(const struct timespec64 ts6
 
 #endif /* HAVE_TIMESPEC64 */
 
 
 #endif /* HAVE_TIMESPEC64 */
 
+#ifndef HAVE_NS_TO_TIMESPEC64
+static inline struct timespec64 ns_to_timespec64(const s64 nsec)
+{
+       struct timespec64 ts;
+       s32 rem;
+
+       if (!nsec)
+               return (struct timespec64) {0, 0};
+
+       ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem);
+       if (unlikely(rem < 0)) {
+               ts.tv_sec--;
+               rem += NSEC_PER_SEC;
+       }
+       ts.tv_nsec = rem;
+
+       return ts;
+}
+#endif
+
 #ifndef HAVE_KTIME_ADD
 # define ktime_add(lhs, rhs) ({ (ktime_t){ .tv64 = (lhs).tv64 + (rhs).tv64 }; })
 #endif /* !HAVE_KTIME_ADD */
 #ifndef HAVE_KTIME_ADD
 # define ktime_add(lhs, rhs) ({ (ktime_t){ .tv64 = (lhs).tv64 + (rhs).tv64 }; })
 #endif /* !HAVE_KTIME_ADD */
@@ -194,7 +214,7 @@ static inline ktime_t timespec64_to_ktime(struct timespec64 ts)
 
 static inline unsigned long cfs_time_seconds(time64_t seconds)
 {
 
 static inline unsigned long cfs_time_seconds(time64_t seconds)
 {
-       return nsecs_to_jiffies(seconds * NSEC_PER_SEC);
+       return nsecs_to_jiffies64(seconds * NSEC_PER_SEC);
 }
 
 #ifdef HAVE_NEW_DEFINE_TIMER
 }
 
 #ifdef HAVE_NEW_DEFINE_TIMER