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

[win-pv-devel] [PATCH 1/2] Simplify unplug request



Since the PDO driver in XENVBD's case is in-box, we don't need to defer
requesting emulated device unplug to when PDOs are started, we can do it
when the FDO is started.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenvbd/fdo.c | 73 ++++++++++++++++++++------------------------------------
 src/xenvbd/fdo.h |  5 ----
 src/xenvbd/pdo.c | 49 ++++++-------------------------------
 3 files changed, 33 insertions(+), 94 deletions(-)

diff --git a/src/xenvbd/fdo.c b/src/xenvbd/fdo.c
index 8d5231f..f6b47f2 100644
--- a/src/xenvbd/fdo.c
+++ b/src/xenvbd/fdo.c
@@ -760,20 +760,8 @@ FdoScan(
             StorPortNotification(BusChangeDetected, Fdo, 0);
         }
 
-        if (NeedReboot) {
-            PXENBUS_UNPLUG_INTERFACE    Unplug;
-
-            Unplug = FdoAcquireUnplug(Fdo);
-            ASSERT(Unplug != NULL);
-
-            XENBUS_UNPLUG(Request,
-                          Unplug,
-                          XENBUS_UNPLUG_DEVICE_TYPE_DISKS,
-                          TRUE);
-            XENBUS_UNPLUG(Release, Unplug);
-
+        if (NeedReboot)
             __FdoNotifyInstaller(Fdo);
-        }
     }
 
     return STATUS_SUCCESS;
