diff options
-rw-r--r-- | sys/vm/vm_map.c | 10 | ||||
-rw-r--r-- | sys/vm/vm_mmap.c | 27 |
2 files changed, 10 insertions, 27 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 40db4c1..0fb7fc1 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -1952,6 +1952,13 @@ done: * If syncio is TRUE, dirty pages are written synchronously. * If invalidate is TRUE, any cached pages are freed as well. * + * If the size of the region from start to end is zero, we are + * supposed to flush all modified pages within the region containing + * start. Unfortunately, a region can be split or coalesced with + * neighboring regions, making it difficult to determine what the + * original region was. Therefore, we approximate this requirement by + * flushing the current region containing start. + * * Returns an error if any part of the specified range is not mapped. */ int @@ -1973,6 +1980,9 @@ vm_map_sync( if (!vm_map_lookup_entry(map, start, &entry)) { vm_map_unlock_read(map); return (KERN_INVALID_ADDRESS); + } else if (start == end) { + start = entry->start; + end = entry->end; } /* * Make a first pass to check for holes. diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 158a443..95e335a 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -546,40 +546,13 @@ msync(td, uap) if ((flags & (MS_ASYNC|MS_INVALIDATE)) == (MS_ASYNC|MS_INVALIDATE)) return (EINVAL); - mtx_lock(&Giant); - map = &td->td_proc->p_vmspace->vm_map; /* - * XXX Gak! If size is zero we are supposed to sync "all modified - * pages with the region containing addr". Unfortunately, we don't - * really keep track of individual mmaps so we approximate by flushing - * the range of the map entry containing addr. This can be incorrect - * if the region splits or is coalesced with a neighbor. - */ - if (size == 0) { - vm_map_entry_t entry; - - vm_map_lock_read(map); - rv = vm_map_lookup_entry(map, addr, &entry); - vm_map_unlock_read(map); - if (rv == FALSE) { - rv = -1; - goto done2; - } - addr = entry->start; - size = entry->end - entry->start; - } - - /* * Clean the pages and interpret the return value. */ rv = vm_map_sync(map, addr, addr + size, (flags & MS_ASYNC) == 0, (flags & MS_INVALIDATE) != 0); - -done2: - mtx_unlock(&Giant); - switch (rv) { case KERN_SUCCESS: return (0); |