On 12/06/2017 08:45 AM, Stefan Hajnoczi wrote: > bdrv_unref() requires the AioContext lock because bdrv_flush() uses > BDRV_POLL_WHILE(), which assumes the AioContext is currently held. If > BDRV_POLL_WHILE() runs without AioContext held the > pthread_mutex_unlock() call in aio_context_release() fails. > > This patch moves bdrv_unref() into the AioContext locked region to solve > the following pthread_mutex_unlock() failure: > > diff --git a/blockdev.c b/blockdev.c > index 56a6b24a0b..3c8d994ced 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1812,8 +1812,8 @@ static void external_snapshot_clean(BlkActionState *common) > DO_UPCAST(ExternalSnapshotState, common, common); > if (state->aio_context) { > bdrv_drained_end(state->old_bs); > - aio_context_release(state->aio_context); > bdrv_unref(state->new_bs); > + aio_context_release(state->aio_context); Reviewed-by: Eric Blake -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org