From nobody Fri Nov 14 05:14:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584563229; cv=none; d=zohomail.com; s=zohoarc; b=Y5DnGYuyQ/m8Z30dyBt0J78oBhJJmjZItpY3dbuxeDgugENMXKtFOuyRAW5x4ZVQVGnHN3R8kqDbbZt+lRKZxV8OO+X/vo+Ay2L8i7xQ+sKao591hTDMuUoyTiOIWdloe4zUcBu/mrFXMmCjfaXqbwqbZxHOougThPBBUD6V6js= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584563229; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JHxH1i/K0GH7hBo2Xl83uRZs9D8rNYlhtL+6rGnwWgY=; b=XG2GXoDZtPAAtehNj8tS9YXRBucirRbH/ccZt1ZuvhM6yHmEiYbp0QYBgVexxHmW1DK231Q4edUD34nNkddp5n9iieS9v1TsmoHmR/2b+KlnMWqywuLQDukv5kU90afqSgG+VLCOu/rlNfI8/o0I8C4EQybP9QU6Wa29jBmcUpk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1584563229587371.6798004417956; Wed, 18 Mar 2020 13:27:09 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-461-0nAtbUzsNM2LAF9Su59MGw-1; Wed, 18 Mar 2020 16:26:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 328A4A0CC9; Wed, 18 Mar 2020 20:25:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 035275DA7C; Wed, 18 Mar 2020 20:25:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AC26687018; Wed, 18 Mar 2020 20:25:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02IKPJvi004722 for ; Wed, 18 Mar 2020 16:25:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5059E60C88; Wed, 18 Mar 2020 20:25:19 +0000 (UTC) Received: from probe.redhat.com (ovpn-112-191.rdu2.redhat.com [10.10.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 741C360BF1; Wed, 18 Mar 2020 20:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584563228; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JHxH1i/K0GH7hBo2Xl83uRZs9D8rNYlhtL+6rGnwWgY=; b=Ne6DAoBXV9jbAKx7aWbOnsMjXRZXGxM9VubJNvpxNcHSuJbAlBNJK2ccbZE9eDLe9LFAjG MFlej5ZP5bLeL0xK1K7HWdGyo/5YtMJKcjRtaI6/5+WKhQW+TpjCJvwBUnW8nWrLkCc8rV ByFJLNN/fBFZp54GSPJEWCMe+Afg/DQ= X-MC-Unique: 0nAtbUzsNM2LAF9Su59MGw-1 From: John Snow To: qemu-devel@nongnu.org, jsnow@redhat.com, Peter Maydell Subject: [PULL v2 11/11] block/qcow2-bitmap: use bdrv_dirty_bitmap_next_dirty Date: Wed, 18 Mar 2020 16:23:41 -0400 Message-Id: <20200318202341.6961-12-jsnow@redhat.com> In-Reply-To: <20200318202341.6961-1-jsnow@redhat.com> References: <20200318202341.6961-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , Fam Zheng , Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org, Juan Quintela , libvir-list@redhat.com, Max Reitz , Stefan Hajnoczi , "Dr. David Alan Gilbert" X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy store_bitmap_data() loop does bdrv_set_dirty_iter() on each iteration, which means that we actually don't need iterator itself and we can use simpler bitmap API. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz Reviewed-by: John Snow Message-id: 20200205112041.6003-11-vsementsov@virtuozzo.com Signed-off-by: John Snow --- block/qcow2-bitmap.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 8cccc2c9f3..cb06954b4a 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1288,7 +1288,6 @@ static uint64_t *store_bitmap_data(BlockDriverState *= bs, uint64_t bm_size =3D bdrv_dirty_bitmap_size(bitmap); const char *bm_name =3D bdrv_dirty_bitmap_name(bitmap); uint8_t *buf =3D NULL; - BdrvDirtyBitmapIter *dbi; uint64_t *tb; uint64_t tb_size =3D size_to_clusters(s, @@ -1307,12 +1306,14 @@ static uint64_t *store_bitmap_data(BlockDriverState= *bs, return NULL; } =20 - dbi =3D bdrv_dirty_iter_new(bitmap); buf =3D g_malloc(s->cluster_size); limit =3D bytes_covered_by_bitmap_cluster(s, bitmap); assert(DIV_ROUND_UP(bm_size, limit) =3D=3D tb_size); =20 - while ((offset =3D bdrv_dirty_iter_next(dbi)) >=3D 0) { + offset =3D 0; + while ((offset =3D bdrv_dirty_bitmap_next_dirty(bitmap, offset, INT64_= MAX)) + >=3D 0) + { uint64_t cluster =3D offset / limit; uint64_t end, write_size; int64_t off; @@ -1355,23 +1356,17 @@ static uint64_t *store_bitmap_data(BlockDriverState= *bs, goto fail; } =20 - if (end >=3D bm_size) { - break; - } - - bdrv_set_dirty_iter(dbi, end); + offset =3D end; } =20 *bitmap_table_size =3D tb_size; g_free(buf); - bdrv_dirty_iter_free(dbi); =20 return tb; =20 fail: clear_bitmap_table(bs, tb, tb_size); g_free(buf); - bdrv_dirty_iter_free(dbi); g_free(tb); =20 return NULL; --=20 2.21.1