[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 40/41] block: wait_for_overlapping_requests() deadlo
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 40/41] block: wait_for_overlapping_requests() deadlock detection |
Date: |
Mon, 5 Dec 2011 15:21:17 +0100 |
From: Stefan Hajnoczi <address@hidden>
Debugging a reentrant request deadlock was fun but in the future we need
a quick and obvious way of detecting such bugs. Add an assert that
checks we are not about to deadlock when waiting for another request.
Suggested-by: Kevin Wolf <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/block.c b/block.c
index ecc5b44..50ce2be 100644
--- a/block.c
+++ b/block.c
@@ -1099,6 +1099,7 @@ struct BdrvTrackedRequest {
int nb_sectors;
bool is_write;
QLIST_ENTRY(BdrvTrackedRequest) list;
+ Coroutine *co; /* owner, used for deadlock detection */
CoQueue wait_queue; /* coroutines blocked on this request */
};
@@ -1126,6 +1127,7 @@ static void tracked_request_begin(BdrvTrackedRequest *req,
.sector_num = sector_num,
.nb_sectors = nb_sectors,
.is_write = is_write,
+ .co = qemu_coroutine_self(),
};
qemu_co_queue_init(&req->wait_queue);
@@ -1189,6 +1191,12 @@ static void coroutine_fn
wait_for_overlapping_requests(BlockDriverState *bs,
QLIST_FOREACH(req, &bs->tracked_requests, list) {
if (tracked_request_overlaps(req, cluster_sector_num,
cluster_nb_sectors)) {
+ /* Hitting this means there was a reentrant request, for
+ * example, a block driver issuing nested requests. This must
+ * never happen since it means deadlock.
+ */
+ assert(qemu_coroutine_self() != req->co);
+
qemu_co_queue_wait(&req->wait_queue);
retry = true;
break;
--
1.7.6.4
- [Qemu-devel] [PATCH 29/41] qemu-common: add QEMU_ALIGN_DOWN() and QEMU_ALIGN_UP() macros, (continued)
- [Qemu-devel] [PATCH 29/41] qemu-common: add QEMU_ALIGN_DOWN() and QEMU_ALIGN_UP() macros, Kevin Wolf, 2011/12/05
- [Qemu-devel] [PATCH 31/41] block: add request tracking, Kevin Wolf, 2011/12/05
- [Qemu-devel] [PATCH 30/41] coroutine: add qemu_co_queue_restart_all(), Kevin Wolf, 2011/12/05
- [Qemu-devel] [PATCH 28/41] block: add bdrv_co_is_allocated() interface, Kevin Wolf, 2011/12/05
- [Qemu-devel] [PATCH 32/41] block: add interface to toggle copy-on-read, Kevin Wolf, 2011/12/05
- [Qemu-devel] [PATCH 39/41] block: implement bdrv_co_is_allocated() boundary cases, Kevin Wolf, 2011/12/05
- [Qemu-devel] [PATCH 37/41] cow: use bdrv_co_is_allocated(), Kevin Wolf, 2011/12/05
- [Qemu-devel] [PATCH 35/41] block: core copy-on-read logic, Kevin Wolf, 2011/12/05
- [Qemu-devel] [PATCH 36/41] block: add -drive copy-on-read=on|off, Kevin Wolf, 2011/12/05
- [Qemu-devel] [PATCH 34/41] block: request overlap detection, Kevin Wolf, 2011/12/05
- [Qemu-devel] [PATCH 40/41] block: wait_for_overlapping_requests() deadlock detection,
Kevin Wolf <=
- [Qemu-devel] [PATCH 41/41] block: convert qemu_aio_flush() calls to bdrv_drain_all(), Kevin Wolf, 2011/12/05
- [Qemu-devel] [PATCH 33/41] block: wait for overlapping requests, Kevin Wolf, 2011/12/05
- [Qemu-devel] [PATCH 38/41] dma-helpers: Add trace events, Kevin Wolf, 2011/12/05