git: e45c358ec663 - stable/13 - tmpfs_destroy_vobject(): clear v_object under the object lock

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 20 May 2024 00:26:05 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=e45c358ec6639209c748f6ad0dd2f89ebedfa91e

commit e45c358ec6639209c748f6ad0dd2f89ebedfa91e
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-05-12 01:26:32 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-05-19 00:59:13 +0000

    tmpfs_destroy_vobject(): clear v_object under the object lock
    
    (cherry picked from commit 46811949797b7e44521cd56cfa61b6c8378c4600)
---
 sys/fs/tmpfs/tmpfs_subr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index 90fffb11e4c6..54d28edb10b5 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -116,7 +116,7 @@ tmpfs_pager_writecount_recalc(vm_object_t object, vm_offset_t old,
 	/*
 	 * Forced unmount?
 	 */
-	if (vp == NULL) {
+	if (vp == NULL || vp->v_object == NULL) {
 		KASSERT((object->flags & OBJ_TMPFS_VREF) == 0,
 		    ("object %p with OBJ_TMPFS_VREF but without vnode",
 		    object));
@@ -909,6 +909,8 @@ tmpfs_destroy_vobject(struct vnode *vp, vm_object_t obj)
 
 	VM_OBJECT_WLOCK(obj);
 	VI_LOCK(vp);
+	vp->v_object = NULL;
+
 	/*
 	 * May be going through forced unmount.
 	 */