From nobody Mon Feb 9 06:07:52 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 1516984598706713.0453137199501; Fri, 26 Jan 2018 08:36:38 -0800 (PST) Received: from localhost ([::1]:37077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6zW-00057v-0C for importer@patchew.org; Fri, 26 Jan 2018 11:36:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6qt-00078S-4G for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6qp-0004B4-Gv for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:43 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38573) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6qp-000496-7F; Fri, 26 Jan 2018 11:27:39 -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 1ef5V7-0007gy-ND; Fri, 26 Jan 2018 16:01:09 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087Q-E1; 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=bbJRURIN4H77B1HFD36DM+52aCzNK/wdgheAS2M68ak=; b=cRsFClhpLI4vabv+Ho4UzVJQOajaclgsag80TvfY0GjHd+5XSgDtq0lfRFdelum4UXPaxJpYH+yE58fOdeE74Yc/AiQU9c7w3G257M2OrwvblTcbCfpijHgK61zo82RKjYWzvItEbbihvvDjT4A6ytJhNzKVFj7rcqjp0OPs6z3vJRLZqN1cijGDCAsB8ZZe6eurtOga3A0yW2tW7FKtQ6drKRpNL+q1ZJpl+shq+5294SAMvjIgOg6wAG0fWUy8onaZ4y5twFoy/Wk/TnR4mTqmmg1vai9mL+K7+0eD1Z68WzEPSPIuqRTU5h4UWxAYk+3NQkNQd0DSrgdn8JvnlA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:48 +0200 Message-Id: <6799e51bdf50179b3632adf20c768cf22c260e8c.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 21/39] qcow2: Update qcow2_alloc_cluster_link_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 , 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" There's a loop in this function that iterates over the L2 entries in a table, so now we need to assert that it remains within the limits of an L2 slice. 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 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 128a82dc5a..abc9e3ed6a 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -923,7 +923,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, Q= CowL2Meta *m) { BDRVQcow2State *s =3D bs->opaque; int i, j =3D 0, l2_index, ret; - uint64_t *old_cluster, *l2_table; + uint64_t *old_cluster, *l2_slice; uint64_t cluster_offset =3D m->alloc_offset; =20 trace_qcow2_cluster_link_l2(qemu_coroutine_self(), m->nb_clusters); @@ -950,13 +950,13 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,= QCowL2Meta *m) s->refcount_block_cache); } =20 - ret =3D get_cluster_table(bs, m->offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, m->offset, &l2_slice, &l2_index); if (ret < 0) { goto err; } - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); =20 - assert(l2_index + m->nb_clusters <=3D s->l2_size); + assert(l2_index + m->nb_clusters <=3D s->l2_slice_size); for (i =3D 0; i < m->nb_clusters; i++) { /* if two concurrent writes happen to the same unallocated cluster * each write allocates separate cluster and writes data concurren= tly. @@ -964,16 +964,16 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,= QCowL2Meta *m) * cluster the second one has to do RMW (which is done above by * perform_cow()), update l2 table with its cluster pointer and fr= ee * old cluster. This is what this loop does */ - if (l2_table[l2_index + i] !=3D 0) { - old_cluster[j++] =3D l2_table[l2_index + i]; + if (l2_slice[l2_index + i] !=3D 0) { + old_cluster[j++] =3D l2_slice[l2_index + i]; } =20 - l2_table[l2_index + i] =3D cpu_to_be64((cluster_offset + + l2_slice[l2_index + i] =3D cpu_to_be64((cluster_offset + (i << s->cluster_bits)) | QCOW_OFLAG_COPIED); } =20 =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 /* * If this was a COW, we need to decrease the refcount of the old clus= ter. --=20 2.11.0