Date: Tue, 4 Feb 2020 19:05:59 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357515 - head/sys/fs/tmpfs Message-ID: <202002041905.014J5xZ4040189@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002041905.014J5xZ4040189>