diff options
author | Poul-Henning Kamp <phk@FreeBSD.org> | 2005-01-28 08:56:48 +0000 |
---|---|---|
committer | Poul-Henning Kamp <phk@FreeBSD.org> | 2005-01-28 08:56:48 +0000 |
commit | 7146d6cb3e9b88a881f8133cb98106feb39a1f44 (patch) | |
tree | f4b1cc4e11ee18932c18b5cd9488e2a1752f1a30 /sys/vm/vnode_pager.c | |
parent | 268334ebbdfb179dce21609d5985e03c731943d9 (diff) | |
download | src-7146d6cb3e9b88a881f8133cb98106feb39a1f44.tar.gz src-7146d6cb3e9b88a881f8133cb98106feb39a1f44.zip |
Move the contents of vop_stddestroyvobject() to the new vnode_pager
function vnode_destroy_vobject().
Make the new function zero the vp->v_object pointer so we can tell
if a call is missing.
Notes
Notes:
svn path=/head/; revision=140929
Diffstat (limited to 'sys/vm/vnode_pager.c')
-rw-r--r-- | sys/vm/vnode_pager.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 96aa36ceb084..0f9c3ebd5337 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -150,6 +150,39 @@ vnode_create_vobject(struct vnode *vp, size_t isize, struct thread *td) return (0); } +void +vnode_destroy_vobject(struct vnode *vp) +{ + struct vm_object *obj; + + obj = vp->v_object; + if (obj == NULL) + return; + vp->v_object = NULL; + VM_OBJECT_LOCK(obj); + if (obj->ref_count == 0) { + /* + * vclean() may be called twice. The first time + * removes the primary reference to the object, + * the second time goes one further and is a + * special-case to terminate the object. + * + * don't double-terminate the object + */ + if ((obj->flags & OBJ_DEAD) == 0) + vm_object_terminate(obj); + else + VM_OBJECT_UNLOCK(obj); + } else { + /* + * Woe to the process that tries to page now :-). + */ + vm_pager_deallocate(obj); + VM_OBJECT_UNLOCK(obj); + } +} + + /* * Allocate (or lookup) pager for a vnode. * Handle is a vnode pointer. |