From: John Stultz <john.stultz@linaro.org>
To: Karsten Blees <karsten.blees@gmail.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v2] time.c::timespec_trunc: fix nanosecond file time rounding
Date: Wed, 1 Jul 2015 11:07:47 -0700 [thread overview]
Message-ID: <CALAqxLWf4CFzHwMvkAWq0yj4hhhry9D1LKiKXodU_ATs4kXOHA@mail.gmail.com> (raw)
In-Reply-To: <558BF083.5060205@gmail.com>
On Thu, Jun 25, 2015 at 5:13 AM, Karsten Blees <karsten.blees@gmail.com> wrote:
> timespec_trunc() avoids rounding if granularity <= nanoseconds-per-jiffie
> (or TICK_NSEC). This optimization assumes that:
>
> 1. current_kernel_time().tv_nsec is already rounded to TICK_NSEC (i.e.
> with HZ=1000 you'd get 1000000, 2000000, 3000000... but never 1000001).
> This is no longer true (probably since hrtimers introduced in 2.6.16).
>
> 2. TICK_NSEC is evenly divisible by all possible granularities. This may
> be true for HZ=100, 250, 1000, but obviously not for HZ=300 /
> TICK_NSEC=3333333 (introduced in 2.6.20).
>
> Thus, sub-second portions of in-core file times are not rounded to on-disk
> granularity. I.e. file times may change when the inode is re-read from disk
> or when the file system is remounted.
>
> This affects all file systems with file time granularities > 1 ns and < 1s,
> e.g. CEPH (1000 ns), UDF (1000 ns), CIFS (100 ns), NTFS (100 ns) and FUSE
> (configurable from user mode via struct fuse_init_out.time_gran).
>
> Steps to reproduce with e.g. UDF:
>
> $ dd if=/dev/zero of=udfdisk count=10000 && mkudffs udfdisk
> $ mkdir udf && mount udfdisk udf
> $ touch udf/test && stat -c %y udf/test
> 2015-06-09 10:22:56.130006767 +0200
> $ umount udf && mount udfdisk udf
> $ stat -c %y udf/test
> 2015-06-09 10:22:56.130006000 +0200
>
> Remounting truncates the mtime to 1 µs.
>
> Fix the rounding in timespec_trunc() and update the documentation.
>
> timespec_trunc() is exclusively used to calculate inode's [acm]time (mostly
> via current_fs_time()), and always with super_block.s_time_gran as second
> argument. So this can safely be changed without side effects.
>
> Note: This does _not_ fix the issue for FAT's 2 second mtime resolution,
> as super_block.s_time_gran isn't prepared to handle different ctime /
> mtime / atime resolutions nor resolutions > 1 second.
>
> Signed-off-by: Karsten Blees <blees@dcon.de>
Ok. Looks good. I'm queuing it for testing, targeting the 4.3 merge window.
thanks
-john
prev parent reply other threads:[~2015-07-01 18:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-09 17:36 [PATCH] time.c::timespec_trunc: fix nanosecond file time rounding Karsten Blees
2015-06-16 17:07 ` John Stultz
2015-06-16 22:39 ` Karsten Blees
2015-06-16 23:08 ` John Stultz
2015-06-25 12:13 ` [PATCH v2] " Karsten Blees
2015-07-01 18:07 ` John Stultz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALAqxLWf4CFzHwMvkAWq0yj4hhhry9D1LKiKXodU_ATs4kXOHA@mail.gmail.com \
--to=john.stultz@linaro.org \
--cc=karsten.blees@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).