mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 01:25:41 +00:00
[NTOS:CC]
- Simplify CcSetFileSizes by using CcPurgeCacheSection CORE-12893 svn path=/trunk/; revision=74357
This commit is contained in:
parent
ef88fe7a1a
commit
25db42d246
1 changed files with 9 additions and 60 deletions
|
@ -225,10 +225,6 @@ CcSetFileSizes (
|
||||||
{
|
{
|
||||||
KIRQL oldirql;
|
KIRQL oldirql;
|
||||||
PROS_SHARED_CACHE_MAP SharedCacheMap;
|
PROS_SHARED_CACHE_MAP SharedCacheMap;
|
||||||
PLIST_ENTRY current_entry;
|
|
||||||
PROS_VACB current;
|
|
||||||
LIST_ENTRY FreeListHead;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
CCTRACE(CC_API_DEBUG, "FileObject=%p FileSizes=%p\n",
|
CCTRACE(CC_API_DEBUG, "FileObject=%p FileSizes=%p\n",
|
||||||
FileObject, FileSizes);
|
FileObject, FileSizes);
|
||||||
|
@ -251,63 +247,16 @@ CcSetFileSizes (
|
||||||
|
|
||||||
if (FileSizes->AllocationSize.QuadPart < SharedCacheMap->SectionSize.QuadPart)
|
if (FileSizes->AllocationSize.QuadPart < SharedCacheMap->SectionSize.QuadPart)
|
||||||
{
|
{
|
||||||
InitializeListHead(&FreeListHead);
|
CcPurgeCacheSection(FileObject->SectionObjectPointer,
|
||||||
KeAcquireGuardedMutex(&ViewLock);
|
&FileSizes->AllocationSize,
|
||||||
KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldirql);
|
0,
|
||||||
|
FALSE);
|
||||||
current_entry = SharedCacheMap->CacheMapVacbListHead.Flink;
|
|
||||||
while (current_entry != &SharedCacheMap->CacheMapVacbListHead)
|
|
||||||
{
|
|
||||||
current = CONTAINING_RECORD(current_entry,
|
|
||||||
ROS_VACB,
|
|
||||||
CacheMapVacbListEntry);
|
|
||||||
current_entry = current_entry->Flink;
|
|
||||||
if (current->FileOffset.QuadPart >= FileSizes->AllocationSize.QuadPart)
|
|
||||||
{
|
|
||||||
if ((current->ReferenceCount == 0) || ((current->ReferenceCount == 1) && current->Dirty))
|
|
||||||
{
|
|
||||||
RemoveEntryList(¤t->CacheMapVacbListEntry);
|
|
||||||
RemoveEntryList(¤t->VacbLruListEntry);
|
|
||||||
if (current->Dirty)
|
|
||||||
{
|
|
||||||
RemoveEntryList(¤t->DirtyVacbListEntry);
|
|
||||||
DirtyPageCount -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
|
|
||||||
}
|
|
||||||
InsertHeadList(&FreeListHead, ¤t->CacheMapVacbListEntry);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DPRINT1("Someone has referenced a VACB behind the new size.\n");
|
|
||||||
KeBugCheck(CACHE_MANAGER);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SharedCacheMap->SectionSize = FileSizes->AllocationSize;
|
|
||||||
SharedCacheMap->FileSize = FileSizes->FileSize;
|
|
||||||
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldirql);
|
|
||||||
KeReleaseGuardedMutex(&ViewLock);
|
|
||||||
|
|
||||||
current_entry = FreeListHead.Flink;
|
|
||||||
while(current_entry != &FreeListHead)
|
|
||||||
{
|
|
||||||
current = CONTAINING_RECORD(current_entry, ROS_VACB, CacheMapVacbListEntry);
|
|
||||||
current_entry = current_entry->Flink;
|
|
||||||
Status = CcRosInternalFreeVacb(current);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("CcRosInternalFreeVacb failed, status = %x\n", Status);
|
|
||||||
KeBugCheck(CACHE_MANAGER);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldirql);
|
|
||||||
SharedCacheMap->SectionSize = FileSizes->AllocationSize;
|
|
||||||
SharedCacheMap->FileSize = FileSizes->FileSize;
|
|
||||||
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldirql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldirql);
|
||||||
|
SharedCacheMap->SectionSize = FileSizes->AllocationSize;
|
||||||
|
SharedCacheMap->FileSize = FileSizes->FileSize;
|
||||||
|
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldirql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue