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
This commit is contained in:
Konstantin Belousov 2020-02-04 19:05:58 +00:00
parent 8d34a3bf7d
commit c1e84733ac
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=357515
2 changed files with 15 additions and 8 deletions

View File

@ -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)

View File

@ -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,