From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyIdz-0006u9-Ep for qemu-devel@nongnu.org; Fri, 29 May 2015 07:40:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyIdy-0007EX-LN for qemu-devel@nongnu.org; Fri, 29 May 2015 07:40:07 -0400 Message-ID: <55685008.3060004@redhat.com> Date: Fri, 29 May 2015 13:39:52 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1432896805-23867-1-git-send-email-famz@redhat.com> <1432896805-23867-4-git-send-email-famz@redhat.com> In-Reply-To: <1432896805-23867-4-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH 03/12] blockdev: Lock BDS during internal snapshot transaction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , fam@euphon.net, Jeff Cody , qemu-block@nongnu.org, Stefan Hajnoczi On 29/05/2015 12:53, Fam Zheng wrote: > 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; No need for 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); > + } ... you can use state->bs != NULL here. Paolo > if (state->aio_context) { > aio_context_release(state->aio_context); > } >