mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jamie Lokier <lk@tantalophile.demon.co.uk>
To: Andi Kleen <ak@suse.de>
Cc: eggert@twinsun.com, linux-kernel@vger.kernel.org
Subject: Re: nanosecond file timestamp resolution in filesystems, GNU make, etc.
Date: Mon, 28 Oct 2002 12:56:52 +0000	[thread overview]
Message-ID: <20021028125652.GA16329@bjl1.asuk.net> (raw)
In-Reply-To: <p73r8eastwo.fsf@oldwotan.suse.de>

Andi Kleen wrote:
> > Unfortunately that application code breaks when the filesystem may
> > have timestamps with resolution better than 1 second, but worse than 1
> > nanosecond. 
> 
> The current resolution is jiffies, which tends to be 1ms
> 
>  Then the application just can't do the right thing,
> > unless it knows what rounding was applied by the kernel/filesystem, so
> > it can change that rounding in a safe direction.
> 
> The rounding is always truncation. So the application can just assume
> that.

This is fine when you are comparing two files with the same timestamp
resolution, but when the resolutions are different you need to know
what they are.

Come to think of it, rounding up is no better than rounding down when
comparing two files.  The application needs to round one of them up
and one of them down, in order to make reliable tests of the form "is
this file definitely newer than this other file".

For those kinds of tests, the application needs to know a lower bound
of the resolution.  Note that a jiffie is not suitable as the lower
bound, because that part of the timestamp is dropped when the inode is
dropped from memory.

The other kind of test is a comparison of one file against against its
own modification time when something derived from the file was last
cached.  (This is appropriate for server requests and JIT compiler
launching, for example).

This time there is only one resolution.  Nevertheless, to make a
reliable test of the form "have the contents of the file definitely
not been modified since mtime T", neither form of rounding on the
kernel side is sufficient: the application needs to know the
resolution.

I think that in all cases, for the application to make useful
decisions it needs to know the resolution of the timestamps in any
particular struct stat.  If those resolutions change when an inode is
flushed from memory: that should change the resolution returned by
struct stat.

So I propose: add a field to struct stat indicating the resolution of
the timestamps in it.  It can go on the end.

-- Jamie


  reply	other threads:[~2002-10-28 12:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 [this message]
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
     [not found] <20021027153651.GB26297@pimlott.net>
2002-10-28  9:47 ` Paul Eggert
2002-10-28 10:28   ` 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=20021028125652.GA16329@bjl1.asuk.net \
    --to=lk@tantalophile.demon.co.uk \
    --cc=ak@suse.de \
    --cc=eggert@twinsun.com \
    --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®