summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2012-02-25 21:06:39 +0000
committeralc <alc@FreeBSD.org>2012-02-25 21:06:39 +0000
commit867c58a8cbe64dde6c6dd33aa36461581b5514bc (patch)
tree3b1ef127dea29d87edd053bff8c9a483719098b3 /sys/vm
parentbf0a7194e723f24702335dd3b8c0ada0fac6be3c (diff)
downloadFreeBSD-src-867c58a8cbe64dde6c6dd33aa36461581b5514bc.zip
FreeBSD-src-867c58a8cbe64dde6c6dd33aa36461581b5514bc.tar.gz
Simplify vm_mmap()'s control flow.
Add a comment describing what vm_mmap_to_errno() does. Reviewed by: kib MFC after: 3 weeks X-MFC after: r232071
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/vm_mmap.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index bf5a8be..9c8d9bb 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -1447,9 +1447,8 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot,
{
boolean_t fitit;
vm_object_t object = NULL;
- int rv = KERN_SUCCESS;
- int docow, error;
struct thread *td = curthread;
+ int docow, error, rv;
boolean_t writecounted;
if (size == 0)
@@ -1555,31 +1554,35 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot,
rv = vm_map_fixed(map, object, foff, *addr, size,
prot, maxprot, docow);
- if (rv != KERN_SUCCESS) {
+ if (rv == KERN_SUCCESS) {
+ /*
+ * If the process has requested that all future mappings
+ * be wired, then heed this.
+ */
+ if (map->flags & MAP_WIREFUTURE)
+ vm_map_wire(map, *addr, *addr + size,
+ VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
+ } else {
/*
- * Lose the object reference. Will destroy the
- * object if it's an unnamed anonymous mapping
- * or named anonymous without other references.
- *
* If this mapping was accounted for in the vnode's
* writecount, then undo that now.
*/
if (writecounted)
vnode_pager_release_writecount(object, 0, size);
+ /*
+ * Lose the object reference. Will destroy the
+ * object if it's an unnamed anonymous mapping
+ * or named anonymous without other references.
+ */
vm_object_deallocate(object);
}
-
- /*
- * If the process has requested that all future mappings
- * be wired, then heed this.
- */
- if ((rv == KERN_SUCCESS) && (map->flags & MAP_WIREFUTURE))
- vm_map_wire(map, *addr, *addr + size,
- VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
-
return (vm_mmap_to_errno(rv));
}
+/*
+ * Translate a Mach VM return code to zero on success or the appropriate errno
+ * on failure.
+ */
int
vm_mmap_to_errno(int rv)
{
OpenPOWER on IntegriCloud