]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/commitdiff
Attempt to process responses on the ring
authorOwen Smith <owen.smith@citrix.com>
Thu, 19 Sep 2019 08:44:15 +0000 (09:44 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Thu, 19 Sep 2019 08:44:15 +0000 (09:44 +0100)
When Disabling the ring, outstanding responses need to be completed.
Poll the ring to complete outstanding responses if the backend is still
connected and valid.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
src/xenvbd/ring.c

index 8dcdee38cc819c2d03b65d6ef15e0957b6db8961..4bb7475ddc3ad09c0b3957ec682fc69c0ca2bf2c 100644 (file)
@@ -2044,11 +2044,57 @@ BlkifRingDisable(
     IN  PXENVBD_BLKIF_RING  BlkifRing
     )
 {
+    PXENVBD_RING            Ring;
+    PCHAR                   Buffer;
+    XenbusState             State;
+    NTSTATUS                status;
+
+    Ring = BlkifRing->Ring;
+
     Trace("====> %u\n", BlkifRing->Index);
 
     __BlkifRingAcquireLock(BlkifRing);
     ASSERT(BlkifRing->Enabled);
 
+    status = XENBUS_STORE(Read,
+                          &Ring->StoreInterface,
+                          NULL,
+                          FrontendGetBackendPath(Ring->Frontend),
+                          "state",
+                          &Buffer);
+    if (!NT_SUCCESS(status)) {
+        State = XenbusStateUnknown;
+    } else {
+        State = (XenbusState) strtol(Buffer, NULL, 10);
+
+        XENBUS_STORE(Free,
+                     &Ring->StoreInterface,
+                     Buffer);
+    }
+
+    if (State == XenbusStateConnected) {
+        ULONG               Attempt;
+
+        Attempt = 0;
+        ASSERT3U(BlkifRing->RequestsPushed, ==, BlkifRing->RequestsPosted);
+        while (BlkifRing->ResponsesProcessed != BlkifRing->RequestsPushed) {
+            Attempt++;
+            if (Attempt > 100)
+                break;
+
+            // Try to move things along
+            __BlkifRingSend(BlkifRing);
+            (VOID) BlkifRingPoll(BlkifRing);
+
+            // We are waiting for a watch event at DISPATCH_LEVEL so
+            // it is our responsibility to poll the store ring.
+            XENBUS_STORE(Poll,
+                         &Ring->StoreInterface);
+
+            KeStallExecutionProcessor(1000);    // 1ms
+        }
+    }
+
     BlkifRing->Enabled = FALSE;
 
     while (!IsListEmpty(&BlkifRing->SubmittedList)) {