https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c779dbd4c5779cfddfd40…
commit c779dbd4c5779cfddfd4054601d996c15ae22ff4
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Mon Jan 15 23:20:53 2018 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Mon Jan 15 23:20:53 2018 +0100
[NTOSKRNL] Implement CcIsThereDirtyData()
---
ntoskrnl/cc/fs.c | 40 +++++++++++++++++++++++++++++++++++++---
ntoskrnl/cc/view.c | 2 +-
ntoskrnl/include/internal/cc.h | 1 +
3 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/ntoskrnl/cc/fs.c b/ntoskrnl/cc/fs.c
index fb5f99aab2..d62e18dee0 100644
--- a/ntoskrnl/cc/fs.c
+++ b/ntoskrnl/cc/fs.c
@@ -111,17 +111,51 @@ CcInitializeCacheMap (
}
/*
- * @unimplemented
+ * @implemented
*/
BOOLEAN
NTAPI
CcIsThereDirtyData (
IN PVPB Vpb)
{
+ PROS_VACB Vacb;
+ PLIST_ENTRY Entry;
+ /* Assume no dirty data */
+ BOOLEAN Dirty = FALSE;
+
CCTRACE(CC_API_DEBUG, "Vpb=%p\n", Vpb);
- UNIMPLEMENTED;
- return FALSE;
+ KeAcquireGuardedMutex(&ViewLock);
+
+ /* Browse dirty VACBs */
+ for (Entry = DirtyVacbListHead.Flink; Entry != &DirtyVacbListHead; Entry =
Entry->Flink)
+ {
+ Vacb = CONTAINING_RECORD(Entry, ROS_VACB, DirtyVacbListEntry);
+ /* Look for these associated with our volume */
+ if (Vacb->SharedCacheMap->FileObject->Vpb != Vpb)
+ {
+ continue;
+ }
+
+ /* From now on, we are associated with our VPB */
+
+ /* Temporary files are not counted as dirty */
+ if (BooleanFlagOn(Vacb->SharedCacheMap->FileObject->Flags,
FO_TEMPORARY_FILE))
+ {
+ continue;
+ }
+
+ /* A single dirty VACB is enough to have dirty data */
+ if (Vacb->Dirty)
+ {
+ Dirty = TRUE;
+ break;
+ }
+ }
+
+ KeReleaseGuardedMutex(&ViewLock);
+
+ return Dirty;
}
/*
diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c
index f38a028d9b..0e37b77efc 100644
--- a/ntoskrnl/cc/view.c
+++ b/ntoskrnl/cc/view.c
@@ -41,7 +41,7 @@
/* GLOBALS *******************************************************************/
-static LIST_ENTRY DirtyVacbListHead;
+LIST_ENTRY DirtyVacbListHead;
static LIST_ENTRY VacbLruListHead;
ULONG DirtyPageCount = 0;
diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h
index 4f7c4823af..58d2b15a50 100644
--- a/ntoskrnl/include/internal/cc.h
+++ b/ntoskrnl/include/internal/cc.h
@@ -40,6 +40,7 @@
// Global Cc Data
//
extern ULONG CcRosTraceLevel;
+extern LIST_ENTRY DirtyVacbListHead;
typedef struct _PF_SCENARIO_ID
{