From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zox2i-0000y3-6j for qemu-devel@nongnu.org; Wed, 21 Oct 2015 13:19:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zox2h-00033w-9o for qemu-devel@nongnu.org; Wed, 21 Oct 2015 13:19:16 -0400 Date: Wed, 21 Oct 2015 13:18:46 -0400 From: Jeff Cody Message-ID: <20151021171846.GE6466@localhost.localdomain> References: <1445393209-26545-1-git-send-email-famz@redhat.com> <1445393209-26545-7-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1445393209-26545-7-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v5 06/12] block: Add "drained begin/end" for transactional external snapshot List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com On Wed, Oct 21, 2015 at 10:06:43AM +0800, Fam Zheng wrote: > This ensures the atomicity of the transaction by avoiding processing of > external requests such as those from ioeventfd. > > Signed-off-by: Fam Zheng > --- > blockdev.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/blockdev.c b/blockdev.c > index 35e5719..e4a5eb4 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1569,6 +1569,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_drained_begin(state->old_bs); > > if (!bdrv_is_inserted(state->old_bs)) { > error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); > @@ -1638,8 +1639,6 @@ static void external_snapshot_commit(BlkTransactionState *common) > * don't want to abort all of them if one of them fails the reopen */ > bdrv_reopen(state->old_bs, state->old_bs->open_flags & ~BDRV_O_RDWR, > NULL); > - > - aio_context_release(state->aio_context); > } > > static void external_snapshot_abort(BlkTransactionState *common) > @@ -1649,7 +1648,14 @@ static void external_snapshot_abort(BlkTransactionState *common) > if (state->new_bs) { > bdrv_unref(state->new_bs); > } > +} > + > +static void external_snapshot_clean(BlkTransactionState *common) > +{ > + ExternalSnapshotState *state = > + DO_UPCAST(ExternalSnapshotState, common, common); > if (state->aio_context) { > + bdrv_drained_end(state->old_bs); > aio_context_release(state->aio_context); > } > } > @@ -1809,6 +1815,7 @@ static const BdrvActionOps actions[] = { > .prepare = external_snapshot_prepare, > .commit = external_snapshot_commit, > .abort = external_snapshot_abort, > + .clean = external_snapshot_clean, > }, > [TRANSACTION_ACTION_KIND_DRIVE_BACKUP] = { > .instance_size = sizeof(DriveBackupState), > -- > 2.4.3 > > Reviewed-by: Jeff Cody