mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@twinsun.com>
To: andrew@pimlott.net
Cc: linux-kernel@vger.kernel.org
Subject: nanosecond file timestamp resolution in filesystems, GNU make, etc.
Date: Mon, 28 Oct 2002 01:47:09 -0800 (PST)	[thread overview]
Message-ID: <200210280947.g9S9l9H01162@sic.twinsun.com> (raw)
In-Reply-To: <20021027153651.GB26297@pimlott.net> (andrew@pimlott.net)

> Date: Sun, 27 Oct 2002 10:36:51 -0500
> From: Andrew Pimlott <andrew@pimlott.net>
> 
> I thought I'd forward these in case you'd like to add anything.
> Andi Kleen is adding nanosecond timestamps to Linux (finally!), and
> I have some concerns about how his implementation might affect
> programs like make....

Thanks for mentioning this, as I don't normally read linux-kernel.
I'll add my comments below and CC: to linux-kernel.  Please reply to
me as well as to linux-kernel if you want me in on the thread.


> From: Andi Kleen (ak@suse.de)
> Date: Sun Oct 27 2002 - 02:01:25 EST

> When an inode is flushed on an old fs with only second resolution the 
> subsecond part is truncated. This has the drawback that an inode
> timestamp can jump backwards on reload as seen by user space.

I see this as a real flaw.  Several programs (and not just GNU make)
rely on file timestamps not being altered.  For example, GNU diff uses
file timestamps to decide whether two files might be the same file; if
their timestamps differ, then they must not be the same file.  If a
file's timestamp might snap back to the previous second, a
nanosecond-aware GNU diff will go astray.  Similarly, GNU tar uses
file timestamps to decide whether a file has changed and needs to be
dumped; if the file timestamp jumps back, a nanosecond-aware GNU tar
will erroneously decide that the file has changed and will dump it
unnecessarily.

> Another way would be to round on flush, but that also has some problems :-

Rounding is even worse.  GNU Make assumes truncation, i.e. it assumes
that a timestamp is truncated (floored, actually) when it is stored on
a non-nanosecond-aware filesystem.

> In my current patchkit I just chose to truncate because that was the 
> easiest and the other more complicated solutions didn't offer any 
> compeling advantage.

Can't you truncate/floor to filesystem timestamp resolution
immediately, i.e., before the inode is flushed?  That would address
the problems that I see.


> Date:	Sun, 27 Oct 2002 10:20:38 -0500
> From:	Andrew Pimlott <andrew@pimlott.net>

> Even the messages to the GNU make mailing list when Paul Eggert
> implemented nanosecond support didn't include a specific rationale.

Partly because it was there.  But also because it avoids some bugs
when "make" assumes that a file is up-to-date because its timestamp
equals some other file's timestamp.  E.g.:

   cp foo1.c foo.c
   make foo.o
   cp foo2.c foo.c
   make foo.o

This works only if timestamps have sufficient resolution.
Admittedly this small example is strained, but I hope you get the idea.
   

> I tend to prefer the proposal to set the nanosecond field to 10^9-1.

We used this trick in one place in GNU make (look for the comment in
remake.c that says "Avoid spurious rebuilds due to low resolution time
stamps") but it is an application-specific hack; I'm dubious that it
is a good idea in general-purpose filesystem code.

My personal experience is that it's hard to read and write code that
futzes with timestamps of various resolutions, and there is a real
advantage to sticking with a simple rule that always takes the floor
when going to a lower-precision timestamp, even if that rule has
suboptimal results in some cases.

       reply	other threads:[~2002-10-28  9:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20021027153651.GB26297@pimlott.net>
2002-10-28  9:47 ` Paul Eggert [this message]
2002-10-28 10:28   ` Jamie Lokier
     [not found] <20021027153651.GB26297@pimlott.net.suse.lists.linux.kernel>
     [not found] ` <200210280947.g9S9l9H01162@sic.twinsun.com.suse.lists.linux.kernel>
2002-10-28 11:05   ` Andi Kleen
     [not found]   ` <20021028102809.GA16062@bjl1.asuk.net.suse.lists.linux.kernel>
2002-10-28 11:08     ` Andi Kleen
2002-10-28 12:56       ` Jamie Lokier
2002-10-28 14:15         ` Andi Kleen
2002-10-28 14:28           ` Maciej W. Rozycki
2002-10-28 15:13             ` Jamie Lokier
2002-10-28 15:40               ` Maciej W. Rozycki
2002-10-28 15:59                 ` Jamie Lokier
2002-10-28 15:17           ` Jamie Lokier

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=200210280947.g9S9l9H01162@sic.twinsun.com \
    --to=eggert@twinsun.com \
    --cc=andrew@pimlott.net \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®