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

[win-pv-devel] [PATCH] Fix race setting SrbStatus



SrbStatus needs to be set to PENDING right at the beginning of the
prepare functions, before the SRB has been added to any queue, otherwise
we risk a race with the completion code.

Reported-by: Andreas Kinzler <ml-ak@xxxxxxxxx>
Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenvbd/pdo.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/xenvbd/pdo.c b/src/xenvbd/pdo.c
index ee2a3cc..3ce48cc 100644
--- a/src/xenvbd/pdo.c
+++ b/src/xenvbd/pdo.c
@@ -1171,6 +1171,8 @@ PrepareReadWrite(
     XENVBD_SG_LIST  SGList;
     ULONG           DebugCount;
 
+    Srb->SrbStatus = SRB_STATUS_PENDING;
+
     InitializeListHead(&List);
     SrbExt->Count = 0;
 
@@ -1213,7 +1215,6 @@ PrepareReadWrite(
     if (DebugCount != (ULONG)SrbExt->Count) {
         Trace("[%u] %d != %u\n", PdoGetTargetId(Pdo), SrbExt->Count, 
DebugCount);
     }
-    Srb->SrbStatus = SRB_STATUS_PENDING;
     return TRUE;
 
 fail3:
@@ -1237,6 +1238,8 @@ PrepareSyncCache(
     LIST_ENTRY          List;
     UCHAR               Operation;
     ULONG               DebugCount;
+
+    Srb->SrbStatus = SRB_STATUS_PENDING;
     
     if (FrontendGetDiskInfo(Pdo->Frontend)->FlushCache)
         Operation = BLKIF_OP_FLUSH_DISKCACHE;
@@ -1260,7 +1263,6 @@ PrepareSyncCache(
     if (DebugCount != (ULONG)SrbExt->Count) {
         Trace("[%u] %d != %u\n", PdoGetTargetId(Pdo), SrbExt->Count, 
DebugCount);
     }
-    Srb->SrbStatus = SRB_STATUS_PENDING;
     return TRUE;
 
 fail1:
@@ -1284,6 +1286,8 @@ PrepareUnmap(
     LIST_ENTRY          List;
     ULONG               DebugCount;
 
+    Srb->SrbStatus = SRB_STATUS_PENDING;
+
     InitializeListHead(&List);
     SrbExt->Count = 0;
 
@@ -1308,7 +1312,6 @@ PrepareUnmap(
     if (DebugCount != (ULONG)SrbExt->Count) {
         Trace("[%u] %d != %u\n", PdoGetTargetId(Pdo), SrbExt->Count, 
DebugCount);
     }
-    Srb->SrbStatus = SRB_STATUS_PENDING;
     return TRUE;
 
 fail1:
-- 
2.5.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®.