mirror of
https://github.com/reactos/reactos.git
synced 2026-05-30 05:51:26 +08:00
[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. svn path=/trunk/; revision=48998
This commit is contained in:
@@ -189,6 +189,7 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
||||
|
||||
(*Count) = 0;
|
||||
|
||||
KeEnterCriticalRegion();
|
||||
KeAcquireGuardedMutex(&ViewLock);
|
||||
|
||||
WriteCount[0] = WriteCount[1];
|
||||
@@ -278,6 +279,7 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
||||
}
|
||||
|
||||
KeReleaseGuardedMutex(&ViewLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
DPRINT("CcRosFlushDirtyPages() finished\n");
|
||||
return(STATUS_SUCCESS);
|
||||
|
||||
@@ -659,6 +659,7 @@ NtSetSystemPowerState(IN POWER_ACTION SystemAction,
|
||||
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 @@ NtSetSystemPowerState(IN POWER_ACTION SystemAction,
|
||||
|
||||
/* 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 */
|
||||
|
||||
Reference in New Issue
Block a user