From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aY5h9-0002gk-L1 for qemu-devel@nongnu.org; Tue, 23 Feb 2016 00:39:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aY5h5-0005gg-K6 for qemu-devel@nongnu.org; Tue, 23 Feb 2016 00:39:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39419) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aY5h5-0005gb-Ea for qemu-devel@nongnu.org; Tue, 23 Feb 2016 00:39:31 -0500 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 D53B364384 for ; Tue, 23 Feb 2016 05:39:30 +0000 (UTC) Date: Tue, 23 Feb 2016 13:39:26 +0800 From: Fam Zheng Message-ID: <20160223053926.GA23182@ad.usersys.redhat.com> References: <1455894643-16280-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1455894643-16280-1-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH] fixup! block-migration: acquire AioContext as necessary List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, mst@redhat.com On Fri, 02/19 16:10, Paolo Bonzini wrote: > Signed-off-by: Paolo Bonzini > --- > migration/block.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/migration/block.c b/migration/block.c > index 3bfa908..eea4788 100644 > --- a/migration/block.c > +++ b/migration/block.c > @@ -54,6 +54,7 @@ typedef struct BlkMigDevState { > int shared_base; > int64_t total_sectors; > QSIMPLEQ_ENTRY(BlkMigDevState) entry; > + Error *blocker; > > /* Only used by migration thread. Does not need a lock. */ > int bulk_completed; > @@ -68,9 +69,10 @@ typedef struct BlkMigDevState { > /* Protected by block migration lock. */ > int64_t completed_sectors; > > - /* Protected by iothread lock / AioContext. */ > + /* During migration this is protected by iothread lock / AioContext. > + * Allocation and free happen during setup and cleanup respectively. > + */ > BdrvDirtyBitmap *dirty_bitmap; > - Error *blocker; > } BlkMigDevState; > > typedef struct BlkMigBlock { > @@ -339,9 +341,10 @@ static int set_dirty_tracking(void) > int ret; > > QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { > - /* Creating/dropping dirty bitmaps only requires the big QEMU lock. */ > + aio_context_acquire(bdrv_get_aio_context(bmds->bs)); > bmds->dirty_bitmap = bdrv_create_dirty_bitmap(bmds->bs, BLOCK_SIZE, > NULL, NULL); > + aio_context_release(bdrv_get_aio_context(bmds->bs)); > if (!bmds->dirty_bitmap) { > ret = -errno; > goto fail; > @@ -352,7 +355,9 @@ static int set_dirty_tracking(void) > fail: > QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { > if (bmds->dirty_bitmap) { > + aio_context_acquire(bdrv_get_aio_context(bmds->bs)); > bdrv_release_dirty_bitmap(bmds->bs, bmds->dirty_bitmap); > + aio_context_release(bdrv_get_aio_context(bmds->bs)); > } > } > return ret; > @@ -365,8 +370,9 @@ static void unset_dirty_tracking(void) > BlkMigDevState *bmds; > > QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { > - /* Creating/dropping dirty bitmaps only requires the big QEMU lock. */ > + aio_context_acquire(bdrv_get_aio_context(bmds->bs)); > bdrv_release_dirty_bitmap(bmds->bs, bmds->dirty_bitmap); > + aio_context_release(bdrv_get_aio_context(bmds->bs)); > } > } > > -- > 2.5.0 > Reviewed-by: Fam Zheng BTW, could you also explain the blk_mig_lock() question (*) I had? *: https://lists.gnu.org/archive/html/qemu-devel/2016-02/msg03317.html Fam