Received: from eggs.gnu.org ([2001:4830:134:3::10]:45556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UuBPo-0000PW-W8 for qemu-devel@nongnu.org; Tue, 02 Jul 2013 20:59:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UuBPm-000595-CP for qemu-devel@nongnu.org; Tue, 02 Jul 2013 20:59:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32577) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UuBPm-00058z-4I for qemu-devel@nongnu.org; Tue, 02 Jul 2013 20:59:22 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r630xKSx004332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 2 Jul 2013 20:59:20 -0400 Date: Wed, 3 Jul 2013 08:59:17 +0800 From: Fam Zheng Message-ID: <20130703005917.GC1949@t430s.nay.redhat.com> References: <1372744789-997-1-git-send-email-famz@redhat.com> <1372744789-997-2-git-send-email-famz@redhat.com> <51D32CDD.8050307@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51D32CDD.8050307@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/7] block: Convert BlockDriverState.in_use to refcount Reply-To: famz@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, obarenbo@redhat.com, armbru@redhat.com, roliveri@redhat.com, hbrock@redhat.com, qemu-devel@nongnu.org, rjones@redhat.com, pmyers@redhat.com, imain@redhat.com, stefanha@redhat.com, pbonzini@redhat.com On Tue, 07/02 13:41, Eric Blake wrote: > On 07/01/2013 11:59 PM, Fam Zheng wrote: > > Use numeric value to replace in_use flag in BDS, this will make > > lifecycle management with ref count possible. This patch only replaces > > existing uses of bdrv_set_in_use, so no logic change here. > > > > Signed-off-by: Fam Zheng > > --- > > block-migration.c | 4 ++-- > > block.c | 23 +++++++++++++++-------- > > blockjob.c | 6 +++--- > > hw/block/dataplane/virtio-blk.c | 4 ++-- > > include/block/block.h | 3 ++- > > include/block/block_int.h | 2 +- > > 6 files changed, 25 insertions(+), 17 deletions(-) > > > > diff --git a/block-migration.c b/block-migration.c > > index 2fd7699..2efb6c0 100644 > > --- a/block-migration.c > > +++ b/block-migration.c > > @@ -321,7 +321,7 @@ static void init_blk_migration_it(void *opaque, BlockDriverState *bs) > > bmds->shared_base = block_mig_state.shared_base; > > alloc_aio_bitmap(bmds); > > drive_get_ref(drive_get_by_blockdev(bs)); > > - bdrv_set_in_use(bs, 1); > > + bdrv_get_ref(bs); > > The old code sets the flag, the new code gets a ref. > > > > > block_mig_state.total_sector_sum += sectors; > > > > @@ -557,7 +557,7 @@ static void blk_mig_cleanup(void) > > blk_mig_lock(); > > while ((bmds = QSIMPLEQ_FIRST(&block_mig_state.bmds_list)) != NULL) { > > QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry); > > - bdrv_set_in_use(bmds->bs, 0); > > + bdrv_get_ref(bmds->bs); > > The old code sets the flag, the new code gets a ref. Shouldn't this be > clearing a ref, with bdrv_put_ref? Yes, thanks for pointing out. -- Fam