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

[PATCH] Don't prematurely fake transmit responses



From: Paul Durrant <pdurrant@xxxxxxxxxx>

If the device is being ejected then the backend state will transition from
XenbusStateConnected to XenbusStateClosing. This is done by the toolstack
and should have no effect on the backend's ability to complete requests.
Therefore, when we fake responses in __TransmitterRingDisable() we could
be racing with an active backend. Hence amend the test in the loop to
consider a backend in either XenbusStateConnected or XenbusStateClosing to
be worth waiting for.

Signed-off-by: Paul Durrant <pdurrant@xxxxxxxxxx>
---
 src/xenvif/transmitter.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/xenvif/transmitter.c b/src/xenvif/transmitter.c
index fefa712b281b..9736d8119f8d 100644
--- a/src/xenvif/transmitter.c
+++ b/src/xenvif/transmitter.c
@@ -3933,6 +3933,7 @@ __TransmitterRingDisable(
     PCHAR                           Buffer;
     XenbusState                     State;
     ULONG                           Attempt;
+    BOOLEAN                         WaitForBackend;
     NTSTATUS                        status;
 
     Transmitter = Ring->Transmitter;
@@ -3985,6 +3986,13 @@ __TransmitterRingDisable(
                      Buffer);
     }
 
+    //
+    // If the we are disabling during an eject then the backend will still be
+    // be there, but it will be in XenbusStateClosing state, not
+    // XenbusStateConnected.
+    //
+    WaitForBackend = (State == XenbusStateConnected) || (State == 
XenbusStateClosing);
+
     Attempt = 0;
     ASSERT3U(Ring->RequestsPushed, ==, Ring->RequestsPosted);
     while (Ring->ResponsesProcessed != Ring->RequestsPushed) {
@@ -3996,7 +4004,7 @@ __TransmitterRingDisable(
         __TransmitterRingSend(Ring);
         (VOID) TransmitterRingPoll(Ring);
 
-        if ((Attempt >= 100) || (State != XenbusStateConnected))
+        if ((Attempt >= 100) || !WaitForBackend)
             break;
 
         // We are waiting for a watch event at DISPATCH_LEVEL so
-- 
2.25.1




 


Rackspace

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