mirror of
https://github.com/reactos/reactos.git
synced 2025-06-10 12:24:48 +00: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:
parent
29764be430
commit
103fbf8518
2 changed files with 7 additions and 1 deletions
|
@ -189,6 +189,7 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
||||||
|
|
||||||
(*Count) = 0;
|
(*Count) = 0;
|
||||||
|
|
||||||
|
KeEnterCriticalRegion();
|
||||||
KeAcquireGuardedMutex(&ViewLock);
|
KeAcquireGuardedMutex(&ViewLock);
|
||||||
|
|
||||||
WriteCount[0] = WriteCount[1];
|
WriteCount[0] = WriteCount[1];
|
||||||
|
@ -278,6 +279,7 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
||||||
}
|
}
|
||||||
|
|
||||||
KeReleaseGuardedMutex(&ViewLock);
|
KeReleaseGuardedMutex(&ViewLock);
|
||||||
|
KeLeaveCriticalRegion();
|
||||||
|
|
||||||
DPRINT("CcRosFlushDirtyPages() finished\n");
|
DPRINT("CcRosFlushDirtyPages() finished\n");
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
|
|
|
@ -659,6 +659,7 @@ NtSetSystemPowerState(IN POWER_ACTION SystemAction,
|
||||||
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
|
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
|
||||||
POP_POWER_ACTION Action = {0};
|
POP_POWER_ACTION Action = {0};
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
ULONG Dummy;
|
||||||
|
|
||||||
/* Check for invalid parameter combinations */
|
/* Check for invalid parameter combinations */
|
||||||
if ((MinSystemState >= PowerSystemMaximum) ||
|
if ((MinSystemState >= PowerSystemMaximum) ||
|
||||||
|
@ -743,8 +744,11 @@ NtSetSystemPowerState(IN POWER_ACTION SystemAction,
|
||||||
/* Check if we're still in an invalid status */
|
/* Check if we're still in an invalid status */
|
||||||
if (!NT_SUCCESS(Status)) break;
|
if (!NT_SUCCESS(Status)) break;
|
||||||
|
|
||||||
|
/* Flush dirty cache pages */
|
||||||
|
CcRosFlushDirtyPages(-1, &Dummy);
|
||||||
|
|
||||||
/* Flush all volumes and the registry */
|
/* Flush all volumes and the registry */
|
||||||
DPRINT1("Flushing volumes\n");
|
DPRINT1("Flushing volumes, cache flushed %d pages\n", Dummy);
|
||||||
PopFlushVolumes(PopAction.Shutdown);
|
PopFlushVolumes(PopAction.Shutdown);
|
||||||
|
|
||||||
/* Set IRP for drivers */
|
/* Set IRP for drivers */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue