Skip to content

Commit 58d7ac1

Browse files
committed
tmpfs: recalculate OBJ_TMPFS_VREF on reinstantiating node' vnode
Reported and tested by: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D45119
1 parent 6638384 commit 58d7ac1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sys/fs/tmpfs/tmpfs_subr.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -1094,15 +1094,19 @@ tmpfs_alloc_vp(struct mount *mp, struct tmpfs_node *node, int lkflag,
10941094
KASSERT((object->flags & OBJ_TMPFS_VREF) == 0,
10951095
("%s: object %p with OBJ_TMPFS_VREF but without vnode",
10961096
__func__, object));
1097-
KASSERT(object->un_pager.swp.writemappings == 0,
1098-
("%s: object %p has writemappings",
1099-
__func__, object));
11001097
VI_LOCK(vp);
11011098
KASSERT(vp->v_object == NULL, ("Not NULL v_object in tmpfs"));
11021099
vp->v_object = object;
11031100
vn_irflag_set_locked(vp, (tm->tm_pgread ? VIRF_PGREAD : 0) |
11041101
VIRF_TEXT_REF);
11051102
VI_UNLOCK(vp);
1103+
VNASSERT((object->flags & OBJ_TMPFS_VREF) == 0, vp,
1104+
("leaked OBJ_TMPFS_VREF"));
1105+
if (object->un_pager.swp.writemappings > 0) {
1106+
vrefact(vp);
1107+
vlazy(vp);
1108+
vm_object_set_flag(object, OBJ_TMPFS_VREF);
1109+
}
11061110
VM_OBJECT_WUNLOCK(object);
11071111
break;
11081112
case VDIR:

0 commit comments

Comments
 (0)