[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 01/55] dma-helpers: ensure AIO callback is invoked after cancella
From: |
Michael Roth |
Subject: |
[PATCH 01/55] dma-helpers: ensure AIO callback is invoked after cancellation |
Date: |
Tue, 5 Nov 2019 14:51:49 -0600 |
From: Paolo Bonzini <address@hidden>
dma_aio_cancel unschedules the BH if there is one, which corresponds
to the reschedule_dma case of dma_blk_cb. This can stall the DMA
permanently, because dma_complete will never get invoked and therefore
nobody will ever invoke the original AIO callback in dbs->common.cb.
Fix this by invoking the callback (which is ensured to happen after
a bdrv_aio_cancel_async, or done manually in the dbs->bh case), and
add assertions to check that the DMA state machine is indeed waiting
for dma_complete or reschedule_dma, but never both.
Reported-by: John Snow <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Message-id: address@hidden
Signed-off-by: John Snow <address@hidden>
(cherry picked from commit 539343c0a47e19d5dd64d846d64d084d9793681f)
Signed-off-by: Michael Roth <address@hidden>
---
dma-helpers.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/dma-helpers.c b/dma-helpers.c
index 2d7e02d35e..d3871dc61e 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -90,6 +90,7 @@ static void reschedule_dma(void *opaque)
{
DMAAIOCB *dbs = (DMAAIOCB *)opaque;
+ assert(!dbs->acb && dbs->bh);
qemu_bh_delete(dbs->bh);
dbs->bh = NULL;
dma_blk_cb(dbs, 0);
@@ -111,15 +112,12 @@ static void dma_complete(DMAAIOCB *dbs, int ret)
{
trace_dma_complete(dbs, ret, dbs->common.cb);
+ assert(!dbs->acb && !dbs->bh);
dma_blk_unmap(dbs);
if (dbs->common.cb) {
dbs->common.cb(dbs->common.opaque, ret);
}
qemu_iovec_destroy(&dbs->iov);
- if (dbs->bh) {
- qemu_bh_delete(dbs->bh);
- dbs->bh = NULL;
- }
qemu_aio_unref(dbs);
}
@@ -179,14 +177,21 @@ static void dma_aio_cancel(BlockAIOCB *acb)
trace_dma_aio_cancel(dbs);
+ assert(!(dbs->acb && dbs->bh));
if (dbs->acb) {
+ /* This will invoke dma_blk_cb. */
blk_aio_cancel_async(dbs->acb);
+ return;
}
+
if (dbs->bh) {
cpu_unregister_map_client(dbs->bh);
qemu_bh_delete(dbs->bh);
dbs->bh = NULL;
}
+ if (dbs->common.cb) {
+ dbs->common.cb(dbs->common.opaque, -ECANCELED);
+ }
}
static AioContext *dma_get_aio_context(BlockAIOCB *acb)
--
2.17.1
- [PATCH 00/55] Patch Round-up for stable 4.1.1, freeze on 2019-11-12, Michael Roth, 2019/11/05
- [PATCH 12/55] vpc: Return 0 from vpc_co_create() on success, Michael Roth, 2019/11/05
- [PATCH 11/55] x86: do not advertise die-id in query-hotpluggbale-cpus if '-smp dies' is not set, Michael Roth, 2019/11/05
- [PATCH 09/55] iotests: Test reverse sub-cluster qcow2 writes, Michael Roth, 2019/11/05
- [PATCH 14/55] iotests: Add supported protocols to execute_test(), Michael Roth, 2019/11/05
- [PATCH 18/55] target/arm: Free TCG temps in trans_VMOV_64_sp(), Michael Roth, 2019/11/05
- [PATCH 19/55] target/arm: Don't abort on M-profile exception return in linux-user mode, Michael Roth, 2019/11/05
- [PATCH 16/55] iotests: Restrict nbd Python tests to nbd, Michael Roth, 2019/11/05
- [PATCH 01/55] dma-helpers: ensure AIO callback is invoked after cancellation,
Michael Roth <=
- [PATCH 23/55] curl: Keep pointer to the CURLState in CURLSocket, Michael Roth, 2019/11/05
- [PATCH 20/55] libvhost-user: fix SLAVE_SEND_FD handling, Michael Roth, 2019/11/05
- [PATCH 24/55] curl: Keep *socket until the end of curl_sock_cb(), Michael Roth, 2019/11/05
- [PATCH 15/55] iotests: Restrict file Python tests to file, Michael Roth, 2019/11/05
- [PATCH 17/55] iotests: Test blockdev-create for vpc, Michael Roth, 2019/11/05
- [PATCH 26/55] curl: Pass CURLSocket to curl_multi_do(), Michael Roth, 2019/11/05
- [PATCH 28/55] curl: Handle success in multi_check_completion, Michael Roth, 2019/11/05
- [PATCH 32/55] qcow2: Fix corruption bug in qcow2_detect_metadata_preallocation(), Michael Roth, 2019/11/05
- [PATCH 36/55] make-release: pull in edk2 submodules so we can build it from tarballs, Michael Roth, 2019/11/05
- [PATCH 27/55] curl: Report only ready sockets, Michael Roth, 2019/11/05