From nobody Mon Feb 9 11:07:44 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 1516984582692967.3745275311688; Fri, 26 Jan 2018 08:36:22 -0800 (PST) Received: from localhost ([::1]:37069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6zF-0004wT-KV for importer@patchew.org; Fri, 26 Jan 2018 11:36:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6qy-0007FJ-LK for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6qx-0004RZ-Mz for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:48 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38614) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6qx-0004Og-CY; Fri, 26 Jan 2018 11:27:47 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Ux-0007gz-SY; Fri, 26 Jan 2018 16:01:00 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087W-H8; Fri, 26 Jan 2018 17:00:17 +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=yKkiGX5dZIQu6WPhncVzfh53D84VK3Ye45h/WQ0NjrY=; b=Zxj5bVKNTaTEje6HVh3NTcYut7Tu/DFYZtlf/aoE+niMsMt1pB6GJQ2Xxn+K6Nm/dTvZRJKTKAf6uVHpyagyR0541WgjUepHKHS4YoilZmmtRMWp65WxXry3jccGbxJvDDk5D8jJg1Nd6jIk9Cp4DCgsGxj04G11r/GAu9pzLze3SYc8AkkxMBA/Lw1m7YCJoCBQ/a9yHYBvLNa6nl5lf1VK6+k2wGPpt0pl08QRorPYhsVTwQzq90hI47REpKdz6yp5iVu/sGjVrmkUPHb0vX9daRll6I3nH2Vzj3DaOu1CxF/LFsVgBQpz8F3l9FlreWsiBk8qdsFNYysBwyNSVA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:50 +0200 Message-Id: <5d8899a6633484768bc66823d9cb30823620fda4.1516978645.git.berto@igalia.com> 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 v3 23/39] qcow2: Update handle_alloc() to support L2 slices 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" handle_alloc() loads an L2 table and limits the number of checked clusters to the amount that fits inside that table. Since we'll be loading L2 slices instead of full tables we need to update that limit. Apart from that, this function doesn't need any additional changes, so this patch simply updates the variable name from l2_table to l2_slice. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2-cluster.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index ac23776b2a..aa374f9928 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1275,7 +1275,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, { BDRVQcow2State *s =3D bs->opaque; int l2_index; - uint64_t *l2_table; + uint64_t *l2_slice; uint64_t entry; uint64_t nb_clusters; int ret; @@ -1288,29 +1288,29 @@ static int handle_alloc(BlockDriverState *bs, uint6= 4_t guest_offset, assert(*bytes > 0); =20 /* - * Calculate the number of clusters to look for. We stop at L2 table + * Calculate the number of clusters to look for. We stop at L2 slice * boundaries to keep things simple. */ nb_clusters =3D size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes); =20 - l2_index =3D offset_to_l2_index(s, guest_offset); - nb_clusters =3D MIN(nb_clusters, s->l2_size - l2_index); + l2_index =3D offset_to_l2_slice_index(s, guest_offset); + nb_clusters =3D MIN(nb_clusters, s->l2_slice_size - l2_index); assert(nb_clusters <=3D INT_MAX); =20 /* Find L2 entry for the first involved cluster */ - ret =3D get_cluster_table(bs, guest_offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, guest_offset, &l2_slice, &l2_index); if (ret < 0) { return ret; } =20 - entry =3D be64_to_cpu(l2_table[l2_index]); + entry =3D be64_to_cpu(l2_slice[l2_index]); =20 /* For the moment, overwrite compressed clusters one by one */ if (entry & QCOW_OFLAG_COMPRESSED) { nb_clusters =3D 1; } else { - nb_clusters =3D count_cow_clusters(s, nb_clusters, l2_table, l2_in= dex); + nb_clusters =3D count_cow_clusters(s, nb_clusters, l2_slice, l2_in= dex); } =20 /* This function is only called when there were no non-COW clusters, s= o if @@ -1339,7 +1339,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, * nb_clusters already to a range of COW clusters */ preallocated_nb_clusters =3D count_contiguous_clusters(nb_clusters, s->cluster_size, - &l2_table[l2_index], QCOW_OFLAG_COPI= ED); + &l2_slice[l2_index], QCOW_OFLAG_COPI= ED); assert(preallocated_nb_clusters > 0); =20 nb_clusters =3D preallocated_nb_clusters; @@ -1350,7 +1350,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, keep_old_clusters =3D true; } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 if (!alloc_cluster_offset) { /* Allocate, if necessary at a given offset in the image file */ --=20 2.11.0