From owner-svn-src-all@FreeBSD.ORG Sun Apr 28 19:25:10 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 5FF535A8; Sun, 28 Apr 2013 19:25:10 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 392501223; Sun, 28 Apr 2013 19:25:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3SJPAHX034667; Sun, 28 Apr 2013 19:25:10 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3SJP9N7034664; Sun, 28 Apr 2013 19:25:09 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201304281925.r3SJP9N7034664@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 28 Apr 2013 19:25:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r250029 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Apr 2013 19:25:10 -0000 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);