diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h index 126b99acba6..7e24fd5e192 100644 --- a/sys/fs/tmpfs/tmpfs.h +++ b/sys/fs/tmpfs/tmpfs.h @@ -428,6 +428,9 @@ struct tmpfs_mount { bool tm_nonc; /* Do not update mtime on writes through mmaped areas. */ bool tm_nomtime; + + /* Read from page cache directly. */ + bool tm_pgread; }; #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_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index 28834a96ee9..69a9936ebcd 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -1061,7 +1061,8 @@ tmpfs_alloc_vp(struct mount *mp, struct tmpfs_node *node, int lkflag, VI_LOCK(vp); KASSERT(vp->v_object == NULL, ("Not NULL v_object in tmpfs")); vp->v_object = object; - vn_irflag_set_locked(vp, VIRF_PGREAD | VIRF_TEXT_REF); + vn_irflag_set_locked(vp, (tm->tm_pgread ? VIRF_PGREAD : 0) | + VIRF_TEXT_REF); VI_UNLOCK(vp); VM_OBJECT_WUNLOCK(object); break; diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index 7a88e7deba9..b04b3c084b3 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -329,7 +329,7 @@ tmpfs_mount(struct mount *mp) struct tmpfs_mount *tmp; struct tmpfs_node *root; int error; - bool nomtime, nonc; + bool nomtime, nonc, pgread; /* Size counters. */ u_quad_t pages; off_t nodes_max, size_max, maxfilesize, ea_max_size; @@ -412,6 +412,7 @@ tmpfs_mount(struct mount *mp) ea_max_size = 0; nonc = vfs_getopt(mp->mnt_optnew, "nonc", NULL, NULL) == 0; nomtime = vfs_getopt(mp->mnt_optnew, "nomtime", NULL, NULL) == 0; + pgread = vfs_getopt(mp->mnt_optnew, "pgread", NULL, NULL) == 0; /* Do not allow mounts if we do not have enough memory to preserve * the minimum reserved pages. */ @@ -462,6 +463,7 @@ tmpfs_mount(struct mount *mp) tmp->tm_ronly = (mp->mnt_flag & MNT_RDONLY) != 0; tmp->tm_nonc = nonc; tmp->tm_nomtime = nomtime; + tmp->tm_pgread = pgread; /* Allocate the root node. */ error = tmpfs_alloc_node(mp, tmp, VDIR, root_uid, root_gid,