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 <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes zfsonlinux/zfs#3006
This commit is contained in:
Tim Chase 2015-01-11 10:37:43 -06:00 committed by Brian Behlendorf
parent 03a783534a
commit 47af4b76ff
1 changed files with 2 additions and 5 deletions

View File

@ -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);
}