Skip to content

Commit 4681194

Browse files
committed
tmpfs_destroy_vobject(): clear v_object under the object lock
Which allows tmpfs_pager_writecount_recalc() to reliably detect reclaimed vnode and make its accesses to object->un_pager.swp.private (== vp) safe against reclaim. Note that vnode instantiation already assigns v_object under the object lock. Reviewed by: markj Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D45119
1 parent 6ada4e8 commit 4681194

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sys/fs/tmpfs/tmpfs_subr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ tmpfs_pager_writecount_recalc(vm_object_t object, vm_offset_t old,
120120
/*
121121
* Forced unmount?
122122
*/
123-
if (vp == NULL) {
123+
if (vp == NULL || vp->v_object == NULL) {
124124
KASSERT((object->flags & OBJ_TMPFS_VREF) == 0,
125125
("object %p with OBJ_TMPFS_VREF but without vnode",
126126
object));
@@ -957,6 +957,8 @@ tmpfs_destroy_vobject(struct vnode *vp, vm_object_t obj)
957957

958958
VM_OBJECT_WLOCK(obj);
959959
VI_LOCK(vp);
960+
vp->v_object = NULL;
961+
960962
/*
961963
* May be going through forced unmount.
962964
*/

0 commit comments

Comments
 (0)