- Fix inconsistent locking
svn path=/trunk/; revision=54746
BOOLEAN Dirty,
BOOLEAN Mapped)
{
BOOLEAN Dirty,
BOOLEAN Mapped)
{
- BOOLEAN WasDirty = CacheSeg->Dirty;
KIRQL oldIrql;
ASSERT(Bcb);
KIRQL oldIrql;
ASSERT(Bcb);
DPRINT("CcReleaseCacheSegment(Bcb 0x%p, CacheSeg 0x%p, Valid %d)\n",
Bcb, CacheSeg, Valid);
DPRINT("CcReleaseCacheSegment(Bcb 0x%p, CacheSeg 0x%p, Valid %d)\n",
Bcb, CacheSeg, Valid);
+ KeAcquireGuardedMutex(&ViewLock);
+ KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
+
+
+ WasDirty = CacheSeg->Dirty;
CacheSeg->Dirty = CacheSeg->Dirty || Dirty;
CacheSeg->Dirty = CacheSeg->Dirty || Dirty;
- KeAcquireGuardedMutex(&ViewLock);
if (!WasDirty && CacheSeg->Dirty)
{
InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry);
if (!WasDirty && CacheSeg->Dirty)
{
InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry);
{
CacheSeg->MappedCount++;
}
{
CacheSeg->MappedCount++;
}
- KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
CcRosCacheSegmentDecRefCount(CacheSeg);
if (Mapped && CacheSeg->MappedCount == 1)
{
CcRosCacheSegmentDecRefCount(CacheSeg);
if (Mapped && CacheSeg->MappedCount == 1)
{
{
CcRosCacheSegmentIncRefCount(CacheSeg);
}
{
CcRosCacheSegmentIncRefCount(CacheSeg);
}
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
KeReleaseGuardedMutex(&ViewLock);
KeReleaseMutex(&CacheSeg->Mutex, 0);
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
KeReleaseGuardedMutex(&ViewLock);
KeReleaseMutex(&CacheSeg->Mutex, 0);
ASSERT(Bcb);
DPRINT("CcRosLookupCacheSegment(Bcb -x%p, FileOffset %d)\n", Bcb, FileOffset);
ASSERT(Bcb);
DPRINT("CcRosLookupCacheSegment(Bcb -x%p, FileOffset %d)\n", Bcb, FileOffset);
+
+ KeAcquireGuardedMutex(&ViewLock);
KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
current_entry = Bcb->BcbSegmentListHead.Flink;
while (current_entry != &Bcb->BcbSegmentListHead)
{
current_entry = Bcb->BcbSegmentListHead.Flink;
while (current_entry != &Bcb->BcbSegmentListHead)
{
{
CcRosCacheSegmentIncRefCount(current);
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
{
CcRosCacheSegmentIncRefCount(current);
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
+ KeReleaseGuardedMutex(&ViewLock);
KeWaitForSingleObject(¤t->Mutex,
Executive,
KernelMode,
KeWaitForSingleObject(¤t->Mutex,
Executive,
KernelMode,
}
current_entry = current_entry->Flink;
}
}
current_entry = current_entry->Flink;
}
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
+ KeReleaseGuardedMutex(&ViewLock);
+
{
KeBugCheck(CACHE_MANAGER);
}
{
KeBugCheck(CACHE_MANAGER);
}
+
+ KeAcquireGuardedMutex(&ViewLock);
+ KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
+
- {
- KeAcquireGuardedMutex(&ViewLock);
InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry);
DirtyPageCount += Bcb->CacheSegmentSize / PAGE_SIZE;
InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry);
DirtyPageCount += Bcb->CacheSegmentSize / PAGE_SIZE;
- KeReleaseGuardedMutex(&ViewLock);
- }
- KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
- CcRosCacheSegmentDecRefCount(CacheSeg);
- KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
+ CcRosCacheSegmentDecRefCount(CacheSeg);
- KeAcquireGuardedMutex(&ViewLock);
-
/* Move to the tail of the LRU list */
RemoveEntryList(&CacheSeg->CacheSegmentLRUListEntry);
InsertTailList(&CacheSegmentLRUListHead, &CacheSeg->CacheSegmentLRUListEntry);
/* Move to the tail of the LRU list */
RemoveEntryList(&CacheSeg->CacheSegmentLRUListEntry);
InsertTailList(&CacheSegmentLRUListHead, &CacheSeg->CacheSegmentLRUListEntry);
- KeReleaseGuardedMutex(&ViewLock);
-
+
+ KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
+ KeReleaseGuardedMutex(&ViewLock);
KeReleaseMutex(&CacheSeg->Mutex, 0);
return(STATUS_SUCCESS);
KeReleaseMutex(&CacheSeg->Mutex, 0);
return(STATUS_SUCCESS);
return(STATUS_UNSUCCESSFUL);
}
return(STATUS_UNSUCCESSFUL);
}
+ KeAcquireGuardedMutex(&ViewLock);
+ KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
+
WasDirty = CacheSeg->Dirty;
CacheSeg->Dirty = CacheSeg->Dirty || NowDirty;
WasDirty = CacheSeg->Dirty;
CacheSeg->Dirty = CacheSeg->Dirty || NowDirty;
if (!WasDirty && NowDirty)
{
if (!WasDirty && NowDirty)
{
- KeAcquireGuardedMutex(&ViewLock);
InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry);
DirtyPageCount += Bcb->CacheSegmentSize / PAGE_SIZE;
InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry);
DirtyPageCount += Bcb->CacheSegmentSize / PAGE_SIZE;
- KeReleaseGuardedMutex(&ViewLock);
- KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
CcRosCacheSegmentDecRefCount(CacheSeg);
if (!WasDirty && NowDirty)
{
CcRosCacheSegmentDecRefCount(CacheSeg);
if (!WasDirty && NowDirty)
{
{
CcRosCacheSegmentDecRefCount(CacheSeg);
}
{
CcRosCacheSegmentDecRefCount(CacheSeg);
}
- KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
+ KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
+ KeReleaseGuardedMutex(&ViewLock);
KeReleaseMutex(&CacheSeg->Mutex, 0);
return(STATUS_SUCCESS);
KeReleaseMutex(&CacheSeg->Mutex, 0);
return(STATUS_SUCCESS);
}
}
KeReleaseMutex(¤t->Mutex, 0);
}
}
KeReleaseMutex(¤t->Mutex, 0);
+
+ KeAcquireGuardedMutex(&ViewLock);
KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
CcRosCacheSegmentDecRefCount(current);
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
CcRosCacheSegmentDecRefCount(current);
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
+ KeReleaseGuardedMutex(&ViewLock);
}
Offset.QuadPart += Bcb->CacheSegmentSize;
}
Offset.QuadPart += Bcb->CacheSegmentSize;