From nobody Mon Feb 9 01:47:18 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 1516979288711444.9507540404337; Fri, 26 Jan 2018 07:08:08 -0800 (PST) Received: from localhost ([::1]:60613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5br-0007zp-Ta for importer@patchew.org; Fri, 26 Jan 2018 10:08:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5VP-0003kv-IY for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5VJ-0005dt-O9 for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:27 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:50824) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5VJ-0005cI-CR; Fri, 26 Jan 2018 10:01:21 -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 1ef5VH-0007gz-Um; Fri, 26 Jan 2018 16:01:20 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087H-8o; 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=/Lzl7qXGe01ubUPUCmVZkgGNh0e5TgZpokHzZ90SRl4=; b=nz37vQK7yYKHPb+Yna6QY662OP2v7gez+i41N8+sfvIKVzyHEpWoP2fG/TUGXoFA/R0YsRMz8Xj6S0axcVfU2kuznbK8NC7Zy9sJasBxZA1s4Wc1vQesh0hWicinhZ2mIaDCd9xHcTc5XlPkrInkHwp4l2G7nK4jilKcCWmVn9M2DHvA45lFD5JM/6zUiNcXmc2pwd/70NNAR5p+1jv/P02T7iyMpVzm0IXxnoZp6H+wC8fff2iQHurkOFb2uO/DdYg3dptnVlnRk5mUZlP24IBsipUyOoHD9/Zekf0BAfYwitI3Ze6q9ata0rrzV5nNltp4dB+H7ffrlRueImSIaw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:45 +0200 Message-Id: <5e98f636670e1741b9bafae624efb0052d9d0b71.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 18/39] qcow2: Refactor get_cluster_table() 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" After the previous patch we're now always using l2_load() in get_cluster_table() regardless of whether a new L2 table has to be allocated or not. This patch refactors that part of the code to use one single l2_load() call. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2-cluster.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 2a53c1dc5f..0c0cab85e8 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -695,15 +695,7 @@ static int get_cluster_table(BlockDriverState *bs, uin= t64_t offset, return -EIO; } =20 - /* seek the l2 table of the given l2 offset */ - - if (s->l1_table[l1_index] & QCOW_OFLAG_COPIED) { - /* load the l2 table in memory */ - ret =3D l2_load(bs, offset, l2_offset, &l2_table); - if (ret < 0) { - return ret; - } - } else { + if (!(s->l1_table[l1_index] & QCOW_OFLAG_COPIED)) { /* First allocate a new L2 table (and do COW if needed) */ ret =3D l2_allocate(bs, l1_index); if (ret < 0) { @@ -719,11 +711,12 @@ static int get_cluster_table(BlockDriverState *bs, ui= nt64_t offset, /* Get the offset of the newly-allocated l2 table */ l2_offset =3D s->l1_table[l1_index] & L1E_OFFSET_MASK; assert(offset_into_cluster(s, l2_offset) =3D=3D 0); - /* Load the l2 table in memory */ - ret =3D l2_load(bs, offset, l2_offset, &l2_table); - if (ret < 0) { - return ret; - } + } + + /* load the l2 table in memory */ + ret =3D l2_load(bs, offset, l2_offset, &l2_table); + if (ret < 0) { + return ret; } =20 /* find the cluster offset for the given disk offset */ --=20 2.11.0