[NTOSKRNL] Add an helper for marking a VACB clean (ie, not dirty).

CORE-14263
This commit is contained in:
Pierre Schweitzer 2018-02-01 08:35:27 +01:00
parent a13c998183
commit 3f8788d6e5
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B
3 changed files with 44 additions and 18 deletions

View file

@ -233,9 +233,7 @@ CcPurgeCacheSection (
RemoveEntryList(&Vacb->VacbLruListEntry);
if (Vacb->Dirty)
{
RemoveEntryList(&Vacb->DirtyVacbListEntry);
CcTotalDirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
Vacb->SharedCacheMap->DirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
CcRosUnmarkDirtyVacb(Vacb, FALSE);
}
RemoveEntryList(&Vacb->CacheMapVacbListEntry);
InsertHeadList(&FreeList, &Vacb->CacheMapVacbListEntry);

View file

@ -167,22 +167,11 @@ CcRosFlushVacb (
PROS_VACB Vacb)
{
NTSTATUS Status;
KIRQL oldIrql;
Status = CcWriteVirtualAddress(Vacb);
if (NT_SUCCESS(Status))
{
KeAcquireGuardedMutex(&ViewLock);
KeAcquireSpinLock(&Vacb->SharedCacheMap->CacheMapLock, &oldIrql);
Vacb->Dirty = FALSE;
RemoveEntryList(&Vacb->DirtyVacbListEntry);
CcTotalDirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
Vacb->SharedCacheMap->DirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
CcRosVacbDecRefCount(Vacb);
KeReleaseSpinLock(&Vacb->SharedCacheMap->CacheMapLock, oldIrql);
KeReleaseGuardedMutex(&ViewLock);
CcRosUnmarkDirtyVacb(Vacb, TRUE);
}
return Status;
@ -619,6 +608,39 @@ CcRosMarkDirtyVacb (
KeReleaseGuardedMutex(&ViewLock);
}
VOID
NTAPI
CcRosUnmarkDirtyVacb (
PROS_VACB Vacb,
BOOLEAN LockViews)
{
KIRQL oldIrql;
PROS_SHARED_CACHE_MAP SharedCacheMap;
SharedCacheMap = Vacb->SharedCacheMap;
if (LockViews)
{
KeAcquireGuardedMutex(&ViewLock);
KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldIrql);
}
ASSERT(Vacb->Dirty);
Vacb->Dirty = FALSE;
RemoveEntryList(&Vacb->DirtyVacbListEntry);
CcTotalDirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
Vacb->SharedCacheMap->DirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
CcRosVacbDecRefCount(Vacb);
if (LockViews)
{
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
KeReleaseGuardedMutex(&ViewLock);
}
}
NTSTATUS
NTAPI
CcRosMarkDirtyFile (
@ -1132,9 +1154,9 @@ CcRosDeleteFileCache (
RemoveEntryList(&current->VacbLruListEntry);
if (current->Dirty)
{
RemoveEntryList(&current->DirtyVacbListEntry);
CcTotalDirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
current->SharedCacheMap->DirtyPages -= VACB_MAPPING_GRANULARITY / PAGE_SIZE;
KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldIrql);
CcRosUnmarkDirtyVacb(current, FALSE);
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
DPRINT1("Freeing dirty VACB\n");
}
InsertHeadList(&FreeList, &current->CacheMapVacbListEntry);

View file

@ -300,6 +300,12 @@ NTAPI
CcRosMarkDirtyVacb(
PROS_VACB Vacb);
VOID
NTAPI
CcRosUnmarkDirtyVacb(
PROS_VACB Vacb,
BOOLEAN LockViews);
NTSTATUS
NTAPI
CcRosFlushDirtyPages(