Date: Fri, 30 Nov 2018 04:18:31 +0000 (UTC) From: Eric van Gyzen <vangyzen@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r341281 - head/sys/vm Message-ID: <201811300418.wAU4IV61095669@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: vangyzen Date: Fri Nov 30 04:18:31 2018 New Revision: 341281 URL: https://svnweb.freebsd.org/changeset/base/341281 Log: 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 Modified: head/sys/vm/vm_object.c Modified: head/sys/vm/vm_object.c ============================================================================== --- head/sys/vm/vm_object.c Fri Nov 30 04:15:56 2018 (r341280) +++ head/sys/vm/vm_object.c Fri Nov 30 04:18:31 2018 (r341281) @@ -2306,16 +2306,28 @@ next_page: } } +/* + * 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811300418.wAU4IV61095669>