From nobody Mon Feb 9 05:10:34 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513342745401995.0170183074025; Fri, 15 Dec 2017 04:59:05 -0800 (PST) Received: from localhost ([::1]:46071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpZq-0004Yy-Ot for importer@patchew.org; Fri, 15 Dec 2017 07:58:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVE-0000WP-E5 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003Gi-54 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:12 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48110) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CY-Uc; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084l-5U; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV8-0004Dq-0Q; Fri, 15 Dec 2017 14:54:06 +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=dFhpDmWIAORXuMOM5fP/1LGpxY1YThW3ApzXNVld4Xw=; b=cskSvzI0pF3IBo6JsoIW97L+fCrKE26l4c0No+AfNXSvyIJcGLY0xwp+IQ1ntcBk+hLafZkKGrjWLWDvRrxNi63B9hnAMWdd6MazE92zJmbu3SrjbyTGHecZzJObdFscGZiS9Lslenf1zAmN2A1WeuCQ+remUa5f5LvC7T2hbcMAbM7TYfP30suLW6iPVRkLPlnWgmDVXyoLqq/ZUhfSDotttxRifTWVadBw4zAQU8Np3zxXzJDcw9qmWvwISEUF2nLSwGrOSIMIn7TFjIDZN0MLDVYbBSX02nrceYw+NX7s+lplULMy8B9QQ1246RBAD3XnwlcwSgw27gF5v8tUOA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:50 +0100 Message-Id: <8f5a1687d5999f3eecb989dd25b57144cc850b28.1513342045.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 v2 22/32] qcow2: Update discard_single_l2() 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 , "Denis V . Lunev" , Alberto Garcia , qemu-block@nongnu.org, Max Reitz 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" discard_single_l2() limits the number of clusters to be discarded to the amount that fits inside an L2 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 --- block/qcow2-cluster.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 0d126581bd..3be8478c75 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1640,7 +1640,7 @@ int qcow2_decompress_cluster(BlockDriverState *bs, ui= nt64_t cluster_offset) =20 /* * This discards as many clusters of nb_clusters as possible at once (i.e. - * all clusters in the same L2 table) and returns the number of discarded + * all clusters in the same L2 slice) and returns the number of discarded * clusters. */ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, @@ -1648,24 +1648,24 @@ static int discard_single_l2(BlockDriverState *bs, = uint64_t offset, bool full_discard) { BDRVQcow2State *s =3D bs->opaque; - uint64_t *l2_table; + uint64_t *l2_slice; int l2_index; int ret; int i; =20 - ret =3D get_cluster_table(bs, offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, offset, &l2_slice, &l2_index); if (ret < 0) { return ret; } =20 - /* Limit nb_clusters to one L2 table */ - nb_clusters =3D MIN(nb_clusters, s->l2_size - l2_index); + /* Limit nb_clusters to one L2 slice */ + nb_clusters =3D MIN(nb_clusters, s->l2_slice_size - l2_index); assert(nb_clusters <=3D INT_MAX); =20 for (i =3D 0; i < nb_clusters; i++) { uint64_t old_l2_entry; =20 - old_l2_entry =3D be64_to_cpu(l2_table[l2_index + i]); + old_l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); =20 /* * If full_discard is false, make sure that a discarded area reads= back @@ -1703,18 +1703,18 @@ static int discard_single_l2(BlockDriverState *bs, = uint64_t offset, } =20 /* First remove L2 entries */ - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); if (!full_discard && s->qcow_version >=3D 3) { - l2_table[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); + l2_slice[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); } else { - l2_table[l2_index + i] =3D cpu_to_be64(0); + l2_slice[l2_index + i] =3D cpu_to_be64(0); } =20 /* Then decrease the refcount */ qcow2_free_any_clusters(bs, old_l2_entry, 1, type); } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 return nb_clusters; } --=20 2.11.0