svn commit: r234763 - in stable/9/sys: i386/conf kern vm
Alan Cox
alc at FreeBSD.org
Sat Apr 28 17:29:09 UTC 2012
Author: alc
Date: Sat Apr 28 17:29:08 2012
New Revision: 234763
URL: http://svn.freebsd.org/changeset/base/234763
Log:
MFC r232166
Simplify vm_mmap()'s control flow.
Add a comment describing what vm_mmap_to_errno() does.
Modified:
stable/9/sys/vm/vm_mmap.c
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/amd64/include/xen/ (props changed)
stable/9/sys/boot/ (props changed)
stable/9/sys/boot/i386/efi/ (props changed)
stable/9/sys/boot/ia64/efi/ (props changed)
stable/9/sys/boot/ia64/ski/ (props changed)
stable/9/sys/boot/powerpc/boot1.chrp/ (props changed)
stable/9/sys/boot/powerpc/ofw/ (props changed)
stable/9/sys/cddl/contrib/opensolaris/ (props changed)
stable/9/sys/conf/ (props changed)
stable/9/sys/contrib/dev/acpica/ (props changed)
stable/9/sys/contrib/octeon-sdk/ (props changed)
stable/9/sys/contrib/pf/ (props changed)
stable/9/sys/contrib/x86emu/ (props changed)
stable/9/sys/fs/ (props changed)
stable/9/sys/fs/ntfs/ (props changed)
stable/9/sys/i386/conf/XENHVM (props changed)
stable/9/sys/kern/subr_witness.c (props changed)
Modified: stable/9/sys/vm/vm_mmap.c
==============================================================================
--- stable/9/sys/vm/vm_mmap.c Sat Apr 28 16:32:49 2012 (r234762)
+++ stable/9/sys/vm/vm_mmap.c Sat Apr 28 17:29:08 2012 (r234763)
@@ -1449,9 +1449,8 @@ vm_mmap(vm_map_t map, vm_offset_t *addr,
{
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)
@@ -1557,31 +1556,35 @@ vm_mmap(vm_map_t map, vm_offset_t *addr,
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)
{
More information about the svn-src-all
mailing list