[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:
Sir Richard 2010-10-05 15:52:00 +00:00
parent 29764be430
commit 103fbf8518
2 changed files with 7 additions and 1 deletions

View file

@ -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);

View file

@ -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 */