From patchwork Fri May 29 10:53:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 477795 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 096D1140E6C for ; Fri, 29 May 2015 20:58:22 +1000 (AEST) Received: from localhost ([::1]:35013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyHzY-00057a-7E for incoming@patchwork.ozlabs.org; Fri, 29 May 2015 06:58:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyHv7-00057T-Df for qemu-devel@nongnu.org; Fri, 29 May 2015 06:53:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyHv5-0006vT-TR for qemu-devel@nongnu.org; Fri, 29 May 2015 06:53:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39724) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyHv2-0006ui-Rq; Fri, 29 May 2015 06:53:40 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 6E310BC903; Fri, 29 May 2015 10:53:40 +0000 (UTC) Received: from cpc-pc.redhat.com (vpn1-4-101.sin2.redhat.com [10.67.4.101]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4TArLx6028288; Fri, 29 May 2015 06:53:36 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 29 May 2015 18:53:16 +0800 Message-Id: <1432896805-23867-4-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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , fam@euphon.net, qemu-block@nongnu.org, Jeff Cody , Stefan Hajnoczi , Paolo Bonzini Subject: [Qemu-devel] [RFC PATCH 03/12] blockdev: Lock BDS during internal snapshot transaction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Fam Zheng --- blockdev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/blockdev.c b/blockdev.c index 5eaf77e..46f8d60 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1262,6 +1262,7 @@ typedef struct InternalSnapshotState { BlockDriverState *bs; AioContext *aio_context; QEMUSnapshotInfo sn; + bool needs_unlock; } InternalSnapshotState; static void internal_snapshot_prepare(BlkTransactionState *common, @@ -1356,6 +1357,8 @@ static void internal_snapshot_prepare(BlkTransactionState *common, } /* 4. succeed, mark a snapshot is created */ + bdrv_lock(bs); + state->needs_unlock = true; state->bs = bs; } @@ -1387,6 +1390,9 @@ static void internal_snapshot_clean(BlkTransactionState *common) InternalSnapshotState *state = DO_UPCAST(InternalSnapshotState, common, common); + if (state->needs_unlock) { + bdrv_unlock(state->bs); + } if (state->aio_context) { aio_context_release(state->aio_context); }