From patchwork Thu Oct 12 13:05:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 824838 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="ZKOuih3d"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yCWlp2kswz9t2S for ; Fri, 13 Oct 2017 00:24:22 +1100 (AEDT) Received: from localhost ([::1]:45501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dTI-00037n-FO for incoming@patchwork.ozlabs.org; Thu, 12 Oct 2017 09:24:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dJw-0004Co-TJ for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:14:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dJt-0006T6-LQ for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:14:40 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:53391) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dJt-0006RY-Bn; Thu, 12 Oct 2017 09:14:37 -0400 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=vUP/40k7BsbrfO1o4l3NRDfeafz/Xp2nd96oTA6kSB0=; b=ZKOuih3dnN/srU35awfG8yBz5BSGqLZk6XxVn5Gst+dSuaZibJ4MSYDVLH80KsrsXjjX2W60gqtKJcwQFjDrrmE11sf5sVUOwSFh8kQ9lY9LsQievmjPskg3InEbquvmC1dNh0ijqTwFb8SoCRcHbMSH9TcvOmXiCa5XkL98olBl4MxCuxy5JD/kwHO6x4mjXKD0ve0unqm7tx7D4t72eGjvkuKIdPoO03TpxWxHomrPPXV+wpfa3wapVTTFu9qXDhkeLjoAcLku8MqZl0AIDzfr6QSuNQBS083OstqQFyySD4ybXufrPagDydsxp82wxOIUmA1/5oSOmr+LUOqiug==; Received: from a88-114-101-76.elisa-laajakaista.fi ([88.114.101.76] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1e2dJr-00075o-UP; Thu, 12 Oct 2017 15:14:36 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003aA-S3; Thu, 12 Oct 2017 16:07:28 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:31 +0300 Message-Id: <1a3e96bdf2db90566105fe2e5d62d812aef2dcb8.1507813391.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 17/31] 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: Kevin Wolf , "Denis V . Lunev" , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- block/qcow2-cluster.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index d3548cc667..580fb50869 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -652,20 +652,20 @@ fail: * get_cluster_table * * for a given disk offset, load (and allocate if needed) - * the l2 table. + * the appropiate 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 = bs->opaque; unsigned int l2_index; uint64_t l1_index, l2_offset; - uint64_t *l2_table = NULL; + uint64_t *l2_slice = NULL; int ret; /* seek to the l2 offset in the l1 table */ @@ -687,11 +687,11 @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset, return -EIO; } - /* seek the l2 table of the given l2 offset */ + /* seek the l2 slice of the given l2 offset */ if (s->l1_table[l1_index] & QCOW_OFLAG_COPIED) { - /* load the l2 table in memory */ - ret = l2_load(bs, offset, l2_offset, &l2_table); + /* load the l2 slice in memory */ + ret = l2_load(bs, offset, l2_offset, &l2_slice); if (ret < 0) { return ret; } @@ -706,8 +706,8 @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset, /* Get the offset of the newly-allocated l2 table */ new_l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK; assert(offset_into_cluster(s, new_l2_offset) == 0); - /* Load the l2 table in memory */ - ret = l2_load(bs, offset, new_l2_offset, &l2_table); + /* Load the l2 slice in memory */ + ret = l2_load(bs, offset, new_l2_offset, &l2_slice); if (ret < 0) { return ret; } @@ -721,9 +721,9 @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset, /* find the cluster offset for the given disk offset */ - l2_index = offset_to_l2_index(s, offset); + l2_index = offset_to_l2_slice_index(s, offset); - *new_l2_table = l2_table; + *new_l2_slice = l2_slice; *new_l2_index = l2_index; return 0;