Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Commit

Permalink
Use current_kernel_time() in the time compatibility wrappers
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes openzfs/zfs#3006
  • Loading branch information
dweeezil authored and behlendorf committed Jan 16, 2015
1 parent 03a7835 commit 47af4b7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions include/sys/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 47af4b7

Please sign in to comment.