From 47af4b76ffe72457166e4abfcfe23848ac51811a Mon Sep 17 00:00:00 2001 From: Tim Chase Date: Sun, 11 Jan 2015 10:37:43 -0600 Subject: [PATCH] Use current_kernel_time() in the time compatibility wrappers Since the Linux kernel's utimens family of functions uses current_kernel_time(), we need to do the same in the context of ZFS or else there can be discrepencies in timestamps (they go backward) if userland code does: fd = creat(FNAME, 0600); (void) futimens(fd, NULL); The getnstimeofday() function generally returns a slightly lower time value. Signed-off-by: Tim Chase Signed-off-by: Brian Behlendorf Closes zfsonlinux/zfs#3006 --- include/sys/time.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/sys/time.h b/include/sys/time.h index b9826d2b7..76ce5f03c 100644 --- a/include/sys/time.h +++ b/include/sys/time.h @@ -54,17 +54,14 @@ static inline void gethrestime(timestruc_t *now) { - struct timespec ts; - getnstimeofday(&ts); - now->tv_sec = ts.tv_sec; - now->tv_nsec = ts.tv_nsec; + *now = current_kernel_time(); } static inline time_t gethrestime_sec(void) { struct timespec ts; - getnstimeofday(&ts); + ts = current_kernel_time(); return (ts.tv_sec); }