From nobody Sat Apr 20 08:17:47 2024 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 1507815522902824.699317255834; Thu, 12 Oct 2017 06:38:42 -0700 (PDT) Received: from localhost ([::1]:45591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dh7-0006r7-1x for importer@patchew.org; Thu, 12 Oct 2017 09:38:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dKo-0004zo-TV for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:15:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dKl-00078z-27 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:15:34 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:53602) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dKk-00078e-Ol; Thu, 12 Oct 2017 09:15:30 -0400 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 1e2dKj-0007Cr-Eu; Thu, 12 Oct 2017 15:15:29 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003ZO-3W; Thu, 12 Oct 2017 16:07:28 +0300 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=J7t/1JCuORll/nfGDSfVCmn/Uep8bTLbi3HLascHKV8=; b=kiccMwMHfobi1HSPMWcRsfrWbKYWbYzArTIV8Xa6lsTSeVaCZ8WXLrG1SXwFN0QeHdYatIKpVPKIY7LDsaPvEGm6rUizPzwEfEIqqOARVL5OYD58jEIrHNGhTXgZhm0Dj7Y0tPzfWDkqjoYJ+QN25GEJYXSzqXKDYaCBaVCtj3QWsFbyVeeuKBM1HP/ZhOCRYyqZOLqPLlug4lo+WRHp+neg5sifG/gjgV33tTk4VemUbuPQRZmx4uPJiwwSLA+YWruSG7uYDX3yx8IVJMRZVCXkeA00YRgGH+cXzT9xdU6sSYxWUo+hIWVszWBqFs2TdT0DC9ZmxboojTiesy7ZNg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:15 +0300 Message-Id: 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 01/31] qcow2: Fix documentation of 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 , "Denis V . Lunev" , Alberto Garcia , qemu-block@nongnu.org, Max Reitz 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" This function has not been returning the offset of the L2 table since commit 3948d1d4876065160583e79533bf604481063833 Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 0e5aec81cb..b926549816 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -640,8 +640,7 @@ fail: * for a given disk offset, load (and allocate if needed) * the l2 table. * - * the l2 table offset in the qcow2 file and the cluster index - * in the l2 table are given to the caller. + * the cluster index in the l2 table is given to the caller. * * Returns 0 on success, -errno in failure case */ --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507814141541682.5943873135826; Thu, 12 Oct 2017 06:15:41 -0700 (PDT) Received: from localhost ([::1]:45447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dKp-0004XY-L6 for importer@patchew.org; Thu, 12 Oct 2017 09:15:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dG4-0000zw-Oh for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:10:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dG0-0000Yd-Kg for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:10:40 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52202) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dG0-0007Rf-8O; Thu, 12 Oct 2017 09:10:36 -0400 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 1e2dFO-0006MO-9j; Thu, 12 Oct 2017 15:09:58 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003ZQ-4n; Thu, 12 Oct 2017 16:07:28 +0300 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=lv+r8MoWJEFSl2ll/qCDr+AlwxRt/zt3p6tWwZKQOi8=; b=EwBl3Bip/x1HsCeQsVbcJZLYUjLa93gRku1dxyVRGxLIhGTBVpk4bV/21cJlSdPOQ9lAzrtOmlPOK6U6DiL8+D/4sRwaYRThGBeNk6LHrQNeHxt8jzMXj/8BHDfEf7Qd2xUiWIKWPatvllRt+xsZs3FMkZn/UNgA0D806PwH/GDA2z677ODdQgFRw0wyf0FuHzW+utB6WURbUm5y8FJ1ozaQj0W+mBv3UqXXntwKDHsSrnXodPCMspJnEHr+nMAbznmXXCHXFkvNQYlccCm95MzQyk4YVTzO2iVOzz1u6f+q+4TD52jT+bTLizQUf3eSforddFt7jN4knjW8Yi4afQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:16 +0300 Message-Id: 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 02/31] qcow2: Add table size field to Qcow2Cache 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+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" The table size in the qcow2 cache is currently equal to the cluster size. This doesn't allow us to use the cache memory efficiently, particularly with large cluster sizes, so we need to be able to have smaller cache tables that are independent from the cluster size. This patch adds a new field to Qcow2Cache that we can use instead of the cluster size. The current table size is still being initialized to the cluster size, so there are no semantic changes yet, but this patch will allow us to prepare the rest of the code and simplify a few function calls. Signed-off-by: Alberto Garcia --- block/qcow2-cache.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 75746a7f43..72cb7148ff 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -39,6 +39,7 @@ struct Qcow2Cache { Qcow2CachedTable *entries; struct Qcow2Cache *depends; int size; + int table_size; bool depends_on_flush; void *table_array; uint64_t lru_counter; @@ -48,17 +49,15 @@ struct Qcow2Cache { static inline void *qcow2_cache_get_table_addr(BlockDriverState *bs, Qcow2Cache *c, int table) { - BDRVQcow2State *s =3D bs->opaque; - return (uint8_t *) c->table_array + (size_t) table * s->cluster_size; + return (uint8_t *) c->table_array + (size_t) table * c->table_size; } =20 static inline int qcow2_cache_get_table_idx(BlockDriverState *bs, Qcow2Cache *c, void *table) { - BDRVQcow2State *s =3D bs->opaque; ptrdiff_t table_offset =3D (uint8_t *) table - (uint8_t *) c->table_ar= ray; - int idx =3D table_offset / s->cluster_size; - assert(idx >=3D 0 && idx < c->size && table_offset % s->cluster_size = =3D=3D 0); + int idx =3D table_offset / c->table_size; + assert(idx >=3D 0 && idx < c->size && table_offset % c->table_size =3D= =3D 0); return idx; } =20 @@ -67,10 +66,9 @@ static void qcow2_cache_table_release(BlockDriverState *= bs, Qcow2Cache *c, { /* Using MADV_DONTNEED to discard memory is a Linux-specific feature */ #ifdef CONFIG_LINUX - BDRVQcow2State *s =3D bs->opaque; void *t =3D qcow2_cache_get_table_addr(bs, c, i); int align =3D getpagesize(); - size_t mem_size =3D (size_t) s->cluster_size * num_tables; + size_t mem_size =3D (size_t) c->table_size * num_tables; size_t offset =3D QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t; size_t length =3D QEMU_ALIGN_DOWN(mem_size - offset, align); if (length > 0) { @@ -120,9 +118,10 @@ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, i= nt num_tables) =20 c =3D g_new0(Qcow2Cache, 1); c->size =3D num_tables; + c->table_size =3D s->cluster_size; c->entries =3D g_try_new0(Qcow2CachedTable, num_tables); c->table_array =3D qemu_try_blockalign(bs->file->bs, - (size_t) num_tables * s->cluster_= size); + (size_t) num_tables * c->table_si= ze); =20 if (!c->entries || !c->table_array) { qemu_vfree(c->table_array); @@ -191,13 +190,13 @@ static int qcow2_cache_entry_flush(BlockDriverState *= bs, Qcow2Cache *c, int i) =20 if (c =3D=3D s->refcount_block_cache) { ret =3D qcow2_pre_write_overlap_check(bs, QCOW2_OL_REFCOUNT_BLOCK, - c->entries[i].offset, s->cluster_size); + c->entries[i].offset, c->table_size); } else if (c =3D=3D s->l2_table_cache) { ret =3D qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L2, - c->entries[i].offset, s->cluster_size); + c->entries[i].offset, c->table_size); } else { ret =3D qcow2_pre_write_overlap_check(bs, 0, - c->entries[i].offset, s->cluster_size); + c->entries[i].offset, c->table_size); } =20 if (ret < 0) { @@ -211,7 +210,7 @@ static int qcow2_cache_entry_flush(BlockDriverState *bs= , Qcow2Cache *c, int i) } =20 ret =3D bdrv_pwrite(bs->file, c->entries[i].offset, - qcow2_cache_get_table_addr(bs, c, i), s->cluster_siz= e); + qcow2_cache_get_table_addr(bs, c, i), c->table_size); if (ret < 0) { return ret; } @@ -318,7 +317,7 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qco= w2Cache *c, offset, read_from_disk); =20 /* Check if the table is already cached */ - i =3D lookup_index =3D (offset / s->cluster_size * 4) % c->size; + i =3D lookup_index =3D (offset / c->table_size * 4) % c->size; do { const Qcow2CachedTable *t =3D &c->entries[i]; if (t->offset =3D=3D offset) { @@ -359,7 +358,7 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qco= w2Cache *c, =20 ret =3D bdrv_pread(bs->file, offset, qcow2_cache_get_table_addr(bs, c, i), - s->cluster_size); + c->table_size); if (ret < 0) { return ret; } --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507815583828135.7919322556436; Thu, 12 Oct 2017 06:39:43 -0700 (PDT) Received: from localhost ([::1]:45594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2diB-0007kD-33 for importer@patchew.org; Thu, 12 Oct 2017 09:39:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dKS-0004g0-1g for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:15:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dKO-0006rg-PE for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:15:12 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:53463) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dKO-0006ql-GS; Thu, 12 Oct 2017 09:15:08 -0400 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 1e2dKM-00075o-37; Thu, 12 Oct 2017 15:15:06 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003ZS-6Q; Thu, 12 Oct 2017 16:07:28 +0300 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=u+CZ1VasCBkRr5A4jCS9QzAhasQ2ssBNxZVjQyGSOP0=; b=SQO0Q7oDakqC9swy0BvKuhBB9vZ32b2i0j5aK3vrp5KSKVDxpGfp+BgDZJKGv3NG/qEiQG5zWDR6AGZtT01HRWrzu8UbAnW8lUKT9rs6Jf2Bd/p2s6mYh2FNAt4HPzDTdG/u6fi2Q8TNh7WZgPj2yLgES3vmLyuGkDKU7AR92kuf6JNO+KQsyNhlxhWNsv9741D0rsfiwl3BRNE7zQVxv6s3tb+urGf1GZHFS09iniHzXRk4qIu1MTlncXFlotzurWlBG+NVw4RPn44VGG5VhKJSFhh2tnkH5gwGuDUe2n8LJ9eX1hnW07DstbOPQHbRU6iw+rWqbj546z0SpNnCUw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:17 +0300 Message-Id: <1aabec73c000402304473c0f1afe1278a4658da3.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 03/31] qcow2: Remove BDS parameter from qcow2_cache_get_table_addr() 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+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" This function was only using the BlockDriverState parameter to get the cache table size (since it was equal to the cluster size). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia --- block/qcow2-cache.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 72cb7148ff..98bd77f3fb 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -46,8 +46,7 @@ struct Qcow2Cache { uint64_t cache_clean_lru_counter; }; =20 -static inline void *qcow2_cache_get_table_addr(BlockDriverState *bs, - Qcow2Cache *c, int table) +static inline void *qcow2_cache_get_table_addr(Qcow2Cache *c, int table) { return (uint8_t *) c->table_array + (size_t) table * c->table_size; } @@ -66,7 +65,7 @@ static void qcow2_cache_table_release(BlockDriverState *b= s, Qcow2Cache *c, { /* Using MADV_DONTNEED to discard memory is a Linux-specific feature */ #ifdef CONFIG_LINUX - void *t =3D qcow2_cache_get_table_addr(bs, c, i); + void *t =3D qcow2_cache_get_table_addr(c, i); int align =3D getpagesize(); size_t mem_size =3D (size_t) c->table_size * num_tables; size_t offset =3D QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t; @@ -210,7 +209,7 @@ static int qcow2_cache_entry_flush(BlockDriverState *bs= , Qcow2Cache *c, int i) } =20 ret =3D bdrv_pwrite(bs->file, c->entries[i].offset, - qcow2_cache_get_table_addr(bs, c, i), c->table_size); + qcow2_cache_get_table_addr(c, i), c->table_size); if (ret < 0) { return ret; } @@ -357,7 +356,7 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qco= w2Cache *c, } =20 ret =3D bdrv_pread(bs->file, offset, - qcow2_cache_get_table_addr(bs, c, i), + qcow2_cache_get_table_addr(c, i), c->table_size); if (ret < 0) { return ret; @@ -369,7 +368,7 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qco= w2Cache *c, /* And return the right table */ found: c->entries[i].ref++; - *table =3D qcow2_cache_get_table_addr(bs, c, i); + *table =3D qcow2_cache_get_table_addr(c, i); =20 trace_qcow2_cache_get_done(qemu_coroutine_self(), c =3D=3D s->l2_table_cache, i); @@ -418,7 +417,7 @@ void *qcow2_cache_is_table_offset(BlockDriverState *bs,= Qcow2Cache *c, =20 for (i =3D 0; i < c->size; i++) { if (c->entries[i].offset =3D=3D offset) { - return qcow2_cache_get_table_addr(bs, c, i); + return qcow2_cache_get_table_addr(c, i); } } return NULL; --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507815348468303.22048335149884; Thu, 12 Oct 2017 06:35:48 -0700 (PDT) Received: from localhost ([::1]:45578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2deG-0004SJ-Ar for importer@patchew.org; Thu, 12 Oct 2017 09:35:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dK7-0004Jq-04 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:14:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dK3-0006fN-KP for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:14:50 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:53419) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dK3-0006ed-Az; Thu, 12 Oct 2017 09:14:47 -0400 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 1e2dK2-00075o-3F; Thu, 12 Oct 2017 15:14:46 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003ZU-8F; Thu, 12 Oct 2017 16:07:28 +0300 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=RNeDZ+LFlVmztkB2SIZgG6pUtpxp1Nbu3I8VIBHp3pM=; b=A+IGwUOUSoh4PrUvpXk6kUibCFxHPyO4LAliWxmqUbbP7Y3DolPVVcxu+WZaBoebPifw8h61J+2hT81AujHkzpa0XwlQ/hBZbzXuMqmJ4RqHLL1fVFSMIPmRYmmTBo+2ZLDJLVQkx2QBLpO9xEHEaCnUH6QcXaliZJj0WhjFcRZ76uubqlx4bvkg3eFYf6KaSdjmtdQpcgGVXoRRqKeyyZ0SeFZNdAUQpYMkmJOtYOe/ChHvU3AtjPSXq7q6YAPwYm+vWSRNiGvVaWyzHpYZ73I2hJoZIYw2Cv3Y2GTzETquSZD1psPdvt/uAYdfDLuCedytURZ8Iw5ushrWhgWESg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:18 +0300 Message-Id: <912f77493be99ef2945f0adacc2a78a3f4d62078.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 04/31] qcow2: Remove BDS parameter from qcow2_cache_get_table_idx() 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+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" This function was only using the BlockDriverState parameter to get the cache table size (since it was equal to the cluster size). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia --- block/qcow2-cache.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 98bd77f3fb..cba6a165e8 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -51,8 +51,7 @@ static inline void *qcow2_cache_get_table_addr(Qcow2Cache= *c, int table) return (uint8_t *) c->table_array + (size_t) table * c->table_size; } =20 -static inline int qcow2_cache_get_table_idx(BlockDriverState *bs, - Qcow2Cache *c, void *table) +static inline int qcow2_cache_get_table_idx(Qcow2Cache *c, void *table) { ptrdiff_t table_offset =3D (uint8_t *) table - (uint8_t *) c->table_ar= ray; int idx =3D table_offset / c->table_size; @@ -390,7 +389,7 @@ int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Ca= che *c, uint64_t offset, =20 void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table) { - int i =3D qcow2_cache_get_table_idx(bs, c, *table); + int i =3D qcow2_cache_get_table_idx(c, *table); =20 c->entries[i].ref--; *table =3D NULL; @@ -405,7 +404,7 @@ void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *= c, void **table) void qcow2_cache_entry_mark_dirty(BlockDriverState *bs, Qcow2Cache *c, void *table) { - int i =3D qcow2_cache_get_table_idx(bs, c, table); + int i =3D qcow2_cache_get_table_idx(c, table); assert(c->entries[i].offset !=3D 0); c->entries[i].dirty =3D true; } @@ -425,7 +424,7 @@ void *qcow2_cache_is_table_offset(BlockDriverState *bs,= Qcow2Cache *c, =20 void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table) { - int i =3D qcow2_cache_get_table_idx(bs, c, table); + int i =3D qcow2_cache_get_table_idx(c, table); =20 assert(c->entries[i].ref =3D=3D 0); =20 --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507815171436689.264233690321; Thu, 12 Oct 2017 06:32:51 -0700 (PDT) Received: from localhost ([::1]:45557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dbT-0002I2-Kp for importer@patchew.org; Thu, 12 Oct 2017 09:32:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dJI-0003gA-GI for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:14:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dJF-0005za-4V for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:14:00 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:53203) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dJE-0005yn-RM; Thu, 12 Oct 2017 09:13:57 -0400 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 1e2dJD-0006pW-JK; Thu, 12 Oct 2017 15:13:55 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003ZY-AE; Thu, 12 Oct 2017 16:07:28 +0300 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=4q1Rn7cY7d7QkOyb30liv1lsVNqPqSp2KDa/lS7tOME=; b=f9fPnIa5c+G7zMQRjmVHA8aW0T/tXUUU5/SA7we9TO8/QN4vBXiIFCKh6Yco853XEeot4LqVyHDfyF7UKhvoD3FFNO9JD99ui3ngjb/KSJ2AlhmCswt2wa4Yfup16i51B2xpgVseF4Eq3pa/+OD9HUTbKwPQFIKVYS/ZjYhXAZLUeP7LHAy6qZeHCVuQFnMidX8NPLZEdKBByZjGstl7BnZFBIaKPgoyFhmuQOBKD97XeUZ6QOX5TxEqH1H46hJE5ACAvmNdkKa5WjuMalrruhhlrnvgo6+NlVRc3IY2bHskC6Or0YcUVQ82zG8h415nKnvg4q7Zyp9eM7PKUj2Jag==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:19 +0300 Message-Id: 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 05/31] qcow2: Remove BDS parameter from qcow2_cache_table_release() 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+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" This function was only using the BlockDriverState parameter to get the cache table size (since it was equal to the cluster size). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia --- block/qcow2-cache.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index cba6a165e8..dac99e95b0 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -59,8 +59,7 @@ static inline int qcow2_cache_get_table_idx(Qcow2Cache *c= , void *table) return idx; } =20 -static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c, - int i, int num_tables) +static void qcow2_cache_table_release(Qcow2Cache *c, int i, int num_tables) { /* Using MADV_DONTNEED to discard memory is a Linux-specific feature */ #ifdef CONFIG_LINUX @@ -102,7 +101,7 @@ void qcow2_cache_clean_unused(BlockDriverState *bs, Qco= w2Cache *c) } =20 if (to_clean > 0) { - qcow2_cache_table_release(bs, c, i - to_clean, to_clean); + qcow2_cache_table_release(c, i - to_clean, to_clean); } } =20 @@ -294,7 +293,7 @@ int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache = *c) c->entries[i].lru_counter =3D 0; } =20 - qcow2_cache_table_release(bs, c, 0, c->size); + qcow2_cache_table_release(c, 0, c->size); =20 c->lru_counter =3D 0; =20 @@ -432,5 +431,5 @@ void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cac= he *c, void *table) c->entries[i].lru_counter =3D 0; c->entries[i].dirty =3D false; =20 - qcow2_cache_table_release(bs, c, i, 1); + qcow2_cache_table_release(c, i, 1); } --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507815004585517.8510875449235; Thu, 12 Oct 2017 06:30:04 -0700 (PDT) Received: from localhost ([::1]:45538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dYh-0008CX-4O for importer@patchew.org; Thu, 12 Oct 2017 09:29:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dIz-0003PR-8R for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:13:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dIv-0005lg-5m for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:13:41 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:53144) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dIu-0005kc-OF; Thu, 12 Oct 2017 09:13:37 -0400 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 1e2dIt-0006pW-Fz; Thu, 12 Oct 2017 15:13:35 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003Zc-Br; Thu, 12 Oct 2017 16:07:28 +0300 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=O2udzopUUavlkg7MzvSIbo/RpnwibgnrPxwOQJYSd9E=; b=b0Zpg8QRxBgpVRMawGTUKSfjulZHeV2jHtlx0jve8szuz6wZHT5yNwVwWfM/q3I4/qYCO+irlz2GW2VedDpE1zISIymyvuLXlLQZGazUQUW1jbEIRmjXSJ1aqajdx42xuA4A5yZZYXPymFc+9o2fvVos1BxOonfYS6gZdQOQQOvWWNMo0UUDyxYNe56XCsHWZL0TUozmZva/HVAGV6ZG4lR03S+u8KW59qFWv9Ngh8cjWYNXtShWurOd7u4LWZb8f5nxl1orLDdMawxNXhCNsKp1/ii9cvbFd4fKBonqR0fvj8CsysHZ/xtFD+FKovKm+QF0cB2H0Z0o8033qyDw4g==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:20 +0300 Message-Id: <08fde64b907b45afa4c4622de4799ce1c5144508.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 06/31] qcow2: Remove BDS parameter from qcow2_cache_entry_mark_dirty() 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This function was only using the BlockDriverState parameter to pass it to qcow2_cache_get_table_idx(). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia --- block/qcow2-cache.c | 3 +-- block/qcow2-cluster.c | 12 ++++++------ block/qcow2-refcount.c | 14 ++++++-------- block/qcow2.h | 3 +-- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index dac99e95b0..e2502d32ae 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -400,8 +400,7 @@ void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *= c, void **table) assert(c->entries[i].ref >=3D 0); } =20 -void qcow2_cache_entry_mark_dirty(BlockDriverState *bs, Qcow2Cache *c, - void *table) +void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table) { int i =3D qcow2_cache_get_table_idx(c, table); assert(c->entries[i].offset !=3D 0); diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index b926549816..372cb64366 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -317,7 +317,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_ind= ex, uint64_t **table) BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE); =20 trace_qcow2_l2_allocate_write_l2(bs, l1_index); - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); ret =3D qcow2_cache_flush(bs, s->l2_table_cache); if (ret < 0) { goto fail; @@ -758,7 +758,7 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDri= verState *bs, /* compressed clusters never have the copied flag */ =20 BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); l2_table[l2_index] =3D cpu_to_be64(cluster_offset); qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); =20 @@ -930,7 +930,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, Q= CowL2Meta *m) if (ret < 0) { goto err; } - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); =20 assert(l2_index + m->nb_clusters <=3D s->l2_size); for (i =3D 0; i < m->nb_clusters; i++) { @@ -1660,7 +1660,7 @@ static int discard_single_l2(BlockDriverState *bs, ui= nt64_t offset, } =20 /* First remove L2 entries */ - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); if (!full_discard && s->qcow_version >=3D 3) { l2_table[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); } else { @@ -1756,7 +1756,7 @@ static int zero_single_l2(BlockDriverState *bs, uint6= 4_t offset, continue; } =20 - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); if (cluster_type =3D=3D QCOW2_CLUSTER_COMPRESSED || unmap) { l2_table[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUE= ST); @@ -1965,7 +1965,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, =20 if (is_active_l1) { if (l2_dirty) { - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_tab= le); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); qcow2_cache_depends_on_flush(s->l2_table_cache); } qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index aa3fd6cf17..f0cc4f090a 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -414,7 +414,7 @@ static int alloc_refcount_block(BlockDriverState *bs, =20 /* Now the new refcount block needs to be written to disk */ BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE); - qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, *refcount_bl= ock); + qcow2_cache_entry_mark_dirty(s->refcount_block_cache, *refcount_block); ret =3D qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { goto fail; @@ -616,7 +616,7 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t start_offset, goto fail; } memset(refblock_data, 0, s->cluster_size); - qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, + qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refblock_data); =20 new_table[i] =3D block_offset; @@ -649,7 +649,7 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t start_offset, s->set_refcount(refblock_data, j, 1); } =20 - qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, + qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refblock_data); } =20 @@ -838,8 +838,7 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(Bloc= kDriverState *bs, } old_table_index =3D table_index; =20 - qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, - refcount_block); + qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refcount_blo= ck); =20 /* we can update the count and save it */ block_index =3D cluster_index & (s->refcount_block_size - 1); @@ -1302,8 +1301,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, s->refcount_block_cache); } l2_table[j] =3D cpu_to_be64(entry); - qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, - l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_tab= le); } } =20 @@ -3096,7 +3094,7 @@ static int qcow2_discard_refcount_block(BlockDriverSt= ate *bs, } s->set_refcount(refblock, block_index, 0); =20 - qcow2_cache_entry_mark_dirty(bs, s->refcount_block_cache, refblock); + qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refblock); =20 qcow2_cache_put(bs, s->refcount_block_cache, &refblock); =20 diff --git a/block/qcow2.h b/block/qcow2.h index 782a206ecb..539c07a46f 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -648,8 +648,7 @@ int qcow2_read_snapshots(BlockDriverState *bs); Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables); int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c); =20 -void qcow2_cache_entry_mark_dirty(BlockDriverState *bs, Qcow2Cache *c, - void *table); +void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table); int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c); int qcow2_cache_write(BlockDriverState *bs, Qcow2Cache *c); int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c, --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507815201470674.6487698110866; Thu, 12 Oct 2017 06:33:21 -0700 (PDT) Received: from localhost ([::1]:45558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dc0-0002fN-Kf for importer@patchew.org; Thu, 12 Oct 2017 09:33:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dIV-00031D-1M for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:13:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dIQ-0005D5-Uv for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:13:11 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52977) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dIQ-0005CP-HC; Thu, 12 Oct 2017 09:13:06 -0400 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 1e2dIP-0006pW-48; Thu, 12 Oct 2017 15:13:05 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003Zg-Cy; Thu, 12 Oct 2017 16:07:28 +0300 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=M1EqQ3z5fGrzem6F9bGlYFVPNycCbUQ1dGAnDpc4WgI=; b=d3+oHossn9fd9Tg2AWqlXwPU4t1qw4A+ma6ZhLtPlrE5I31wZA4c5DPjZwteyxzLbTO2CyNz7xGXuqlsBA7Bg2mmd3ao0jvATqoieUEZeAiX9yjVhIoCR6UpCXo9Wy7afjrnDCUSPTeTDLVoZUDm9UlHpSgqCWxoh3ipBfkjZbK717y00O8m+olpg86qasSe2km+18lBiBXz2T591dppGPCWfo/z5gN5yUIft+ir2vIznkiPP47avOwk0o5x2gBdIplDyAT9YYbpfU05a/YgXbiPeXbrsNQ5fscwFF9XSv4rNbX8HjgYQCfme2ME/ohKoDIvHr9qiewHJG4JvKioQw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:21 +0300 Message-Id: <2510b8a4c5a72033274ffe68955e482f9a87df1d.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 07/31] qcow2: Remove BDS parameter from qcow2_cache_put() 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+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" This function was only using the BlockDriverState parameter to pass it to qcow2_cache_get_table_idx(). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia --- block/qcow2-cache.c | 2 +- block/qcow2-cluster.c | 28 ++++++++++++++-------------- block/qcow2-refcount.c | 30 +++++++++++++++--------------- block/qcow2.h | 2 +- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index e2502d32ae..bd2bc7e063 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -386,7 +386,7 @@ int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Ca= che *c, uint64_t offset, return qcow2_cache_do_get(bs, c, offset, table, false); } =20 -void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table) +void qcow2_cache_put(Qcow2Cache *c, void **table) { int i =3D qcow2_cache_get_table_idx(c, *table); =20 diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 372cb64366..45d05f86fe 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -310,7 +310,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_ind= ex, uint64_t **table) =20 memcpy(l2_table, old_table, s->cluster_size); =20 - qcow2_cache_put(bs, s->l2_table_cache, (void **) &old_table); + qcow2_cache_put(s->l2_table_cache, (void **) &old_table); } =20 /* write the l2 table to the file */ @@ -338,7 +338,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_ind= ex, uint64_t **table) fail: trace_qcow2_l2_allocate_done(bs, l1_index, ret); if (l2_table !=3D NULL) { - qcow2_cache_put(bs, s->l2_table_cache, (void**) table); + qcow2_cache_put(s->l2_table_cache, (void **) table); } s->l1_table[l1_index] =3D old_l2_offset; if (l2_offset > 0) { @@ -612,7 +612,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, abort(); } =20 - qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 bytes_available =3D (int64_t)c * s->cluster_size; =20 @@ -630,7 +630,7 @@ out: return type; =20 fail: - qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table); + qcow2_cache_put(s->l2_table_cache, (void **)&l2_table); return ret; } =20 @@ -737,13 +737,13 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockD= riverState *bs, * allocated. */ cluster_offset =3D be64_to_cpu(l2_table[l2_index]); if (cluster_offset & L2E_OFFSET_MASK) { - qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); return 0; } =20 cluster_offset =3D qcow2_alloc_bytes(bs, compressed_size); if (cluster_offset < 0) { - qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); return 0; } =20 @@ -760,7 +760,7 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDri= verState *bs, BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); l2_table[l2_index] =3D cpu_to_be64(cluster_offset); - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 return cluster_offset; } @@ -949,7 +949,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, Q= CowL2Meta *m) } =20 =20 - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 /* * If this was a COW, we need to decrease the refcount of the old clus= ter. @@ -1167,7 +1167,7 @@ static int handle_copied(BlockDriverState *bs, uint64= _t guest_offset, =20 /* Cleanup */ out: - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 /* Only return a host offset if we actually made progress. Otherwise we * would make requirements for handle_alloc() that it can't fulfill */ @@ -1315,7 +1315,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, keep_old_clusters =3D true; } =20 - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 if (!alloc_cluster_offset) { /* Allocate, if necessary at a given offset in the image file */ @@ -1671,7 +1671,7 @@ static int discard_single_l2(BlockDriverState *bs, ui= nt64_t offset, qcow2_free_any_clusters(bs, old_l2_entry, 1, type); } =20 - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 return nb_clusters; } @@ -1765,7 +1765,7 @@ static int zero_single_l2(BlockDriverState *bs, uint6= 4_t offset, } } =20 - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 return nb_clusters; } @@ -1968,7 +1968,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); qcow2_cache_depends_on_flush(s->l2_table_cache); } - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); } else { if (l2_dirty) { ret =3D qcow2_pre_write_overlap_check(bs, @@ -1999,7 +1999,7 @@ fail: if (!is_active_l1) { qemu_vfree(l2_table); } else { - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); } } return ret; diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index f0cc4f090a..e93c1acd79 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -277,7 +277,7 @@ int qcow2_get_refcount(BlockDriverState *bs, int64_t cl= uster_index, block_index =3D cluster_index & (s->refcount_block_size - 1); *refcount =3D s->get_refcount(refcount_block, block_index); =20 - qcow2_cache_put(bs, s->refcount_block_cache, &refcount_block); + qcow2_cache_put(s->refcount_block_cache, &refcount_block); =20 return 0; } @@ -442,7 +442,7 @@ static int alloc_refcount_block(BlockDriverState *bs, return -EAGAIN; } =20 - qcow2_cache_put(bs, s->refcount_block_cache, refcount_block); + qcow2_cache_put(s->refcount_block_cache, refcount_block); =20 /* * If we come here, we need to grow the refcount table. Again, a new @@ -494,7 +494,7 @@ static int alloc_refcount_block(BlockDriverState *bs, =20 fail: if (*refcount_block !=3D NULL) { - qcow2_cache_put(bs, s->refcount_block_cache, refcount_block); + qcow2_cache_put(s->refcount_block_cache, refcount_block); } return ret; } @@ -653,7 +653,7 @@ int64_t qcow2_refcount_area(BlockDriverState *bs, uint6= 4_t start_offset, refblock_data); } =20 - qcow2_cache_put(bs, s->refcount_block_cache, &refblock_data); + qcow2_cache_put(s->refcount_block_cache, &refblock_data); } =20 assert(block_offset =3D=3D table_offset); @@ -829,7 +829,7 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(Bloc= kDriverState *bs, /* Load the refcount block and allocate it if needed */ if (table_index !=3D old_table_index) { if (refcount_block) { - qcow2_cache_put(bs, s->refcount_block_cache, &refcount_blo= ck); + qcow2_cache_put(s->refcount_block_cache, &refcount_block); } ret =3D alloc_refcount_block(bs, cluster_index, &refcount_bloc= k); if (ret < 0) { @@ -867,7 +867,7 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(Bloc= kDriverState *bs, table =3D qcow2_cache_is_table_offset(bs, s->refcount_block_ca= che, offset); if (table !=3D NULL) { - qcow2_cache_put(bs, s->refcount_block_cache, &refcount_blo= ck); + qcow2_cache_put(s->refcount_block_cache, &refcount_block); qcow2_cache_discard(bs, s->refcount_block_cache, table); } =20 @@ -890,7 +890,7 @@ fail: =20 /* Write last changed block to disk */ if (refcount_block) { - qcow2_cache_put(bs, s->refcount_block_cache, &refcount_block); + qcow2_cache_put(s->refcount_block_cache, &refcount_block); } =20 /* @@ -1305,7 +1305,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, } } =20 - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); =20 if (addend !=3D 0) { ret =3D qcow2_update_cluster_refcount(bs, l2_offset >> @@ -1333,7 +1333,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, ret =3D bdrv_flush(bs); fail: if (l2_table) { - qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); } =20 s->cache_discards =3D false; @@ -2787,7 +2787,7 @@ static int walk_over_reftable(BlockDriverState *bs, u= int64_t **new_reftable, new_reftable_size, new_refblock, new_refblock_empty, allocated, errp); if (ret < 0) { - qcow2_cache_put(bs, s->refcount_block_cache, &refb= lock); + qcow2_cache_put(s->refcount_block_cache, &refblock= ); return ret; } =20 @@ -2800,7 +2800,7 @@ static int walk_over_reftable(BlockDriverState *bs, u= int64_t **new_reftable, if (new_refcount_bits < 64 && refcount >> new_refcount_bit= s) { uint64_t offset; =20 - qcow2_cache_put(bs, s->refcount_block_cache, &refblock= ); + qcow2_cache_put(s->refcount_block_cache, &refblock); =20 offset =3D ((reftable_index << s->refcount_block_bits) + refblock_index) << s->cluster_bits; @@ -2821,7 +2821,7 @@ static int walk_over_reftable(BlockDriverState *bs, u= int64_t **new_reftable, new_refblock_empty =3D new_refblock_empty && refcount =3D= =3D 0; } =20 - qcow2_cache_put(bs, s->refcount_block_cache, &refblock); + qcow2_cache_put(s->refcount_block_cache, &refblock); } else { /* No refblock means every refcount is 0 */ for (refblock_index =3D 0; refblock_index < s->refcount_block_= size; @@ -3089,14 +3089,14 @@ static int qcow2_discard_refcount_block(BlockDriver= State *bs, offset_to_reftable_index(s, discard_block_= offs), discard_block_offs, s->get_refcount(refblock, block_index)); - qcow2_cache_put(bs, s->refcount_block_cache, &refblock); + qcow2_cache_put(s->refcount_block_cache, &refblock); return -EINVAL; } s->set_refcount(refblock, block_index, 0); =20 qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refblock); =20 - qcow2_cache_put(bs, s->refcount_block_cache, &refblock); + qcow2_cache_put(s->refcount_block_cache, &refblock); =20 if (cluster_index < s->free_cluster_index) { s->free_cluster_index =3D cluster_index; @@ -3149,7 +3149,7 @@ int qcow2_shrink_reftable(BlockDriverState *bs) } else { unused_block =3D buffer_is_zero(refblock, s->cluster_size); } - qcow2_cache_put(bs, s->refcount_block_cache, &refblock); + qcow2_cache_put(s->refcount_block_cache, &refblock); =20 reftable_tmp[i] =3D unused_block ? 0 : cpu_to_be64(s->refcount_tab= le[i]); } diff --git a/block/qcow2.h b/block/qcow2.h index 539c07a46f..7fa195bc22 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -662,7 +662,7 @@ int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c= , uint64_t offset, void **table); int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t of= fset, void **table); -void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table); +void qcow2_cache_put(Qcow2Cache *c, void **table); void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset); void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table); --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507814669135821.8922292594087; Thu, 12 Oct 2017 06:24:29 -0700 (PDT) Received: from localhost ([::1]:45503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dTL-0003Lc-Ay for importer@patchew.org; Thu, 12 Oct 2017 09:24:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dHv-0002YI-Ed for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:12:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dHr-0004f7-8R for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:12:35 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52884) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dHq-0004eE-VL; Thu, 12 Oct 2017 09:12:31 -0400 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 1e2dHp-0006MO-O8; Thu, 12 Oct 2017 15:12:29 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003Zj-ET; Thu, 12 Oct 2017 16:07:28 +0300 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=/tK7/fmsWNEmPETnkbfDG9w5pU8HjSQpL5b5LL8ZdW4=; b=rdEtzJmte73ZF7kVfZpHY+zLbC5cAmvhf1dbeAhyIw4hzhjyjChAwA7ZL0/AeK+Dh0pS90bqHoom2Dc6EO7zcfuDwpbTjqX0mvMxjrxTAOQaFQJOntJkx7FJ/pyqYuA0ucY34oCT7INQtR7IlEazzt3WANKhoiIEaqbH7Vu5uGQRQhsj10zzpRppv1GId/DvkDchV5DvdKNXDGBg7eHR7V94ElJfhacZ1o/ZmBKsIs1Dc/nt2YICtHBsL7M5Gu8UBy1k1nIGaNkcYHdtf2SA0iIy4G+0bcz8+4DbfVgzRKB7O6cVnIYsVzM8AY/fopemFgr0LDa6OAX0cJRfs4Da6A==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:22 +0300 Message-Id: <070b0cebec08d8f7445a6d58e34075f64a239269.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 08/31] qcow2: Remove BDS parameter from qcow2_cache_destroy() 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+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" This function was never using the BlockDriverState parameter so it can be safely removed. Signed-off-by: Alberto Garcia --- block/qcow2-cache.c | 2 +- block/qcow2.c | 16 ++++++++-------- block/qcow2.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index bd2bc7e063..a50a56bd8b 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -130,7 +130,7 @@ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, in= t num_tables) return c; } =20 -int qcow2_cache_destroy(BlockDriverState *bs, Qcow2Cache *c) +int qcow2_cache_destroy(Qcow2Cache *c) { int i; =20 diff --git a/block/qcow2.c b/block/qcow2.c index dff903e05c..ba8139f82c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1031,10 +1031,10 @@ static void qcow2_update_options_commit(BlockDriver= State *bs, int i; =20 if (s->l2_table_cache) { - qcow2_cache_destroy(bs, s->l2_table_cache); + qcow2_cache_destroy(s->l2_table_cache); } if (s->refcount_block_cache) { - qcow2_cache_destroy(bs, s->refcount_block_cache); + qcow2_cache_destroy(s->refcount_block_cache); } s->l2_table_cache =3D r->l2_table_cache; s->refcount_block_cache =3D r->refcount_block_cache; @@ -1060,10 +1060,10 @@ static void qcow2_update_options_abort(BlockDriverS= tate *bs, Qcow2ReopenState *r) { if (r->l2_table_cache) { - qcow2_cache_destroy(bs, r->l2_table_cache); + qcow2_cache_destroy(r->l2_table_cache); } if (r->refcount_block_cache) { - qcow2_cache_destroy(bs, r->refcount_block_cache); + qcow2_cache_destroy(r->refcount_block_cache); } qapi_free_QCryptoBlockOpenOptions(r->crypto_opts); } @@ -1492,10 +1492,10 @@ static int qcow2_do_open(BlockDriverState *bs, QDic= t *options, int flags, s->l1_table =3D NULL; cache_clean_timer_del(bs); if (s->l2_table_cache) { - qcow2_cache_destroy(bs, s->l2_table_cache); + qcow2_cache_destroy(s->l2_table_cache); } if (s->refcount_block_cache) { - qcow2_cache_destroy(bs, s->refcount_block_cache); + qcow2_cache_destroy(s->refcount_block_cache); } qcrypto_block_free(s->crypto); qapi_free_QCryptoBlockOpenOptions(s->crypto_opts); @@ -2078,8 +2078,8 @@ static void qcow2_close(BlockDriverState *bs) } =20 cache_clean_timer_del(bs); - qcow2_cache_destroy(bs, s->l2_table_cache); - qcow2_cache_destroy(bs, s->refcount_block_cache); + qcow2_cache_destroy(s->l2_table_cache); + qcow2_cache_destroy(s->refcount_block_cache); =20 qcrypto_block_free(s->crypto); s->crypto =3D NULL; diff --git a/block/qcow2.h b/block/qcow2.h index 7fa195bc22..ddf60fa290 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -646,7 +646,7 @@ int qcow2_read_snapshots(BlockDriverState *bs); =20 /* qcow2-cache.c functions */ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables); -int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c); +int qcow2_cache_destroy(Qcow2Cache *c); =20 void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table); int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c); --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507815017002941.6983040914055; Thu, 12 Oct 2017 06:30:17 -0700 (PDT) Received: from localhost ([::1]:45539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dYx-0008RE-62 for importer@patchew.org; Thu, 12 Oct 2017 09:30:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dJc-0003vS-U5 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:14:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dJZ-0006FG-CL for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:14:20 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:53279) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dJZ-0006Dg-3B; Thu, 12 Oct 2017 09:14:17 -0400 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 1e2dJX-0006pW-Qe; Thu, 12 Oct 2017 15:14:15 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003Zm-G8; Thu, 12 Oct 2017 16:07:28 +0300 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=AdCuWeWFKJ8OO2KwkKsvFNjZmcso+UZrfXCNUfd5bP0=; b=HYpMr5zirfOI5aVe5W97zEGZsWn8jQ1pdKfEqkj3S7TlAVBIeQTamlCQ7ObjVpFwCuO/kUZlD7j34WSxZFQTxZI1/I0R87B9/x6dh4AFQs8dbqlwZ/lBeafEf+EULz/y3XqdX368+ovv2llwF5mOJ8/NwLKLAF5Z2Imzq73AF2WXTaKB5EuKTG4S8uPY1lq86o76yiO7SWBwmaSHNcrpquktcUsdz5/IzEn9TbaN7refqEFFyp5Bjf6hUDaxI58NH5BF3RLr2fFgYkmLgDrCQqiRDeRqFoVMLhmJ0VKvjLB63WsZBdspsc2k0kyeT1wOElocp8DYjakbglnxqRtohg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:23 +0300 Message-Id: <565e039128a3b791d66b9c469b87e4d492245065.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 09/31] qcow2: Remove BDS parameter from qcow2_cache_clean_unused() 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+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" This function was only using the BlockDriverState parameter to pass it to qcow2_cache_table_release(). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia --- block/qcow2-cache.c | 2 +- block/qcow2.c | 4 ++-- block/qcow2.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index a50a56bd8b..cc7995c4bf 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -81,7 +81,7 @@ static inline bool can_clean_entry(Qcow2Cache *c, int i) t->lru_counter <=3D c->cache_clean_lru_counter; } =20 -void qcow2_cache_clean_unused(BlockDriverState *bs, Qcow2Cache *c) +void qcow2_cache_clean_unused(Qcow2Cache *c) { int i =3D 0; while (i < c->size) { diff --git a/block/qcow2.c b/block/qcow2.c index ba8139f82c..9f55e0a9ff 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -693,8 +693,8 @@ static void cache_clean_timer_cb(void *opaque) { BlockDriverState *bs =3D opaque; BDRVQcow2State *s =3D bs->opaque; - qcow2_cache_clean_unused(bs, s->l2_table_cache); - qcow2_cache_clean_unused(bs, s->refcount_block_cache); + qcow2_cache_clean_unused(s->l2_table_cache); + qcow2_cache_clean_unused(s->refcount_block_cache); timer_mod(s->cache_clean_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + (int64_t) s->cache_clean_interval * 1000); } diff --git a/block/qcow2.h b/block/qcow2.h index ddf60fa290..9e6b5102f0 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -655,7 +655,7 @@ int qcow2_cache_set_dependency(BlockDriverState *bs, Qc= ow2Cache *c, Qcow2Cache *dependency); void qcow2_cache_depends_on_flush(Qcow2Cache *c); =20 -void qcow2_cache_clean_unused(BlockDriverState *bs, Qcow2Cache *c); +void qcow2_cache_clean_unused(Qcow2Cache *c); int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c); =20 int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset, --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507814830801536.0011481315726; Thu, 12 Oct 2017 06:27:10 -0700 (PDT) Received: from localhost ([::1]:45518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dVx-0005gz-3U for importer@patchew.org; Thu, 12 Oct 2017 09:27:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dI7-0002hW-Hs for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:12:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dI6-0004sf-I9 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:12:47 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52921) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dI6-0004qw-8P; Thu, 12 Oct 2017 09:12:46 -0400 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 1e2dI4-0006pW-TJ; Thu, 12 Oct 2017 15:12:45 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003Zp-I5; Thu, 12 Oct 2017 16:07:28 +0300 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=788QrZzELYDioLFlTf2aI2xBaR/vcWzI7tuQ7P+lyQs=; b=meF9n42DXd7NeQcbaJd6o2pFVtlThlCs6zX04InuFmqy/5wQwdHjI4CDqbz2e3AxUVniRMKf6zy235Q7/aZiTySa8y+koRiN6CVMwZBdcgnqKy1TEZAUDX9JeTtxJgffeomFIbMkYTurye/XBRya8m3MuMHSDBp6xJq7ttgLo1/cyy+36quEjpD6YBgzt1ZUyLcmcVGdJWH6prFqLemuWLIKA4yrJi2BeDUKgbhZNe84dzv2mbczD7G1lNkQnj32N4YHsg0m/g3srcu6bn6wLfwI1iTbmgsBTbS9QZc7n5etzL15M4WGWmbYZ74aT8d13aDEgn9mJ3uLs96NEvG4Mw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:24 +0300 Message-Id: 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 10/31] qcow2: Remove BDS parameter from qcow2_cache_discard() 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+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" This function was only using the BlockDriverState parameter to pass it to qcow2_cache_get_table_idx() and qcow2_cache_table_release(). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia --- block/qcow2-cache.c | 2 +- block/qcow2-refcount.c | 6 +++--- block/qcow2.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index cc7995c4bf..4775bec838 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -420,7 +420,7 @@ void *qcow2_cache_is_table_offset(BlockDriverState *bs,= Qcow2Cache *c, return NULL; } =20 -void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table) +void qcow2_cache_discard(Qcow2Cache *c, void *table) { int i =3D qcow2_cache_get_table_idx(c, table); =20 diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index e93c1acd79..6eb71a2a5f 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -868,12 +868,12 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(Bl= ockDriverState *bs, offset); if (table !=3D NULL) { qcow2_cache_put(s->refcount_block_cache, &refcount_block); - qcow2_cache_discard(bs, s->refcount_block_cache, table); + qcow2_cache_discard(s->refcount_block_cache, table); } =20 table =3D qcow2_cache_is_table_offset(bs, s->l2_table_cache, o= ffset); if (table !=3D NULL) { - qcow2_cache_discard(bs, s->l2_table_cache, table); + qcow2_cache_discard(s->l2_table_cache, table); } =20 if (s->discard_passthrough[type]) { @@ -3106,7 +3106,7 @@ static int qcow2_discard_refcount_block(BlockDriverSt= ate *bs, discard_block_offs); if (refblock) { /* discard refblock from the cache if refblock is cached */ - qcow2_cache_discard(bs, s->refcount_block_cache, refblock); + qcow2_cache_discard(s->refcount_block_cache, refblock); } update_refcount_discard(bs, discard_block_offs, s->cluster_size); =20 diff --git a/block/qcow2.h b/block/qcow2.h index 9e6b5102f0..ec0225c016 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -665,7 +665,7 @@ int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Ca= che *c, uint64_t offset, void qcow2_cache_put(Qcow2Cache *c, void **table); void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset); -void qcow2_cache_discard(BlockDriverState *bs, Qcow2Cache *c, void *table); +void qcow2_cache_discard(Qcow2Cache *c, void *table); =20 /* qcow2-bitmap.c functions */ int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *r= es, --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507814865229827.9339377985376; Thu, 12 Oct 2017 06:27:45 -0700 (PDT) Received: from localhost ([::1]:45519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dWa-0006KT-EW for importer@patchew.org; Thu, 12 Oct 2017 09:27:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dIo-0003HN-Vj for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:13:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dIk-0005YO-V7 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:13:30 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:53118) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dIk-0005Wr-LU; Thu, 12 Oct 2017 09:13:26 -0400 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 1e2dIj-0006pW-A4; Thu, 12 Oct 2017 15:13:25 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003Zs-Jq; Thu, 12 Oct 2017 16:07:28 +0300 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=eMOXB/bMpTfujYwAapjQWdKMtCY/HfLuC7qB82XZaHI=; b=kDtvxFdw+5fRwbmW3zFc+gioVuWf3rg9ax+P9O2z7i+JRe9w2lYLv5rKujAGeTxtPxWWQjtl6hKfjFK+aHrHtnWw20LfxbfyrOWkDn7/IXCvlvqP1KLzv+f1TS8u2hzdpZSwkI27xh1rBT+QfobgsfQ9Knym4X4ManNug1zF1ZxRbvHqgvXwyjVGzr9Swb0W/r8zNIAMiZTCXmSL9FSnX/CDFuqK7FrO3yf98uoYcqQjLpxCoaRzAGfiKx0mC4C0nJ3gatQbcEj8vcZ2GiZG81aTTBP5lQHWkYrabEUVpeT8lxtJMsx84E4V9WfDCWtVsJTqfzsyx4xBX7Pbw1Dnkg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:25 +0300 Message-Id: <865d86b08ea789d42d7696778dfe5cfe46892917.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 11/31] qcow2: Remove BDS parameter from qcow2_cache_is_table_offset() 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+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" This function was only using the BlockDriverState parameter to pass it to qcow2_cache_get_table_addr(). This is no longer necessary so this parameter can be removed. Signed-off-by: Alberto Garcia --- block/qcow2-cache.c | 3 +-- block/qcow2-refcount.c | 6 +++--- block/qcow2.h | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 4775bec838..788a1fb31d 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -407,8 +407,7 @@ void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *= table) c->entries[i].dirty =3D true; } =20 -void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c, - uint64_t offset) +void *qcow2_cache_is_table_offset(Qcow2Cache *c, uint64_t offset) { int i; =20 diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 6eb71a2a5f..64cb9f40be 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -864,14 +864,14 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(Bl= ockDriverState *bs, if (refcount =3D=3D 0) { void *table; =20 - table =3D qcow2_cache_is_table_offset(bs, s->refcount_block_ca= che, + table =3D qcow2_cache_is_table_offset(s->refcount_block_cache, offset); if (table !=3D NULL) { qcow2_cache_put(s->refcount_block_cache, &refcount_block); qcow2_cache_discard(s->refcount_block_cache, table); } =20 - table =3D qcow2_cache_is_table_offset(bs, s->l2_table_cache, o= ffset); + table =3D qcow2_cache_is_table_offset(s->l2_table_cache, offse= t); if (table !=3D NULL) { qcow2_cache_discard(s->l2_table_cache, table); } @@ -3102,7 +3102,7 @@ static int qcow2_discard_refcount_block(BlockDriverSt= ate *bs, s->free_cluster_index =3D cluster_index; } =20 - refblock =3D qcow2_cache_is_table_offset(bs, s->refcount_block_cache, + refblock =3D qcow2_cache_is_table_offset(s->refcount_block_cache, discard_block_offs); if (refblock) { /* discard refblock from the cache if refblock is cached */ diff --git a/block/qcow2.h b/block/qcow2.h index ec0225c016..c3ab19ddd0 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -663,8 +663,7 @@ int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c= , uint64_t offset, int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t of= fset, void **table); void qcow2_cache_put(Qcow2Cache *c, void **table); -void *qcow2_cache_is_table_offset(BlockDriverState *bs, Qcow2Cache *c, - uint64_t offset); +void *qcow2_cache_is_table_offset(Qcow2Cache *c, uint64_t offset); void qcow2_cache_discard(Qcow2Cache *c, void *table); =20 /* qcow2-bitmap.c functions */ --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 15078150375441003.4614299804111; Thu, 12 Oct 2017 06:30:37 -0700 (PDT) Received: from localhost ([::1]:45541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dZH-0000Ix-PE for importer@patchew.org; Thu, 12 Oct 2017 09:30:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dIK-0002rC-FC for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:13:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dIG-00053Q-F1 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:13:00 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52952) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dIG-00051v-6e; Thu, 12 Oct 2017 09:12:56 -0400 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 1e2dIE-0006pW-Ug; Thu, 12 Oct 2017 15:12:55 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003Zv-Kx; Thu, 12 Oct 2017 16:07:28 +0300 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=F07fD/iAP4nvDSCh7B2s68r9yciBvkHPNeqYg7I0n+E=; b=DvMsGAfxKvn6n+p5u454NYpokBWQuQK7QrFBwp+7isbV3MULZDxv/EBwAwYzd/i8ILMGb5JJtrbOP8vxDF48jgKx7++vdR6z161KPW5dFc1rpBQwWVCj+EO3AJwCb+vQfZrarkX0vNnD0eyvvnATytTQLn+ffydM48MZsGgdDy5EgCoX9dvMX9ScFwrYJJTVyHl3djWSpintSpfW9K7PnS8OUhMyqW2+snWJJtOBNUc+QOyaMrEftif2rcsRJZYPROTQNoOWEDUzLQilsRfC3JC69fwhHA4f8mQwPv+bsQ9kkyohb0/mGae45AyF43toZna57+2csMV5hZippLucxg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:26 +0300 Message-Id: <0df578270b431a74b00109930825fa6145bf4873.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 12/31] qcow2: Add offset_to_l1_index() 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+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" Similar to offset_to_l2_index(), this function returns the index in the L1 table for a given guest offset. This is only used in a couple of places and it's not a particularly complex calculation, but it makes the code a bit more readable. Although in the qcow2_get_cluster_offset() case the old code was taking advantage of the l1_bits variable, we're going to get rid of the other uses of l1_bits in a later patch anyway, so it doesn't make sense to keep it just for this. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 4 ++-- block/qcow2.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 45d05f86fe..f35bb20dd5 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -533,7 +533,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, =20 /* seek to the l2 offset in the l1 table */ =20 - l1_index =3D offset >> l1_bits; + l1_index =3D offset_to_l1_index(s, offset); if (l1_index >=3D s->l1_size) { type =3D QCOW2_CLUSTER_UNALLOCATED; goto out; @@ -656,7 +656,7 @@ static int get_cluster_table(BlockDriverState *bs, uint= 64_t offset, =20 /* seek to the l2 offset in the l1 table */ =20 - l1_index =3D offset >> (s->l2_bits + s->cluster_bits); + l1_index =3D offset_to_l1_index(s, offset); if (l1_index >=3D s->l1_size) { ret =3D qcow2_grow_l1_table(bs, l1_index + 1, false); if (ret < 0) { diff --git a/block/qcow2.h b/block/qcow2.h index c3ab19ddd0..61c6c27673 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -463,6 +463,11 @@ static inline int64_t size_to_l1(BDRVQcow2State *s, in= t64_t size) return (size + (1ULL << shift) - 1) >> shift; } =20 +static inline int offset_to_l1_index(BDRVQcow2State *s, uint64_t offset) +{ + return offset >> (s->l2_bits + s->cluster_bits); +} + static inline int offset_to_l2_index(BDRVQcow2State *s, int64_t offset) { return (offset >> s->cluster_bits) & (s->l2_size - 1); --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507815424066738.8233251762596; Thu, 12 Oct 2017 06:37:04 -0700 (PDT) Received: from localhost ([::1]:45582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dfR-0005RY-5y for importer@patchew.org; Thu, 12 Oct 2017 09:36:53 -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 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 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==; 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+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" 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 =3D=3D 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, Qemu= Opts *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(BlockDriverStat= e *bs, } } =20 + r->l2_slice_size =3D s->cluster_size / sizeof(uint64_t); r->l2_table_cache =3D qcow2_cache_create(bs, l2_cache_size); r->refcount_block_cache =3D qcow2_cache_create(bs, refcount_cache_size= ); if (r->l2_table_cache =3D=3D NULL || r->refcount_block_cache =3D=3D NU= LL) { @@ -1038,6 +1040,7 @@ static void qcow2_update_options_commit(BlockDriverSt= ate *bs, } s->l2_table_cache =3D r->l2_table_cache; s->refcount_block_cache =3D r->refcount_block_cache; + s->l2_slice_size =3D r->l2_slice_size; =20 s->overlap_check =3D r->overlap_check; s->use_lazy_refcounts =3D 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; --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507814588989562.3107396199981; Thu, 12 Oct 2017 06:23:08 -0700 (PDT) Received: from localhost ([::1]:45490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dRn-00020C-AX for importer@patchew.org; Thu, 12 Oct 2017 09:22:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dJS-0003np-M0 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:14:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dJP-00068h-Fh for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:14:10 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:53224) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dJP-00068J-6G; Thu, 12 Oct 2017 09:14:07 -0400 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 1e2dJN-0006pW-PL; Thu, 12 Oct 2017 15:14:05 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003a1-NH; Thu, 12 Oct 2017 16:07:28 +0300 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=SsMLvCEiIySRlGqfmsUKZgel/5FVoeBAwU1dy7vbpSw=; b=YN8IKEsjqQ5XaEuX0dy9eMFjZ1OTrWQ3TQhG4VBPUF9OH4FJOCMx6ABzc1iXxnwZxGbNGRBoIMyjTrmeBlfMEogxr0DnF1TKcgGAsxJgSUyH3HD9ZtQymPSjR8dozg5KHOTtC6lzXRS254J9dOKt4C/fuhyZSoQOyRxHQGNPMBBL9mPQCSKMGAj6aor9DAI5vJsejJ4OyvVHpzB9sJ+nsYc1eU13LcQdmVy827iqdUdqWKw81ZSvPCaVMNntrabI4hhSx+l7dkA7LOCEHjU4qjSiXI1aqUCz6XF9vMc5PlTtIaRzQUlUlboS1p/CIkLfzsFDK8dVvkHeaydNOoMHwg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:28 +0300 Message-Id: <4a09034dec07286f1dc73be9b34884306a932950.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 14/31] qcow2: Add offset_to_l2_slice_index() 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+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" Similar to offset_to_l2_index(), this function takes a guest offset and returns the index in the L2 slice that contains its L2 entry. An L2 slice has currently the same size as an L2 table (one cluster), so both functions return the same value for now. Signed-off-by: Alberto Garcia --- block/qcow2.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/qcow2.h b/block/qcow2.h index 9c1ea97f0e..341d841836 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -474,6 +474,11 @@ static inline int offset_to_l2_index(BDRVQcow2State *s= , int64_t offset) return (offset >> s->cluster_bits) & (s->l2_size - 1); } =20 +static inline int offset_to_l2_slice_index(BDRVQcow2State *s, int64_t offs= et) +{ + return (offset >> s->cluster_bits) & (s->l2_slice_size - 1); +} + static inline int64_t align_offset(int64_t offset, int n) { offset =3D (offset + n - 1) & ~(n - 1); --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507814399005196.90679373733747; Thu, 12 Oct 2017 06:19:59 -0700 (PDT) Received: from localhost ([::1]:45471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dOz-00080y-8s for importer@patchew.org; Thu, 12 Oct 2017 09:19:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dJ9-0003YD-70 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:13:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dJ5-0005qO-53 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:13:51 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:53175) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dJ4-0005pU-RA; Thu, 12 Oct 2017 09:13:47 -0400 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 1e2dJ3-0006pW-Hn; Thu, 12 Oct 2017 15:13:45 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003a4-Ot; Thu, 12 Oct 2017 16:07:28 +0300 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=AlB6XbDqsDJpCAWPFxPdeDWO25mpdFfKhDTDjyetSRo=; b=npI+cNEPcxLKQY6nBusE6ofxtgubsbk8HwheVwFR3XIV997Yneri60psyW9bA8n2Y2O/vpL62JNKBa3f/MQiQibENuNIbWI8vdT1phXvY5eFKdLtbgaq79VU26iKdtpXe65zScc6j7HDajliA0X7Le2Nm7tJEaCvJ/W+EBu6SejLqPMSGs7DJCD9kwZ/FpkEYchF/OwklKaBITbaPjMT7ISifzkCbgvBxP/Hbv9+5hiP3wfGq59pN24u1gMC+mSVZu59ycG2SgoGfAEUAg5OB1EF6UhlnFTBENW8j+DG6QicM1yNj9aH1tMxiTTQpgjGSyObwfpsbhSFtyO1a1m1LQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:29 +0300 Message-Id: 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 15/31] qcow2: Update l2_load() 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+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" Each entry in the qcow2 L2 cache stores a full L2 table (which uses a complete cluster in the qcow2 image). A cluster is usually too large to be used efficiently as the size for a cache entry, so we want to decouple both values by allowing smaller cache entries. Therefore the qcow2 L2 cache will no longer return full L2 tables but slices instead. This patch updates l2_load() so it can handle L2 slices correctly. Apart from the offset of the L2 table (which we already had) we also need the guest offset in order to calculate which one of the slices we need. An L2 slice has currently the same size as an L2 table (one cluster), so for now this function will load exactly the same data as before. This patch also removes a stale comment about the return value being a pointer to the L2 table. This function returns an error code since 55c17e9821c474d5fcdebdc82ed2fc096777d611. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index f35bb20dd5..aafc19a21b 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -196,20 +196,26 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_= t min_size, /* * l2_load * - * Loads a L2 table into memory. If the table is in the cache, the cache - * is used; otherwise the L2 table is loaded from the image file. + * @bs: The BlockDriverState + * @offset: A guest offset, used to calculate what slice of the L2 + * table to load. + * @l2_offset: Offset to the L2 table in the image file. + * @l2_slice: Location to store the pointer to the L2 slice. * - * Returns a pointer to the L2 table on success, or NULL if the read from - * the image file failed. + * Loads a L2 slice into memory (L2 slices are the parts of L2 tables + * that are loaded by the qcow2 cache). If the slice is in the cache, + * the cache is used; otherwise the L2 slice is loaded from the image + * file. */ - -static int l2_load(BlockDriverState *bs, uint64_t l2_offset, - uint64_t **l2_table) +static int l2_load(BlockDriverState *bs, uint64_t offset, + uint64_t l2_offset, uint64_t **l2_slice) { BDRVQcow2State *s =3D bs->opaque; + int start_of_slice =3D sizeof(uint64_t) * + (offset_to_l2_index(s, offset) - offset_to_l2_slice_index(s, offse= t)); =20 - return qcow2_cache_get(bs, s->l2_table_cache, l2_offset, - (void **)l2_table); + return qcow2_cache_get(bs, s->l2_table_cache, l2_offset + start_of_sli= ce, + (void **)l2_slice); } =20 /* @@ -554,7 +560,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, =20 /* load the l2 table in memory */ =20 - ret =3D l2_load(bs, l2_offset, &l2_table); + ret =3D l2_load(bs, offset, l2_offset, &l2_table); if (ret < 0) { return ret; } @@ -677,7 +683,7 @@ static int get_cluster_table(BlockDriverState *bs, uint= 64_t offset, =20 if (s->l1_table[l1_index] & QCOW_OFLAG_COPIED) { /* load the l2 table in memory */ - ret =3D l2_load(bs, l2_offset, &l2_table); + ret =3D l2_load(bs, offset, l2_offset, &l2_table); if (ret < 0) { return ret; } --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507814707496330.6203826035636; Thu, 12 Oct 2017 06:25:07 -0700 (PDT) Received: from localhost ([::1]:45504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dTz-0003uh-Mf for importer@patchew.org; Thu, 12 Oct 2017 09:25:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dIe-0003AN-To for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:13:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dIa-0005Tg-RA for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:13:20 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:53036) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dIa-0005T5-Ha; Thu, 12 Oct 2017 09:13:16 -0400 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 1e2dIZ-0006pW-9F; Thu, 12 Oct 2017 15:13:15 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003a7-Qb; Thu, 12 Oct 2017 16:07:28 +0300 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=GCCJOZLG9e0P8uuwgYLvPV2KjCLZF14xVPTV/aMPfjA=; b=EwxFqqLHGdUb8swQIIiccUsaix5Fgm6/ycwqNWCyVGrCkmdqrru4IMjVroEOJbKyhW2bJbh+zbBko/Yxn3967/D1UUMTHnQ3KAQpJ22XHxtRcrUY2i+v/WQDekkFMiXMe6nfeeZFrZWbzMFfu66wu78CJS1xY9w4nO86DG73c9Krs1U6SqzR+KyWAttY4o8SrUI9E9u/SGMDhmhk5TX0UFKyXWkhmnl5sHF53hktV8PZmK+o1FH4xoK8bqZqg1pRe8jCx1Htal/XZe7vL1qFsrBcAaznvDVlZJOd5nheA1I9F7WzipHrYD2zXFmLzkKMiyM/rJHdqgRJBEJMF/FHLw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:30 +0300 Message-Id: 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 16/31] qcow2: Update l2_allocate() 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+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" This patch updates l2_allocate() to support the qcow2 cache returning L2 slices instead of full L2 tables. The old code simply gets an L2 table from the cache and initializes it with zeroes or with the contents of an existing table. With a cache that returns slices instead of tables the idea remains the same, but the code must now iterate over all the slices that are contained in an L2 table. Since now we're operating with slices the function can no longer return the newly-allocated table, so it's up to the caller to retrieve the appropriate L2 slice after calling l2_allocate() (note that with this patch the caller is still loading full L2 tables, but we'll deal with that in a separate patch). Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 86 +++++++++++++++++++++++++++++++----------------= ---- 1 file changed, 52 insertions(+), 34 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index aafc19a21b..d3548cc667 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -264,11 +264,12 @@ int qcow2_write_l1_entry(BlockDriverState *bs, int l1= _index) * */ =20 -static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **tabl= e) +static int l2_allocate(BlockDriverState *bs, int l1_index) { BDRVQcow2State *s =3D bs->opaque; uint64_t old_l2_offset; - uint64_t *l2_table =3D NULL; + uint64_t *l2_slice =3D NULL; + unsigned slice, slice_size, n_slices; int64_t l2_offset; int ret; =20 @@ -291,42 +292,50 @@ static int l2_allocate(BlockDriverState *bs, int l1_i= ndex, uint64_t **table) =20 /* allocate a new entry in the l2 cache */ =20 + slice_size =3D s->l2_slice_size * sizeof(uint64_t); + n_slices =3D s->cluster_size / slice_size; + trace_qcow2_l2_allocate_get_empty(bs, l1_index); - ret =3D qcow2_cache_get_empty(bs, s->l2_table_cache, l2_offset, (void*= *) table); - if (ret < 0) { - goto fail; - } - - l2_table =3D *table; - - if ((old_l2_offset & L1E_OFFSET_MASK) =3D=3D 0) { - /* if there was no old l2 table, clear the new table */ - memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); - } else { - uint64_t* old_table; - - /* if there was an old l2 table, read it from the disk */ - BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_COW_READ); - ret =3D qcow2_cache_get(bs, s->l2_table_cache, - old_l2_offset & L1E_OFFSET_MASK, - (void**) &old_table); + for (slice =3D 0; slice < n_slices; slice++) { + ret =3D qcow2_cache_get_empty(bs, s->l2_table_cache, + l2_offset + slice * slice_size, + (void **) &l2_slice); if (ret < 0) { goto fail; } =20 - memcpy(l2_table, old_table, s->cluster_size); + if ((old_l2_offset & L1E_OFFSET_MASK) =3D=3D 0) { + /* if there was no old l2 table, clear the new slice */ + memset(l2_slice, 0, slice_size); + } else { + uint64_t *old_slice; + uint64_t old_l2_slice_offset =3D + (old_l2_offset & L1E_OFFSET_MASK) + slice * slice_size; + + /* if there was an old l2 table, read an slice from the disk */ + BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_COW_READ); + ret =3D qcow2_cache_get(bs, s->l2_table_cache, old_l2_slice_of= fset, + (void **) &old_slice); + if (ret < 0) { + goto fail; + } + + memcpy(l2_slice, old_slice, slice_size); =20 - qcow2_cache_put(s->l2_table_cache, (void **) &old_table); - } + qcow2_cache_put(s->l2_table_cache, (void **) &old_slice); + } + + /* write the l2 slice to the file */ + BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE); =20 - /* write the l2 table to the file */ - BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE); + trace_qcow2_l2_allocate_write_l2(bs, l1_index); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); + ret =3D qcow2_cache_flush(bs, s->l2_table_cache); + if (ret < 0) { + goto fail; + } =20 - trace_qcow2_l2_allocate_write_l2(bs, l1_index); - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); - ret =3D qcow2_cache_flush(bs, s->l2_table_cache); - if (ret < 0) { - goto fail; + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } =20 /* update the L1 entry */ @@ -337,14 +346,13 @@ static int l2_allocate(BlockDriverState *bs, int l1_i= ndex, uint64_t **table) goto fail; } =20 - *table =3D l2_table; trace_qcow2_l2_allocate_done(bs, l1_index, 0); return 0; =20 fail: trace_qcow2_l2_allocate_done(bs, l1_index, ret); - if (l2_table !=3D NULL) { - qcow2_cache_put(s->l2_table_cache, (void **) table); + if (l2_slice !=3D NULL) { + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } s->l1_table[l1_index] =3D old_l2_offset; if (l2_offset > 0) { @@ -688,8 +696,18 @@ static int get_cluster_table(BlockDriverState *bs, uin= t64_t offset, return ret; } } else { + uint64_t new_l2_offset; /* First allocate a new L2 table (and do COW if needed) */ - ret =3D l2_allocate(bs, l1_index, &l2_table); + ret =3D l2_allocate(bs, l1_index); + if (ret < 0) { + return ret; + } + + /* Get the offset of the newly-allocated l2 table */ + new_l2_offset =3D s->l1_table[l1_index] & L1E_OFFSET_MASK; + assert(offset_into_cluster(s, new_l2_offset) =3D=3D 0); + /* Load the l2 table in memory */ + ret =3D l2_load(bs, offset, new_l2_offset, &l2_table); if (ret < 0) { return ret; } --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507814738100579.2073032435763; Thu, 12 Oct 2017 06:25:38 -0700 (PDT) Received: from localhost ([::1]:45505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dUN-0004De-84 for importer@patchew.org; Thu, 12 Oct 2017 09:25:27 -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 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 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==; 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+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" 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 =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 */ @@ -687,11 +687,11 @@ static int get_cluster_table(BlockDriverState *bs, ui= nt64_t offset, return -EIO; } =20 - /* seek the l2 table of the given l2 offset */ + /* seek the l2 slice of the given l2 offset */ =20 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); + /* load the l2 slice in memory */ + ret =3D l2_load(bs, offset, l2_offset, &l2_slice); if (ret < 0) { return ret; } @@ -706,8 +706,8 @@ static int get_cluster_table(BlockDriverState *bs, uint= 64_t offset, /* Get the offset of the newly-allocated l2 table */ new_l2_offset =3D s->l1_table[l1_index] & L1E_OFFSET_MASK; assert(offset_into_cluster(s, new_l2_offset) =3D=3D 0); - /* Load the l2 table in memory */ - ret =3D l2_load(bs, offset, new_l2_offset, &l2_table); + /* Load the l2 slice in memory */ + ret =3D 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, uint= 64_t offset, =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.11.0 From nobody Sat Apr 20 08:17:47 2024 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 15078145266451023.9816643287413; Thu, 12 Oct 2017 06:22:06 -0700 (PDT) Received: from localhost ([::1]:45487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dR4-0001Km-0G for importer@patchew.org; Thu, 12 Oct 2017 09:22:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dHk-0002P7-Kg for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:12:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dHh-0004Wy-62 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:12:24 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52803) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dHg-0004WW-TH; Thu, 12 Oct 2017 09:12:21 -0400 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 1e2dHf-0006MO-I1; Thu, 12 Oct 2017 15:12:19 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003aD-Te; Thu, 12 Oct 2017 16:07:28 +0300 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=xL9HhrvUkPkfeN3IY7sf6zYpYshm0fP7NYRwGdAnaIA=; b=NRRnYYQONbvdpFAWvDcB3BZxP7onj+FDcql8r/RBipKmyKtX1NDZ3q+eNcG3ZM0n8ZDIFKZQm175Owi8wtf4i8UsQu7lQslymEQtd54Zh3BpSdezR9a0EK+hbKz5ENJMhjCzSbhIT3PH6T9l374GqT/qSjZlNyf1hX15lUccFnz82nzOsmP2e3I5jVeS0kUvVWTKkqXWF1HDJ62QxJbcGCAqCmS5W/7Dv/bh+AL00E429YpPY5gBANpFKKY05a4A7YAg0fa5VvERE1QI8cHidOYuumINdGFUzcaHpv9I22K5rRecGT5zgsli6/pt7gUB7ICJufRK6MkMA5NgUTp15A==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:32 +0300 Message-Id: <65c2b2b32a686d3084a1579583334a85b706edcb.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 18/31] qcow2: Update qcow2_get_cluster_offset() 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+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" qcow2_get_cluster_offset() checks how many contiguous bytes are available at a given offset. The returned number of bytes is limited by the amount that can be addressed without having to load more than one L2 table. Since we'll be loading L2 slices instead of full tables this patch changes the limit accordingly using the size of the L2 slice for the calculations instead of the full table size. The l2_table variable is also renamed to l2_slice to reflect this, and offset_to_l2_index() is replaced with offset_to_l2_slice_index(). Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 580fb50869..860e56ec7c 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -522,8 +522,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, { BDRVQcow2State *s =3D bs->opaque; unsigned int l2_index; - uint64_t l1_index, l2_offset, *l2_table; - int l1_bits, c; + uint64_t l1_index, l2_offset, *l2_slice; + int c; unsigned int offset_in_cluster; uint64_t bytes_available, bytes_needed, nb_clusters; QCow2ClusterType type; @@ -532,12 +532,11 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, ui= nt64_t offset, offset_in_cluster =3D offset_into_cluster(s, offset); bytes_needed =3D (uint64_t) *bytes + offset_in_cluster; =20 - l1_bits =3D s->l2_bits + s->cluster_bits; - /* compute how many bytes there are between the start of the cluster - * containing offset and the end of the l1 entry */ - bytes_available =3D (1ULL << l1_bits) - (offset & ((1ULL << l1_bits) -= 1)) - + offset_in_cluster; + * containing offset and the end of the l2 slice that contains + * the entry pointing to it */ + bytes_available =3D (s->l2_slice_size - offset_to_l2_slice_index(s, of= fset)) + << s->cluster_bits; =20 if (bytes_needed > bytes_available) { bytes_needed =3D bytes_available; @@ -566,17 +565,17 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, ui= nt64_t offset, return -EIO; } =20 - /* load the l2 table in memory */ + /* load the l2 slice in memory */ =20 - ret =3D l2_load(bs, offset, l2_offset, &l2_table); + 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); - *cluster_offset =3D be64_to_cpu(l2_table[l2_index]); + l2_index =3D offset_to_l2_slice_index(s, offset); + *cluster_offset =3D be64_to_cpu(l2_slice[l2_index]); =20 nb_clusters =3D size_to_clusters(s, bytes_needed); /* bytes_needed <=3D *bytes + offset_in_cluster, both of which are uns= igned @@ -603,14 +602,14 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, ui= nt64_t offset, case QCOW2_CLUSTER_UNALLOCATED: /* how many empty clusters ? */ c =3D count_contiguous_clusters_unallocated(nb_clusters, - &l2_table[l2_index], typ= e); + &l2_slice[l2_index], typ= e); *cluster_offset =3D 0; break; case QCOW2_CLUSTER_ZERO_ALLOC: case QCOW2_CLUSTER_NORMAL: /* how many allocated clusters ? */ c =3D count_contiguous_clusters(nb_clusters, s->cluster_size, - &l2_table[l2_index], QCOW_OFLAG_ZERO= ); + &l2_slice[l2_index], QCOW_OFLAG_ZERO= ); *cluster_offset &=3D L2E_OFFSET_MASK; if (offset_into_cluster(s, *cluster_offset)) { qcow2_signal_corruption(bs, true, -1, -1, @@ -626,7 +625,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, abort(); } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 bytes_available =3D (int64_t)c * s->cluster_size; =20 @@ -644,7 +643,7 @@ out: return type; =20 fail: - qcow2_cache_put(s->l2_table_cache, (void **)&l2_table); + qcow2_cache_put(s->l2_table_cache, (void **)&l2_slice); return ret; } =20 --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507814820868910.6285135836105; Thu, 12 Oct 2017 06:27:00 -0700 (PDT) Received: from localhost ([::1]:45516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dVg-0005QR-FH for importer@patchew.org; Thu, 12 Oct 2017 09:26:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dHa-0002H5-W1 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:12:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dHX-0004Dz-0B for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:12:14 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52720) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dHW-0004Ai-NK; Thu, 12 Oct 2017 09:12:10 -0400 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 1e2dHV-0006MO-Gt; Thu, 12 Oct 2017 15:12:09 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCy-0003aG-VQ; Thu, 12 Oct 2017 16:07:28 +0300 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=cP780Jf2hpR64NlyGI4GlEjSnbBXjIrC6LJ+4X+QtQw=; b=B4yIFy7z1eoWj3OP85iqCKXssCjXS1CGsua9n2HJfunjfDAK4A2sfTWNa5OW6b8Elfbxp3vokOVQ9EMV5J/wNd6CExabXOfJukLBjmzmH1OwKoYhltAPArAhUpb8GkAv194aK7wmpas35gMqucr6E11rfVcmyhw9fnBYXEX5oZ3u/UB3YlOcn+pfcHC4OJLJgErvW9tr9sFFVlcrvZRoIXzTVYdk2sOUMQjV3qvWFxwI4GKa69ab8JN/6sWnbLDPjxMyZhRvVeKECLTNyJWS+NmMu+chvXu2fdkODD9aAI+gQP2BolMxTtGKB7KY58SmFAI5T0mtN7hVRLPq4TP9xw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:33 +0300 Message-Id: <80992b09202b081f0c7ace58c51d18974e96e79d.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 19/31] 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 , "Denis V . Lunev" , Alberto Garcia , qemu-block@nongnu.org, Max Reitz 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 --- 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 860e56ec7c..1dccdbdd94 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -922,7 +922,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); @@ -949,13 +949,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. @@ -963,16 +963,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 From nobody Sat Apr 20 08:17:47 2024 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 1507814662724891.7989928864172; Thu, 12 Oct 2017 06:24:22 -0700 (PDT) Received: from localhost ([::1]:45502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dT8-0003Bj-W7 for importer@patchew.org; Thu, 12 Oct 2017 09:24:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dHS-0002Bb-Sp for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:12:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dHN-0003yI-1k for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:12:06 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52694) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dHM-0003xv-OV; Thu, 12 Oct 2017 09:12:00 -0400 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 1e2dHL-0006MO-ET; Thu, 12 Oct 2017 15:11:59 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCz-0003aJ-0b; Thu, 12 Oct 2017 16:07:29 +0300 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=EwnQ4sZs8pcoUDe3m4dD8d0O8He4UXTkszzzRkNIRdQ=; b=fL8vPAMSBJqo2NlLEPRcHbMfiyOzyjB8mt9t16ZomJKqGVYy+UHFdCK3+JEA9IflGUNqCcCMeObRdnX+TANzK1nFrAQ05nPjhsFhE4uxMyw4qMy6Aetz335tm9WHKOQihnaJNuGtgorvOaFBbU9jNyofbdne2qK19w2mpA44lgMSJWD8Va17rQJbpRC6m2SzrAFyGyMhZqXL7Au6k85x6arch5HEmkZohKrvBUCzk60lkItnMzxoeuDp/lZdMaqK72N8wuUsWEtbDw4riWkh9McPnJAhceEsh5IoEJZeDIEIraNdxCEOjKvzUsrNQIt443lvPN/t6TUL4vjlH+yQBA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:34 +0300 Message-Id: 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 20/31] qcow2: Update handle_copied() 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+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" handle_copied() loads an L2 table and limits the number of checked clusters to the amount that fits inside that table. Since we'll be loading L2 slices instead of full tables we need to update that limit. 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 --- 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 1dccdbdd94..d74b3b047a 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1119,7 +1119,7 @@ static int handle_copied(BlockDriverState *bs, uint64= _t guest_offset, BDRVQcow2State *s =3D bs->opaque; int l2_index; uint64_t cluster_offset; - uint64_t *l2_table; + uint64_t *l2_slice; uint64_t nb_clusters; unsigned int keep_clusters; int ret; @@ -1131,23 +1131,23 @@ static int handle_copied(BlockDriverState *bs, uint= 64_t guest_offset, =3D=3D offset_into_cluster(s, *host_offset= )); =20 /* - * Calculate the number of clusters to look for. We stop at L2 table + * Calculate the number of clusters to look for. We stop at L2 slice * boundaries to keep things simple. */ nb_clusters =3D size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes); =20 - l2_index =3D offset_to_l2_index(s, guest_offset); - nb_clusters =3D MIN(nb_clusters, s->l2_size - l2_index); + l2_index =3D offset_to_l2_slice_index(s, guest_offset); + nb_clusters =3D MIN(nb_clusters, s->l2_slice_size - l2_index); assert(nb_clusters <=3D INT_MAX); =20 /* Find L2 entry for the first involved cluster */ - ret =3D get_cluster_table(bs, guest_offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, guest_offset, &l2_slice, &l2_index); if (ret < 0) { return ret; } =20 - cluster_offset =3D be64_to_cpu(l2_table[l2_index]); + cluster_offset =3D be64_to_cpu(l2_slice[l2_index]); =20 /* Check how many clusters are already allocated and don't need COW */ if (qcow2_get_cluster_type(cluster_offset) =3D=3D QCOW2_CLUSTER_NORMAL @@ -1175,7 +1175,7 @@ static int handle_copied(BlockDriverState *bs, uint64= _t guest_offset, /* We keep all QCOW_OFLAG_COPIED clusters */ keep_clusters =3D count_contiguous_clusters(nb_clusters, s->cluster_size, - &l2_table[l2_index], + &l2_slice[l2_index], QCOW_OFLAG_COPIED | QCOW_OFLAG_ZERO); assert(keep_clusters <=3D nb_clusters); =20 @@ -1190,7 +1190,7 @@ static int handle_copied(BlockDriverState *bs, uint64= _t guest_offset, =20 /* Cleanup */ out: - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 /* Only return a host offset if we actually made progress. Otherwise we * would make requirements for handle_alloc() that it can't fulfill */ --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507814209176792.763993118653; Thu, 12 Oct 2017 06:16:49 -0700 (PDT) Received: from localhost ([::1]:45453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dLh-0005Kg-2M for importer@patchew.org; Thu, 12 Oct 2017 09:16:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dHG-00021b-Fe for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dHC-0003gW-Pq for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:54 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52670) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dHC-0003et-Gd; Thu, 12 Oct 2017 09:11:50 -0400 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 1e2dHB-0006MO-96; Thu, 12 Oct 2017 15:11:49 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCz-0003aM-27; Thu, 12 Oct 2017 16:07:29 +0300 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=CJDJKTBlhK5vghd6awV+IRWdyy7kZk04SzbtPSdEyvU=; b=A0L8YnV+eiouPTnYEOdvlZBp01o88RT93Raql30z9Op7zT1tAmvf0szbdv/zYIQD8qb5himt36NsAnsBpYD6XN0v2O53uMczQH+7GlsHzu35dG9jP8+TE979SgRmqyOZDPAyz3pTPgZRv1xgsdTBkSnC+XF57NguUjavXaJdOzqa2/052WFVK49rnMG4LK6RkiFuyhEb8DlDnhI8khWE/TIjyk5jpylQcgmMnUxpUUqQc6lH3xJQy9y2nqDV8tDBQOst12wP+eHzme4KLEAXDIGfgv5Ed88DF2SAzvL6zhq0poFIdW1Q9UNFwWIpIRKL/zzRb4/neLKkjfWTR8xmxQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:35 +0300 Message-Id: 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 21/31] qcow2: Update handle_alloc() 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+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" handle_alloc() loads an L2 table and limits the number of checked clusters to the amount that fits inside that table. Since we'll be loading L2 slices instead of full tables we need to update that limit. 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 --- block/qcow2-cluster.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index d74b3b047a..463b24a4fd 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1274,7 +1274,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, { BDRVQcow2State *s =3D bs->opaque; int l2_index; - uint64_t *l2_table; + uint64_t *l2_slice; uint64_t entry; uint64_t nb_clusters; int ret; @@ -1287,29 +1287,29 @@ static int handle_alloc(BlockDriverState *bs, uint6= 4_t guest_offset, assert(*bytes > 0); =20 /* - * Calculate the number of clusters to look for. We stop at L2 table + * Calculate the number of clusters to look for. We stop at L2 slice * boundaries to keep things simple. */ nb_clusters =3D size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes); =20 - l2_index =3D offset_to_l2_index(s, guest_offset); - nb_clusters =3D MIN(nb_clusters, s->l2_size - l2_index); + l2_index =3D offset_to_l2_slice_index(s, guest_offset); + nb_clusters =3D MIN(nb_clusters, s->l2_slice_size - l2_index); assert(nb_clusters <=3D INT_MAX); =20 /* Find L2 entry for the first involved cluster */ - ret =3D get_cluster_table(bs, guest_offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, guest_offset, &l2_slice, &l2_index); if (ret < 0) { return ret; } =20 - entry =3D be64_to_cpu(l2_table[l2_index]); + entry =3D be64_to_cpu(l2_slice[l2_index]); =20 /* For the moment, overwrite compressed clusters one by one */ if (entry & QCOW_OFLAG_COMPRESSED) { nb_clusters =3D 1; } else { - nb_clusters =3D count_cow_clusters(s, nb_clusters, l2_table, l2_in= dex); + nb_clusters =3D count_cow_clusters(s, nb_clusters, l2_slice, l2_in= dex); } =20 /* This function is only called when there were no non-COW clusters, s= o if @@ -1327,7 +1327,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, * nb_clusters already to a range of COW clusters */ int preallocated_nb_clusters =3D count_contiguous_clusters(nb_clusters, s->cluster_size, - &l2_table[l2_index], QCOW_OFLAG_COPI= ED); + &l2_slice[l2_index], QCOW_OFLAG_COPI= ED); assert(preallocated_nb_clusters > 0); =20 nb_clusters =3D preallocated_nb_clusters; @@ -1338,7 +1338,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, keep_old_clusters =3D true; } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 if (!alloc_cluster_offset) { /* Allocate, if necessary at a given offset in the image file */ --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507814359337220.50754321978684; Thu, 12 Oct 2017 06:19:19 -0700 (PDT) Received: from localhost ([::1]:45468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dOK-0007Sv-Ip for importer@patchew.org; Thu, 12 Oct 2017 09:19:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dH6-0001lM-Po for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dH2-0003D1-PJ for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:44 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52641) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dH2-0003B5-H9; Thu, 12 Oct 2017 09:11:40 -0400 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 1e2dH1-0006MO-8D; Thu, 12 Oct 2017 15:11:39 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCz-0003aP-3k; Thu, 12 Oct 2017 16:07:29 +0300 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=zxRt8H+zVGd8lxpYTnoSuuFDc0t6v5QK3iRnEXN0j1g=; b=AJsQQQ7WFQ6rTis/hdPqf4K2IsyevWwJ70S8kUlDGCtT+AQht8W8Vz3g64GwBWkKA3RzwIDFr4s8Z6CdcJUAmB5x+ErUK+za1/w7zhfo3FV6HSb6vSTX2lOCBz4OjQNnE0eT+OGh0Sq5akr7pXOZRnIiA6n+zgknnpe41b0W8n6CcQo5Ua6pnyqtDJrAhLYACQNBP3xuAxjhE+vOLwEqtQwddNOAVt9HDqRVUv3VuBFeW35v8BJgO2kktxwly8nRg4oNBiOk44eTMGYoYNbpFbLuPD6+2KSq6ppt8SQQSOvMmFbrcd+07h6VsprZHMlknKjnAib32wZkQSA1yj9Leg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:36 +0300 Message-Id: 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 22/31] qcow2: Update discard_single_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 , "Denis V . Lunev" , Alberto Garcia , qemu-block@nongnu.org, Max Reitz 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" discard_single_l2() limits the number of clusters to be discarded to the amount that fits inside an L2 table. Since we'll be loading L2 slices instead of full tables we need to update that limit. 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 --- block/qcow2-cluster.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 463b24a4fd..536077079b 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1620,7 +1620,7 @@ int qcow2_decompress_cluster(BlockDriverState *bs, ui= nt64_t cluster_offset) =20 /* * This discards as many clusters of nb_clusters as possible at once (i.e. - * all clusters in the same L2 table) and returns the number of discarded + * all clusters in the same L2 slice) and returns the number of discarded * clusters. */ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, @@ -1628,24 +1628,24 @@ static int discard_single_l2(BlockDriverState *bs, = uint64_t offset, bool full_discard) { BDRVQcow2State *s =3D bs->opaque; - uint64_t *l2_table; + uint64_t *l2_slice; int l2_index; int ret; int i; =20 - ret =3D get_cluster_table(bs, offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, offset, &l2_slice, &l2_index); if (ret < 0) { return ret; } =20 - /* Limit nb_clusters to one L2 table */ - nb_clusters =3D MIN(nb_clusters, s->l2_size - l2_index); + /* Limit nb_clusters to one L2 slice */ + nb_clusters =3D MIN(nb_clusters, s->l2_slice_size - l2_index); assert(nb_clusters <=3D INT_MAX); =20 for (i =3D 0; i < nb_clusters; i++) { uint64_t old_l2_entry; =20 - old_l2_entry =3D be64_to_cpu(l2_table[l2_index + i]); + old_l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); =20 /* * If full_discard is false, make sure that a discarded area reads= back @@ -1683,18 +1683,18 @@ static int discard_single_l2(BlockDriverState *bs, = uint64_t offset, } =20 /* First remove L2 entries */ - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); if (!full_discard && s->qcow_version >=3D 3) { - l2_table[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); + l2_slice[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); } else { - l2_table[l2_index + i] =3D cpu_to_be64(0); + l2_slice[l2_index + i] =3D cpu_to_be64(0); } =20 /* Then decrease the refcount */ qcow2_free_any_clusters(bs, old_l2_entry, 1, type); } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 return nb_clusters; } --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507814022229447.4170204070268; Thu, 12 Oct 2017 06:13:42 -0700 (PDT) Received: from localhost ([::1]:45437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dIx-0002z9-Ai for importer@patchew.org; Thu, 12 Oct 2017 09:13:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dGw-0001f7-T5 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dGs-0002yH-OZ for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:34 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52617) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dGs-0002xd-Df; Thu, 12 Oct 2017 09:11:30 -0400 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 1e2dGr-0006MO-6W; Thu, 12 Oct 2017 15:11:29 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCz-0003aS-58; Thu, 12 Oct 2017 16:07:29 +0300 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=pClQH5AKYcDYYTHZwSkysn7ES8LJUUPh23mLFfMZb78=; b=cCUHkIpcw165Be7B0hZ7Oh07I+HPAxkcPp0LQVriKqum072FvibMmOH+BvoAb4wkWKxnj8mVlPg8r/17AQJEa1DgSc2mWtJ+0gyyM3+SJ82KqWzmFEq0Tv4J+LtZw1eeUVCRTWwQV8YpLx6Q9Tjm4mrrHiASrcsa61Kcc8DaVZPukPUt0L7o7cR2QQWr8qdOAfzkycxUIxgZZtMySBifQhiz8ekba48D5WKnrruMU5HKIeGxKGaBCTAlsA4rMXVPkkPndfRVl2xB/Ph3ojn8c3OK8neVsQNZteqmLFOgEc+O4l88U3kbswMqIOcTGrv9XUM0r5ZtIYRhX7nBTKx1fw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:37 +0300 Message-Id: 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 23/31] qcow2: Update zero_single_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 , "Denis V . Lunev" , Alberto Garcia , qemu-block@nongnu.org, Max Reitz 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" zero_single_l2() limits the number of clusters to be zeroed to the amount that fits inside an L2 table. Since we'll be loading L2 slices instead of full tables we need to update that limit. 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 --- block/qcow2-cluster.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 536077079b..9909c06c24 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1741,33 +1741,33 @@ fail: =20 /* * This zeroes as many clusters of nb_clusters as possible at once (i.e. - * all clusters in the same L2 table) and returns the number of zeroed + * all clusters in the same L2 slice) and returns the number of zeroed * clusters. */ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, uint64_t nb_clusters, int flags) { BDRVQcow2State *s =3D bs->opaque; - uint64_t *l2_table; + uint64_t *l2_slice; int l2_index; int ret; int i; bool unmap =3D !!(flags & BDRV_REQ_MAY_UNMAP); =20 - ret =3D get_cluster_table(bs, offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, offset, &l2_slice, &l2_index); if (ret < 0) { return ret; } =20 - /* Limit nb_clusters to one L2 table */ - nb_clusters =3D MIN(nb_clusters, s->l2_size - l2_index); + /* Limit nb_clusters to one L2 slice */ + nb_clusters =3D MIN(nb_clusters, s->l2_slice_size - l2_index); assert(nb_clusters <=3D INT_MAX); =20 for (i =3D 0; i < nb_clusters; i++) { uint64_t old_offset; QCow2ClusterType cluster_type; =20 - old_offset =3D be64_to_cpu(l2_table[l2_index + i]); + old_offset =3D be64_to_cpu(l2_slice[l2_index + i]); =20 /* * Minimize L2 changes if the cluster already reads back as @@ -1779,16 +1779,16 @@ static int zero_single_l2(BlockDriverState *bs, uin= t64_t offset, continue; } =20 - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); if (cluster_type =3D=3D QCOW2_CLUSTER_COMPRESSED || unmap) { - l2_table[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); + l2_slice[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUE= ST); } else { - l2_table[l2_index + i] |=3D cpu_to_be64(QCOW_OFLAG_ZERO); + l2_slice[l2_index + i] |=3D cpu_to_be64(QCOW_OFLAG_ZERO); } } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 return nb_clusters; } --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507814494344788.7734343647173; Thu, 12 Oct 2017 06:21:34 -0700 (PDT) Received: from localhost ([::1]:45486 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dQY-0000wI-24 for importer@patchew.org; Thu, 12 Oct 2017 09:21:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dGm-0001Xv-Ry for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dGi-0002pE-R6 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:24 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52560) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dGi-0002nE-CV; Thu, 12 Oct 2017 09:11:20 -0400 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 1e2dGh-0006MO-0W; Thu, 12 Oct 2017 15:11:19 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCz-0003aV-6e; Thu, 12 Oct 2017 16:07:29 +0300 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=G1Z4Cg2cZU/nzVEMFFSI8XlSfhiSBvA0s/Wc7sxroxo=; b=KPn/q9+wkK1KVXDf2paRlkP0z4CLS9r2UpyD7bbhshSp/dWyQnD9l8grdByM/25zXQ9v1e41kiXypIqA4foy/1WM9/2FCw5Q0WkcJxIS73qrNlfHE/OvH36wZOF9K/RaDqH6Ld4aPbeb143Ja5FJJw4A6GOU7WNGyhmSjYx3XnouKuYw6QeX844hG5xgoEbxaNEjXNv+0Ra52XJ4/3iwEzjgk+uGS0AbDvNYln5aDpQnJgOzhH7FEA0LiyJhNsnp556xXOWqbtPxK5YpbY5/sj/9bdDNv6TZS88J2ulW1mw1VR2ds85/mnPHzPtEpwl3Qhdz1e0XmXw2GVYrYFQ/kQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:38 +0300 Message-Id: <62214ccece31472d0ca47647c9246f32a19bf78f.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 24/31] qcow2: Update qcow2_update_snapshot_refcount() 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+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" qcow2_update_snapshot_refcount() increases the refcount of all clusters of a given snapshot. In order to do that it needs to load all its L2 tables and iterate over their entries. Since we'll be loading L2 slices instead of full tables we need to add an extra loop that iterates over all slices of each L2 table. This function doesn't need any additional changes so apart from that this patch simply updates the variable name from l2_table to l2_slice. Signed-off-by: Alberto Garcia --- block/qcow2-refcount.c | 150 ++++++++++++++++++++++++++-------------------= ---- 1 file changed, 80 insertions(+), 70 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 64cb9f40be..94ade3d1e1 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1169,18 +1169,22 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, int64_t l1_table_offset, int l1_size, int addend) { BDRVQcow2State *s =3D bs->opaque; - uint64_t *l1_table, *l2_table, l2_offset, entry, l1_size2, refcount; + uint64_t *l1_table, *l2_slice, l2_offset, entry, l1_size2, refcount; bool l1_allocated =3D false; int64_t old_entry, old_l2_offset; + unsigned slice, slice_size, n_slices; int i, j, l1_modified =3D 0, nb_csectors; int ret; =20 assert(addend >=3D -1 && addend <=3D 1); =20 - l2_table =3D NULL; + l2_slice =3D NULL; l1_table =3D NULL; l1_size2 =3D l1_size * sizeof(uint64_t); =20 + slice_size =3D s->l2_slice_size * sizeof(uint64_t); + n_slices =3D s->cluster_size / slice_size; + s->cache_discards =3D true; =20 /* WARNING: qcow2_snapshot_goto relies on this function not using the @@ -1222,91 +1226,97 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, goto fail; } =20 - ret =3D qcow2_cache_get(bs, s->l2_table_cache, l2_offset, - (void**) &l2_table); - if (ret < 0) { - goto fail; - } + for (slice =3D 0; slice < n_slices; slice++) { + ret =3D qcow2_cache_get(bs, s->l2_table_cache, + l2_offset + slice * slice_size, + (void **) &l2_slice); + if (ret < 0) { + goto fail; + } =20 - for (j =3D 0; j < s->l2_size; j++) { - uint64_t cluster_index; - uint64_t offset; + for (j =3D 0; j < s->l2_slice_size; j++) { + uint64_t cluster_index; + uint64_t offset; =20 - entry =3D be64_to_cpu(l2_table[j]); - old_entry =3D entry; - entry &=3D ~QCOW_OFLAG_COPIED; - offset =3D entry & L2E_OFFSET_MASK; + entry =3D be64_to_cpu(l2_slice[j]); + old_entry =3D entry; + entry &=3D ~QCOW_OFLAG_COPIED; + offset =3D entry & L2E_OFFSET_MASK; =20 - switch (qcow2_get_cluster_type(entry)) { - case QCOW2_CLUSTER_COMPRESSED: - nb_csectors =3D ((entry >> s->csize_shift) & - s->csize_mask) + 1; - if (addend !=3D 0) { - ret =3D update_refcount(bs, - (entry & s->cluster_offset_mask) & ~511, + switch (qcow2_get_cluster_type(entry)) { + case QCOW2_CLUSTER_COMPRESSED: + nb_csectors =3D ((entry >> s->csize_shift) & + s->csize_mask) + 1; + if (addend !=3D 0) { + ret =3D update_refcount( + bs, (entry & s->cluster_offset_mask) & ~51= 1, nb_csectors * 512, abs(addend), addend < 0, QCOW2_DISCARD_SNAPSHOT); - if (ret < 0) { + if (ret < 0) { + goto fail; + } + } + /* compressed clusters are never modified */ + refcount =3D 2; + break; + + case QCOW2_CLUSTER_NORMAL: + case QCOW2_CLUSTER_ZERO_ALLOC: + if (offset_into_cluster(s, offset)) { + int l2_index =3D slice * s->l2_slice_size + j; + qcow2_signal_corruption( + bs, true, -1, -1, "Cluster " + "allocation offset %#" PRIx64 + " unaligned (L2 offset: %#" + PRIx64 ", L2 index: %#x)", + offset, l2_offset, l2_index); + ret =3D -EIO; goto fail; } - } - /* compressed clusters are never modified */ - refcount =3D 2; - break; =20 - case QCOW2_CLUSTER_NORMAL: - case QCOW2_CLUSTER_ZERO_ALLOC: - if (offset_into_cluster(s, offset)) { - qcow2_signal_corruption(bs, true, -1, -1, "Cluster= " - "allocation offset %#" PRI= x64 - " unaligned (L2 offset: %#" - PRIx64 ", L2 index: %#x)", - offset, l2_offset, j); - ret =3D -EIO; - goto fail; - } + cluster_index =3D offset >> s->cluster_bits; + assert(cluster_index); + if (addend !=3D 0) { + ret =3D qcow2_update_cluster_refcount( + bs, cluster_index, abs(addend), addend < 0, + QCOW2_DISCARD_SNAPSHOT); + if (ret < 0) { + goto fail; + } + } =20 - cluster_index =3D offset >> s->cluster_bits; - assert(cluster_index); - if (addend !=3D 0) { - ret =3D qcow2_update_cluster_refcount(bs, - cluster_index, abs(addend), addend < 0, - QCOW2_DISCARD_SNAPSHOT); + ret =3D qcow2_get_refcount(bs, cluster_index, &ref= count); if (ret < 0) { goto fail; } - } + break; =20 - ret =3D qcow2_get_refcount(bs, cluster_index, &refcoun= t); - if (ret < 0) { - goto fail; - } - break; + case QCOW2_CLUSTER_ZERO_PLAIN: + case QCOW2_CLUSTER_UNALLOCATED: + refcount =3D 0; + break; =20 - case QCOW2_CLUSTER_ZERO_PLAIN: - case QCOW2_CLUSTER_UNALLOCATED: - refcount =3D 0; - break; - - default: - abort(); - } + default: + abort(); + } =20 - if (refcount =3D=3D 1) { - entry |=3D QCOW_OFLAG_COPIED; - } - if (entry !=3D old_entry) { - if (addend > 0) { - qcow2_cache_set_dependency(bs, s->l2_table_cache, - s->refcount_block_cache); + if (refcount =3D=3D 1) { + entry |=3D QCOW_OFLAG_COPIED; + } + if (entry !=3D old_entry) { + if (addend > 0) { + qcow2_cache_set_dependency(bs, s->l2_table_cac= he, + s->refcount_block_c= ache); + } + l2_slice[j] =3D cpu_to_be64(entry); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, + l2_slice); } - l2_table[j] =3D cpu_to_be64(entry); - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_tab= le); } + + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); - if (addend !=3D 0) { ret =3D qcow2_update_cluster_refcount(bs, l2_offset >> s->cluster_bits, @@ -1332,8 +1342,8 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, =20 ret =3D bdrv_flush(bs); fail: - if (l2_table) { - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + if (l2_slice) { + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } =20 s->cache_discards =3D false; --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507814472744220.15382378940546; Thu, 12 Oct 2017 06:21:12 -0700 (PDT) Received: from localhost ([::1]:45480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dQ9-0000cW-SB for importer@patchew.org; Thu, 12 Oct 2017 09:21:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dGc-0001Pz-Ls for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dGY-0002I7-Kw for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:14 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52480) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dGY-00028p-87; Thu, 12 Oct 2017 09:11:10 -0400 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 1e2dGW-0006MO-Su; Thu, 12 Oct 2017 15:11:09 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCz-0003aY-7z; Thu, 12 Oct 2017 16:07:29 +0300 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=7f14lSHUEydxKh/Irov2y/CSPEHZX8jyEOBdKFaFOQk=; b=C3mF7St5zPXW3uZm5qE2LAHEKajQpV5DM2GEY7s828JmfZiGlxacZ65U+/vOJlXr8xae/7fLD9MlqtNEaYwVfORc6ekA4u2tRsWKMWcVxfANkyQIbFSHA2WdHGuxxrUBkot7j/pDIm2lLQIpjEq3AqLhxJb5kBSfnicLycWS42UPWsSVwDe8frreq8gbMz86MXFNvJddhZxeq69Dt7SoQRKuc6fq8vz2jHYBRPtLXYffYG0gcyVPEBh9PkttOd75qbb1wjIsdqSEHVOiUgtbJFVD8Nk6MA6jlObTN5GCTNQI7+Ok+JGbQOr4EvlkcXfzRZi3XayWHvQSuOgrJJy6Vw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:39 +0300 Message-Id: <00f274ec5108e8caf48deef13b675f2f5a62ff1b.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 25/31] qcow2: Update expand_zero_clusters_in_l1() 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+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" expand_zero_clusters_in_l1() expands zero clusters as a necessary step to downgrade qcow2 images to a version that doesn't support metadata zero clusters. This function takes an L1 table (which may or may not be active) and iterates over all its L2 tables looking for zero clusters. Since we'll be loading L2 slices instead of full tables we need to add an extra loop that iterates over all slices of each L2 table, and we should also use the slice size when allocating the buffer used when the L1 table is not active. As a consequence of the new loop the refcount data also needs to be loaded before the L2 data, but this is a trivial change with no side effects. This function doesn't need any additional changes so apart from that this patch simply updates the variable name from l2_table to l2_slice. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 207 +++++++++++++++++++++++++++-------------------= ---- 1 file changed, 110 insertions(+), 97 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 9909c06c24..eb5094e593 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1852,15 +1852,19 @@ static int expand_zero_clusters_in_l1(BlockDriverSt= ate *bs, uint64_t *l1_table, { BDRVQcow2State *s =3D bs->opaque; bool is_active_l1 =3D (l1_table =3D=3D s->l1_table); - uint64_t *l2_table =3D NULL; + uint64_t *l2_slice =3D NULL; + unsigned slice, slice_size, n_slices; int ret; int i, j; =20 + slice_size =3D s->l2_slice_size * sizeof(uint64_t); + n_slices =3D s->cluster_size / slice_size; + if (!is_active_l1) { /* inactive L2 tables require a buffer to be stored in when loading * them from disk */ - l2_table =3D qemu_try_blockalign(bs->file->bs, s->cluster_size); - if (l2_table =3D=3D NULL) { + l2_slice =3D qemu_try_blockalign(bs->file->bs, slice_size); + if (l2_slice =3D=3D NULL) { return -ENOMEM; } } @@ -1887,124 +1891,133 @@ static int expand_zero_clusters_in_l1(BlockDriver= State *bs, uint64_t *l1_table, goto fail; } =20 - if (is_active_l1) { - /* get active L2 tables from cache */ - ret =3D qcow2_cache_get(bs, s->l2_table_cache, l2_offset, - (void **)&l2_table); - } else { - /* load inactive L2 tables from disk */ - ret =3D bdrv_read(bs->file, l2_offset / BDRV_SECTOR_SIZE, - (void *)l2_table, s->cluster_sectors); - } - if (ret < 0) { - goto fail; - } - ret =3D qcow2_get_refcount(bs, l2_offset >> s->cluster_bits, &l2_refcount); if (ret < 0) { goto fail; } =20 - for (j =3D 0; j < s->l2_size; j++) { - uint64_t l2_entry =3D be64_to_cpu(l2_table[j]); - int64_t offset =3D l2_entry & L2E_OFFSET_MASK; - QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(l2_en= try); - - if (cluster_type !=3D QCOW2_CLUSTER_ZERO_PLAIN && - cluster_type !=3D QCOW2_CLUSTER_ZERO_ALLOC) { - continue; + for (slice =3D 0; slice < n_slices; slice++) { + uint64_t slice_offset =3D l2_offset + slice * slice_size; + if (is_active_l1) { + /* get active L2 tables from cache */ + ret =3D qcow2_cache_get(bs, s->l2_table_cache, slice_offse= t, + (void **)&l2_slice); + } else { + /* load inactive L2 tables from disk */ + ret =3D bdrv_read(bs->file, slice_offset >> BDRV_SECTOR_BI= TS, + (void *)l2_slice, + slice_size >> BDRV_SECTOR_BITS); + } + if (ret < 0) { + goto fail; } =20 - if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { - if (!bs->backing) { - /* not backed; therefore we can simply deallocate the - * cluster */ - l2_table[j] =3D 0; - l2_dirty =3D true; + for (j =3D 0; j < s->l2_slice_size; j++) { + uint64_t l2_entry =3D be64_to_cpu(l2_slice[j]); + int64_t offset =3D l2_entry & L2E_OFFSET_MASK; + QCow2ClusterType cluster_type =3D + qcow2_get_cluster_type(l2_entry); + + if (cluster_type !=3D QCOW2_CLUSTER_ZERO_PLAIN && + cluster_type !=3D QCOW2_CLUSTER_ZERO_ALLOC) { continue; } =20 - offset =3D qcow2_alloc_clusters(bs, s->cluster_size); - if (offset < 0) { - ret =3D offset; - goto fail; - } + if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { + if (!bs->backing) { + /* not backed; therefore we can simply deallocate = the + * cluster */ + l2_slice[j] =3D 0; + l2_dirty =3D true; + continue; + } =20 - if (l2_refcount > 1) { - /* For shared L2 tables, set the refcount accordingly = (it is - * already 1 and needs to be l2_refcount) */ - ret =3D qcow2_update_cluster_refcount(bs, - offset >> s->cluster_bits, + offset =3D qcow2_alloc_clusters(bs, s->cluster_size); + if (offset < 0) { + ret =3D offset; + goto fail; + } + + if (l2_refcount > 1) { + /* For shared L2 tables, set the refcount accordin= gly + * (it is already 1 and needs to be l2_refcount) */ + ret =3D qcow2_update_cluster_refcount( + bs, offset >> s->cluster_bits, refcount_diff(1, l2_refcount), false, QCOW2_DISCARD_OTHER); - if (ret < 0) { + if (ret < 0) { + qcow2_free_clusters(bs, offset, s->cluster_siz= e, + QCOW2_DISCARD_OTHER); + goto fail; + } + } + } + + if (offset_into_cluster(s, offset)) { + int l2_index =3D slice * s->l2_slice_size + j; + qcow2_signal_corruption( + bs, true, -1, -1, + "Cluster allocation offset " + "%#" PRIx64 " unaligned (L2 offset: %#" + PRIx64 ", L2 index: %#x)", offset, + l2_offset, l2_index); + if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { qcow2_free_clusters(bs, offset, s->cluster_size, - QCOW2_DISCARD_OTHER); - goto fail; + QCOW2_DISCARD_ALWAYS); } + ret =3D -EIO; + goto fail; } - } =20 - if (offset_into_cluster(s, offset)) { - qcow2_signal_corruption(bs, true, -1, -1, - "Cluster allocation offset " - "%#" PRIx64 " unaligned (L2 offset= : %#" - PRIx64 ", L2 index: %#x)", offset, - l2_offset, j); - if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { - qcow2_free_clusters(bs, offset, s->cluster_size, - QCOW2_DISCARD_ALWAYS); + ret =3D qcow2_pre_write_overlap_check(bs, 0, offset, + s->cluster_size); + if (ret < 0) { + if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { + qcow2_free_clusters(bs, offset, s->cluster_size, + QCOW2_DISCARD_ALWAYS); + } + goto fail; } - ret =3D -EIO; - goto fail; - } =20 - ret =3D qcow2_pre_write_overlap_check(bs, 0, offset, s->cluste= r_size); - if (ret < 0) { - if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { - qcow2_free_clusters(bs, offset, s->cluster_size, - QCOW2_DISCARD_ALWAYS); + ret =3D bdrv_pwrite_zeroes(bs->file, offset, s->cluster_si= ze, 0); + if (ret < 0) { + if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { + qcow2_free_clusters(bs, offset, s->cluster_size, + QCOW2_DISCARD_ALWAYS); + } + goto fail; } - goto fail; - } =20 - ret =3D bdrv_pwrite_zeroes(bs->file, offset, s->cluster_size, = 0); - if (ret < 0) { - if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { - qcow2_free_clusters(bs, offset, s->cluster_size, - QCOW2_DISCARD_ALWAYS); + if (l2_refcount =3D=3D 1) { + l2_slice[j] =3D cpu_to_be64(offset | QCOW_OFLAG_COPIED= ); + } else { + l2_slice[j] =3D cpu_to_be64(offset); } - goto fail; + l2_dirty =3D true; } =20 - if (l2_refcount =3D=3D 1) { - l2_table[j] =3D cpu_to_be64(offset | QCOW_OFLAG_COPIED); + if (is_active_l1) { + if (l2_dirty) { + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_sli= ce); + qcow2_cache_depends_on_flush(s->l2_table_cache); + } + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } else { - l2_table[j] =3D cpu_to_be64(offset); - } - l2_dirty =3D true; - } + if (l2_dirty) { + ret =3D qcow2_pre_write_overlap_check( + bs, QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2, + slice_offset, slice_size); + if (ret < 0) { + goto fail; + } =20 - if (is_active_l1) { - if (l2_dirty) { - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); - qcow2_cache_depends_on_flush(s->l2_table_cache); - } - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); - } else { - if (l2_dirty) { - ret =3D qcow2_pre_write_overlap_check(bs, - QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2, l2_offs= et, - s->cluster_size); - if (ret < 0) { - goto fail; - } - - ret =3D bdrv_write(bs->file, l2_offset / BDRV_SECTOR_SIZE, - (void *)l2_table, s->cluster_sectors); - if (ret < 0) { - goto fail; + ret =3D bdrv_write(bs->file, slice_offset >> BDRV_SECT= OR_BITS, + (void *)l2_slice, + slice_size >> BDRV_SECTOR_BITS); + if (ret < 0) { + goto fail; + } } } } @@ -2018,11 +2031,11 @@ static int expand_zero_clusters_in_l1(BlockDriverSt= ate *bs, uint64_t *l1_table, ret =3D 0; =20 fail: - if (l2_table) { + if (l2_slice) { if (!is_active_l1) { - qemu_vfree(l2_table); + qemu_vfree(l2_slice); } else { - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } } return ret; --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507814299475350.69958548141346; Thu, 12 Oct 2017 06:18:19 -0700 (PDT) Received: from localhost ([::1]:45464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dNG-0006fG-GG for importer@patchew.org; Thu, 12 Oct 2017 09:18:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dGS-0001Gg-Ef for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dGO-0001cC-FB for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:04 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52452) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dGO-0001YY-5c; Thu, 12 Oct 2017 09:11:00 -0400 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 1e2dGM-0006MO-RS; Thu, 12 Oct 2017 15:10:58 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCz-0003ab-9I; Thu, 12 Oct 2017 16:07:29 +0300 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=uFDeYvxX2OIPpz0ZHBdw24rUur+df7Ywo60hNeGBmyE=; b=GklAHMMXe/rLrMnD8ge/k1mbYCBfBbYLqoueUVRY650H7g9ueRgs0YJcypQxqq/ovafi6mMxmit+qR7wV0Z+1K+0Re//ptgGw994rCIcTqfTAcuNCbokE2PqDdL3NZx020sePcYONqMxVHq68/akFCug21fgO9SwyZyuTv8rmN+g/S95Opai/d0vYeZgJesicyDi0u9GS4pN3FdpLL7YnUmPNMcFDIpJ/2shR5iGEs4IYR36XA+lS5xFKeMHv2zReG4KQB8PdAcDw4gvQiIJLYRTxsuhQG+71TkfkAds+wfeBpFQ0J3WAvByASUcjbtgEeTM32S32GlFjudzVyi5pg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:40 +0300 Message-Id: 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 26/31] qcow2: Update qcow2_truncate() 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+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" The qcow2_truncate() code is mostly independent from whether we're using L2 slices or full L2 tables, but in full and falloc preallocation modes new L2 tables are allocated using qcow2_alloc_cluster_link_l2(). Therefore the code needs to be modified to ensure that all nb_clusters that are processed in each call can be allocated with just one L2 slice. Signed-off-by: Alberto Garcia --- block/qcow2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index e5458fcffd..63e88a1d6e 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3252,8 +3252,9 @@ static int qcow2_truncate(BlockDriverState *bs, int64= _t offset, guest_offset =3D old_length; while (nb_new_data_clusters) { int64_t guest_cluster =3D guest_offset >> s->cluster_bits; - int64_t nb_clusters =3D MIN(nb_new_data_clusters, - s->l2_size - guest_cluster % s->l2_s= ize); + int64_t nb_clusters =3D MIN( + nb_new_data_clusters, + s->l2_slice_size - guest_cluster % s->l2_slice_size); QCowL2Meta allocation =3D { .offset =3D guest_offset, .alloc_offset =3D host_offset, --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507814141988884.0480058797209; Thu, 12 Oct 2017 06:15:41 -0700 (PDT) Received: from localhost ([::1]:45451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dKv-0004cD-6s for importer@patchew.org; Thu, 12 Oct 2017 09:15:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dGF-00016Z-Mi for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:10:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dGE-0001B3-8Q for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:10:51 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52429) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dGD-000191-Ve; Thu, 12 Oct 2017 09:10:50 -0400 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 1e2dGC-0006MO-Lx; Thu, 12 Oct 2017 15:10:48 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCz-0003ae-Aa; Thu, 12 Oct 2017 16:07:29 +0300 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=NoyzltaMDfK7vkSufSSg52fnAyOO3KAo80cwMeAhF/I=; b=sYuXkungq5F/Yt97yuqh0Dt6mLIhRO6bKpc1wa3fA4sZMOReBZBjwcNUm3VzH26xZti79N0FiuAiuGBr+GPbPDp+Y9gIKIKWht9xfdLeUW9ktvhSlFnLJisRxTBFhUYD8XhDqRM83DEh3yvzsYC7r71fQKTXqJz+GDQTINl1q4elnn9yM1qHbRnVOCbRmz1eVEafGGTWOVHegPsN4DGxjAHhB+3ux5ZQjviD9AiO3OnE3lZwM7yJsAKDY8s7gkf1K1N4xs8JaPxQsoskdZfHdUA2/2oG//zJbpaN3fZ0vk9POfQ3b7kVW5PFaFn40DCFxEF2zCZ6RwXR9L7RTPL9Ww==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:41 +0300 Message-Id: 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 27/31] qcow2: Rename l2_table in qcow2_alloc_compressed_cluster_offset() 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+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" This function doesn't need any changes to support L2 slices, but since it's now dealing with slices intead of full tables, the l2_table variable is renamed for clarity. Signed-off-by: Alberto Garcia --- 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 eb5094e593..e7b07d3366 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -747,26 +747,26 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockD= riverState *bs, { BDRVQcow2State *s =3D bs->opaque; int l2_index, ret; - uint64_t *l2_table; + uint64_t *l2_slice; int64_t cluster_offset; int nb_csectors; =20 - ret =3D get_cluster_table(bs, offset, &l2_table, &l2_index); + ret =3D get_cluster_table(bs, offset, &l2_slice, &l2_index); if (ret < 0) { return 0; } =20 /* Compression can't overwrite anything. Fail if the cluster was alrea= dy * allocated. */ - cluster_offset =3D be64_to_cpu(l2_table[l2_index]); + cluster_offset =3D be64_to_cpu(l2_slice[l2_index]); if (cluster_offset & L2E_OFFSET_MASK) { - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); return 0; } =20 cluster_offset =3D qcow2_alloc_bytes(bs, compressed_size); if (cluster_offset < 0) { - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); return 0; } =20 @@ -781,9 +781,9 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDri= verState *bs, /* compressed clusters never have the copied flag */ =20 BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); - l2_table[l2_index] =3D cpu_to_be64(cluster_offset); - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); + l2_slice[l2_index] =3D cpu_to_be64(cluster_offset); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 return cluster_offset; } --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507813963814863.9417053177374; Thu, 12 Oct 2017 06:12:43 -0700 (PDT) Received: from localhost ([::1]:45434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dHw-0002BS-Ln for importer@patchew.org; Thu, 12 Oct 2017 09:12:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dG5-00010I-9l for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:10:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dG4-0000ii-Dx for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:10:41 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52400) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dG4-0000ef-3N; Thu, 12 Oct 2017 09:10:40 -0400 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 1e2dG2-0006MO-Kl; Thu, 12 Oct 2017 15:10:38 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCz-0003ah-Bw; Thu, 12 Oct 2017 16:07:29 +0300 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=7Dx6sWuXbxcFcmOVmV1xRfEs0qW1Y+OPQFzJmlxBBoo=; b=MHx8qk4S6fBp5sirUTMmOeADBfpEyoEsBq/lNnYsbcP2G29ACGM2Mw26Owt4wfMe5MN8dIh06dXtNyg2h1mumRhux+xzC4hyRUuFzEAqAoDU7pubhs/FLsuIHU45ciyNY429JKLD1ix0L9+V77WTESJgJcu/GJK36OY//Py8a5ozGAmnUknEE50xcB26cxVRohqcB3KR5ZYmp93AsgmDJfwRybMMJoXVVpj+6us2D6RWk3SGpv14taquee+aaPvXRxC0aKVQaG4IIkDxsjQlCWRyg2ev2hpOXCcdxVUwISXe8fXfB/szmpc/gc5N97hZlAsOBTDTRfsyqKcgkTL0zw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:42 +0300 Message-Id: <97641359a12a95f2cc8cad3441432c552da6d369.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 28/31] qcow2: Rename l2_table in count_contiguous_clusters() 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+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" This function doesn't need any changes to support L2 slices, but since it's now dealing with slices intead of full tables, the l2_table variable is renamed for clarity. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index e7b07d3366..a961901da0 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -363,19 +363,19 @@ fail: } =20 /* - * Checks how many clusters in a given L2 table are contiguous in the image + * Checks how many clusters in a given L2 slice are contiguous in the image * file. As soon as one of the flags in the bitmask stop_flags changes com= pared * to the first cluster, the search is stopped and the cluster is not coun= ted * as contiguous. (This allows it, for example, to stop at the first compr= essed * cluster which may require a different handling) */ static int count_contiguous_clusters(int nb_clusters, int cluster_size, - uint64_t *l2_table, uint64_t stop_flags) + uint64_t *l2_slice, uint64_t stop_flags) { int i; QCow2ClusterType first_cluster_type; uint64_t mask =3D stop_flags | L2E_OFFSET_MASK | QCOW_OFLAG_COMPRESSED; - uint64_t first_entry =3D be64_to_cpu(l2_table[0]); + uint64_t first_entry =3D be64_to_cpu(l2_slice[0]); uint64_t offset =3D first_entry & mask; =20 if (!offset) { @@ -388,7 +388,7 @@ static int count_contiguous_clusters(int nb_clusters, i= nt cluster_size, first_cluster_type =3D=3D QCOW2_CLUSTER_ZERO_ALLOC); =20 for (i =3D 0; i < nb_clusters; i++) { - uint64_t l2_entry =3D be64_to_cpu(l2_table[i]) & mask; + uint64_t l2_entry =3D be64_to_cpu(l2_slice[i]) & mask; if (offset + (uint64_t) i * cluster_size !=3D l2_entry) { break; } --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507814318599292.7706591403314; Thu, 12 Oct 2017 06:18:38 -0700 (PDT) Received: from localhost ([::1]:45467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dNg-0006wg-QX for importer@patchew.org; Thu, 12 Oct 2017 09:18:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dGT-0001HZ-Go for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dGP-0001fd-D8 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:11:05 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52380) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dGP-0000Lc-3Y; Thu, 12 Oct 2017 09:11:01 -0400 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 1e2dFs-0006MO-Iq; Thu, 12 Oct 2017 15:10:28 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCz-0003ak-De; Thu, 12 Oct 2017 16:07:29 +0300 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=wkojKuYkCxgIE6sBvxs7K8OAvNWYGOouYqEWfKFX8bc=; b=pWlQ4E8ERwPgT2q0Og9a0diHZM99hWI4FyzyeNLVTqdtQ+k96jFdS2IeWQyFUWQFxKN4/ZOaG5hjthMs5Zr0sOPe5/D6s7tQABoHXjhmrRBBuRgWmmwtYD0c8TwqU6a6aMEavZOemX+lelppBYrg2TZ7Dl7RP33DSxSlaWXf0m3NnaS28C6AOQoeKgmPd9KZ7khxTgnH4DXdBCaoyCT1HcPNbeGlwsIojkt6nj0RSwkDwVn4d144355RbkyQhDr9hGiNpvHYHTwJF14Dih1scVkcxAe3NeXQtdYFyIAAUxtXrn4u+qEbYXAJFwNlBgoBLiu+09sWWPBpiqOqNkwHng==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:43 +0300 Message-Id: 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 29/31] qcow2: Rename l2_table in count_contiguous_clusters_unallocated() 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+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" This function doesn't need any changes to support L2 slices, but since it's now dealing with slices intead of full tables, the l2_table variable is renamed for clarity. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index a961901da0..bc94467733 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -399,10 +399,10 @@ static int count_contiguous_clusters(int nb_clusters,= int cluster_size, =20 /* * Checks how many consecutive unallocated clusters in a given L2 - * table have the same cluster type. + * slice have the same cluster type. */ static int count_contiguous_clusters_unallocated(int nb_clusters, - uint64_t *l2_table, + uint64_t *l2_slice, QCow2ClusterType wanted_t= ype) { int i; @@ -410,7 +410,7 @@ static int count_contiguous_clusters_unallocated(int nb= _clusters, assert(wanted_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN || wanted_type =3D=3D QCOW2_CLUSTER_UNALLOCATED); for (i =3D 0; i < nb_clusters; i++) { - uint64_t entry =3D be64_to_cpu(l2_table[i]); + uint64_t entry =3D be64_to_cpu(l2_slice[i]); QCow2ClusterType type =3D qcow2_get_cluster_type(entry); =20 if (type !=3D wanted_type) { --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 150781411707989.12876035538852; Thu, 12 Oct 2017 06:15:17 -0700 (PDT) Received: from localhost ([::1]:45444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dKO-00048I-4x for importer@patchew.org; Thu, 12 Oct 2017 09:15:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dGG-00017a-Lk for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:10:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dGF-0001Dr-Nv for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:10:52 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52304) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dGF-0008JV-Ev; Thu, 12 Oct 2017 09:10:51 -0400 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 1e2dFi-0006MO-E3; Thu, 12 Oct 2017 15:10:18 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCz-0003an-F8; Thu, 12 Oct 2017 16:07:29 +0300 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=jv7VABHtfSbnAV5/F2P2VAfXiB+tWVPcgCtqkPxiRxQ=; b=K9t/WmyNdnL12vuhcNJ/2Csye+8WpUhMPsCAzb1sf1hMlJaaJcGwRsi4v7R4ibwGdrKPZ7jpM4H6FIZlpb8gklG00kseV3mT8SXPKd/zUGXxVWPncXMAlV/glOfBPtdOROr2KROvUJeVDRX9Wi79OCp9PcrXguUCq/66ySNsG1BgOywVoo3ReyQVJmYXGRjvBL02U0U8N5L/kPrh0VQRH66E8feMeTqg6vgTU7011A0mZKa4rbKYrrHv1pUvwcZtDUYtpTSuq9wJofEKyoEAYD7qyBrbwPk/wii6/gUGZLy6eGUrXMRdGqnISWF3aHl5LQe6ihLmlRf1K1xj0vNMoA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:44 +0300 Message-Id: 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 30/31] qcow2: Rename l2_table in count_cow_clusters() 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+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" This function doesn't need any changes to support L2 slices, but since it's now dealing with slices intead of full tables, the l2_table variable is renamed for clarity. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index bc94467733..465140b388 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -999,12 +999,12 @@ err: * which must copy from the backing file) */ static int count_cow_clusters(BDRVQcow2State *s, int nb_clusters, - uint64_t *l2_table, int l2_index) + uint64_t *l2_slice, int l2_index) { int i; =20 for (i =3D 0; i < nb_clusters; i++) { - uint64_t l2_entry =3D be64_to_cpu(l2_table[l2_index + i]); + uint64_t l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(l2_entry); =20 switch(cluster_type) { --=20 2.11.0 From nobody Sat Apr 20 08:17:47 2024 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 1507813966313624.6178004752111; Thu, 12 Oct 2017 06:12:46 -0700 (PDT) Received: from localhost ([::1]:45435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dI3-0002EW-F7 for importer@patchew.org; Thu, 12 Oct 2017 09:12:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2dG7-00011S-0g for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:10:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2dG5-0000mD-G0 for qemu-devel@nongnu.org; Thu, 12 Oct 2017 09:10:42 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:52230) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2dG5-0007jb-36; Thu, 12 Oct 2017 09:10:41 -0400 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 1e2dFY-0006MO-BW; Thu, 12 Oct 2017 15:10:08 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e2dCz-0003aq-Gc; Thu, 12 Oct 2017 16:07:29 +0300 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=4ceisKUP9dq77GxCH6n8JWoS+SDPo2H2AYAWCjXhgd8=; b=NdMQ6NlQyCGoWhlMtLGWwUlAaT3ZphuIPssfL0rK7r3Dgckcyy3+gmGibhM/IeX+gjCqG2o5ezTPkaSIgULjMlqyb273BmQwc7DqNDycns7x2AZ20BVABNCk91G+Xkw4xLvcmhu7VSbV1YivW4eL9jzFNIh22wZg+JZIwYulRXXrSBnf4yki5lTmTmL0OZf++XXU+tp78QqLRFcHjp0KfdJFwK/+T8eNBPjWGEXAcOEYk2g768XmHtfVvZ4Le2X2phgDVgo4hghNZ8ZweC4a5m1Nw3mp6tBxz4q7rks3wYLZu2CxhzvmSqI4d8HGPXTXEOaEdd/pUZrwfLhQrrNa+w==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 12 Oct 2017 16:05:45 +0300 Message-Id: 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 31/31] qcow2: Allow configuring the L2 slice size 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+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" Now that the code is ready to handle L2 slices we can finally add an option to allow configuring their size. An L2 slice is the portion of an L2 table that is read by the qcow2 cache. Until now the cache was always reading full L2 tables, and since the L2 table size is equal to the cluster size this was not very efficient with large clusters. Here's a more detailed explanation of why it makes sense to have smaller cache entries in order to load L2 data: https://lists.gnu.org/archive/html/qemu-block/2017-09/msg00635.html This patch introduces a new command-line option to the qcow2 driver named l2-cache-entry-size (cf. l2-cache-size). The cache entry size has the same restrictions as the cluster size: it must be a power of two and it has the same range of allowed values, with the additional requirement that it must not be larger than the cluster size. The L2 cache entry size (L2 slice size) remains equal to the cluster size for now by default, so this feature must be explicitly enabled. Although my tests show that 4KB slices consistently improve performance and give the best results, let's wait and make more tests with different cluster sizes before deciding on an optimal default. Signed-off-by: Alberto Garcia --- block/qcow2-cache.c | 10 ++++++++-- block/qcow2.c | 33 +++++++++++++++++++++++++++------ block/qcow2.h | 4 +++- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 788a1fb31d..313481f5bd 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -108,14 +108,20 @@ void qcow2_cache_clean_unused(Qcow2Cache *c) c->cache_clean_lru_counter =3D c->lru_counter; } =20 -Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables) +Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables, + unsigned table_size) { BDRVQcow2State *s =3D bs->opaque; Qcow2Cache *c; =20 + assert(num_tables > 0); + assert(is_power_of_2(table_size)); + assert(table_size >=3D (1 << MIN_CLUSTER_BITS)); + assert(table_size <=3D s->cluster_size); + c =3D g_new0(Qcow2Cache, 1); c->size =3D num_tables; - c->table_size =3D s->cluster_size; + c->table_size =3D table_size; c->entries =3D g_try_new0(Qcow2CachedTable, num_tables); c->table_array =3D qemu_try_blockalign(bs->file->bs, (size_t) num_tables * c->table_si= ze); diff --git a/block/qcow2.c b/block/qcow2.c index 63e88a1d6e..ea984ce9a6 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -663,6 +663,11 @@ static QemuOptsList qcow2_runtime_opts =3D { .help =3D "Maximum L2 table cache size", }, { + .name =3D QCOW2_OPT_L2_CACHE_ENTRY_SIZE, + .type =3D QEMU_OPT_SIZE, + .help =3D "Size of each entry in the L2 cache", + }, + { .name =3D QCOW2_OPT_REFCOUNT_CACHE_SIZE, .type =3D QEMU_OPT_SIZE, .help =3D "Maximum refcount block cache size", @@ -734,6 +739,7 @@ static void qcow2_attach_aio_context(BlockDriverState *= bs, =20 static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, uint64_t *l2_cache_size, + uint64_t *l2_cache_entry_size, uint64_t *refcount_cache_size, Error **errp) { BDRVQcow2State *s =3D bs->opaque; @@ -789,6 +795,17 @@ static void read_cache_sizes(BlockDriverState *bs, Qem= uOpts *opts, / DEFAULT_L2_REFCOUNT_SIZE_RATIO; } } + + *l2_cache_entry_size =3D qemu_opt_get_size( + opts, QCOW2_OPT_L2_CACHE_ENTRY_SIZE, s->cluster_size); + if (*l2_cache_entry_size < (1 << MIN_CLUSTER_BITS) || + *l2_cache_entry_size > s->cluster_size || + !is_power_of_2(*l2_cache_entry_size)) { + error_setg(errp, "L2 cache entry size must be a power of two " + " between %d and the cluster size (%d)", + 1 << MIN_CLUSTER_BITS, s->cluster_size); + return; + } } =20 typedef struct Qcow2ReopenState { @@ -811,7 +828,7 @@ static int qcow2_update_options_prepare(BlockDriverStat= e *bs, QemuOpts *opts =3D NULL; const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template =3D 0; - uint64_t l2_cache_size, refcount_cache_size; + uint64_t l2_cache_size, l2_cache_entry_size, refcount_cache_size; int i; const char *encryptfmt; QDict *encryptopts =3D NULL; @@ -830,8 +847,8 @@ static int qcow2_update_options_prepare(BlockDriverStat= e *bs, } =20 /* get L2 table/refcount block cache size from command line options */ - read_cache_sizes(bs, opts, &l2_cache_size, &refcount_cache_size, - &local_err); + read_cache_sizes(bs, opts, &l2_cache_size, &l2_cache_entry_size, + &refcount_cache_size, &local_err); if (local_err) { error_propagate(errp, local_err); ret =3D -EINVAL; @@ -876,9 +893,13 @@ static int qcow2_update_options_prepare(BlockDriverSta= te *bs, } } =20 - r->l2_slice_size =3D s->cluster_size / sizeof(uint64_t); - r->l2_table_cache =3D qcow2_cache_create(bs, l2_cache_size); - r->refcount_block_cache =3D qcow2_cache_create(bs, refcount_cache_size= ); + l2_cache_size *=3D s->cluster_size / l2_cache_entry_size; + + r->l2_slice_size =3D l2_cache_entry_size / sizeof(uint64_t); + r->l2_table_cache =3D qcow2_cache_create(bs, l2_cache_size, + l2_cache_entry_size); + r->refcount_block_cache =3D qcow2_cache_create(bs, refcount_cache_size, + s->cluster_size); if (r->l2_table_cache =3D=3D NULL || r->refcount_block_cache =3D=3D NU= LL) { error_setg(errp, "Could not allocate metadata caches"); ret =3D -ENOMEM; diff --git a/block/qcow2.h b/block/qcow2.h index 341d841836..7ef5dbcc2a 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -100,6 +100,7 @@ #define QCOW2_OPT_OVERLAP_INACTIVE_L2 "overlap-check.inactive-l2" #define QCOW2_OPT_CACHE_SIZE "cache-size" #define QCOW2_OPT_L2_CACHE_SIZE "l2-cache-size" +#define QCOW2_OPT_L2_CACHE_ENTRY_SIZE "l2-cache-entry-size" #define QCOW2_OPT_REFCOUNT_CACHE_SIZE "refcount-cache-size" #define QCOW2_OPT_CACHE_CLEAN_INTERVAL "cache-clean-interval" =20 @@ -656,7 +657,8 @@ void qcow2_free_snapshots(BlockDriverState *bs); int qcow2_read_snapshots(BlockDriverState *bs); =20 /* qcow2-cache.c functions */ -Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables); +Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables, + unsigned table_size); int qcow2_cache_destroy(Qcow2Cache *c); =20 void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table); --=20 2.11.0