Change default VFS timestamp precision?

Warner Losh imp at bsdimp.com
Tue Dec 16 22:41:37 UTC 2014


> On Dec 16, 2014, at 12:37 PM, John Baldwin <jhb at FreeBSD.org> wrote:
> 
> On Tuesday, December 16, 2014 1:51:09 pm Warner Losh wrote:
>> 
>>> On Dec 16, 2014, at 11:48 AM, John Baldwin <jhb at freebsd.org> wrote:
>>> 
>>> We still ship with vfs.timestamp_precision=0 by default meaning that VFS
>>> timestamps have a granularity of one second.  It is not unusual on modern
>>> systems for multiple updates to a file or directory to occur within a single
>>> second (and thus share the same effective timestamp).  This can break things
>>> that depend on timestamps to know when something has changed or is stale (such
>>> as make(1) or NFS clients).  On hardware that has a cheap timecounter, I we
>>> should use the most-precise timestamps (vfs.timestamp_precision=3).  However,
>>> I'm less sure of what to do for other cases such as i386/amd64 when not using
>>> TSC, or on other platforms.  OTOH, perhaps you aren't doing lots of heavy I/O
>>> access on a system with a slow timecounter (or if you are doing heavy I/O,
>>> slow timecounter access won't be your bottleneck)?
>>> 
>>> I can think of a few options:
>>> 
>>> 1) Change vfs.timestamp_precision default to 3 for all systems.
>>> 
>>> 2) Only change vfs.timestamp_precision default to 3 for amd64/i386 using an
>>>   #ifdef.
>>> 
>>> 3) Something else?
>>> 
>>> What do other folks think?
>> 
>> (1). If there’s a specific kernel / platform that’s slow, we can make it an option
>> for those kernels.
> 
> Mm, so something like:
> 
> Index: vfs_subr.c
> ===================================================================
> --- vfs_subr.c	(revision 275828)
> +++ vfs_subr.c	(working copy)
> @@ -632,7 +632,11 @@ vfs_getnewfsid(struct mount *mp)
>  */
> enum { TSP_SEC, TSP_HZ, TSP_USEC, TSP_NSEC };
> 
> +#ifdef VFS_CHEAP_TIMESTAMPS
> static int timestamp_precision = TSP_SEC;
> +#else
> +static int timestamp_precision = TSP_NSEC;
> +#endif
> SYSCTL_INT(_vfs, OID_AUTO, timestamp_precision, CTLFLAG_RW,
>     &timestamp_precision, 0, "File timestamp precision (0: seconds, "
>     "1: sec + ns accurate to 1/HZ, 2: sec + ns truncated to ms, "
> 
> where VFS_CHEAP_TIMESTAMPS becomes a new kernel config option?
> 
> (We should also probably make this a loader tunable)

Yea, the DEFAULT behavior should be set at compile time, the run-time behavior should be set by this variable…. Tunable is good too, but the sysctl likely will suffice for that given how early the sysctl.conf file is snarfed.

Warner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20141216/21c0fd0f/attachment.sig>


More information about the freebsd-arch mailing list