]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/commitdiff
Rework request submission
authorOwen Smith <owen.smith@citrix.com>
Thu, 5 Sep 2019 15:29:04 +0000 (16:29 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Thu, 5 Sep 2019 15:29:31 +0000 (16:29 +0100)
Make BlkifRingPostRequests return success for submitting 0 or more requests,
or failure when the ring is full. This prevents the loop in
BlkifRingSchedule() from preparing the next SRB when the ring is already
full.
Also attempt to notify the backend of changes every iteration of the loop in
BlkifRingSchedule(), to trigger the backend as soon as possible.

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

index 45a885d8ffe7049bf3adf56a4f77f6f46fd157e0..2b3538eb61db45daa784cd90054224ab183d260a 100644 (file)
@@ -1089,28 +1089,21 @@ __BlkifRingPostRequests(
     IN  PXENVBD_BLKIF_RING  BlkifRing
     )
 {
-#define RING_SLOTS_AVAILABLE(_Front, _req_prod, _rsp_cons)   \
-        (RING_SIZE(_Front) - ((_req_prod) - (_rsp_cons)))
-
     PXENVBD_SRB_STATE       State;
-    RING_IDX                req_prod;
-    RING_IDX                rsp_cons;
-    NTSTATUS                status;
 
     State = &BlkifRing->State;
 
-    req_prod = BlkifRing->Front.req_prod_pvt;
-    rsp_cons = BlkifRing->Front.rsp_cons;
-
-    status = STATUS_ALLOTTED_SPACE_EXCEEDED;
-    if (RING_SLOTS_AVAILABLE(&BlkifRing->Front, req_prod, rsp_cons) <= 1)
-        goto fail1;
-
-    while (State->Count != 0) {
+    for (;;) {
         blkif_request_t     *req;
         PXENVBD_REQUEST     Request;
         PLIST_ENTRY         ListEntry;
 
+        if (State->Count == 0)
+            return STATUS_SUCCESS;
+
+        if (RING_FULL(&BlkifRing->Front))
+            return STATUS_ALLOTTED_SPACE_EXCEEDED;
+
         --State->Count;
 
         ListEntry = RemoveHeadList(&State->List);
@@ -1122,8 +1115,8 @@ __BlkifRingPostRequests(
                                     XENVBD_REQUEST,
                                     ListEntry);
 
-        req = RING_GET_REQUEST(&BlkifRing->Front, req_prod);
-        req_prod++;
+        req = RING_GET_REQUEST(&BlkifRing->Front, BlkifRing->Front.req_prod_pvt);
+        BlkifRing->Front.req_prod_pvt++;
         BlkifRing->RequestsPosted++;
 
         __BlkifRingInsertRequest(BlkifRing,
@@ -1131,19 +1124,7 @@ __BlkifRingPostRequests(
                                  req);
 
         InsertTailList(&BlkifRing->SubmittedList, ListEntry);
-
-        if (RING_SLOTS_AVAILABLE(&BlkifRing->Front, req_prod, rsp_cons) <= 1)
-            break;
     }
-
-    BlkifRing->Front.req_prod_pvt = req_prod;
-
-    return STATUS_SUCCESS;
-
-fail1:
-    return status;
-
-#undef  RING_SLOTS_AVAILABLE
 }
 
 static FORCEINLINE PXENVBD_REQUEST
@@ -1424,9 +1405,7 @@ BlkifRingSchedule(
             continue;
         }
 
-        if (BlkifRing->RequestsPosted - BlkifRing->RequestsPushed >=
-            RING_SIZE(&BlkifRing->Front) / 4)
-            __BlkifRingPushRequests(BlkifRing);
+        __BlkifRingPushRequests(BlkifRing);
 
         if (IsListEmpty(&BlkifRing->SrbQueue))
             break;