> "Richard L. Hamilton" <[EMAIL PROTECTED]> wrote:
> 
> > > This sounds OK as long as the O_NOATIME flag may
> be
> > > added after an open(2)
> > > via fcntl(2) - to preventfuture atime updates
> with
> > > read(2). This is needed 
> > > in order to allow O_NOATIME to be useful for
> files
> > > opened via fopen(3).
> > > 
> >
> > I'd like that too, but is it really necessary?
>  Instead of inserting 
> 
> >     if ((fl=fcntl(fileno(mystream),F_GETFL,0)) !=
> -1)
> >
>         fcntl(fileno(mystream),F_SETFL,fl|O_NOATIME);
> r the fopen(), couldn't one just replace the fopen()
> > with an open()/fdopen() pair, where the open() used
> the desired flags?
> 
> Sometimes, a bigger long existing software structure
> may prevent this.
> 
> Jörg

Well, I _think_ it would be little or no extra trouble to make
it available via fcntl() anyway.  From sys/fcntl.h, it looks like the
0x20 open flag is the last (16-bit) value not already used (unless I missed it).
If that were used, it looks like perhaps open() and fcntl() wouldn't even
have to be changed to pass it through; it would be up to each filesystem, if
it wanted to support it.  NFS probably couldn't (at least not without a
protocol change?), not that it would make much sense for NFS anyway.
I expect most local filesystems could do this without huge difficulty - the
flag should get passed to the filesystem via the uio pointer (2nd arg to
VOP_READ() ).  Likely start would be ufs and zfs; I think those are the
only two that currently have a noatime mount option (which might mean
it would be easier to do for them).  I think it might not be bad to have
pcfs support this as well.

The question is whether someone already had plans for that last bit
(of struct file's f_flag member or of struct uio's  uio_fmode member).

In favor of a O_NOATIME flag, it looks like Linux has this, defined as
> O_NOATIME
>    (Since Linux 2.6.8) Do not update the file last access time (st_atime in
> the inode) 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.

However, I think there should be a new privilege for it, such that if one
didn't have the privilege, open() and fcntl() would just silently cause the
flag to be ignored.  That wouldn't break anything as such, but would
keep the atime something that could mostly be relied on.

Still, adding support for the flag would not only provide a cleaner and
more generic way to achieve the objective, it would increase portability
of backup or "desktop" file indexing code written for Linux, which would
IMO probably be good provided doing so isn't ugly.

And the more I look at this, the easier it looks like it just might be...
 
 
This message posted from opensolaris.org
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to