From 96eb96dfb613e4c745db6bd1f53a92fe7e2290fc Mon Sep 17 00:00:00 2001 From: karlf Date: Thu, 11 Aug 2016 13:28:13 -0700 Subject: Updated for "Windows 10 Anniversary Update" (Version 1607) --- storage/class/disk/src/disk.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'storage/class/disk/src/disk.c') diff --git a/storage/class/disk/src/disk.c b/storage/class/disk/src/disk.c index 3d4d19b4..05f0d6d3 100644 --- a/storage/class/disk/src/disk.c +++ b/storage/class/disk/src/disk.c @@ -1550,6 +1550,7 @@ Return Value: PIO_STACK_LOCATION irpSp = NULL; PSTOR_ADDR_BTL8 storAddrBtl8; PSRBEX_DATA_SCSI_CDB16 srbExDataCdb16; + NTSTATUS SyncCacheStatus = STATUS_SUCCESS; // // Fill in the srb fields appropriately @@ -1623,7 +1624,7 @@ Return Value: TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_SCSI, "DiskFlushDispatch: sending sync cache\n")); - ClassSendSrbSynchronous(Fdo, srb, NULL, 0, TRUE); + SyncCacheStatus = ClassSendSrbSynchronous(Fdo, srb, NULL, 0, TRUE); } // @@ -1669,7 +1670,7 @@ Return Value: irpSp->MajorFunction = IRP_MJ_SCSI; irpSp->Parameters.Scsi.Srb = srb; - IoSetCompletionRoutine(FlushContext->CurrIrp, DiskFlushComplete, NULL, TRUE, TRUE, TRUE); + IoSetCompletionRoutine(FlushContext->CurrIrp, DiskFlushComplete, (PVOID)SyncCacheStatus, TRUE, TRUE, TRUE); TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_SCSI, "DiskFlushDispatch: sending srb flush on irp %p\n", FlushContext->CurrIrp)); @@ -1700,7 +1701,9 @@ Arguments: Fdo - The device object which requested the completion routine Irp - The irp that is being completed - Context - The flush group context + Context - If disk had write cache enabled and SYNC CACHE command was sent as 1st part of FLUSH processing + then context must carry the completion status of SYNC CACHE request, + else context must be set to STATUS_SUCCESS. Return Value: @@ -1713,8 +1716,7 @@ Return Value: NTSTATUS status; PFUNCTIONAL_DEVICE_EXTENSION fdoExt; PDISK_DATA diskData; - - UNREFERENCED_PARAMETER(Context); + NTSTATUS SyncCacheStatus = (NTSTATUS) Context; TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_GENERAL, "DiskFlushComplete: %p %p\n", Fdo, Irp)); @@ -1741,6 +1743,15 @@ Return Value: // NT_ASSERT(status != STATUS_MORE_PROCESSING_REQUIRED); + // + // If sync cache failed earlier, final status of the flush request needs to be failure + // even if SRB_FUNCTION_FLUSH srb request succeeded + // + if (NT_SUCCESS(status) && + (!NT_SUCCESS(SyncCacheStatus))) { + Irp->IoStatus.Status = status = SyncCacheStatus; + } + // // Complete the flush requests tagged to this one // -- cgit v1.3.1