Author: sir_richard Date: Tue Oct 5 15:52:00 2010 New Revision: 48998
URL: http://svn.reactos.org/svn/reactos?rev=48998&view=rev Log: [NTOS]: When shutting down, call Cc to flush the dirty cached pages, otherwise these might've gotten lost (and lead to lost/corrupted data on disk). [NTOS]: Don't assume that CcFlushDirtyPages will run with APCs disabled. Go ahead and actually enter/leave a critical region (Acquire/ReleaseForLazyWrite depend on this). The guarded mutex does disable APCs, but it's released when the actual flush happens.
Modified: trunk/reactos/ntoskrnl/cc/view.c trunk/reactos/ntoskrnl/po/power.c
Modified: trunk/reactos/ntoskrnl/cc/view.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/view.c?rev=4899... ============================================================================== --- trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] Tue Oct 5 15:52:00 2010 @@ -189,6 +189,7 @@
(*Count) = 0;
+ KeEnterCriticalRegion(); KeAcquireGuardedMutex(&ViewLock);
WriteCount[0] = WriteCount[1]; @@ -278,6 +279,7 @@ }
KeReleaseGuardedMutex(&ViewLock); + KeLeaveCriticalRegion();
DPRINT("CcRosFlushDirtyPages() finished\n"); return(STATUS_SUCCESS);
Modified: trunk/reactos/ntoskrnl/po/power.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/po/power.c?rev=489... ============================================================================== --- trunk/reactos/ntoskrnl/po/power.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/po/power.c [iso-8859-1] Tue Oct 5 15:52:00 2010 @@ -659,6 +659,7 @@ KPROCESSOR_MODE PreviousMode = KeGetPreviousMode(); POP_POWER_ACTION Action = {0}; NTSTATUS Status; + ULONG Dummy;
/* Check for invalid parameter combinations */ if ((MinSystemState >= PowerSystemMaximum) || @@ -742,9 +743,12 @@
/* Check if we're still in an invalid status */ if (!NT_SUCCESS(Status)) break; + + /* Flush dirty cache pages */ + CcRosFlushDirtyPages(-1, &Dummy);
/* Flush all volumes and the registry */ - DPRINT1("Flushing volumes\n"); + DPRINT1("Flushing volumes, cache flushed %d pages\n", Dummy); PopFlushVolumes(PopAction.Shutdown);
/* Set IRP for drivers */