diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2021-07-03 00:16:36 +0300 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2021-07-20 13:14:45 +0200 |
commit | d44dae1a7cf782ec9235746ebb0e6c1a20dd7288 (patch) | |
tree | ca473538c698f1375c84a3eb9968f9d0d6eb508e /block/mirror.c | |
parent | e0f69d83d5c5c039b133b60b5a7130dedeeaca42 (diff) | |
download | qemu-d44dae1a7cf782ec9235746ebb0e6c1a20dd7288.zip qemu-d44dae1a7cf782ec9235746ebb0e6c1a20dd7288.tar.gz qemu-d44dae1a7cf782ec9235746ebb0e6c1a20dd7288.tar.bz2 |
block/mirror: fix active mirror dead-lock in mirror_wait_on_conflicts
It's possible that requests start to wait each other in
mirror_wait_on_conflicts(). To avoid it let's use same technique as in
block/io.c in bdrv_wait_serialising_requests_locked() /
bdrv_find_conflicting_request(): don't wait on intersecting request if
it is already waiting for some other request.
For details of the dead-lock look at testIntersectingActiveIO()
test-case which we actually fixing now.
Fixes: d06107ade0ce74dc39739bac80de84b51ec18546
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210702211636.228981-4-vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/mirror.c')
-rw-r--r-- | block/mirror.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/block/mirror.c b/block/mirror.c index ad6aac2..98fc66e 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -107,6 +107,7 @@ struct MirrorOp { bool is_in_flight; CoQueue waiting_requests; Coroutine *co; + MirrorOp *waiting_for_op; QTAILQ_ENTRY(MirrorOp) next; }; @@ -159,7 +160,18 @@ static void coroutine_fn mirror_wait_on_conflicts(MirrorOp *self, if (ranges_overlap(self_start_chunk, self_nb_chunks, op_start_chunk, op_nb_chunks)) { + /* + * If the operation is already (indirectly) waiting for us, or + * will wait for us as soon as it wakes up, then just go on + * (instead of producing a deadlock in the former case). + */ + if (op->waiting_for_op) { + continue; + } + + self->waiting_for_op = op; qemu_co_queue_wait(&op->waiting_requests, NULL); + self->waiting_for_op = NULL; break; } } |