From 358d06c47ca31d8854c8ba2ffa16ab577f798e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Tue, 29 Dec 2020 10:07:57 +0100 Subject: [PATCH] [NTOS:CC] Always honor WriteThrough parameter in CcUnpinRepinnedBcb --- ntoskrnl/cc/pin.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/ntoskrnl/cc/pin.c b/ntoskrnl/cc/pin.c index 597468f6fd7..8a79ee45031 100644 --- a/ntoskrnl/cc/pin.c +++ b/ntoskrnl/cc/pin.c @@ -629,29 +629,25 @@ CcUnpinRepinnedBcb ( SharedCacheMap = iBcb->Vacb->SharedCacheMap; IoStatus->Status = STATUS_SUCCESS; + if (WriteThrough) + { + CcFlushCache(iBcb->Vacb->SharedCacheMap->FileObject->SectionObjectPointer, + &iBcb->PFCB.MappedFileOffset, + iBcb->PFCB.MappedLength, + IoStatus); + } + else + { + IoStatus->Status = STATUS_SUCCESS; + IoStatus->Information = 0; + } + KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql); if (--iBcb->RefCount == 0) { RemoveEntryList(&iBcb->BcbEntry); KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql); - IoStatus->Information = 0; - if (WriteThrough) - { - if (iBcb->Vacb->Dirty) - { - IoStatus->Status = CcRosFlushVacb(iBcb->Vacb); - } - else - { - IoStatus->Status = STATUS_SUCCESS; - } - } - else - { - IoStatus->Status = STATUS_SUCCESS; - } - if (iBcb->PinCount != 0) { ExReleaseResourceLite(&iBcb->Lock);