From owner-svn-src-head@freebsd.org Tue Feb 4 19:05:59 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B96372302CF; Tue, 4 Feb 2020 19:05:59 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48BvKz4TH4z4N0F; Tue, 4 Feb 2020 19:05:59 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 90ABD1E786; Tue, 4 Feb 2020 19:05:59 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 014J5xkN040191; Tue, 4 Feb 2020 19:05:59 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 014J5xZ4040189; Tue, 4 Feb 2020 19:05:59 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202002041905.014J5xZ4040189@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 4 Feb 2020 19:05:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357515 - head/sys/fs/tmpfs X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/fs/tmpfs X-SVN-Commit-Revision: 357515 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Feb 2020 19:05:59 -0000 Author: kib Date: Tue Feb 4 19:05:58 2020 New Revision: 357515 URL: https://svnweb.freebsd.org/changeset/base/357515 Log: tmpfs: add nomtime mount option, which disables tracking mtime updates due to writes through the shared mapped areas backed by tmpfs files. This removes periodic scans which downgrades rw mapped pages to ro to note the writes. Suggested by: mjg Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D23432 Modified: head/sys/fs/tmpfs/tmpfs.h head/sys/fs/tmpfs/tmpfs_vfsops.c Modified: head/sys/fs/tmpfs/tmpfs.h ============================================================================== --- head/sys/fs/tmpfs/tmpfs.h Tue Feb 4 19:03:37 2020 (r357514) +++ head/sys/fs/tmpfs/tmpfs.h Tue Feb 4 19:05:58 2020 (r357515) @@ -382,6 +382,8 @@ struct tmpfs_mount { bool tm_ronly; /* Do not use namecache. */ bool tm_nonc; + /* Do not update mtime on writes through mmaped areas. */ + bool tm_nomtime; }; #define TMPFS_LOCK(tm) mtx_lock(&(tm)->tm_allnode_lock) #define TMPFS_UNLOCK(tm) mtx_unlock(&(tm)->tm_allnode_lock) Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_vfsops.c Tue Feb 4 19:03:37 2020 (r357514) +++ head/sys/fs/tmpfs/tmpfs_vfsops.c Tue Feb 4 19:05:58 2020 (r357515) @@ -92,20 +92,19 @@ static void tmpfs_susp_clean(struct mount *); static const char *tmpfs_opts[] = { "from", "size", "maxfilesize", "inodes", "uid", "gid", "mode", "export", - "union", "nonc", NULL + "union", "nonc", "nomtime", NULL }; static const char *tmpfs_updateopts[] = { - "from", "export", "size", NULL + "from", "export", "nomtime", "size", NULL }; /* - * Handle updates of time from writes to mmaped regions. Use - * MNT_VNODE_FOREACH_ALL instead of MNT_VNODE_FOREACH_LAZY, since + * Handle updates of time from writes to mmaped regions, if allowed. + * Use MNT_VNODE_FOREACH_ALL instead of MNT_VNODE_FOREACH_LAZY, since * unmap of the tmpfs-backed vnode does not call vinactive(), due to - * vm object type is OBJT_SWAP. - * If lazy, only handle delayed update of mtime due to the writes to - * mapped files. + * vm object type is OBJT_SWAP. If lazy, only handle delayed update + * of mtime due to the writes to mapped files. */ static void tmpfs_update_mtime(struct mount *mp, bool lazy) @@ -113,6 +112,8 @@ tmpfs_update_mtime(struct mount *mp, bool lazy) struct vnode *vp, *mvp; struct vm_object *obj; + if (VFS_TO_TMPFS(mp)->tm_nomtime) + return; MNT_VNODE_FOREACH_ALL(vp, mp, mvp) { if (vp->v_type != VREG) { VI_UNLOCK(vp); @@ -327,7 +328,7 @@ tmpfs_mount(struct mount *mp) struct tmpfs_mount *tmp; struct tmpfs_node *root; int error; - bool nonc; + bool nomtime, nonc; /* Size counters. */ u_quad_t pages; off_t nodes_max, size_max, maxfilesize; @@ -370,6 +371,8 @@ tmpfs_mount(struct mount *mp) mp->mnt_flag &= ~MNT_RDONLY; MNT_IUNLOCK(mp); } + tmp->tm_nomtime = vfs_getopt(mp->mnt_optnew, "nomtime", NULL, + 0) == 0; return (0); } @@ -395,6 +398,7 @@ tmpfs_mount(struct mount *mp) if (vfs_getopt_size(mp->mnt_optnew, "maxfilesize", &maxfilesize) != 0) maxfilesize = 0; nonc = vfs_getopt(mp->mnt_optnew, "nonc", NULL, NULL) == 0; + nomtime = vfs_getopt(mp->mnt_optnew, "nomtime", NULL, NULL) == 0; /* Do not allow mounts if we do not have enough memory to preserve * the minimum reserved pages. */ @@ -441,6 +445,7 @@ tmpfs_mount(struct mount *mp) new_unrhdr64(&tmp->tm_ino_unr, 2); tmp->tm_ronly = (mp->mnt_flag & MNT_RDONLY) != 0; tmp->tm_nonc = nonc; + tmp->tm_nomtime = nomtime; /* Allocate the root node. */ error = tmpfs_alloc_node(mp, tmp, VDIR, root_uid, root_gid,