From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyHvE-0005BV-1l for qemu-devel@nongnu.org; Fri, 29 May 2015 06:53:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyHvD-0006wg-0w for qemu-devel@nongnu.org; Fri, 29 May 2015 06:53:51 -0400 From: Fam Zheng Date: Fri, 29 May 2015 18:53:17 +0800 Message-Id: <1432896805-23867-5-git-send-email-famz@redhat.com> In-Reply-To: <1432896805-23867-1-git-send-email-famz@redhat.com> References: <1432896805-23867-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [RFC PATCH 04/12] blockdev: Lock BDS during external snapshot transaction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , fam@euphon.net, qemu-block@nongnu.org, Jeff Cody , Stefan Hajnoczi , Paolo Bonzini Lock immediately follows aio_context_acquire, so unlock right before the corresponding aio_context_release. Signed-off-by: Fam Zheng --- blockdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/blockdev.c b/blockdev.c index 46f8d60..1c3946a 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1473,6 +1473,7 @@ static void external_snapshot_prepare(BlkTransactionState *common, /* Acquire AioContext now so any threads operating on old_bs stop */ state->aio_context = bdrv_get_aio_context(state->old_bs); aio_context_acquire(state->aio_context); + bdrv_lock(state->old_bs); if (!bdrv_is_inserted(state->old_bs)) { error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); @@ -1542,6 +1543,7 @@ static void external_snapshot_commit(BlkTransactionState *common) bdrv_reopen(state->new_bs, state->new_bs->open_flags & ~BDRV_O_RDWR, NULL); + bdrv_unlock(state->old_bs); aio_context_release(state->aio_context); } @@ -1553,6 +1555,7 @@ static void external_snapshot_abort(BlkTransactionState *common) bdrv_unref(state->new_bs); } if (state->aio_context) { + bdrv_unlock(state->old_bs); aio_context_release(state->aio_context); } } -- 2.4.2