]> git.proxmox.com Git - mirror_spl.git/commitdiff
Use current_kernel_time() in the time compatibility wrappers
authorTim Chase <tim@chase2k.com>
Sun, 11 Jan 2015 16:37:43 +0000 (10:37 -0600)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 16 Jan 2015 21:54:35 +0000 (13:54 -0800)
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 <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes zfsonlinux/zfs#3006

include/sys/time.h

index b9826d2b7aaff1049ba61ed1f37e41cd99703f06..76ce5f03c769dfd51b462875783a270b5dffe258 100644 (file)
 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);
 }