Index | Thread | Search

From:
Rafael Sadowski <rafael@sizeofvoid.org>
Subject:
Re: relatime mount option for ffs filesystems
To:
tech@openbsd.org, Marcus Glocker <marcus@nazgul.ch>
Date:
Fri, 19 Sep 2025 19:31:56 +0200

Download raw body.

Thread
On Thu Sep 18, 2025 at 07:13:51PM +0200, Jeremie Courreges-Anglas wrote:
> On Tue, Aug 05, 2025 at 10:29:53AM +0100, Stuart Henderson wrote:
> > On 2025/08/05 06:59, Marcus Glocker wrote:
> > > On Mon, Aug 04, 2025 at 05:35:01PM +0200, Jeremie Courreges-Anglas wrote:
> > > 
> > > > 
> > > > With relatime, access time is updated on reads only if the file has
> > > > been modified (mtime/ctime) since the last read.  So merely reading
> > > > files no longer incurs pointless writes.
> > ..
> > > > The diff below implements it for ffs only.  It doesn't implement
> > > > possible tweaks like updating atime if previous access happened more
> > > > than 24 hours ago.
> > 
> > the ">24h" possible tweak would be helpful for this:
> > 
> > > /dev/sd0d on /tmp type ffs (local, relatime, nodev, nosuid)
> > 
> > without that, you should probably not use it for /tmp.
> > 
> > $ grep -A8 tmp /etc/daily
> 
> Indeed, here's a diff that adds the >24h check.
> 
> I still think we want something like this, though I won't push for
> this before the next release cycle.
> 
> Feedback and input still welcome.
> 

See below a proposal for the manpage.

> 
> Index: lib/libc/sys/mount.2
> ===================================================================
> RCS file: /home/cvs/src/lib/libc/sys/mount.2,v
> diff -u -p -r1.53 mount.2
> --- lib/libc/sys/mount.2	6 Aug 2025 13:23:27 -0000	1.53
> +++ lib/libc/sys/mount.2	18 Sep 2025 16:46:57 -0000
> @@ -78,6 +78,9 @@ suppress default semantics which affect 
>  .It Dv MNT_RDONLY
>  The filesystem should be treated as read-only:
>  even the superuser may not write to it.
> +.It Dv MNT_RELATIME
> +Only update the access time on files in the filesystem if the modification
> +or status change times are newer.

Only update the access time on files in the filesystem if the access time
is older than the modification or status change time, or if the access time
is more than 24 hours old.

>  .It Dv MNT_NOATIME
>  Do not update the access time on files in the filesystem unless
>  the modification or status change times are also being updated.
> Index: sbin/mount/mntopts.h
> ===================================================================
> RCS file: /home/cvs/src/sbin/mount/mntopts.h,v
> diff -u -p -r1.18 mntopts.h
> --- sbin/mount/mntopts.h	10 Sep 2016 16:53:30 -0000	1.18
> +++ sbin/mount/mntopts.h	18 Sep 2025 16:46:57 -0000
> @@ -61,6 +61,7 @@ union mntval {
>  #define MOPT_NOPERM	{ "perm",	MNT_NOPERM, MFLAG_INVERSE | MFLAG_SET }
>  #define MOPT_WXALLOWED	{ "wxallowed",	MNT_WXALLOWED, MFLAG_SET }
>  #define MOPT_RDONLY	{ "rdonly",	MNT_RDONLY, MFLAG_SET }
> +#define MOPT_RELATIME	{ "relatime",	MNT_RELATIME, MFLAG_SET }
>  #define MOPT_SYNC	{ "sync",	MNT_SYNCHRONOUS, MFLAG_SET }
>  #define MOPT_USERQUOTA	{ "userquota",	0, MFLAG_SET | MFLAG_STRVAL \
>  					    | MFLAG_OPT }
> Index: sbin/mount/mount.8
> ===================================================================
> RCS file: /home/cvs/src/sbin/mount/mount.8,v
> diff -u -p -r1.92 mount.8
> --- sbin/mount/mount.8	10 Nov 2023 00:26:00 -0000	1.92
> +++ sbin/mount/mount.8	18 Sep 2025 16:46:57 -0000
> @@ -178,8 +178,16 @@ The same as
>  .Fl f ;
>  forces the revocation of write access when trying to downgrade
>  a file system mount status from read-write to read-only.
> +.It Cm relatime
> +(FFS only)
> +Only update the access time on files in the filesystem if it is older
> +than the modification or change time.
> +Like

Only update the access time on files in the filesystem if the access time
is older than the modification or status change time, or if the access time
is more than 24 hours old.

> +.Cm noatime ,
> +it is useful to avoid extra disk activity, but is also more friendly
> +to some applications.
>  .It Cm noatime
> -Do not update atime on files in the system unless the mtime or ctime
> +Do not update atime on files in the filesystem unless the mtime or ctime
>  is being changed as well.