Add assertions and comment to vm_object_vnode()

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D2724
This commit is contained in:
Eric van Gyzen 2018-11-30 04:18:31 +00:00
parent a85c2efc11
commit 0951bd362c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=341281

View File

@ -2306,16 +2306,28 @@ vm_object_unwire(vm_object_t object, vm_ooffset_t offset, vm_size_t length,
}
}
/*
* Return the vnode for the given object, or NULL if none exists.
* For tmpfs objects, the function may return NULL if there is
* no vnode allocated at the time of the call.
*/
struct vnode *
vm_object_vnode(vm_object_t object)
{
struct vnode *vp;
VM_OBJECT_ASSERT_LOCKED(object);
if (object->type == OBJT_VNODE)
return (object->handle);
if (object->type == OBJT_SWAP && (object->flags & OBJ_TMPFS) != 0)
return (object->un_pager.swp.swp_tmpfs);
return (NULL);
if (object->type == OBJT_VNODE) {
vp = object->handle;
KASSERT(vp != NULL, ("%s: OBJT_VNODE has no vnode", __func__));
} else if (object->type == OBJT_SWAP &&
(object->flags & OBJ_TMPFS) != 0) {
vp = object->un_pager.swp.swp_tmpfs;
KASSERT(vp != NULL, ("%s: OBJT_TMPFS has no vnode", __func__));
} else {
vp = NULL;
}
return (vp);
}
static int