[PATCH] O_NOATIME support for open(2)

Konstantin Belousov kostikbel at gmail.com
Sun Aug 27 14:17:19 UTC 2017


On Sun, Aug 27, 2017 at 03:18:06PM +0200, Daniel Roethlisberger wrote:
> Konstantin Belousov <kostikbel at gmail.com> 2017-08-26:
> > On Sat, Aug 26, 2017 at 06:18:27PM +0200, Daniel Roethlisberger wrote:
> > > I'm trying to implement O_NOATIME support for open(2) in order to
> > > provide a more elegant way for backup/archiving software to
> > > prevent atime clobbering.  Except for a 2008 thread on this list
> > > I did not find any material; not sure if anybody is interested in
> > > this or if there are reasons why this was never implemented.
> > Please point out the thread, e.g. by providing a link to the first
> > message in the thread in mailman archive.
> 
> https://lists.freebsd.org/pipermail/freebsd-hackers/2008-October/thread.html#26531
> https://lists.freebsd.org/pipermail/freebsd-hackers/2008-October/026531.html
> 
Thank you.

> > > The attached patch against 11.1 implements O_NOATIME support for
> > > open(2); it prevents read(2) and mmap(2) from clobbering atime if
> > > the file descriptor was opened with O_NOATIME.  O_NOATIME is only
> > > permitted for root and the owner of the file.  Currently it is
> > > only implemented for ufs/ffs.  It seems to work for me but has
> > > not been extensively tested.
> > What would happen when additional page-in occurs on the mmaped area ?
> 
> With mmap, the vnode is marked for atime update at the time of
> calling mmap (unless O_NOATIME is set on the fd).  I do not see
> how the patch would impact page-ins in any way.  Can you
> elaborate?

I mean, do we have some code paths which would cause page-ins to set
atime ? If we currently do not have that, fine. My brief reading of the
code suggests that we do not, at least for UFS.

Somewhat related, if an image file is opened O_EXEC | O_NOATIME, does
calling fexecve(2) on the fd prevents atime update with your patch ?
It seems to me that the case is not handled.

Note that in kernel code, we usually prefer O_XXX spelling for the open
flags over the FXXX.


More information about the freebsd-hackers mailing list