From nobody Sun Oct 5 19:25:52 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504127774894173.98951904251226; Wed, 30 Aug 2017 14:16:14 -0700 (PDT) Received: from localhost ([::1]:52746 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnALM-0004QH-QK for importer@patchew.org; Wed, 30 Aug 2017 17:16:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnAC0-00049Y-Q1 for qemu-devel@nongnu.org; Wed, 30 Aug 2017 17:06:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnABz-0007jz-QH for qemu-devel@nongnu.org; Wed, 30 Aug 2017 17:06:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35026) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dnABw-0007ij-NQ; Wed, 30 Aug 2017 17:06:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BABA87EBD6; Wed, 30 Aug 2017 21:06:27 +0000 (UTC) Received: from red.redhat.com (ovpn-122-186.rdu2.redhat.com [10.10.122.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA1279816B; Wed, 30 Aug 2017 21:06:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BABA87EBD6 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=eblake@redhat.com From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 30 Aug 2017 16:05:39 -0500 Message-Id: <20170830210542.2153-16-eblake@redhat.com> In-Reply-To: <20170830210542.2153-1-eblake@redhat.com> References: <20170830210542.2153-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 30 Aug 2017 21:06:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v6 15/18] qcow2: Switch load_bitmap_data() to byte-based iteration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, jsnow@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now that we have adjusted the majority of the calls this function makes to be byte-based, it is easier to read the code if it makes passes over the image using bytes rather than sectors. Signed-off-by: Eric Blake Reviewed-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- v5: no change v4: new patch --- block/qcow2-bitmap.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index c7c60dfca2..b807298484 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -291,9 +291,8 @@ static int load_bitmap_data(BlockDriverState *bs, { int ret =3D 0; BDRVQcow2State *s =3D bs->opaque; - uint64_t sector, limit, sbc; + uint64_t offset, limit; uint64_t bm_size =3D bdrv_dirty_bitmap_size(bitmap); - uint64_t bm_sectors =3D DIV_ROUND_UP(bm_size, BDRV_SECTOR_SIZE); uint8_t *buf =3D NULL; uint64_t i, tab_size =3D size_to_clusters(s, @@ -305,32 +304,27 @@ static int load_bitmap_data(BlockDriverState *bs, buf =3D g_malloc(s->cluster_size); limit =3D bytes_covered_by_bitmap_cluster(s, bitmap); - sbc =3D limit >> BDRV_SECTOR_BITS; - for (i =3D 0, sector =3D 0; i < tab_size; ++i, sector +=3D sbc) { - uint64_t count =3D MIN(bm_sectors - sector, sbc); + for (i =3D 0, offset =3D 0; i < tab_size; ++i, offset +=3D limit) { + uint64_t count =3D MIN(bm_size - offset, limit); uint64_t entry =3D bitmap_table[i]; - uint64_t offset =3D entry & BME_TABLE_ENTRY_OFFSET_MASK; + uint64_t data_offset =3D entry & BME_TABLE_ENTRY_OFFSET_MASK; assert(check_table_entry(entry, s->cluster_size) =3D=3D 0); - if (offset =3D=3D 0) { + if (data_offset =3D=3D 0) { if (entry & BME_TABLE_ENTRY_FLAG_ALL_ONES) { - bdrv_dirty_bitmap_deserialize_ones(bitmap, - sector * BDRV_SECTOR_SI= ZE, - count * BDRV_SECTOR_SIZ= E, + bdrv_dirty_bitmap_deserialize_ones(bitmap, offset, count, false); } else { /* No need to deserialize zeros because the dirty bitmap is * already cleared */ } } else { - ret =3D bdrv_pread(bs->file, offset, buf, s->cluster_size); + ret =3D bdrv_pread(bs->file, data_offset, buf, s->cluster_size= ); if (ret < 0) { goto finish; } - bdrv_dirty_bitmap_deserialize_part(bitmap, buf, - sector * BDRV_SECTOR_SIZE, - count * BDRV_SECTOR_SIZE, + bdrv_dirty_bitmap_deserialize_part(bitmap, buf, offset, count, false); } } --=20 2.13.5