From owner-svn-src-stable@FreeBSD.ORG Wed Apr 8 02:15:14 2015 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B49784E0; Wed, 8 Apr 2015 02:15:14 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 951592FF; Wed, 8 Apr 2015 02:15:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t382FEIS002606; Wed, 8 Apr 2015 02:15:14 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t382FDC0002604; Wed, 8 Apr 2015 02:15:13 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201504080215.t382FDC0002604@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 8 Apr 2015 02:15:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r281255 - stable/10/sys/fs/devfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Apr 2015 02:15:14 -0000 Author: kib Date: Wed Apr 8 02:15:13 2015 New Revision: 281255 URL: https://svnweb.freebsd.org/changeset/base/281255 Log: 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. Modified: stable/10/sys/fs/devfs/devfs_devs.c stable/10/sys/fs/devfs/devfs_vnops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/devfs/devfs_devs.c ============================================================================== --- stable/10/sys/fs/devfs/devfs_devs.c Wed Apr 8 01:55:22 2015 (r281254) +++ stable/10/sys/fs/devfs/devfs_devs.c Wed Apr 8 02:15:13 2015 (r281255) @@ -61,7 +61,7 @@ static MALLOC_DEFINE(M_DEVFS2, "DEVFS2", 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, Modified: stable/10/sys/fs/devfs/devfs_vnops.c ============================================================================== --- stable/10/sys/fs/devfs/devfs_vnops.c Wed Apr 8 01:55:22 2015 (r281254) +++ stable/10/sys/fs/devfs/devfs_vnops.c Wed Apr 8 02:15:13 2015 (r281255) @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -79,6 +80,32 @@ SX_SYSINIT(clone_drain_lock, &clone_drai 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 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 ui 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;