svn commit: r280308 - head/sys/fs/devfs

Jilles Tjoelker jilles at stack.nl
Sun Mar 22 13:37:15 UTC 2015


On Sat, Mar 21, 2015 at 08:49:00PM +1100, Bruce Evans wrote:
> On Sat, 21 Mar 2015, Xin LI wrote:

> > Log:
> >  Disable timestamping on devfs read/write operations by default.

> >  Currently we update timestamps unconditionally when doing read or
> >  write operations.  This may slow things down on hardware where
> >  reading timestamps is expensive (e.g. HPET, because of the default
> >  vfs.timestamp_precision setting is nanosecond now) with limited
> >  benefit.

> >  A new sysctl variable, vfs.devfs.dotimes is added, which can be
> >  set to non-zero value when the old behavior is desirable.

> I don't like this.  It defaults to non-POSIX-conformant behaviour...

> The slowness is mostly from no delayed update of times in devfs.
> Switching vfs.timestamp_precision to a hardware timecounter would
> have been even more expensive for regular files if file systems
> didn't have delayed updates.  The assumption that vfs_timestamp()
> doesn't use a slow timecounter was so often satisfied that no one
> missed devfs also not supporting mounting with -noatime.

> Delayed updates are even easier to implement for devfs than for disk
> file systems the times never need to be written to disk.  A slow update
> is still wasteful for atimes, but not as bad as for disk file systems
> since it doesn't trigger a slower sync to disk.

Yes, I think implementing delayed updates is the right solution to this
problem. This way, only stat and last close will need to read the clock.
No configuration option will be needed.

A subtle difference with most other file systems is that devfs nodes
often stay open for very long, so the timestamps will usually come from
stat() calls, which may be much later than the actual read or write.
Still that is better than not updating timestamps at all.

> > ...
> > Modified: head/sys/fs/devfs/devfs_vnops.c
> > ==============================================================================
> > --- head/sys/fs/devfs/devfs_vnops.c	Sat Mar 21 00:21:30 2015	(r280307)
> > +++ head/sys/fs/devfs/devfs_vnops.c	Sat Mar 21 01:14:11 2015	(r280308)
> > ...
> > @@ -1700,7 +1708,8 @@ devfs_write_f(struct file *fp, struct ui
> > 	resid = uio->uio_resid;
> >
> > 	error = dsw->d_write(dev, uio, ioflag);
> > -	if (uio->uio_resid != resid || (error == 0 && resid != 0)) {
> > +	if (devfs_dotimes &&
> > +	    (uio->uio_resid != resid || (error == 0 && resid != 0))) {
> > 		vfs_timestamp(&dev->si_ctime);
> > 		dev->si_mtime = dev->si_ctime;
> > 	}

> An old bug is evident in the diff.  Writing shouldn't change the ctime.

That is not a bug. POSIX unambiguously requires write() to update both
mtime and ctime.

-- 
Jilles Tjoelker


More information about the svn-src-head mailing list