Skip to contentSkip to conversation

9pfs: fix multiple flush for same request

PATCH In review Greg Kurz 2 participants 3 messages Mar 30, 2017

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

PATCH 1/1 9pfs: fix multiple flush for same request

If a client tries to flush the same outstanding request several times, only the first flush completes. Subsequent ones keep waiting for the request completion in v9fs_flush() and, therefore, leak a PDU. This will cause QEMU to hang when draining active PDUs the next time the device is reset.

Let have each flush request wake up the next one if any. The last waiter frees the cancelled PDU.

---
 hw/9pfs/9p.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/9pfs/9p.c +4 -2
index 48babce836b6..ef47a0a5ad6f 100644
@@ -2387,8 +2387,10 @@ static void coroutine_fn v9fs_flush(void *opaque)
          * Wait for pdu to complete.
          */
         qemu_co_queue_wait(&cancel_pdu->complete, NULL);
-        cancel_pdu->cancelled = 0;
-        pdu_free(cancel_pdu);
+        if (!qemu_co_queue_next(&cancel_pdu->complete)) {
+            cancel_pdu->cancelled = 0;
+            pdu_free(cancel_pdu);
+        }
     }
     pdu_complete(pdu, 7);
 }
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Greg Kurz

If a client tries to flush the same outstanding request several times, only the first flush completes. Subsequent ones keep waiting for the request completion in v9fs_flush() and, therefore, leak a PDU. This will cause QEMU to hang when draining active PDUs the next time the device is reset.

Since this fixes a hang, is it 2.9 material?

Quoted 9 lines

Let have each flush request wake up the next one if any. The last waiter frees the cancelled PDU.

---
 hw/9pfs/9p.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 20 lines
hw/9pfs/9p.c +4 -2
index 48babce836b6..ef47a0a5ad6f 100644
@@ -2387,8 +2387,10 @@ static void coroutine_fn v9fs_flush(void *opaque)
          * Wait for pdu to complete.
          */
         qemu_co_queue_wait(&cancel_pdu->complete, NULL);
-        cancel_pdu->cancelled = 0;
-        pdu_free(cancel_pdu);
+        if (!qemu_co_queue_next(&cancel_pdu->complete)) {
+            cancel_pdu->cancelled = 0;
+            pdu_free(cancel_pdu);
+        }
     }
     pdu_complete(pdu, 7);
 }
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#2 lore raw
Quoted 8 lines · On Thu, 30 Mar 2017 08:18:34 -0500 Eric Blake <[email protected]> wrote:
Quoted 4 lines · Greg Kurz

If a client tries to flush the same outstanding request several times, only the first flush completes. Subsequent ones keep waiting for the request completion in v9fs_flush() and, therefore, leak a PDU. This will cause QEMU to hang when draining active PDUs the next time the device is reset.

Since this fixes a hang, is it 2.9 material?

Yes, definitely, I just forgot to add the for-2.9 tag :)

Quoted 33 lines
Quoted 9 lines

Let have each flush request wake up the next one if any. The last waiter frees the cancelled PDU.

---
 hw/9pfs/9p.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 20 lines
hw/9pfs/9p.c +4 -2
index 48babce836b6..ef47a0a5ad6f 100644
@@ -2387,8 +2387,10 @@ static void coroutine_fn v9fs_flush(void *opaque)
          * Wait for pdu to complete.
          */
         qemu_co_queue_wait(&cancel_pdu->complete, NULL);
-        cancel_pdu->cancelled = 0;
-        pdu_free(cancel_pdu);
+        if (!qemu_co_queue_next(&cancel_pdu->complete)) {
+            cancel_pdu->cancelled = 0;
+            pdu_free(cancel_pdu);
+        }
     }
     pdu_complete(pdu, 7);
 }