Author: cgutman Date: Wed Dec 21 19:08:59 2011 New Revision: 54729
URL: http://svn.reactos.org/svn/reactos?rev=54729&view=rev Log: [NTOSKRNL] - Change the method of segment locking from a push lock to a mutex - Fixes the 'OldValue.Locked' assertion failure
Modified: trunk/reactos/ntoskrnl/cc/pin.c trunk/reactos/ntoskrnl/cc/view.c trunk/reactos/ntoskrnl/include/internal/cc.h
Modified: trunk/reactos/ntoskrnl/cc/pin.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/pin.c?rev=54729... ============================================================================== --- trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] Wed Dec 21 19:08:59 2011 @@ -240,8 +240,11 @@ IoStatus->Information = 0; if (WriteThrough) { - KeEnterCriticalRegion(); - ExAcquirePushLockExclusive(&iBcb->CacheSegment->Lock); + KeWaitForSingleObject(&iBcb->CacheSegment->Mutex, + Executive, + KernelMode, + FALSE, + NULL); if (iBcb->CacheSegment->Dirty) { IoStatus->Status = CcRosFlushCacheSegment(iBcb->CacheSegment); @@ -250,8 +253,7 @@ { IoStatus->Status = STATUS_SUCCESS; } - ExReleasePushLockExclusive(&iBcb->CacheSegment->Lock); - KeLeaveCriticalRegion(); + KeReleaseMutex(&iBcb->CacheSegment->Mutex, 0); } else {
Modified: trunk/reactos/ntoskrnl/cc/view.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/view.c?rev=5472... ============================================================================== --- trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] Wed Dec 21 19:08:59 2011 @@ -230,25 +230,29 @@ { continue; } - - ExAcquirePushLockExclusive(¤t->Lock); - + + KeWaitForSingleObject(¤t->Mutex, + Executive, + KernelMode, + FALSE, + NULL); + ASSERT(current->Dirty); if (current->ReferenceCount > 1) { - ExReleasePushLock(¤t->Lock); + KeReleaseMutex(¤t->Mutex, 0); current->Bcb->Callbacks->ReleaseFromLazyWrite( current->Bcb->LazyWriteContext); continue; } - + PagesPerSegment = current->Bcb->CacheSegmentSize / PAGE_SIZE;
KeReleaseGuardedMutex(&ViewLock);
Status = CcRosFlushCacheSegment(current);
- ExReleasePushLock(¤t->Lock); + KeReleaseMutex(¤t->Mutex, 0); current->Bcb->Callbacks->ReleaseFromLazyWrite( current->Bcb->LazyWriteContext);
@@ -440,8 +444,7 @@ } KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); KeReleaseGuardedMutex(&ViewLock); - ExReleasePushLock(&CacheSeg->Lock); - KeLeaveCriticalRegion(); + KeReleaseMutex(&CacheSeg->Mutex, 0);
return(STATUS_SUCCESS); } @@ -470,8 +473,11 @@ { CcRosCacheSegmentIncRefCount(current); KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); - KeEnterCriticalRegion(); - ExAcquirePushLockExclusive(¤t->Lock); + KeWaitForSingleObject(¤t->Mutex, + Executive, + KernelMode, + FALSE, + NULL); return(current); } current_entry = current_entry->Flink; @@ -519,8 +525,7 @@ KeReleaseGuardedMutex(&ViewLock);
CacheSeg->Dirty = TRUE; - ExReleasePushLock(&CacheSeg->Lock); - KeLeaveCriticalRegion(); + KeReleaseMutex(&CacheSeg->Mutex, 0);
return(STATUS_SUCCESS); } @@ -569,8 +574,7 @@ } KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
- ExReleasePushLock(&CacheSeg->Lock); - KeLeaveCriticalRegion(); + KeReleaseMutex(&CacheSeg->Mutex, 0);
return(STATUS_SUCCESS); } @@ -618,9 +622,12 @@ current->DirtySegmentListEntry.Flink = NULL; current->DirtySegmentListEntry.Blink = NULL; current->ReferenceCount = 1; - ExInitializePushLock(¤t->Lock); - KeEnterCriticalRegion(); - ExAcquirePushLockExclusive(¤t->Lock); + KeInitializeMutex(¤t->Mutex, 0); + KeWaitForSingleObject(¤t->Mutex, + Executive, + KernelMode, + FALSE, + NULL); KeAcquireGuardedMutex(&ViewLock);
*CacheSeg = current; @@ -650,12 +657,15 @@ current ); } #endif - ExReleasePushLock(&(*CacheSeg)->Lock); + KeReleaseMutex(&(*CacheSeg)->Mutex, 0); KeReleaseGuardedMutex(&ViewLock); ExFreeToNPagedLookasideList(&CacheSegLookasideList, *CacheSeg); *CacheSeg = current; - /* We're still in the critical region from above */ - ExAcquirePushLockExclusive(¤t->Lock); + KeWaitForSingleObject(¤t->Mutex, + Executive, + KernelMode, + FALSE, + NULL); return STATUS_SUCCESS; } if (current->FileOffset < FileOffset) @@ -1040,8 +1050,7 @@ IoStatus->Status = Status; } } - ExReleasePushLock(¤t->Lock); - KeLeaveCriticalRegion(); + KeReleaseMutex(¤t->Mutex, 0); KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql); CcRosCacheSegmentDecRefCount(current); KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
Modified: trunk/reactos/ntoskrnl/include/internal/cc.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/c... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/cc.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/cc.h [iso-8859-1] Wed Dec 21 19:08:59 2011 @@ -145,8 +145,8 @@ LIST_ENTRY CacheSegmentLRUListEntry; /* Offset in the file which this cache segment maps. */ ULONG FileOffset; - /* Lock. */ - EX_PUSH_LOCK Lock; + /* Mutex */ + KMUTEX Mutex; /* Number of references. */ ULONG ReferenceCount; /* Pointer to the BCB for the file which this cache segment maps data for. */