@@ -1000,14 +988,8 @@ __FdoAcquire(
     if (!NT_SUCCESS(status))
         goto fail6;
 
-    status = XENBUS_UNPLUG(Acquire, &Fdo->Unplug);
-    if (!NT_SUCCESS(status))
-        goto fail7;
-
     return STATUS_SUCCESS;
 
-fail7:
-    XENBUS_UNPLUG(Release, &Fdo->Unplug);
 fail6:
     XENBUS_EVTCHN(Release, &Fdo->Evtchn);
 fail5:
@@ -1027,7 +1009,6 @@ __FdoRelease(
     __in PXENVBD_FDO             Fdo
     )
 {
-    XENBUS_UNPLUG(Release, &Fdo->Unplug);
     XENBUS_STORE(Release, &Fdo->Store);
     XENBUS_EVTCHN(Release, &Fdo->Evtchn);
     XENBUS_GNTTAB(Release, &Fdo->Gnttab);
@@ -1518,6 +1499,26 @@ FdoAdapterControl(
     return ScsiAdapterControlSuccess;
 }
 
+static VOID
+FdoUnplugRequest(
+    IN  PXENVBD_FDO Fdo,
+    IN  BOOLEAN     Make
+    )
+{
+    NTSTATUS        status;
+
+    status = XENBUS_UNPLUG(Acquire, &Fdo->Unplug);
+    if (!NT_SUCCESS(status))
+        return;
+
+    XENBUS_UNPLUG(Request,
+                  &Fdo->Unplug,
+                  XENBUS_UNPLUG_DEVICE_TYPE_DISKS,
+                  Make);
+
+    XENBUS_UNPLUG(Release, &Fdo->Unplug);
+}
+
 ULONG
 FdoFindAdapter(
     __in PXENVBD_FDO                 Fdo,
@@ -1555,6 +1556,9 @@ FdoFindAdapter(
 
     if (!NT_SUCCESS(__FdoInitialize(Fdo)))
         return SP_RETURN_ERROR;
+
+    FdoUnplugRequest(Fdo, TRUE);
+
     if (!NT_SUCCESS(__FdoD3ToD0(Fdo)))
         return SP_RETURN_ERROR;
 
@@ -1656,6 +1660,7 @@ FdoDispatchPnp(
     case IRP_MN_REMOVE_DEVICE:
         Verbose("FDO:IRP_MN_REMOVE_DEVICE\n");
         __FdoD0ToD3(Fdo);
+        FdoUnplugRequest(Fdo, FALSE);
         // drop ref-count acquired in DriverGetFdo *before* destroying Fdo
         FdoDereference(Fdo);
         __FdoTerminate(Fdo);
@@ -1681,20 +1686,8 @@ FdoDispatchPnp(
             if (NeedInvalidate)
                 FdoLogTargets("QUERY_RELATIONS", Fdo);
 
-            if (NeedReboot) {
-                PXENBUS_UNPLUG_INTERFACE    Unplug;
-
-                Unplug = FdoAcquireUnplug(Fdo);
-                ASSERT(Unplug != NULL);
-
-                XENBUS_UNPLUG(Request,
-                              Unplug,
-                              XENBUS_UNPLUG_DEVICE_TYPE_DISKS,
-                              TRUE);
-                XENBUS_UNPLUG(Release, Unplug);
-
+            if (NeedReboot)
                 __FdoNotifyInstaller(Fdo);
-            }
         }
         FdoDereference(Fdo);
         break;
@@ -1977,17 +1970,3 @@ FdoAcquireSuspend(
 
     return &Fdo->Suspend;
 }
-
-PXENBUS_UNPLUG_INTERFACE
-FdoAcquireUnplug(
-    __in PXENVBD_FDO    Fdo
-    )
-{
-    NTSTATUS            status;
-
-    status = XENBUS_UNPLUG(Acquire, &Fdo->Unplug);
-    if (!NT_SUCCESS(status))
-        return NULL;
-
-    return &Fdo->Unplug;
-}
diff --git a/src/xenvbd/fdo.h b/src/xenvbd/fdo.h
index 981ffbb..c1974ec 100644
--- a/src/xenvbd/fdo.h
+++ b/src/xenvbd/fdo.h
@@ -193,9 +193,4 @@ FdoAcquireSuspend(
     __in PXENVBD_FDO                 Fdo
     );
 
-extern PXENBUS_UNPLUG_INTERFACE
-FdoAcquireUnplug(
-    __in PXENVBD_FDO                 Fdo
-    );
-
 #endif // _XENVBD_FDO_H
diff --git a/src/xenvbd/pdo.c b/src/xenvbd/pdo.c
index f0d6674..e00729e 100644
--- a/src/xenvbd/pdo.c
+++ b/src/xenvbd/pdo.c
@@ -2595,23 +2595,11 @@ PdoDispatchPnp(
     __PdoCheckEjectPending(Pdo);
 
     switch (Stack->MinorFunction) {
-    case IRP_MN_START_DEVICE: {
-        PXENBUS_UNPLUG_INTERFACE    Unplug;
-
-        Unplug = FdoAcquireUnplug(PdoGetFdo(Pdo));
-        ASSERT(Unplug != NULL);
-
-        XENBUS_UNPLUG(Request,
-                      Unplug,
-                      XENBUS_UNPLUG_DEVICE_TYPE_DISKS,
-                      TRUE);
-        XENBUS_UNPLUG(Release, Unplug);
-
+    case IRP_MN_START_DEVICE:
         (VOID) PdoD3ToD0(Pdo);
-
         PdoSetDevicePnpState(Pdo, Started);
         break;
-    }
+
     case IRP_MN_QUERY_STOP_DEVICE:
         PdoSetDevicePnpState(Pdo, StopPending);
         break;
@@ -2620,22 +2608,11 @@ PdoDispatchPnp(
         __PdoRestoreDevicePnpState(Pdo, StopPending);
         break;
 
-    case IRP_MN_STOP_DEVICE: {
-        PXENBUS_UNPLUG_INTERFACE    Unplug;
-
-        Unplug = FdoAcquireUnplug(PdoGetFdo(Pdo));
-        ASSERT(Unplug != NULL);
-
+    case IRP_MN_STOP_DEVICE:
+        PdoD0ToD3(Pdo);
         PdoSetDevicePnpState(Pdo, Stopped);
-
-        XENBUS_UNPLUG(Request,
-                      Unplug,
-                      XENBUS_UNPLUG_DEVICE_TYPE_DISKS,
-                      FALSE);
-        XENBUS_UNPLUG(Release, Unplug);
-
         break;
-    }
+
     case IRP_MN_QUERY_REMOVE_DEVICE:
         PdoSetDevicePnpState(Pdo, RemovePending);
         break;
@@ -2649,22 +2626,10 @@ PdoDispatchPnp(
         PdoSetDevicePnpState(Pdo, SurpriseRemovePending);
         break;
 
-    case IRP_MN_REMOVE_DEVICE: {
-        PXENBUS_UNPLUG_INTERFACE    Unplug;
-
-        Unplug = FdoAcquireUnplug(PdoGetFdo(Pdo));
-        ASSERT(Unplug != NULL);
-
+    case IRP_MN_REMOVE_DEVICE:
         __PdoRemoveDevice(Pdo);
-
-        XENBUS_UNPLUG(Request,
-                      Unplug,
-                      XENBUS_UNPLUG_DEVICE_TYPE_DISKS,
-                      FALSE);
-        XENBUS_UNPLUG(Release, Unplug);
-
         break;
-    }
+
     case IRP_MN_EJECT:
         __PdoEject(Pdo);
         break;
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

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