https://git.reactos.org/?p=reactos.git;a=commitdiff;h=469e15c7ae5d2b7dc266fd...
commit 469e15c7ae5d2b7dc266fdde7beb173d8263d563 Author: Pierre Schweitzer pierre@reactos.org AuthorDate: Sun Aug 26 21:49:05 2018 +0200 Commit: Pierre Schweitzer pierre@reactos.org CommitDate: Sun Aug 26 22:05:11 2018 +0200
[NTOSKRNL] Stubplement CcPinMappedData() and simplify CcPinRead()
It's based on the code that was in CcPinRead() implementation. This made no sense to have CcPinMappedData() doing nothing while implementing everything in CcPinRead(). Indeed, drivers (starting with MS drivers) can map data first and pin it afterwards with CcPinMappedData(). It was leading to incorrect behavior with our previous noop implementation. --- ntoskrnl/cc/pin.c | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-)
diff --git a/ntoskrnl/cc/pin.c b/ntoskrnl/cc/pin.c index 2d48a27a0a..8b99b8c210 100644 --- a/ntoskrnl/cc/pin.c +++ b/ntoskrnl/cc/pin.c @@ -161,6 +161,7 @@ CcPinMappedData ( IN ULONG Flags, OUT PVOID * Bcb) { + PINTERNAL_BCB iBcb; PROS_SHARED_CACHE_MAP SharedCacheMap;
CCTRACE(CC_API_DEBUG, "FileOffset=%p FileOffset=%p Length=%lu Flags=0x%lx\n", @@ -174,7 +175,21 @@ CcPinMappedData ( ASSERT(SharedCacheMap); ASSERT(SharedCacheMap->PinAccess);
- /* no-op for current implementation. */ + iBcb = *Bcb; + ASSERT(iBcb->Pinned == FALSE); + + iBcb->Pinned = TRUE; + iBcb->Vacb->PinCount++; + + if (Flags & PIN_EXCLUSIVE) + { + ExAcquireResourceExclusiveLite(&iBcb->Lock, TRUE); + } + else + { + ExAcquireResourceSharedLite(&iBcb->Lock, TRUE); + } + return TRUE; }
@@ -191,8 +206,6 @@ CcPinRead ( OUT PVOID * Bcb, OUT PVOID * Buffer) { - PINTERNAL_BCB iBcb; - CCTRACE(CC_API_DEBUG, "FileOffset=%p FileOffset=%p Length=%lu Flags=0x%lx\n", FileObject, FileOffset, Length, Flags);
@@ -205,32 +218,20 @@ CcPinRead ( ++CcPinReadNoWait; }
- if (CcMapData(FileObject, FileOffset, Length, Flags, Bcb, Buffer)) + /* Map first */ + if (!CcMapData(FileObject, FileOffset, Length, Flags, Bcb, Buffer)) { - if (CcPinMappedData(FileObject, FileOffset, Length, Flags, Bcb)) - { - iBcb = *Bcb; - - ASSERT(iBcb->Pinned == FALSE); - - iBcb->Pinned = TRUE; - iBcb->Vacb->PinCount++; - - if (Flags & PIN_EXCLUSIVE) - { - ExAcquireResourceExclusiveLite(&iBcb->Lock, TRUE); - } - else - { - ExAcquireResourceSharedLite(&iBcb->Lock, TRUE); - } + return FALSE; + }
- return TRUE; - } - else - CcUnpinData(*Bcb); + /* Pin then */ + if (!CcPinMappedData(FileObject, FileOffset, Length, Flags, Bcb)) + { + CcUnpinData(*Bcb); + return FALSE; } - return FALSE; + + return TRUE; }
/*