linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Proposal: Use hi-res clock for file timestamps
@ 2010-08-13 18:25 Patrick J. LoPresti
       [not found] ` <AANLkTimnyXKahtjaFeSsgcq=xMy-pP3na1jidQhZ-dt2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 42+ messages in thread
From: Patrick J. LoPresti @ 2010-08-13 18:25 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-nfs, linux-kernel

For concreteness, let me start with the patch I have in mind.  Call it
"patch version 1".


--- linux-2.6.32.13-0.4/kernel/time.c.orig      2010-08-13
10:52:50.000000000 -0700
+++ linux-2.6.32.13-0.4/kernel/time.c   2010-08-13 10:53:20.000000000 -0700
@@ -229,7 +229,7 @@ SYSCALL_DEFINE1(adjtimex, struct timex _
  */
 struct timespec current_fs_time(struct super_block *sb)
 {
-        struct timespec now = current_kernel_time();
+       struct timespec now = getnstimeofday();
        return timespec_trunc(now, sb->s_time_gran);
 }
 EXPORT_SYMBOL(current_fs_time);

...

I recently spent nearly a week tracking down an NFS cache coherence
problem in an application:

http://www.spinics.net/lists/linux-nfs/msg14974.html

Here is what caused my problem:

1) File dir/A is created locally on NFS server.
2) NFS client does LOOKUP on file dir/B, gets ENOENT.
3) File dir/B is created locally on NFS server.

In my case, these all happened in less than 4 milliseconds (much less,
actually).  Since HZ on my system is 250, the file creation in step
(3) failed to update the ctime/mtime on the directory.  The result is
that the NFS client's "dentry lookup cache" became stale, but did not
know it was stale (since it relies on the directory ctime/mtime to
detect that).  Worse, the staleness persists even if additional
changes are made to the directory from the NFS client, thanks to NFS
v3's "weak cache consistency" optimizations.

Why did this take me a week to diagnose?  Because I am using XFS, and
I know XFS and NFS use nanosecond resolution for file timestamps.  It
never occurred to me that, here in 2010, Linux would have an actual
file timestamp resolution 6.5 orders of magnitude worse.

I know, I know, "use NFS v4 and i_version".  But that is not the
point.  The point is that 4 milliseconds is a very long time these
days; an awful lot of file system operations can happen in such an
interval.

I am guessing the objection to the above patch will be:  "Waaah it's
slow!"  My responses would be:

1) Anybody who cares about file system performance is already using
"noatime" or "relatime", which mitigates the hit greatly.

2) Correctness is more important than performance, and 4 milliseconds
is just embarrassing.

3) On the 99.99% of Linux systems that are post-1990 x86, it is not
slow at all, and the performance difference will be utterly
undetectable in the real world.

When was XFS designed?  It has nanosecond timestamps.  When was NFS
designed?  It has nanosecond timestamps.  Even ext4 has nanosecond
timestamps...  But what is the point if 22 bits' worth will forever be
meaningless?

If the above patch is too slow for some architectures, how about
making it a configuration option?  Call it "CONFIG_1980S_FILE_TICK",
have it default to YES on the architectures that care and NO on
anything remotely modern and sane.

OK that's my proposal.  Bash away.

 - Pat

^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2010-08-19 22:53 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-13 18:25 Proposal: Use hi-res clock for file timestamps Patrick J. LoPresti
     [not found] ` <AANLkTimnyXKahtjaFeSsgcq=xMy-pP3na1jidQhZ-dt2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-08-13 18:45   ` john stultz
2010-08-13 18:57     ` Patrick J. LoPresti
2010-08-13 19:09       ` john stultz
     [not found]         ` <1281726579.2810.10.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-08-13 20:53           ` Patrick J. LoPresti
2010-08-14 16:45             ` Patrick J. LoPresti
2010-08-15  1:50             ` Bret Towe
2010-08-17 14:54   ` Andi Kleen
     [not found]     ` <87aaolwar8.fsf-3rXA9MLqAseW/qJFnhkgxti2O/JbrIOy@public.gmane.org>
2010-08-17 17:41       ` J. Bruce Fields
     [not found]         ` <20100817174134.GA23176-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2010-08-17 18:29           ` Andi Kleen
2010-08-17 19:04             ` J. Bruce Fields
     [not found]               ` <20100817190447.GA28049-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2010-08-17 19:18                 ` Patrick J. LoPresti
     [not found]                   ` <AANLkTi=w1UA5ZZDBigpxMiL7A7DnbnQhLkg62JZpC6Ri-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-08-17 19:39                     ` Alan Cox
     [not found]                       ` <20100817203941.729830b7-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2010-08-17 19:29                         ` J. Bruce Fields
     [not found]                           ` <20100817192937.GD26609-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2010-08-17 19:52                             ` Alan Cox
2010-08-18  5:53                             ` Neil Brown
2010-08-18 14:46                               ` Patrick J. LoPresti
2010-08-18 17:32                               ` J. Bruce Fields
     [not found]                                 ` <20100818173203.GC32430-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2010-08-18 18:15                                   ` Chuck Lever
     [not found]                                     ` <0F91AB9D-0E14-4384-ADD6-0A467C3ABFAC-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2010-08-18 23:41                                       ` Neil Brown
2010-08-19  0:52                                         ` Neil Brown
2010-08-19  2:08                                           ` J. Bruce Fields
     [not found]                                             ` <20100819020803.GA30151-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2010-08-19  2:44                                               ` Neil Brown
2010-08-19 22:46                                                 ` J. Bruce Fields
2010-08-18 23:47                                   ` Neil Brown
2010-08-18 17:50                               ` Andi Kleen
2010-08-18 18:54                                 ` J. Bruce Fields
2010-08-18 19:25                                   ` Andi Kleen
2010-08-18 19:30                                     ` J. Bruce Fields
2010-08-17 19:34                         ` Patrick J. LoPresti
2010-08-17 19:54                           ` Alan Cox
     [not found]                             ` <20100817205441.200ab9a4-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2010-08-17 19:43                               ` Patrick J. LoPresti
     [not found]                                 ` <AANLkTi=BB-zVFyCLgC+RWai9FFecaOad=pUC2=XFnY3J-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-08-17 19:45                                   ` J. Bruce Fields
2010-08-18 18:12                           ` J. Bruce Fields
2010-08-19  1:41                             ` john stultz
     [not found]                               ` <AANLkTi=cx31Mgfe7FxJz6LUmTKFR4=9KEBgbFsNLjiSE-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-08-19  2:31                                 ` J. Bruce Fields
     [not found]                                   ` <20100819023106.GB30151-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2010-08-19  3:17                                     ` john stultz
2010-08-19 22:53                                       ` J. Bruce Fields
     [not found]             ` <20100817182920.GD18161-u0/ZJuX+froe6aEkudXLsA@public.gmane.org>
2010-08-17 18:50               ` Patrick J. LoPresti
2010-08-18 18:20               ` David Woodhouse
2010-08-18 18:32                 ` Patrick J. LoPresti
2010-08-18 18:53                 ` Andi Kleen

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).