From a89cd2a4bd751f9fd832c47aeb0d48ed093ab95f Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Wed, 28 Aug 2019 20:35:23 +0000 Subject: [PATCH] tmpfs: use VOP_NEED_INACTIVE Reviewed by: kib Tested by: pho Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21371 --- sys/fs/tmpfs/tmpfs_vnops.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 4bbf3485909f..1b3aa6d2db92 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -1283,6 +1283,27 @@ tmpfs_inactive(struct vop_inactive_args *v) return (0); } +static int +tmpfs_need_inactive(struct vop_need_inactive_args *ap) +{ + struct vnode *vp; + struct tmpfs_node *node; + struct vm_object *obj; + + vp = ap->a_vp; + node = VP_TO_TMPFS_NODE(vp); + if (node->tn_links == 0) + goto need; + if (vp->v_type == VREG) { + obj = vp->v_object; + if ((obj->flags & OBJ_TMPFS_DIRTY) != 0) + goto need; + } + return (0); +need: + return (1); +} + int tmpfs_reclaim(struct vop_reclaim_args *v) { @@ -1584,6 +1605,7 @@ struct vop_vector tmpfs_vnodeop_entries = { .vop_readdir = tmpfs_readdir, .vop_readlink = tmpfs_readlink, .vop_inactive = tmpfs_inactive, + .vop_need_inactive = tmpfs_need_inactive, .vop_reclaim = tmpfs_reclaim, .vop_print = tmpfs_print, .vop_pathconf = tmpfs_pathconf,