To implement the sequential access optimization, vm_fault() may need to

reacquire the "first" object's lock while a backing object's lock is held.
Since this is a lock-order reversal, vm_fault() uses trylock to acquire
the first object's lock, skipping the sequential access optimization in
the unlikely event that the trylock fails.
This commit is contained in:
Alan Cox 2003-08-23 06:52:32 +00:00
parent 21a708cfde
commit 8d8b9c6e70

View File

@ -446,13 +446,14 @@ readrest:
if (ahead > VM_FAULT_READ_AHEAD)
ahead = VM_FAULT_READ_AHEAD;
}
if ((fs.first_object->type != OBJT_DEVICE) &&
(behavior == MAP_ENTRY_BEHAV_SEQUENTIAL ||
(behavior != MAP_ENTRY_BEHAV_RANDOM &&
fs.pindex >= fs.entry->lastr &&
fs.pindex < fs.entry->lastr + VM_FAULT_READ))
) {
is_first_object_locked = FALSE;
if ((behavior == MAP_ENTRY_BEHAV_SEQUENTIAL ||
(behavior != MAP_ENTRY_BEHAV_RANDOM &&
fs.pindex >= fs.entry->lastr &&
fs.pindex < fs.entry->lastr + VM_FAULT_READ)) &&
(fs.first_object == fs.object ||
(is_first_object_locked = VM_OBJECT_TRYLOCK(fs.first_object))) &&
fs.first_object->type != OBJT_DEVICE) {
vm_pindex_t firstpindex, tmppindex;
if (fs.first_pindex < 2 * VM_FAULT_READ)
@ -492,7 +493,8 @@ readrest:
ahead += behind;
behind = 0;
}
if (is_first_object_locked)
VM_OBJECT_UNLOCK(fs.first_object);
/*
* now we find out if any other pages should be paged
* in at this time this routine checks to see if the