bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] Re: [patch] O_NOATIME support


From: Paul Eggert
Subject: [Bug-tar] Re: [patch] O_NOATIME support
Date: Wed, 21 Sep 2005 16:02:12 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Ian Turner <address@hidden> writes:

> Ah, so you're thinking of something like stat, read the whole file, and stat 
> again.

No, I wasn't thinking of adding any more system calls in the usual
case.  Tar already records the time that it starts up.  

Here is the heuristic I was thinking of, to be done just after we've
finished reading the file:

  * If the file is empty, stop.

  * If we have already detected that O_NOATIME works for this file system,
    stop.

  * If the final fstat (which tar is already doing) reports a
    last-access time that is older than tar's startup time, then
    O_NOATIME worked; record this fact for the current file system,
    and stop.

  * Fall back on the existing --preserve-atime method.  I.e., use
    futimes etc.

This heuristic never uses more system calls than the existing
--preserve-atime method.  In the usual case it never uses more system
calls than the existing code without --preserve-atime.  It's not
perfect, but it's better than the existing --preserve-atime in all
cases.

The heuristic can be made a bit fancier, if you like, to make the race
condition smaller, by checking the current time and rereading a small
part of the file before falling back on --preserve-atime.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]