git: 58d7ac11e77d - main - tmpfs: recalculate OBJ_TMPFS_VREF on reinstantiating node' vnode
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 13 May 2024 18:34:24 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=58d7ac11e77db28640b8e47f9f9c1fe81d15baf5
commit 58d7ac11e77db28640b8e47f9f9c1fe81d15baf5
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-05-06 18:31:31 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-05-13 18:33:29 +0000
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
---
sys/fs/tmpfs/tmpfs_subr.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index 9bdcc4575511..84ce323441c1 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -1094,15 +1094,19 @@ loop:
KASSERT((object->flags & OBJ_TMPFS_VREF) == 0,
("%s: object %p with OBJ_TMPFS_VREF but without vnode",
__func__, object));
- KASSERT(object->un_pager.swp.writemappings == 0,
- ("%s: object %p has writemappings",
- __func__, object));
VI_LOCK(vp);
KASSERT(vp->v_object == NULL, ("Not NULL v_object in tmpfs"));
vp->v_object = object;
vn_irflag_set_locked(vp, (tm->tm_pgread ? VIRF_PGREAD : 0) |
VIRF_TEXT_REF);
VI_UNLOCK(vp);
+ VNASSERT((object->flags & OBJ_TMPFS_VREF) == 0, vp,
+ ("leaked OBJ_TMPFS_VREF"));
+ if (object->un_pager.swp.writemappings > 0) {
+ vrefact(vp);
+ vlazy(vp);
+ vm_object_set_flag(object, OBJ_TMPFS_VREF);
+ }
VM_OBJECT_WUNLOCK(object);
break;
case VDIR: