From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yzcmc-0002oL-ME for qemu-devel@nongnu.org; Mon, 01 Jun 2015 23:22:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yzcmc-0008BR-0A for qemu-devel@nongnu.org; Mon, 01 Jun 2015 23:22:30 -0400 From: Fam Zheng Date: Tue, 2 Jun 2015 11:21:53 +0800 Message-Id: <1433215322-23529-5-git-send-email-famz@redhat.com> In-Reply-To: <1433215322-23529-1-git-send-email-famz@redhat.com> References: <1433215322-23529-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v2 04/13] 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 , Paolo Bonzini , Jeff Cody , Stefan Hajnoczi , qemu-block@nongnu.org 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 fdc5a17..a8d5b10 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1471,6 +1471,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); @@ -1540,6 +1541,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); } @@ -1551,6 +1553,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.1