Date: Sun, 28 Apr 2013 19:25:09 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r250029 - head/sys/vm Message-ID: <201304281925.r3SJP9N7034664@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Sun Apr 28 19:25:09 2013 New Revision: 250029 URL: http://svnweb.freebsd.org/changeset/base/250029 Log: Make vm_object_page_clean() and vm_mmap_vnode() tolerate the vnode' v_object of non OBJT_VNODE type. For vm_object_page_clean(), simply do not assert that object type must be OBJT_VNODE, and add a comment explaining how the check for OBJ_MIGHTBEDIRTY prevents the rest of function from operating on such objects. For vm_mmap_vnode(), if the object type is not OBJT_VNODE, require it to be for swap pager (or default), handle the bypass filesystems, and correctly acquire the object reference in this case. Reviewed by: alc Tested by: pho, bf MFC after: 1 week Modified: head/sys/vm/vm_mmap.c head/sys/vm/vm_object.c Modified: head/sys/vm/vm_mmap.c ============================================================================== --- head/sys/vm/vm_mmap.c Sun Apr 28 19:19:26 2013 (r250028) +++ head/sys/vm/vm_mmap.c Sun Apr 28 19:25:09 2013 (r250029) @@ -1284,7 +1284,7 @@ vm_mmap_vnode(struct thread *td, vm_size error = EINVAL; goto done; } - if (obj->handle != vp) { + if (obj->type == OBJT_VNODE && obj->handle != vp) { vput(vp); vp = (struct vnode *)obj->handle; /* @@ -1333,7 +1333,14 @@ vm_mmap_vnode(struct thread *td, vm_size objsize = round_page(va.va_size); if (va.va_nlink == 0) flags |= MAP_NOSYNC; - obj = vm_pager_allocate(OBJT_VNODE, vp, objsize, prot, foff, cred); + if (obj->type == OBJT_VNODE) + obj = vm_pager_allocate(OBJT_VNODE, vp, objsize, prot, foff, + cred); + else { + KASSERT(obj->type == OBJT_DEFAULT || obj->type == OBJT_SWAP, + ("wrong object type")); + vm_object_reference(obj); + } if (obj == NULL) { error = ENOMEM; goto done; Modified: head/sys/vm/vm_object.c ============================================================================== --- head/sys/vm/vm_object.c Sun Apr 28 19:19:26 2013 (r250028) +++ head/sys/vm/vm_object.c Sun Apr 28 19:25:09 2013 (r250029) @@ -820,7 +820,12 @@ vm_object_page_clean(vm_object_t object, boolean_t clearobjflags, eio, res; VM_OBJECT_ASSERT_WLOCKED(object); - KASSERT(object->type == OBJT_VNODE, ("Not a vnode object")); + + /* + * The OBJ_MIGHTBEDIRTY flag is only set for OBJT_VNODE + * objects. The check below prevents the function from + * operating on non-vnode objects. + */ if ((object->flags & OBJ_MIGHTBEDIRTY) == 0 || object->resident_page_count == 0) return (TRUE);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304281925.r3SJP9N7034664>