aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/vnode_pager.c
diff options
context:
space:
mode:
authorJeff Roberson <jeff@FreeBSD.org>2019-10-29 20:58:46 +0000
committerJeff Roberson <jeff@FreeBSD.org>2019-10-29 20:58:46 +0000
commit51df53213c2e297c8f36ff49550f9d17da0e6178 (patch)
tree86bae6e1449d1e46be0c161ac9c4f61c9a940469 /sys/vm/vnode_pager.c
parent4b3e066539b43e64c6da1cc8ec46c65be7b6790e (diff)
Notes
Diffstat (limited to 'sys/vm/vnode_pager.c')
-rw-r--r--sys/vm/vnode_pager.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c
index 2133449aea95..d46fc3472407 100644
--- a/sys/vm/vnode_pager.c
+++ b/sys/vm/vnode_pager.c
@@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$");
#include <sys/ktr.h>
#include <sys/limits.h>
#include <sys/conf.h>
+#include <sys/refcount.h>
#include <sys/rwlock.h>
#include <sys/sf_buf.h>
#include <sys/domainset.h>
@@ -172,9 +173,9 @@ vnode_create_vobject(struct vnode *vp, off_t isize, struct thread *td)
* Dereference the reference we just created. This assumes
* that the object is associated with the vp.
*/
- VM_OBJECT_WLOCK(object);
- object->ref_count--;
- VM_OBJECT_WUNLOCK(object);
+ VM_OBJECT_RLOCK(object);
+ refcount_release(&object->ref_count);
+ VM_OBJECT_RUNLOCK(object);
vrele(vp);
KASSERT(vp->v_object != NULL, ("vnode_create_vobject: NULL object"));
@@ -285,7 +286,7 @@ retry:
KASSERT(object->ref_count == 1,
("leaked ref %p %d", object, object->ref_count));
object->type = OBJT_DEAD;
- object->ref_count = 0;
+ refcount_init(&object->ref_count, 0);
VM_OBJECT_WUNLOCK(object);
vm_object_destroy(object);
goto retry;
@@ -294,7 +295,7 @@ retry:
VI_UNLOCK(vp);
} else {
VM_OBJECT_WLOCK(object);
- object->ref_count++;
+ refcount_acquire(&object->ref_count);
#if VM_NRESERVLEVEL > 0
vm_object_color(object, 0);
#endif