diff options
author | kib <kib@FreeBSD.org> | 2015-04-08 02:15:13 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2015-04-08 02:15:13 +0000 |
commit | e5886b520a9b363350787735e15fcff6b2b69b8a (patch) | |
tree | 3005e659d8e4276f2e8292cf6111769e9853315d /sys/fs | |
parent | 3713ef6b03e4017a5ba9e902268968038c9c14de (diff) | |
download | FreeBSD-src-e5886b520a9b363350787735e15fcff6b2b69b8a.zip FreeBSD-src-e5886b520a9b363350787735e15fcff6b2b69b8a.tar.gz |
MFC r280308 (by delphij):
Disable timestamping on devfs read/write operations by default.
MFC r280949:
Refine r280308. Use seconds precision for devfs timestamps by default.
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/devfs/devfs_devs.c | 2 | ||||
-rw-r--r-- | sys/fs/devfs/devfs_vnops.c | 31 |
2 files changed, 30 insertions, 3 deletions
diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c index c2d40d3..5070985 100644 --- a/sys/fs/devfs/devfs_devs.c +++ b/sys/fs/devfs/devfs_devs.c @@ -61,7 +61,7 @@ static MALLOC_DEFINE(M_DEVFS2, "DEVFS2", "DEVFS data 2"); static MALLOC_DEFINE(M_DEVFS3, "DEVFS3", "DEVFS data 3"); static MALLOC_DEFINE(M_CDEVP, "DEVFS1", "DEVFS cdev_priv storage"); -static SYSCTL_NODE(_vfs, OID_AUTO, devfs, CTLFLAG_RW, 0, "DEVFS filesystem"); +SYSCTL_NODE(_vfs, OID_AUTO, devfs, CTLFLAG_RW, 0, "DEVFS filesystem"); static unsigned devfs_generation; SYSCTL_UINT(_vfs_devfs, OID_AUTO, generation, CTLFLAG_RD, diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 134f8b0..7f20389 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -57,6 +57,7 @@ #include <sys/proc.h> #include <sys/stat.h> #include <sys/sx.h> +#include <sys/sysctl.h> #include <sys/time.h> #include <sys/ttycom.h> #include <sys/unistd.h> @@ -79,6 +80,32 @@ SX_SYSINIT(clone_drain_lock, &clone_drain_lock, "clone events drain lock"); struct mtx cdevpriv_mtx; MTX_SYSINIT(cdevpriv_mtx, &cdevpriv_mtx, "cdevpriv lock", MTX_DEF); +SYSCTL_DECL(_vfs_devfs); + +static int devfs_dotimes; +SYSCTL_INT(_vfs_devfs, OID_AUTO, dotimes, CTLFLAG_RW, + &devfs_dotimes, 0, "Update timestamps on DEVFS with default precision"); + +/* + * Update devfs node timestamp. Note that updates are unlocked and + * stat(2) could see partially updated times. + */ +static void +devfs_timestamp(struct timespec *tsp) +{ + time_t ts; + + if (devfs_dotimes) { + vfs_timestamp(tsp); + } else { + ts = time_second; + if (tsp->tv_sec != ts) { + tsp->tv_sec = ts; + tsp->tv_nsec = 0; + } + } +} + static int devfs_fp_check(struct file *fp, struct cdev **devp, struct cdevsw **dswp, int *ref) @@ -1200,7 +1227,7 @@ devfs_read_f(struct file *fp, struct uio *uio, struct ucred *cred, foffset_lock_uio(fp, uio, flags | FOF_NOLOCK); error = dsw->d_read(dev, uio, ioflag); if (uio->uio_resid != resid || (error == 0 && resid != 0)) - vfs_timestamp(&dev->si_atime); + devfs_timestamp(&dev->si_atime); td->td_fpop = fpop; dev_relthread(dev, ref); @@ -1679,7 +1706,7 @@ devfs_write_f(struct file *fp, struct uio *uio, struct ucred *cred, error = dsw->d_write(dev, uio, ioflag); if (uio->uio_resid != resid || (error == 0 && resid != 0)) { - vfs_timestamp(&dev->si_ctime); + devfs_timestamp(&dev->si_ctime); dev->si_mtime = dev->si_ctime; } td->td_fpop = fpop; |