[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/4] SDV: RemoveLock rule violations


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Durrant, Paul" <xadimgnik@xxxxxxxxx>
  • Date: Fri, 11 Feb 2022 20:01:15 +0000
  • Delivery-date: Fri, 11 Feb 2022 20:01:21 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

On 07/02/2022 13:15, Owen Smith wrote:
Calls to IoAcquireRemoveLock and IoReleaseRemoveLock should be paired within
the same dispatch entry point, unless the IoCompletionRoutine does some work.
Remove completion routines that are not required and call IoReleaseRemoveLock
after the IRP has been passed to IoCallDriver.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>

The completion routines were intended to be there in case we needed them, often as a convenient point to put logging or trap in the debugger. I guess, now that drivers are mature, it is reasonable to dispense with them.

Acked-by: Paul Durrant <paul@xxxxxxx>

---
  src/xenfilt/fdo.c | 284 ++++--------------------------------------
  src/xenfilt/pdo.c | 307 ++++------------------------------------------
  2 files changed, 46 insertions(+), 545 deletions(-)

diff --git a/src/xenfilt/fdo.c b/src/xenfilt/fdo.c
index 6a45b0f..63fa7b3 100644
--- a/src/xenfilt/fdo.c
+++ b/src/xenfilt/fdo.c
@@ -581,27 +581,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-FdoQueryStopDeviceCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  FdoQueryStopDevice(
      IN  PXENFILT_FDO    Fdo,
@@ -617,15 +596,10 @@ FdoQueryStopDevice(
      __FdoSetDevicePnpState(Fdo, StopPending);
      Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           FdoQueryStopDeviceCompletion,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
return status; @@ -636,27 +610,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-FdoCancelStopDeviceCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  FdoCancelStopDevice(
      IN  PXENFILT_FDO    Fdo,
@@ -673,15 +626,10 @@ FdoCancelStopDevice(
__FdoRestoreDevicePnpState(Fdo, StopPending); - IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           FdoCancelStopDeviceCompletion,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
return status; @@ -692,27 +640,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-FdoStopDeviceCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  FdoStopDevice(
      IN  PXENFILT_FDO            Fdo,
@@ -739,15 +666,10 @@ FdoStopDevice(
      __FdoSetDevicePnpState(Fdo, Stopped);
      Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           FdoStopDeviceCompletion,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
return status; @@ -758,27 +680,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-FdoQueryRemoveDeviceCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  FdoQueryRemoveDevice(
      IN  PXENFILT_FDO    Fdo,
@@ -794,15 +695,10 @@ FdoQueryRemoveDevice(
      __FdoSetDevicePnpState(Fdo, RemovePending);
      Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           FdoQueryRemoveDeviceCompletion,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
return status; @@ -813,27 +709,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-FdoCancelRemoveDeviceCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  FdoCancelRemoveDevice(
      IN  PXENFILT_FDO    Fdo,
@@ -849,15 +724,10 @@ FdoCancelRemoveDevice(
      __FdoRestoreDevicePnpState(Fdo, RemovePending);
      Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           FdoCancelRemoveDeviceCompletion,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
return status; @@ -868,27 +738,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-FdoSurpriseRemovalCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  FdoSurpriseRemoval(
      IN  PXENFILT_FDO    Fdo,
@@ -904,15 +753,10 @@ FdoSurpriseRemoval(
      __FdoSetDevicePnpState(Fdo, SurpriseRemovePending);
      Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           FdoSurpriseRemovalCompletion,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
return status; @@ -974,10 +818,9 @@ FdoRemoveDevice(
  done:
      __FdoSetDevicePnpState(Fdo, Deleted);
- IoReleaseRemoveLockAndWait(&Fdo->Dx->RemoveLock, Irp);
-
      status = FdoForwardIrpSynchronously(Fdo, Irp);
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+    IoReleaseRemoveLockAndWait(&Fdo->Dx->RemoveLock, Irp);
__FdoAcquireMutex(Fdo);
      ASSERT3U(Fdo->References, !=, 0);
@@ -990,6 +833,8 @@ done:
          DriverReleaseMutex();
      }
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
      return status;
fail1:
@@ -1159,26 +1004,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-FdoDispatchPnpCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  FdoDispatchPnp(
      IN  PXENFILT_FDO    Fdo,
@@ -1234,15 +1059,10 @@ FdoDispatchPnp(
          if (!NT_SUCCESS(status))
              goto fail1;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-        IoSetCompletionRoutine(Irp,
-                               FdoDispatchPnpCompletion,
-                               Fdo,
-                               TRUE,
-                               TRUE,
-                               TRUE);
+        IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
+        IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
          break;
      }
@@ -1754,26 +1574,6 @@ FdoSystemPower(
      return STATUS_SUCCESS;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-FdoDispatchPowerCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  FdoDispatchPower(
      IN  PXENFILT_FDO    Fdo,
@@ -1794,15 +1594,10 @@ FdoDispatchPower(
if (MinorFunction != IRP_MN_QUERY_POWER &&
          MinorFunction != IRP_MN_SET_POWER) {
-        IoCopyCurrentIrpStackLocationToNext(Irp);
-        IoSetCompletionRoutine(Irp,
-                               FdoDispatchPowerCompletion,
-                               Fdo,
-                               TRUE,
-                               TRUE,
-                               TRUE);
+        IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
+        IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
goto done;
      }
@@ -1840,15 +1635,10 @@ FdoDispatchPower(
          break;
default:
-        IoCopyCurrentIrpStackLocationToNext(Irp);
-        IoSetCompletionRoutine(Irp,
-                               FdoDispatchPowerCompletion,
-                               Fdo,
-                               TRUE,
-                               TRUE,
-                               TRUE);
+        IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
+        IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
          break;
      }
@@ -1870,27 +1660,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-FdoDispatchDefaultCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  FdoDispatchDefault(
      IN  PXENFILT_FDO    Fdo,
@@ -1903,15 +1672,10 @@ FdoDispatchDefault(
      if (!NT_SUCCESS(status))
          goto fail1;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           FdoDispatchDefaultCompletion,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
return status; diff --git a/src/xenfilt/pdo.c b/src/xenfilt/pdo.c
index b3569a3..741c2f3 100644
--- a/src/xenfilt/pdo.c
+++ b/src/xenfilt/pdo.c
@@ -523,27 +523,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-PdoQueryStopDeviceCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  PdoQueryStopDevice(
      IN  PXENFILT_PDO    Pdo,
@@ -559,15 +538,10 @@ PdoQueryStopDevice(
      __PdoSetDevicePnpState(Pdo, StopPending);
      Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           PdoQueryStopDeviceCompletion,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
return status; @@ -578,27 +552,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-PdoCancelStopDeviceCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  PdoCancelStopDevice(
      IN  PXENFILT_PDO    Pdo,
@@ -615,15 +568,10 @@ PdoCancelStopDevice(
__PdoRestoreDevicePnpState(Pdo, StopPending); - IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           PdoCancelStopDeviceCompletion,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
return status; @@ -634,27 +582,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-PdoStopDeviceCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  PdoStopDevice(
      IN  PXENFILT_PDO    Pdo,
@@ -682,15 +609,10 @@ done:
      __PdoSetDevicePnpState(Pdo, Stopped);
      Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           PdoStopDeviceCompletion,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
return status; @@ -701,27 +623,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-PdoQueryRemoveDeviceCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  PdoQueryRemoveDevice(
      IN  PXENFILT_PDO    Pdo,
@@ -737,15 +638,10 @@ PdoQueryRemoveDevice(
      __PdoSetDevicePnpState(Pdo, RemovePending);
      Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           PdoQueryRemoveDeviceCompletion,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
return status; @@ -756,27 +652,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-PdoCancelRemoveDeviceCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  PdoCancelRemoveDevice(
      IN  PXENFILT_PDO    Pdo,
@@ -792,15 +667,10 @@ PdoCancelRemoveDevice(
      __PdoRestoreDevicePnpState(Pdo, RemovePending);
      Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           PdoCancelRemoveDeviceCompletion,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
return status; @@ -811,27 +681,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-PdoSurpriseRemovalCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  PdoSurpriseRemoval(
      IN  PXENFILT_PDO    Pdo,
@@ -847,15 +696,10 @@ PdoSurpriseRemoval(
      __PdoSetDevicePnpState(Pdo, SurpriseRemovePending);
      Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           PdoSurpriseRemovalCompletion,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
return status; @@ -930,27 +774,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-PdoQueryInterfaceCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  #define DEFINE_PDO_QUERY_INTERFACE(_Interface)                      \
  static NTSTATUS                                                     \
  PdoQuery ## _Interface ## Interface(                                \
@@ -1041,15 +864,10 @@ PdoQueryInterface(
      }
done:
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           PdoQueryInterfaceCompletion,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
return status; @@ -1283,26 +1101,6 @@ PdoEject(
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-PdoDispatchPnpCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  PdoDispatchPnp(
      IN  PXENFILT_PDO    Pdo,
@@ -1370,15 +1168,10 @@ PdoDispatchPnp(
          if (!NT_SUCCESS(status))
              goto fail1;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-        IoSetCompletionRoutine(Irp,
-                               PdoDispatchPnpCompletion,
-                               Pdo,
-                               TRUE,
-                               TRUE,
-                               TRUE);
+        IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
+        IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
          break;
      }
@@ -1894,26 +1687,6 @@ PdoSystemPower(
      return STATUS_SUCCESS;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-PdoDispatchPowerCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  PdoDispatchPower(
      IN  PXENFILT_PDO    Pdo,
@@ -1934,15 +1707,10 @@ PdoDispatchPower(
if (MinorFunction != IRP_MN_QUERY_POWER &&
          MinorFunction != IRP_MN_SET_POWER) {
-        IoCopyCurrentIrpStackLocationToNext(Irp);
-        IoSetCompletionRoutine(Irp,
-                               PdoDispatchPowerCompletion,
-                               Pdo,
-                               TRUE,
-                               TRUE,
-                               TRUE);
+        IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
+        IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
goto done;
      }
@@ -1980,15 +1748,10 @@ PdoDispatchPower(
          break;
default:
-        IoCopyCurrentIrpStackLocationToNext(Irp);
-        IoSetCompletionRoutine(Irp,
-                               PdoDispatchPowerCompletion,
-                               Pdo,
-                               TRUE,
-                               TRUE,
-                               TRUE);
+        IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
+        IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
          break;
      }
@@ -2010,27 +1773,6 @@ fail1:
      return status;
  }
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-PdoDispatchDefaultCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENFILT_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
  static NTSTATUS
  PdoDispatchDefault(
      IN  PXENFILT_PDO    Pdo,
@@ -2043,15 +1785,10 @@ PdoDispatchDefault(
      if (!NT_SUCCESS(status))
          goto fail1;
- IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           PdoDispatchDefaultCompletion,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
+    IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
+    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
return status;




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.