NTSTATUS Status;
PLIST_ENTRY NextEntry;
PCMHIVE CmHive;
- BOOLEAN Result;
+ BOOLEAN Result;
ULONG HiveCount = CmpLazyFlushHiveCount;
/* Set Defaults */
*Error = FALSE;
*DirtyCount = 0;
-
+
/* Don't do anything if we're not supposed to */
if (CmpNoWrite) return TRUE;
{
/* Great sucess! */
Result = TRUE;
-
+
/* Ignore clean or volatile hves */
if (!(CmHive->Hive.DirtyCount) ||
(CmHive->Hive.HiveFlags & HIVE_VOLATILE))
/* Try the next one */
NextEntry = NextEntry->Flink;
}
-
+
/* Check if we've flushed everything */
if (NextEntry == &CmpHiveListHead)
{
/* We need to be called again */
Result = TRUE;
}
-
+
/* Unlock the list and return the result */
ExReleasePushLock(&CmpHiveListHeadLock);
return Result;
}
+_Function_class_(KDEFERRED_ROUTINE)
VOID
NTAPI
CmpEnableLazyFlushDpcRoutine(IN PKDPC Dpc,
CmpHoldLazyFlush = FALSE;
}
+_Function_class_(KDEFERRED_ROUTINE)
VOID
NTAPI
CmpLazyFlushDpcRoutine(IN PKDPC Dpc,
{
LARGE_INTEGER DueTime;
PAGED_CODE();
-
+
/* Check if we should set the lazy flush timer */
if ((!CmpNoWrite) && (!CmpHoldLazyFlush))
{
}
}
+_Function_class_(WORKER_THREAD_ROUTINE)
VOID
NTAPI
CmpLazyFlushWorker(IN PVOID Parameter)
/* Don't do anything if lazy flushing isn't enabled yet */
if (CmpHoldLazyFlush) return;
-
+
/* Check if we are forcing a flush */
ForceFlush = CmpForceForceFlush;
if (ForceFlush)
CmpLockRegistry();
InterlockedIncrement(&CmpFlushStarveWriters);
}
-
+
/* Flush the next hive */
MoreWork = CmpDoFlushNextHive(ForceFlush, &Result, &DirtyCount);
if (!MoreWork)
/* Not pending anymore, release the registry lock */
CmpLazyFlushPending = FALSE;
CmpUnlockRegistry();
-
+
/* Check if we need to flush another hive */
if ((MoreWork) || (DirtyCount)) CmpLazyFlush();
}
NTAPI
CmpCmdInit(IN BOOLEAN SetupBoot)
{
- LARGE_INTEGER DueTime;
+ LARGE_INTEGER DueTime;
PAGED_CODE();
-
+
/* Setup the lazy DPC */
KeInitializeDpc(&CmpLazyFlushDpc, CmpLazyFlushDpcRoutine, NULL);
-
+
/* Setup the lazy timer */
KeInitializeTimer(&CmpLazyFlushTimer);
-
+
/* Setup the lazy worker */
ExInitializeWorkItem(&CmpLazyWorkItem, CmpLazyFlushWorker, NULL);
CmpEnableLazyFlushDpcRoutine,
NULL);
KeInitializeTimer(&CmpEnableLazyFlushTimer);
-
+
/* Enable lazy flushing after 10 minutes */
DueTime.QuadPart = Int32x32To64(600, -10 * 1000 * 1000);
KeSetTimer(&CmpEnableLazyFlushTimer, DueTime, &CmpEnableLazyFlushDpc);
/* Setup flush variables */
CmpNoWrite = CmpMiniNTBoot;
CmpWasSetupBoot = SetupBoot;
-
+
/* Testing: Force Lazy Flushing */
CmpHoldLazyFlush = FALSE;
-
+
/* Setup the hive list */
CmpInitializeHiveList(SetupBoot);
}