From nobody Fri Dec 19 15:46:30 2025 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 151854387491658.54106950417338; Tue, 13 Feb 2018 09:44:34 -0800 (PST) Received: from localhost ([::1]:56307 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eled8-0001ov-2o for importer@patchew.org; Tue, 13 Feb 2018 12:44:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ele27-0003Q9-LE for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ele24-0005dn-FB for qemu-devel@nongnu.org; Tue, 13 Feb 2018 12:06:19 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37832 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 1ele1w-0005Xt-TY; Tue, 13 Feb 2018 12:06:08 -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 82CE24022909; Tue, 13 Feb 2018 17:06:08 +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 D2B1C10075C2; Tue, 13 Feb 2018 17:06:07 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 13 Feb 2018 18:05:09 +0100 Message-Id: <20180213170529.10858-36-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.6]); Tue, 13 Feb 2018 17:06:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 13 Feb 2018 17:06:08 +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 35/55] qcow2: Update get_cluster_table() 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: 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 This patch updates get_cluster_table() to return L2 slices instead of full L2 tables. The code itself needs almost no changes, it only needs to call offset_to_l2_slice_index() instead of offset_to_l2_index(). This patch also renames all the relevant variables and the documentation. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-id: 64cf064c0021ba315d3f3032da0f95db1b615f33.1517840877.git.berto@i= galia.com Signed-off-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 044eccda72..cd1ba40f74 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -659,20 +659,20 @@ fail: * get_cluster_table * * for a given disk offset, load (and allocate if needed) - * the l2 table. + * the appropriate slice of its l2 table. * - * the cluster index in the l2 table is given to the caller. + * the cluster index in the l2 slice is given to the caller. * * Returns 0 on success, -errno in failure case */ static int get_cluster_table(BlockDriverState *bs, uint64_t offset, - uint64_t **new_l2_table, + uint64_t **new_l2_slice, int *new_l2_index) { BDRVQcow2State *s =3D bs->opaque; unsigned int l2_index; uint64_t l1_index, l2_offset; - uint64_t *l2_table =3D NULL; + uint64_t *l2_slice =3D NULL; int ret; =20 /* seek to the l2 offset in the l1 table */ @@ -712,17 +712,17 @@ static int get_cluster_table(BlockDriverState *bs, ui= nt64_t offset, assert(offset_into_cluster(s, l2_offset) =3D=3D 0); } =20 - /* load the l2 table in memory */ - ret =3D l2_load(bs, offset, l2_offset, &l2_table); + /* load the l2 slice in memory */ + ret =3D l2_load(bs, offset, l2_offset, &l2_slice); if (ret < 0) { return ret; } =20 /* find the cluster offset for the given disk offset */ =20 - l2_index =3D offset_to_l2_index(s, offset); + l2_index =3D offset_to_l2_slice_index(s, offset); =20 - *new_l2_table =3D l2_table; + *new_l2_slice =3D l2_slice; *new_l2_index =3D l2_index; =20 return 0; --=20 2.13.6