https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1505abbc095f9f9414e15…
commit 1505abbc095f9f9414e15847ce840d2a8fe592d9
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Tue Dec 22 11:31:51 2020 +0100
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Wed Feb 3 09:41:23 2021 +0100
[NTOS:CC] Do not write behind concurrently the same file
---
ntoskrnl/cc/view.c | 12 ++++++++++++
ntoskrnl/include/internal/cc.h | 1 +
2 files changed, 13 insertions(+)
diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c
index 35d0df31545..e6ac23c2b6e 100644
--- a/ntoskrnl/cc/view.c
+++ b/ntoskrnl/cc/view.c
@@ -262,6 +262,15 @@ CcRosFlushDirtyPages (
ASSERT(current->Dirty);
+ /* Do not lazy-write the same file concurrently. Fastfat ASSERTS on that */
+ if (current->SharedCacheMap->Flags & SHARED_CACHE_MAP_IN_LAZYWRITE)
+ {
+ CcRosVacbDecRefCount(current);
+ continue;
+ }
+
+ current->SharedCacheMap->Flags |= SHARED_CACHE_MAP_IN_LAZYWRITE;
+
KeReleaseQueuedSpinLock(LockQueueMasterLock, OldIrql);
Locked = current->SharedCacheMap->Callbacks->AcquireForLazyWrite(
@@ -272,6 +281,7 @@ CcRosFlushDirtyPages (
ASSERT(!Wait);
OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock);
CcRosVacbDecRefCount(current);
+ current->SharedCacheMap->Flags &= ~SHARED_CACHE_MAP_IN_LAZYWRITE;
continue;
}
@@ -287,6 +297,8 @@ CcRosFlushDirtyPages (
CcRosVacbDecRefCount(current);
OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock);
+ current->SharedCacheMap->Flags &= ~SHARED_CACHE_MAP_IN_LAZYWRITE;
+
if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE) &&
(Status != STATUS_MEDIA_WRITE_PROTECTED))
{
diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h
index 862a759ef7a..65fd3fe6ffa 100644
--- a/ntoskrnl/include/internal/cc.h
+++ b/ntoskrnl/include/internal/cc.h
@@ -200,6 +200,7 @@ typedef struct _ROS_SHARED_CACHE_MAP
#define READAHEAD_DISABLED 0x1
#define WRITEBEHIND_DISABLED 0x2
#define SHARED_CACHE_MAP_IN_CREATION 0x4
+#define SHARED_CACHE_MAP_IN_LAZYWRITE 0x8
typedef struct _ROS_VACB
{