From patchwork Thu Oct 12 13:05:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 824857 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="aVB+aBtQ"; 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 3yCX0w11Qtz9sNw for ; Fri, 13 Oct 2017 00:35:44 +1100 (AEDT) Received: from localhost ([::1]:45570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2deI-0004G8-6H for incoming@patchwork.ozlabs.org; Thu, 12 Oct 2017 09:35:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dKG-0004S4-V4 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:15:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dKD-0006mA-MZ for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:15:00 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:53445) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dKD-0006lq-DG; Thu, 12 Oct 2017 09:14:57 -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=p6ah++si824KD1hrWAqJHnI5PwXzpVuzyk9mDBUOjbk=; b=aVB+aBtQcJeXF48KeEA5Y8yUGdN9fPu01HAUy7QloA+92hxIxjh7E5FPupAHfdui5alOCaNUplt26/kCCJsox+mcdPlphLgmeSCAabU6UlVZMnxBGsXJ5yVmHdetRjqU59ZJ24yzUwitgZbhn4sWIDKiTBLPpqYiFNiyrFpInccAfci70HDJGNNB86lkll7CY41CXXDVmKhIkrPT0ab6U8yGvlZArTFfZgk2sAV2HTJAhVLF2hwnbDOUPOCjlQ596t2otK/P0CLw7i9D0PkXY0okRY6DcYHD+WAQqYFwnK4tnsK68MGly3VlpLOPSomzYOlVOUYj+VgeCRnZiydEtw==; 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 1e2dKC-00075o-2l; Thu, 12 Oct 2017 15:14:56 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003Zy-M7; Thu, 12 Oct 2017 16:07:28 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:27 +0300 Message-Id: <0c316e8b75e52d8485248ac18d691a6d7d0170ee.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 13/31] qcow2: Add l2_slice_size field to BDRVQcow2State 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" The BDRVQcow2State structure contains an l2_size field, which stores the number of 64-bit entries in an L2 table. For efficiency reasons we want to be able to load slices instead of full L2 tables, so we need to know how many entries an L2 slice can hold. An L2 slice is the portion of an L2 table that is loaded by the qcow2 cache. At the moment that cache can only load complete tables, therefore an L2 slice has the same size as an L2 table (one cluster) and l2_size == l2_slice_size. Later we'll allow smaller slices, but until then we have to use this new l2_slice_size field to make the rest of the code ready for that. Signed-off-by: Alberto Garcia --- block/qcow2.c | 3 +++ block/qcow2.h | 1 + 2 files changed, 4 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 9f55e0a9ff..e5458fcffd 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -794,6 +794,7 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, typedef struct Qcow2ReopenState { Qcow2Cache *l2_table_cache; Qcow2Cache *refcount_block_cache; + int l2_slice_size; bool use_lazy_refcounts; int overlap_check; bool discard_passthrough[QCOW2_DISCARD_MAX]; @@ -875,6 +876,7 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, } } + r->l2_slice_size = s->cluster_size / sizeof(uint64_t); r->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); r->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); if (r->l2_table_cache == NULL || r->refcount_block_cache == NULL) { @@ -1038,6 +1040,7 @@ static void qcow2_update_options_commit(BlockDriverState *bs, } s->l2_table_cache = r->l2_table_cache; s->refcount_block_cache = r->refcount_block_cache; + s->l2_slice_size = r->l2_slice_size; s->overlap_check = r->overlap_check; s->use_lazy_refcounts = r->use_lazy_refcounts; diff --git a/block/qcow2.h b/block/qcow2.h index 61c6c27673..9c1ea97f0e 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -251,6 +251,7 @@ typedef struct BDRVQcow2State { int cluster_bits; int cluster_size; int cluster_sectors; + int l2_slice_size; int l2_bits; int l2_size; int l1_size;