From nobody Sun Feb 8 21:09:31 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; dkim=fail; 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 1517841869648784.4375456427274; Mon, 5 Feb 2018 06:44:29 -0800 (PST) Received: from localhost ([::1]:50777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eii0S-0002i8-MD for importer@patchew.org; Mon, 05 Feb 2018 09:44:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eihrh-0002j6-R1 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 09:35:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eihrc-0006TR-8J for qemu-devel@nongnu.org; Mon, 05 Feb 2018 09:35:25 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48498) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eihrb-00069p-UM; Mon, 05 Feb 2018 09:35:20 -0500 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1eihr4-0001rv-VO; Mon, 05 Feb 2018 15:34:47 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1eihqJ-0008OP-BI; Mon, 05 Feb 2018 16:33:59 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=/6BTEAfgh1GZnbnGYvHS0c0wyHfKxT+wAGMzII6WEw4=; b=skjF8fGr1I/lP5XqDljm/qunIFO3S7Su4JOfh0pr7ELAb2hi4AeOtBiJgV43UHWeA/YjAI5lHZwCB3Fxa5YR7/gyqXM1r9E9kuJyCFuUTDWKybua1b6VfTTTIkYzDoOGwUS7yD7SWfCv0cY1yWCZg+7I5PktIwKN/Az1myvtpWcYyvpae66xczcP29tmCsksXjA2g90fPmsFEVAM70nfM+L9mn4q2Keu4v+IR2TDLIJn2Is5nFHcrDNYS2CQpe1T0UKjFbYC/yP4/jMnRZ5Dg1qmz1wHYIJl1cc6+TXHqL+eTw01/3xq01A82dOeeWtg32Gt6sOrzuLAL6+TMYX7Yw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 16:33:13 +0200 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v4 13/39] 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: Kevin Wolf , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- block/qcow2.c | 3 +++ block/qcow2.h | 1 + 2 files changed, 4 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index e2d4bf7ad5..78f067cae7 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -805,6 +805,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]; @@ -886,6 +887,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) { @@ -1049,6 +1051,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; diff --git a/block/qcow2.h b/block/qcow2.h index 0559afbc63..e0aee88811 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; --=20 2.11.0