--- src/sys/vm/vm_map.c 2004/10/12 19:21:16 1.33 +++ src/sys/vm/vm_map.c 2004/10/25 19:14:33 1.34 @@ -3262,255 +3262,6 @@ vm_map_lookup_done(vm_map_t map, vm_map_ vm_map_entry_release(count); } -#ifdef ENABLE_VFS_IOOPT - -/* - * Implement uiomove with VM operations. This handles (and collateral changes) - * support every combination of source object modification, and COW type - * operations. - * - * XXX this is extremely dangerous, enabling this option is NOT recommended. - */ -int -vm_uiomove(vm_map_t mapa, vm_object_t srcobject, off_t cp, int cnta, - vm_offset_t uaddra, int *npages) -{ - vm_map_t map; - vm_object_t first_object, oldobject, object; - vm_map_entry_t entry; - vm_prot_t prot; - boolean_t wired; - int tcnt, rv; - vm_offset_t uaddr, start, end, tend; - vm_pindex_t first_pindex, osize, oindex; - off_t ooffset; - int cnt; - int count; - int s; - - if (npages) - *npages = 0; - - cnt = cnta; - uaddr = uaddra; - - while (cnt > 0) { - map = mapa; - - count = vm_map_entry_reserve(MAP_RESERVE_COUNT); - - if ((vm_map_lookup(&map, uaddr, - VM_PROT_READ, &entry, &first_object, - &first_pindex, &prot, &wired)) != KERN_SUCCESS) { - return EFAULT; - } - - vm_map_clip_start(map, entry, uaddr, &count); - - tcnt = cnt; - tend = uaddr + tcnt; - if (tend > entry->end) { - tcnt = entry->end - uaddr; - tend = entry->end; - } - - vm_map_clip_end(map, entry, tend, &count); - - start = entry->start; - end = entry->end; - - osize = atop(tcnt); - - oindex = OFF_TO_IDX(cp); - if (npages) { - vm_pindex_t idx; - - /* - * spl protection is needed to avoid a race between - * the lookup and an interrupt/unbusy/free occuring - * prior to our busy check. - */ - crit_enter(); - for (idx = 0; idx < osize; idx++) { - vm_page_t m; - if ((m = vm_page_lookup(srcobject, oindex + idx)) == NULL) { - crit_exit(); - vm_map_lookup_done(map, entry, count); - return 0; - } - /* - * disallow busy or invalid pages, but allow - * m->busy pages if they are entirely valid. - */ - if ((m->flags & PG_BUSY) || - ((m->valid & VM_PAGE_BITS_ALL) != VM_PAGE_BITS_ALL)) { - crit_exit(); - vm_map_lookup_done(map, entry, count); - return 0; - } - } - crit_exit(); - } - -/* - * If we are changing an existing map entry, just redirect - * the object, and change mappings. - */ - if ((first_object->type == OBJT_VNODE) && - ((oldobject = entry->object.vm_object) == first_object)) { - - if ((entry->offset != cp) || (oldobject != srcobject)) { - /* - * Remove old window into the file - */ - pmap_remove (map->pmap, uaddr, tend); - - /* - * Force copy on write for mmaped regions - */ - vm_object_pmap_copy_1 (srcobject, oindex, oindex + osize); - - /* - * Point the object appropriately - */ - if (oldobject != srcobject) { - - /* - * Set the object optimization hint flag - */ - vm_object_set_flag(srcobject, OBJ_OPT); - vm_object_reference(srcobject); - entry->object.vm_object = srcobject; - - if (oldobject) { - vm_object_deallocate(oldobject); - } - } - - entry->offset = cp; - map->timestamp++; - } else { - pmap_remove (map->pmap, uaddr, tend); - } - - } else if ((first_object->ref_count == 1) && - (first_object->size == osize) && - ((first_object->type == OBJT_DEFAULT) || - (first_object->type == OBJT_SWAP)) ) { - - oldobject = first_object->backing_object; - - if ((first_object->backing_object_offset != cp) || - (oldobject != srcobject)) { - /* - * Remove old window into the file - */ - pmap_remove (map->pmap, uaddr, tend); - - /* - * Remove unneeded old pages - */ - vm_object_page_remove(first_object, 0, 0, 0); - - /* - * Invalidate swap space - */ - if (first_object->type == OBJT_SWAP) { - swap_pager_freespace(first_object, - 0, - first_object->size); - } - - /* - * Force copy on write for mmaped regions - */ - vm_object_pmap_copy_1 (srcobject, oindex, oindex + osize); - - /* - * Point the object appropriately - */ - if (oldobject != srcobject) { - - /* - * Set the object optimization hint flag - */ - vm_object_set_flag(srcobject, OBJ_OPT); - vm_object_reference(srcobject); - - if (oldobject) { - LIST_REMOVE( - first_object, shadow_list); - oldobject->shadow_count--; - /* XXX bump generation? */ - vm_object_deallocate(oldobject); - } - - LIST_INSERT_HEAD(&srcobject->shadow_head, - first_object, shadow_list); - srcobject->shadow_count++; - /* XXX bump generation? */ - - first_object->backing_object = srcobject; - } - first_object->backing_object_offset = cp; - map->timestamp++; - } else { - pmap_remove (map->pmap, uaddr, tend); - } -/* - * Otherwise, we have to do a logical mmap. - */ - } else { - - vm_object_set_flag(srcobject, OBJ_OPT); - vm_object_reference(srcobject); - - pmap_remove (map->pmap, uaddr, tend); - - vm_object_pmap_copy_1 (srcobject, oindex, oindex + osize); - vm_map_lock_upgrade(map); - - if (entry == &map->header) { - map->first_free = &map->header; - } else if (map->first_free->start >= start) { - map->first_free = entry->prev; - } - - SAVE_HINT(map, entry->prev); - vm_map_entry_delete(map, entry, &count); - - object = srcobject; - ooffset = cp; - - rv = vm_map_insert(map, &count, - object, ooffset, start, tend, - VM_PROT_ALL, VM_PROT_ALL, MAP_COPY_ON_WRITE); - - if (rv != KERN_SUCCESS) - panic("vm_uiomove: could not insert new entry: %d", rv); - } - -/* - * Map the window directly, if it is already in memory - */ - pmap_object_init_pt(map->pmap, uaddr, entry->protection, - srcobject, oindex, tcnt, 0); - - map->timestamp++; - vm_map_unlock(map); - vm_map_entry_release(count); - - cnt -= tcnt; - uaddr += tcnt; - cp += tcnt; - if (npages) - *npages += osize; - } - return 0; -} - -#endif - /* * Performs the copy_on_write operations necessary to allow the virtual copies * into user space to work. This has to be called for write(2) system calls