aboutsummaryrefslogtreecommitdiff
path: root/sys/fs
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2020-02-04 19:05:58 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2020-02-04 19:05:58 +0000
commitc1e84733ac7e506e1f0c7fa2f812947ea2f12632 (patch)
tree7d82eeaae3f47dc1d350b4688d92ae8bfda4525a /sys/fs
parent8d34a3bf7d64f61bc6d1519cf75c76e976572469 (diff)
downloadsrc-c1e84733ac7e506e1f0c7fa2f812947ea2f12632.tar.gz
src-c1e84733ac7e506e1f0c7fa2f812947ea2f12632.zip
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
Notes
Notes: svn path=/head/; revision=357515
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/tmpfs/tmpfs.h2
-rw-r--r--sys/fs/tmpfs/tmpfs_vfsops.c21
2 files changed, 15 insertions, 8 deletions
diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h
index 1645661f0b5c..8b6ea0789b43 100644
--- a/sys/fs/tmpfs/tmpfs.h
+++ b/sys/fs/tmpfs/tmpfs.h
@@ -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)
diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c
index a159f94570f1..2ce471d9917d 100644
--- a/sys/fs/tmpfs/tmpfs_vfsops.c
+++ b/sys/fs/tmpfs/tmpfs_vfsops.c
@@ -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,