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

[win-pv-devel] [PATCH 09/26] Move non-queue-srb handling to BuildIo



From: Owen Smith <owen.smith@xxxxxxxxxx>

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenvbd/adapter.c | 45 ++++++++++++++++++++----------------
 src/xenvbd/target.c  | 64 ++++++++++++++++++++++++++++++++--------------------
 2 files changed, 65 insertions(+), 44 deletions(-)

diff --git a/src/xenvbd/adapter.c b/src/xenvbd/adapter.c
index e262fe3..53c858f 100644
--- a/src/xenvbd/adapter.c
+++ b/src/xenvbd/adapter.c
@@ -1638,33 +1638,38 @@ AdapterHwStartIo(
     PXENVBD_SRBEXT          SrbExt = Srb->SrbExtension;
     PXENVBD_TARGET          Target;
 
-    Srb->SrbStatus = SRB_STATUS_INVALID_TARGET_ID;
     Target = AdapterGetTarget(Adapter, Srb->TargetId);
-    if (Target) {
-        switch (Srb->Function) {
-        case SRB_FUNCTION_EXECUTE_SCSI:
-            TargetStartSrb(Target, SrbExt);
-            break;
+    ASSERT(Target != NULL);
+    if (Target == NULL) {
+        Srb->SrbStatus = SRB_STATUS_INVALID_TARGET_ID;
+        goto complete_srb;
+    }
 
-        case SRB_FUNCTION_RESET_DEVICE:
-            TargetReset(Target);
-            Srb->SrbStatus = SRB_STATUS_SUCCESS;
-            break;
+    ASSERT(Srb->SrbStatus == SRB_STATUS_PENDING);
+    switch (Srb->Function) {
+    case SRB_FUNCTION_EXECUTE_SCSI:
+        TargetStartSrb(Target, SrbExt);
+        break;
 
-        case SRB_FUNCTION_FLUSH:
-            TargetFlush(Target, SrbExt);
-            break;
+    case SRB_FUNCTION_RESET_DEVICE:
+        TargetReset(Target);
+        Srb->SrbStatus = SRB_STATUS_SUCCESS;
+        break;
 
-        case SRB_FUNCTION_SHUTDOWN:
-            TargetShutdown(Target, SrbExt);
-            break;
+    case SRB_FUNCTION_FLUSH:
+        TargetFlush(Target, SrbExt);
+        break;
 
-        default:
-            Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
-            break;
-        }
+    case SRB_FUNCTION_SHUTDOWN:
+        TargetShutdown(Target, SrbExt);
+        break;
+
+    default:
+        Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
+        break;
     }
 
+complete_srb:
     if (Srb->SrbStatus != SRB_STATUS_PENDING)
         AdapterCompleteSrb(Adapter, SrbExt);
 
diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index 49dfc09..c8ff531 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -992,19 +992,6 @@ TargetShutdown(
     BlockRingKick(Target->BlockRing);
 }
 
-VOID
-TargetPrepareSrb(
-    IN  PXENVBD_TARGET  Target,
-    IN  PXENVBD_SRBEXT  SrbExt
-    )
-{
-    PSCSI_REQUEST_BLOCK Srb = SrbExt->OriginalReq;
-
-    UNREFERENCED_PARAMETER(Target);
-
-    Srb->SrbStatus = SRB_STATUS_PENDING;
-}
-
 static FORCEINLINE VOID
 TargetQueueSrb(
     IN  PXENVBD_TARGET  Target,
@@ -1371,7 +1358,7 @@ TargetCheckSectors(
 }
 
 VOID
-TargetStartSrb(
+TargetPrepareSrb(
     IN  PXENVBD_TARGET  Target,
     IN  PXENVBD_SRBEXT  SrbExt
     )
@@ -1383,24 +1370,27 @@ TargetStartSrb(
     switch (Operation) {
     case SCSIOP_READ:
     case SCSIOP_WRITE:
-        if (!TargetCheckSectors(Target, SrbExt))
-            Srb->SrbStatus = SRB_STATUS_ERROR;
-        else
-            TargetQueueSrb(Target, SrbExt);
+        Srb->SrbStatus = SRB_STATUS_PENDING;
+        if (TargetCheckSectors(Target, SrbExt))
+            break;
+        // Sectors out of range, fail SRB
+        Srb->SrbStatus = SRB_STATUS_ERROR;
         break;
 
     case SCSIOP_UNMAP:
+        Srb->SrbStatus = SRB_STATUS_PENDING;
         if (Target->FeatureDiscard)
-            TargetQueueSrb(Target, SrbExt);
-        else
-            Srb->SrbStatus = SRB_STATUS_SUCCESS;
+            break;
+        // Discard not supported, just succeed SRB
+        Srb->SrbStatus = SRB_STATUS_SUCCESS;
         break;
 
     case SCSIOP_SYNCHRONIZE_CACHE:
+        Srb->SrbStatus = SRB_STATUS_PENDING;
         if (Target->FeatureBarrier || Target->FeatureFlush)
-            TargetQueueSrb(Target, SrbExt);
-        else
-            Srb->SrbStatus = SRB_STATUS_SUCCESS;
+            break;
+        // Barrier and Flush not supported, just succeed SRB
+        Srb->SrbStatus = SRB_STATUS_SUCCESS;
         break;
 
     case SCSIOP_INQUIRY:
@@ -1440,6 +1430,32 @@ TargetStartSrb(
     }
 }
 
+VOID
+TargetStartSrb(
+    IN  PXENVBD_TARGET  Target,
+    IN  PXENVBD_SRBEXT  SrbExt
+    )
+{
+    PSCSI_REQUEST_BLOCK Srb = SrbExt->OriginalReq;
+    UCHAR               Operation;
+
+    Operation = Cdb_OperationEx(Srb);
+    switch (Operation) {
+    case SCSIOP_READ:
+    case SCSIOP_WRITE:
+    case SCSIOP_UNMAP:
+    case SCSIOP_SYNCHRONIZE_CACHE:
+        ASSERT(Srb->SrbStatus == SRB_STATUS_PENDING);
+        TargetQueueSrb(Target, SrbExt);
+        break;
+
+    default:
+        // BuildIo should complete non-queue-worthy SRBs
+        Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
+        break;
+    }
+}
+
 static VOID
 TargetStoreReadDiskInfo(
     IN  PXENVBD_TARGET  Target
-- 
2.8.3


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://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®.