summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_mmap.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2013-04-28 19:25:09 +0000
committerkib <kib@FreeBSD.org>2013-04-28 19:25:09 +0000
commitd4d37d6d8889403ad1350f932cbb9421b9b6023d (patch)
treeeab8c64a9ac67fa54d6074b6926472ab85af746d /sys/vm/vm_mmap.c
parentdae393576885009863cdf2f416eba41391fa7712 (diff)
downloadFreeBSD-src-d4d37d6d8889403ad1350f932cbb9421b9b6023d.zip
FreeBSD-src-d4d37d6d8889403ad1350f932cbb9421b9b6023d.tar.gz
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
Diffstat (limited to 'sys/vm/vm_mmap.c')
-rw-r--r--sys/vm/vm_mmap.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index c17e9ce..ef63f85 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -1284,7 +1284,7 @@ vm_mmap_vnode(struct thread *td, vm_size_t objsize,
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_t objsize,
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;
OpenPOWER on IntegriCloud