From nobody Mon Feb 9 05:03:16 2026 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518543686294457.5190401549255; Tue, 13 Feb 2018 09:41:26 -0800 (PST) Received: from localhost ([::1]:56283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elea5-0007Xx-F1 for importer@patchew.org; Tue, 13 Feb 2018 12:41:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele1u-0003AT-Ml for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele1t-0005VG-Oc for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:06 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50790 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ele1r-0005TD-DT; Tue, 13 Feb 2018 12:06:03 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E99AEB6ED; Tue, 13 Feb 2018 17:06:03 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FC8C10073CD; Tue, 13 Feb 2018 17:06:02 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:03 +0100 Message-Id: <20180213170529.10858-30-kwolf@redhat.com> In-Reply-To: <20180213170529.10858-1-kwolf@redhat.com> References: <20180213170529.10858-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 13 Feb 2018 17:06:03 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 29/55] qcow2: Add l2_slice_size field to BDRVQcow2State 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, qemu-devel@nongnu.org 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" From: Alberto Garcia The BDRVQcow2State structure contains an l2_size field, which stores the number of 64-bit entries in an L2 table. For efficiency reasons we want to be able to load slices instead of full L2 tables, so we need to know how many entries an L2 slice can hold. An L2 slice is the portion of an L2 table that is loaded by the qcow2 cache. At the moment that cache can only load complete tables, therefore an L2 slice has the same size as an L2 table (one cluster) and l2_size =3D=3D l2_slice_size. Later we'll allow smaller slices, but until then we have to use this new l2_slice_size field to make the rest of the code ready for that. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: adb048595f9fb5dfb110c802a8b3c3be3b937f37.1517840877.git.berto@i= galia.com Signed-off-by: Max Reitz --- block/qcow2.h | 1 + block/qcow2.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/block/qcow2.h b/block/qcow2.h index d9ba57c030..45fb7f4299 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -251,6 +251,7 @@ typedef struct BDRVQcow2State { int cluster_bits; int cluster_size; int cluster_sectors; + int l2_slice_size; int l2_bits; int l2_size; int l1_size; diff --git a/block/qcow2.c b/block/qcow2.c index 461cc7ab1c..ba8d71c72d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -807,6 +807,7 @@ static void read_cache_sizes(BlockDriverState *bs, Qemu= Opts *opts, typedef struct Qcow2ReopenState { Qcow2Cache *l2_table_cache; Qcow2Cache *refcount_block_cache; + int l2_slice_size; /* Number of entries in a slice of the L2 table */ bool use_lazy_refcounts; int overlap_check; bool discard_passthrough[QCOW2_DISCARD_MAX]; @@ -888,6 +889,7 @@ static int qcow2_update_options_prepare(BlockDriverStat= e *bs, } } =20 + r->l2_slice_size =3D s->cluster_size / sizeof(uint64_t); r->l2_table_cache =3D qcow2_cache_create(bs, l2_cache_size); r->refcount_block_cache =3D qcow2_cache_create(bs, refcount_cache_size= ); if (r->l2_table_cache =3D=3D NULL || r->refcount_block_cache =3D=3D NU= LL) { @@ -1051,6 +1053,7 @@ static void qcow2_update_options_commit(BlockDriverSt= ate *bs, } s->l2_table_cache =3D r->l2_table_cache; s->refcount_block_cache =3D r->refcount_block_cache; + s->l2_slice_size =3D r->l2_slice_size; =20 s->overlap_check =3D r->overlap_check; s->use_lazy_refcounts =3D r->use_lazy_refcounts; --=20 2.13.6