[0.4.9] cherry-pick [FASTFAT] When extending a file, also lock the DirResource.

This avoids race conditions under high IOs and thus corruption on
the FS, or assertions failures in the kernel.
Easily triggered by building ReactOS on ReactOS ;-).

(cherry picked from commit 30b836bf3f)
This commit is contained in:
Pierre Schweitzer 2018-05-21 10:28:44 +02:00 committed by Joachim Henze
parent a04d7c300e
commit 4af12f40ca

View file

@ -1064,9 +1064,18 @@ VfatWrite(
ByteOffset.u.LowPart + Length > Fcb->RFCB.FileSize.u.LowPart)
{
LARGE_INTEGER AllocationSize;
if (!ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource, CanWait))
{
goto ByeBye;
}
AllocationSize.QuadPart = ByteOffset.u.LowPart + Length;
Status = VfatSetAllocationSizeInformation(IrpContext->FileObject, Fcb,
IrpContext->DeviceExt, &AllocationSize);
ExReleaseResourceLite(&IrpContext->DeviceExt->DirResource);
if (!NT_SUCCESS (Status))
{
goto ByeBye;