[PATCH] O_NOATIME support for open(2)
Daniel Roethlisberger
daniel at roe.ch
Sun Aug 27 23:54:29 UTC 2017
Konstantin Belousov <kostikbel at gmail.com> 2017-08-27:
> > > > 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.
Thanks for clarifying. I am not aware of any atime-updating
page-in code paths.
> 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.
Correct, thanks.
> Note that in kernel code, we usually prefer O_XXX spelling for the open
> flags over the FXXX.
I removed FNOATIME entirely based on your feedback.
Attached a revised patch that incorporates most of the feedback,
plus supports setting/unsetting O_NOATIME through fcntl and
handles many of the local file systems. It also enables
O_NOATIME in the Linux compat shim. Docs are still missing, and
testing on other filesystems than UFS very limited or not at all.
Additional feedback much appreciated, especially on the code in
kern_fcntl and vn_open_vnode.
Daniel
--
Daniel Roethlisberger
http://daniel.roe.ch/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: onoatime-v3.diff
Type: text/x-diff
Size: 12050 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20170828/d7273ca1/attachment.diff>
More information about the freebsd-hackers
mailing list