[Aide] O_NOATIME for open(2) (also O_DIRECT, O_LARGEFILE ?)

Vlada Macek tuttle at bbs.cvut.cz
Mon Aug 8 18:42:41 EEST 2005


[At 08.08.2005 14:04, Richard van den Berg kindly sent the following
quotation.]

> Vlada Macek wrote:
>
>> there is a feature in Linux kernel since version 2.6.8 where root
>> (and possibly owner of the file?) can open(2) files with
>> O_NOATIME attribute. Then the access time of the hash-checked
>> files wont be altered. Is Aide using or going to use this
>> feature? It fits programs like Aide very well in my opinion.
>
>
> Sure. If you can point me to some sample code, as well as a way to
> detect the support of O_NOATIME using autoconf, I'll try to include
> it into aide.

I found a reasonable (IMHO) usage in this Linus's GIT source:

http://pasky.or.cz/~pasky/dev/git/git/sha1_file.c

    - The symbol is defined here, since many systems do not have
O_NOATIME #defined in their /usr/include yet, even when the kernel is
capable of the feature. Beware, this symbol unfortunately has
different numerical value for among architectures.

    - The fallback mechanism at open() is interesting.

I also found another Linux feature suitable for consideration  -
O_DIRECT ("bypass the I/O cache" hint).

One more thing, Aide is probably not opening files with O_LARGEFILE.
Isn't it a good habit these days? I'm not sure, I was just told...

Relevant parts of the manual (source: http://linuxreviews.org/man/open/):

O_DIRECT
    Try to minimize cache effects of the I/O to and from this file. In
    general this will degrade performance, but it is useful in special
    situations, such as when applications do their own caching. File
    I/O is done directly to/from user space buffers. The I/O is
    synchronous, i.e., at the completion of the read(2) or write(2)
    system call, data is guaranteed to have been transferred. Under
    Linux 2.4 transfer sizes, and the alignment of user buffer and
    file offset must all be multiples of the logical block size of the
    file system. Under Linux 2.6 alignment to 512-byte boundaries
    suffices.
    A semantically similar interface for block devices is described in
    raw(8).

O_LARGEFILE
    (LFS) Allow files whose sizes cannot be represented in an off_t
    (but can be represented in an off64_t) to be opened.

O_NOATIME
    (Since Linux 2.6.8) Do not update the file last access time when
    the file is read(2). This flag is intended for use by indexing or
    backup programs, where its use can significantly reduce the amount
    of disk activity. This flag may not be effective on all
    filesystems. One example is NFS, where the server maintains the
    access time.


EPERM
    The O_NOATIME flag was specified, but the effective user ID of the
    caller did not match the owner of the file and the caller was not
    privileged (CAP_FOWNER).


The O_NOATIME, O_NOFOLLOW, and O_DIRECTORY flags are Linux-specific.
One may have to define the _GNU_SOURCE macro to get their definitions.

The O_DIRECT flag was introduced in SGI IRIX, where it has alignment
restrictions similar to those of Linux 2.4. IRIX has also a fcntl(2)
call to query appropriate alignments, and sizes. FreeBSD 4.x
introduced a flag of same name, but without alignment restrictions.
Support was added under Linux in kernel version 2.4.10. Older Linux
kernels simply ignore this flag.

"The thing that has always disturbed me about O_DIRECT is that the
whole interface is just stupid, and was probably designed by a
deranged monkey on some serious mind-controlling substances." -- Linus

-- 

\//\/\
(Sometimes credited as 1494 F8DD 6379 4CD7 E7E3 1FC9 D750 4243 1F05 9424.)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://mailman.cs.tut.fi/pipermail/aide/attachments/20050808/dd11ad44/signature.bin


More information about the Aide mailing list