]> git.proxmox.com Git - mirror_qemu.git/commitdiff
9pfs: fix multiple flush for same request
authorGreg Kurz <groug@kaod.org>
Tue, 4 Apr 2017 16:06:01 +0000 (18:06 +0200)
committerGreg Kurz <groug@kaod.org>
Tue, 4 Apr 2017 16:06:01 +0000 (18:06 +0200)
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.

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
hw/9pfs/9p.c

index 48babce836b640fddccaa74e19f830c85b6b9139..ef47a0a5ad6f64f5f08f85b6cb131ccbe3971b0a 100644 (file)
@@ -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);
 }