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

[win-pv-devel] [PATCH v2 2/4] Fail SRBs if ring is not Enabled


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Wed, 18 Sep 2019 14:25:15 +0100
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=owen.smith@xxxxxxxxxx; spf=Pass smtp.mailfrom=owen.smith@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Wed, 18 Sep 2019 13:26:08 +0000
  • Ironport-sdr: 6WqsW8XLH5FozRdSbzHLl2vZAKwYe4lAsXPNGBU+Lia5BIaNpLs2b98QqobchQ1wcW4oRfiuTR yxjDKfp1BZUNsgwY+4t08nl+i8k9AlW7S5bzd5MvfmF4+bDmU9i8sHv8fuSXDXDR/yX4YGc7n6 S3cMwhPbOTndBi13OL06Q8qkoWyyum30X61xrz8d14ZtPuAQPTyNo09YsOwb3Tiz5dnzIHB4qr NDN1juFj15UodOE/db+Dd9AIlYn5bk1B8klnSXlavc2EzM7rI1Gma9dcOdNyqStRRUuuvg+tHi nk4=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

Dont queue incomming SRBs if the ring is not able to process requests.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenvbd/adapter.c |  6 ++----
 src/xenvbd/ring.c    | 34 +++++++++++++++++++++++++++-------
 src/xenvbd/ring.h    |  2 +-
 src/xenvbd/target.c  |  8 ++++----
 src/xenvbd/target.h  |  4 ++--
 5 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/src/xenvbd/adapter.c b/src/xenvbd/adapter.c
index 79a5a0e..2d8d65f 100644
--- a/src/xenvbd/adapter.c
+++ b/src/xenvbd/adapter.c
@@ -1993,13 +1993,11 @@ AdapterHwStartIo(
         break;
 
     case SRB_FUNCTION_FLUSH:
-        TargetFlush(Target, SrbExt);
-        WasQueued = TRUE;
+        WasQueued = TargetFlush(Target, SrbExt);
         break;
 
     case SRB_FUNCTION_SHUTDOWN:
-        TargetShutdown(Target, SrbExt);
-        WasQueued = TRUE;
+        WasQueued = TargetShutdown(Target, SrbExt);
         break;
 
     default:
diff --git a/src/xenvbd/ring.c b/src/xenvbd/ring.c
index 514374c..6edee5c 100644
--- a/src/xenvbd/ring.c
+++ b/src/xenvbd/ring.c
@@ -2147,7 +2147,7 @@ BlkifRingDisconnect(
     Trace("<==== %u\n", BlkifRing->Index);
 }
 
-static VOID
+static BOOLEAN
 __BlkifRingQueueSrb(
     IN  PXENVBD_BLKIF_RING  BlkifRing,
     IN  PXENVBD_SRBEXT      SrbExt
@@ -2158,6 +2158,9 @@ __BlkifRingQueueSrb(
     ULONG_PTR               LockBit;
     ULONG_PTR               New;
 
+    if (!BlkifRing->Enabled)
+        goto fail1;
+
     ListEntry = &SrbExt->ListEntry;
 
     do {
@@ -2177,17 +2180,36 @@ __BlkifRingQueueSrb(
 
     if (__BlkifRingTryAcquireLock(BlkifRing))
         __BlkifRingReleaseLock(BlkifRing);
+
+    return TRUE;
+
+fail1:
+    Error("fail1\n");
+
+    SrbExt->Srb->SrbStatus = SRB_STATUS_BUSY;
+    return FALSE;
 }
 
-static VOID
+static BOOLEAN
 __BlkifRingQueueShutdown(
     IN  PXENVBD_BLKIF_RING  BlkifRing,
     IN  PXENVBD_SRBEXT      SrbExt
     )
 {
+    if (!BlkifRing->Enabled)
+        goto fail1;
+
     __BlkifRingAcquireLock(BlkifRing);
     InsertTailList(&BlkifRing->ShutdownQueue, &SrbExt->ListEntry);
     __BlkifRingReleaseLock(BlkifRing);
+
+    return TRUE;
+
+fail1:
+    Error("fail1\n");
+
+    SrbExt->Srb->SrbStatus = SRB_STATUS_BUSY;
+    return FALSE;
 }
 
 static DECLSPEC_NOINLINE VOID
@@ -2616,12 +2638,10 @@ RingQueueRequest(
     BlkifRing = __RingGetBlkifRing(Ring, Srb->QueueTag);
     ASSERT(BlkifRing != NULL);
 
-    __BlkifRingQueueSrb(BlkifRing, SrbExt);
-
-    return TRUE;
+    return __BlkifRingQueueSrb(BlkifRing, SrbExt);
 }
 
-VOID
+BOOLEAN
 RingQueueShutdown(
     IN  PXENVBD_RING    Ring,
     IN  PXENVBD_SRBEXT  SrbExt
@@ -2633,5 +2653,5 @@ RingQueueShutdown(
     BlkifRing = __RingGetBlkifRing(Ring, Srb->QueueTag);
     ASSERT(BlkifRing != NULL);
 
-    __BlkifRingQueueShutdown(BlkifRing, SrbExt);
+    return __BlkifRingQueueShutdown(BlkifRing, SrbExt);
 }
diff --git a/src/xenvbd/ring.h b/src/xenvbd/ring.h
index e3309e2..81c2644 100644
--- a/src/xenvbd/ring.h
+++ b/src/xenvbd/ring.h
@@ -80,7 +80,7 @@ RingQueueRequest(
     IN  PXENVBD_SRBEXT  SrbExt
     );
 
-extern VOID
+extern BOOLEAN
 RingQueueShutdown(
     IN  PXENVBD_RING    Ring,
     IN  PXENVBD_SRBEXT  SrbExt
diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index 176cbbe..e322949 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -973,22 +973,22 @@ TargetReset(
     Verbose("[%u] <=====\n", TargetGetTargetId(Target));
 }
 
-VOID
+BOOLEAN
 TargetFlush(
     IN  PXENVBD_TARGET  Target,
     IN  PXENVBD_SRBEXT  SrbExt
     )
 {
-    RingQueueShutdown(FrontendGetRing(Target->Frontend), SrbExt);
+    return RingQueueShutdown(FrontendGetRing(Target->Frontend), SrbExt);
 }
 
-VOID
+BOOLEAN
 TargetShutdown(
     IN  PXENVBD_TARGET  Target,
     IN  PXENVBD_SRBEXT  SrbExt
     )
 {
-    RingQueueShutdown(FrontendGetRing(Target->Frontend), SrbExt);
+    return RingQueueShutdown(FrontendGetRing(Target->Frontend), SrbExt);
 }
 
 VOID
diff --git a/src/xenvbd/target.h b/src/xenvbd/target.h
index dd360f5..cbd0ba4 100644
--- a/src/xenvbd/target.h
+++ b/src/xenvbd/target.h
@@ -110,13 +110,13 @@ TargetReset(
     IN  PXENVBD_TARGET  Target
     );
 
-extern VOID
+extern BOOLEAN
 TargetFlush(
     IN  PXENVBD_TARGET  Target,
     IN  PXENVBD_SRBEXT  SrbExt
     );
 
-extern VOID
+extern BOOLEAN
 TargetShutdown(
     IN  PXENVBD_TARGET  Target,
     IN  PXENVBD_SRBEXT  SrbExt
-- 
2.16.2.windows.1


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

 


Rackspace

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