From 28c58286efb9e342b92be14455e6fa869df040f2 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 11 Jun 2002 19:13:59 +0000 Subject: [PATCH] o Properly handle a failure by vm_fault_wire() or vm_fault_user_wire() in vm_map_wire(). o Make two white-space changes in vm_map_wire(). Reviewed by: tegge --- sys/vm/vm_map.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index f762698e65ac..9d182c11d30d 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -1650,7 +1650,7 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, */ } vm_map_lock(map); - if (last_timestamp+1 != map->timestamp) { + if (last_timestamp + 1 != map->timestamp) { /* * Look again for the entry because the map was * modified while it was unlocked. @@ -1704,7 +1704,7 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, else rv = vm_fault_wire(map, saved_start, saved_end); vm_map_lock(map); - if (last_timestamp+1 != map->timestamp) { + if (last_timestamp + 1 != map->timestamp) { /* * Look again for the entry because the map was * modified while it was unlocked. The entry @@ -1719,14 +1719,24 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, else first_entry = NULL; entry = tmp_entry; - while (entry->end < saved_end) + while (entry->end < saved_end) { + if (rv != KERN_SUCCESS) { + KASSERT(entry->wired_count == 1, + ("vm_map_wire: bad count")); + entry->wired_count = -1; + } entry = entry->next; + } } last_timestamp = map->timestamp; if (rv != KERN_SUCCESS) { + KASSERT(entry->wired_count == 1, + ("vm_map_wire: bad count")); /* - * XXX + * Assign an out-of-range value to represent + * the failure to wire this entry. */ + entry->wired_count = -1; end = entry->end; goto done; } @@ -1757,6 +1767,12 @@ vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, if (rv == KERN_SUCCESS) { if (user_wire) entry->eflags |= MAP_ENTRY_USER_WIRED; + } else if (entry->wired_count == -1) { + /* + * Wiring failed on this entry. Thus, unwiring is + * unnecessary. + */ + entry->wired_count = 0; } else { if (!user_wire || (entry->wired_count == 1 && (entry->eflags & MAP_ENTRY_USER_WIRED) == 0))