mirror of
https://github.com/reactos/reactos.git
synced 2024-11-19 05:22:59 +00:00
[NTOSKRNL] Simplify (and speedup!) CcCanIWrite() using the dirty pages count in cache map.
This commit is contained in:
parent
5cc0668b21
commit
dc85171674
2 changed files with 5 additions and 28 deletions
|
@ -376,9 +376,6 @@ CcCanIWrite (
|
|||
IN BOOLEAN Wait,
|
||||
IN BOOLEAN Retrying)
|
||||
{
|
||||
KIRQL OldIrql;
|
||||
ULONG DirtyPages;
|
||||
PLIST_ENTRY ListEntry;
|
||||
PFSRTL_COMMON_FCB_HEADER Fcb;
|
||||
PROS_SHARED_CACHE_MAP SharedCacheMap;
|
||||
|
||||
|
@ -409,27 +406,8 @@ CcCanIWrite (
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* There's a limit, start counting dirty pages */
|
||||
DirtyPages = 0;
|
||||
KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &OldIrql);
|
||||
for (ListEntry = SharedCacheMap->CacheMapVacbListHead.Flink;
|
||||
ListEntry != &SharedCacheMap->CacheMapVacbListHead;
|
||||
ListEntry = ListEntry->Flink)
|
||||
{
|
||||
PROS_VACB Vacb;
|
||||
|
||||
Vacb = CONTAINING_RECORD(ListEntry,
|
||||
ROS_VACB,
|
||||
CacheMapVacbListEntry);
|
||||
if (Vacb->Dirty)
|
||||
{
|
||||
DirtyPages += VACB_MAPPING_GRANULARITY / PAGE_SIZE;
|
||||
}
|
||||
}
|
||||
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql);
|
||||
|
||||
/* Is dirty page count above local threshold? */
|
||||
if (DirtyPages > SharedCacheMap->DirtyPageThreshold)
|
||||
if (SharedCacheMap->DirtyPages > SharedCacheMap->DirtyPageThreshold)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -437,7 +415,7 @@ CcCanIWrite (
|
|||
/* We cannot write if dirty pages count will bring use above
|
||||
* XXX: Might not be accurate
|
||||
*/
|
||||
if (DirtyPages + (BytesToWrite / PAGE_SIZE) > SharedCacheMap->DirtyPageThreshold)
|
||||
if (SharedCacheMap->DirtyPages + (BytesToWrite / PAGE_SIZE) > SharedCacheMap->DirtyPageThreshold)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -1521,6 +1521,9 @@ ExpKdbgExtFileCache(ULONG Argc, PCHAR Argv[])
|
|||
|
||||
SharedCacheMap = CONTAINING_RECORD(ListEntry, ROS_SHARED_CACHE_MAP, SharedCacheMapLinks);
|
||||
|
||||
/* Dirty size */
|
||||
Dirty = (SharedCacheMap->DirtyPages * PAGE_SIZE) / 1024;
|
||||
|
||||
/* First, count for all the associated VACB */
|
||||
for (Vacbs = SharedCacheMap->CacheMapVacbListHead.Flink;
|
||||
Vacbs != &SharedCacheMap->CacheMapVacbListHead;
|
||||
|
@ -1529,10 +1532,6 @@ ExpKdbgExtFileCache(ULONG Argc, PCHAR Argv[])
|
|||
PROS_VACB Vacb;
|
||||
|
||||
Vacb = CONTAINING_RECORD(Vacbs, ROS_VACB, CacheMapVacbListEntry);
|
||||
if (Vacb->Dirty)
|
||||
{
|
||||
Dirty += VACB_MAPPING_GRANULARITY / 1024;
|
||||
}
|
||||
if (Vacb->Valid)
|
||||
{
|
||||
Valid += VACB_MAPPING_GRANULARITY / 1024;
|
||||
|
|
Loading…
Reference in a new issue