mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
- Acquire always the segmemt lock in CcRosLookupCacheSegment/CcRosCreateCacheSegment.
- Try to remove mapped section pages from a cache segment in CcRosTrimCache. svn path=/trunk/; revision=5134
This commit is contained in:
parent
4610a1b077
commit
e6d3e40053
1 changed files with 36 additions and 29 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: view.c,v 1.66 2003/07/11 01:23:14 royce Exp $
|
/* $Id: view.c,v 1.67 2003/07/15 19:30:33 hbirr Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/cc/view.c
|
* FILE: ntoskrnl/cc/view.c
|
||||||
|
@ -132,9 +132,6 @@ CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment)
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID CcRosRemoveUnusedFiles(VOID);
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
||||||
{
|
{
|
||||||
|
@ -231,7 +228,7 @@ CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
PCACHE_SEGMENT current;
|
PCACHE_SEGMENT current, last = NULL;
|
||||||
ULONG PagesPerSegment;
|
ULONG PagesPerSegment;
|
||||||
ULONG PagesFreed;
|
ULONG PagesFreed;
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
|
@ -266,7 +263,33 @@ CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
KeReleaseSpinLock(¤t->Bcb->BcbLock, oldIrql);
|
if (last != current && current->MappedCount > 0 && !current->Dirty)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
current->ReferenceCount++;
|
||||||
|
last = current;
|
||||||
|
KeReleaseSpinLock(¤t->Bcb->BcbLock, oldIrql);
|
||||||
|
ExReleaseFastMutex(&ViewLock);
|
||||||
|
for (i = 0; i < current->Bcb->CacheSegmentSize / PAGE_SIZE; i++)
|
||||||
|
{
|
||||||
|
PHYSICAL_ADDRESS Page;
|
||||||
|
Page = MmGetPhysicalAddress(current->BaseAddress + i * PAGE_SIZE);
|
||||||
|
Status = MmPageOutPhysicalAddress(Page);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ExAcquireFastMutex(&ViewLock);
|
||||||
|
KeAcquireSpinLock(¤t->Bcb->BcbLock, &oldIrql);
|
||||||
|
current->ReferenceCount--;
|
||||||
|
KeReleaseSpinLock(¤t->Bcb->BcbLock, oldIrql);
|
||||||
|
current_entry = ¤t->CacheSegmentLRUListEntry;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
KeReleaseSpinLock(¤t->Bcb->BcbLock, oldIrql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExReleaseFastMutex(&ViewLock);
|
ExReleaseFastMutex(&ViewLock);
|
||||||
|
@ -353,6 +376,7 @@ CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset)
|
||||||
{
|
{
|
||||||
current->ReferenceCount++;
|
current->ReferenceCount++;
|
||||||
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
|
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
|
||||||
|
ExAcquireFastMutex(¤t->Lock);
|
||||||
return(current);
|
return(current);
|
||||||
}
|
}
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
|
@ -376,7 +400,6 @@ CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset)
|
||||||
{
|
{
|
||||||
KeBugCheck(0);
|
KeBugCheck(0);
|
||||||
}
|
}
|
||||||
ExAcquireFastMutex(&CacheSeg->Lock);
|
|
||||||
if (!CacheSeg->Dirty)
|
if (!CacheSeg->Dirty)
|
||||||
{
|
{
|
||||||
ExAcquireFastMutex(&ViewLock);
|
ExAcquireFastMutex(&ViewLock);
|
||||||
|
@ -415,7 +438,6 @@ CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty)
|
||||||
{
|
{
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
ExAcquireFastMutex(&CacheSeg->Lock);
|
|
||||||
|
|
||||||
WasDirty = CacheSeg->Dirty;
|
WasDirty = CacheSeg->Dirty;
|
||||||
CacheSeg->Dirty = CacheSeg->Dirty || NowDirty;
|
CacheSeg->Dirty = CacheSeg->Dirty || NowDirty;
|
||||||
|
@ -449,8 +471,7 @@ CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty)
|
||||||
NTSTATUS STATIC
|
NTSTATUS STATIC
|
||||||
CcRosCreateCacheSegment(PBCB Bcb,
|
CcRosCreateCacheSegment(PBCB Bcb,
|
||||||
ULONG FileOffset,
|
ULONG FileOffset,
|
||||||
PCACHE_SEGMENT* CacheSeg,
|
PCACHE_SEGMENT* CacheSeg)
|
||||||
BOOLEAN Lock)
|
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
PCACHE_SEGMENT current;
|
PCACHE_SEGMENT current;
|
||||||
|
@ -507,10 +528,7 @@ CcRosCreateCacheSegment(PBCB Bcb,
|
||||||
ExReleaseFastMutex(&ViewLock);
|
ExReleaseFastMutex(&ViewLock);
|
||||||
ExFreeToNPagedLookasideList(&CacheSegLookasideList, *CacheSeg);
|
ExFreeToNPagedLookasideList(&CacheSegLookasideList, *CacheSeg);
|
||||||
*CacheSeg = current;
|
*CacheSeg = current;
|
||||||
if (Lock)
|
ExAcquireFastMutex(¤t->Lock);
|
||||||
{
|
|
||||||
ExAcquireFastMutex(¤t->Lock);
|
|
||||||
}
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
if (current->FileOffset < FileOffset)
|
if (current->FileOffset < FileOffset)
|
||||||
|
@ -600,11 +618,6 @@ CcRosCreateCacheSegment(PBCB Bcb,
|
||||||
KeBugCheck(0);
|
KeBugCheck(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Lock)
|
|
||||||
{
|
|
||||||
ExReleaseFastMutex(¤t->Lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,14 +654,13 @@ CcRosGetCacheSegmentChain(PBCB Bcb,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CcRosCreateCacheSegment(Bcb, CurrentOffset, ¤t, FALSE);
|
CcRosCreateCacheSegment(Bcb, CurrentOffset, ¤t);
|
||||||
CacheSegList[i] = current;
|
CacheSegList[i] = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < (Length / Bcb->CacheSegmentSize); i++)
|
for (i = 0; i < (Length / Bcb->CacheSegmentSize); i++)
|
||||||
{
|
{
|
||||||
ExAcquireFastMutex(&CacheSegList[i]->Lock);
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
*CacheSeg = CacheSegList[i];
|
*CacheSeg = CacheSegList[i];
|
||||||
|
@ -684,16 +696,12 @@ CcRosGetCacheSegment(PBCB Bcb,
|
||||||
* Look for a cache segment already mapping the same data.
|
* Look for a cache segment already mapping the same data.
|
||||||
*/
|
*/
|
||||||
current = CcRosLookupCacheSegment(Bcb, FileOffset);
|
current = CcRosLookupCacheSegment(Bcb, FileOffset);
|
||||||
if (current != NULL)
|
if (current == NULL)
|
||||||
{
|
|
||||||
ExAcquireFastMutex(¤t->Lock);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Otherwise create a new segment.
|
* Otherwise create a new segment.
|
||||||
*/
|
*/
|
||||||
Status = CcRosCreateCacheSegment(Bcb, FileOffset, ¤t, TRUE);
|
Status = CcRosCreateCacheSegment(Bcb, FileOffset, ¤t);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -873,7 +881,6 @@ CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointers,
|
||||||
current = CcRosLookupCacheSegment (Bcb, Offset.u.LowPart);
|
current = CcRosLookupCacheSegment (Bcb, Offset.u.LowPart);
|
||||||
if (current != NULL)
|
if (current != NULL)
|
||||||
{
|
{
|
||||||
ExAcquireFastMutex(¤t->Lock);
|
|
||||||
if (current->Dirty)
|
if (current->Dirty)
|
||||||
{
|
{
|
||||||
Status = CcRosFlushCacheSegment(current);
|
Status = CcRosFlushCacheSegment(current);
|
||||||
|
@ -1000,7 +1007,7 @@ VOID CcRosReferenceCache(PFILE_OBJECT FileObject)
|
||||||
VOID CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer)
|
VOID CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer)
|
||||||
{
|
{
|
||||||
PBCB Bcb;
|
PBCB Bcb;
|
||||||
// DPRINT1("CcRosSetRemoveOnClose()\n");
|
DPRINT("CcRosSetRemoveOnClose()\n");
|
||||||
ExAcquireFastMutex(&ViewLock);
|
ExAcquireFastMutex(&ViewLock);
|
||||||
Bcb = (PBCB)SectionObjectPointer->SharedCacheMap;
|
Bcb = (PBCB)SectionObjectPointer->SharedCacheMap;
|
||||||
if (Bcb)
|
if (Bcb)
|
||||||
|
|
Loading…
Reference in a new issue