From nobody Sat Apr 20 09:32:30 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 1513342754734200.2652958839949; Fri, 15 Dec 2017 04:59:14 -0800 (PST) Received: from localhost ([::1]:46074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpZu-0004bW-3b for importer@patchew.org; Fri, 15 Dec 2017 07:59:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVG-0000Wd-4s for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003J6-TK for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:14 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48105) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CV-US; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-000843-ER; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004CU-9u; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=tSE0+YwAWGJRD/F5bwsHbKG/kp039c+OxJNjLLYP8Q8=; b=Bctw8j4EYHs25RaAUztVTLP5tqRyKPv6mqeM9TNeQphfbEnNDkHssah3QI7Y49Ek0ME2cfd6vIp6BnfR1uWs9oPQcKZm2wShd5ha7JGAgoGvo6MgPUnJGZvuPLexrxfH5SeOj0lZNEnCJu7KP1dC2mnIOzaiC4+d/LoPKXoNdMO5/BwepJEDt7IutUkmuYWKJztWFJJjeBTuTaFw6y7KxSp3DeLnUc6dwi4FHHvGBzGpU7PHheTCt/PJfX4IxCKXnx59ItiFvti8AKo3Mt3gF5CD11QBt/rxHsKQMtO9uxeGKLod4FXJL4mqtrl1LHRwetxCvYVU9z23DvDAx2AJ5A==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:29 +0100 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 v2 01/32] 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_6 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 Reviewed-by: Eric Blake --- 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 a3fec27bf9..8163983d28 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -648,8 +648,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 09:32:30 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 1513343908451925.7735475770222; Fri, 15 Dec 2017 05:18:28 -0800 (PST) Received: from localhost ([::1]:46236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpsg-0004yw-Ck for importer@patchew.org; Fri, 15 Dec 2017 08:18:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVG-0000Wo-VJ for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003GZ-0m for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:14 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48089) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CT-UZ; Fri, 15 Dec 2017 07:54:09 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-000844-FU; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004CX-Av; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=96cJ4ZaCSMNpIQH9lDxZ4RN5uS1v4P/sybtGYFj8FNg=; b=TxWbhtIgIw6fIfs1ltMqqB+GLXUMeRa/mhKTyXJ16pofCaKWLD4J5CilU8hwdvM7uP5ksPcHIEOHuOIz+o4xLE1xJR9weF5qxvazGYPgVLgvSJ80x54CzoUbQJYxhNm8iGAXAo/gfSm1uQBmQoYvzeiBIJnTZFhmKAV2Ei5vxEp3Yz5DAwsVAGLm0j8MtSgWOoJ+ItZhjZ8/OBGbk7ItszMdASFRwyf7/XzB4KtfXW22nn3BM50NDxRJG0xmEOlUTUnonpXq/YEsC4nMbubf8NjkhkUbDC18zQ1wLy8SU1jUe3LDmJffX1SgD8QjK969KqFOq4t/d/vEW7rUAOurFg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:30 +0100 Message-Id: <97419f591a3aeb5c69c9b24a495f3e603cacb32f.1513342045.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 v2 02/32] 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 Reviewed-by: Eric Blake --- block/qcow2-cache.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index c48ffebd8f..d068fed98e 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 @@ -79,10 +78,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 (mem_size > offset && length > 0) { @@ -132,9 +130,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); @@ -203,13 +202,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) { @@ -223,7 +222,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; } @@ -331,7 +330,7 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qco= w2Cache *c, trace_qcow2_cache_get(qemu_coroutine_self(), c =3D=3D s->l2_table_cach= e, offset, read_from_disk); =20 - if (offset_into_cluster(s, offset)) { + if (offset & (c->table_size - 1)) { qcow2_signal_corruption(bs, true, -1, -1, "Cannot get entry from %= s " "cache: Offset %#" PRIx64 " is unaligned", qcow2_cache_get_name(s, c), offset); @@ -339,7 +338,7 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qco= w2Cache *c, } =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) { @@ -380,7 +379,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 09:32:30 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 1513342596510446.8808965425537; Fri, 15 Dec 2017 04:56:36 -0800 (PST) Received: from localhost ([::1]:46059 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpXH-00021p-JF for importer@patchew.org; Fri, 15 Dec 2017 07:56:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVE-0000WQ-E8 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVB-0003FP-7a for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:12 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48069) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CH-RM; Fri, 15 Dec 2017 07:54:09 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-000845-Fa; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004Ca-Bs; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=4dSwLSqeMFjKZbmC9Gd8aiG4S5FoIC6zRwD3ABItsmI=; b=bNXnwlHrFif8LI7mwsxFTEqKQECsZAbHPLlARzCezVZYmrf/hiRrZS1ZxPpSLZQDJvLupP83+HpCoXd49W4PC36A/Ee0ErkeesiThAa1hvXJLpgDZJwsiAH1UivugTYMaEcPvvZ6wd5fsjBGlZlxY19uRUPTpee/8F1AbMCCtFWYFB9ww5tEQIHCAarh8YPulcnNXgeRgThJHefMmSecJXLX35omWVjWorbvhqEbPnih8/d39OIQ+dJiWwTQ9F5zlgqCAzgFskKgWEj8kNBtSLIQAaVLmeCvLtCP46GoetN8EbgWOfxciTPI6qwtvFHPoQjBpgzi9KyWnPS2P+6bqQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:31 +0100 Message-Id: <44e3c682947299e968706e058ac665fbac5bb719.1513342045.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 v2 03/32] 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_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 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 Reviewed-by: Eric Blake --- 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 d068fed98e..ff793fc532 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; } @@ -78,7 +77,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; @@ -222,7 +221,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; } @@ -378,7 +377,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; @@ -390,7 +389,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); @@ -439,7 +438,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 09:32:30 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 151334292161766.91750529375349; Fri, 15 Dec 2017 05:02:01 -0800 (PST) Received: from localhost ([::1]:46094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpcg-000780-UX for importer@patchew.org; Fri, 15 Dec 2017 08:01:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVG-0000Wh-H3 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003HH-5t for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:14 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48114) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CZ-V3; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-000846-Gx; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004Cd-Cm; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=nMoQKHM7grRJXmAsxB3cAfgLE4R8/sA1T8y3IWgV3jY=; b=hYvpy14nz2ChO1pjsi3gE3A0rit75nshxgOKwe7yxHKOsYn0eebzJJafL0satmZ74tShj5xgkJIoA6Xi1dqUk2Nyv60DTB+Qb1xr/pOI1+j1PdEMyqUk3Y2fw0BXldmzrsSelsBpenrCgb1vmMIjvD37rx5o6g8797rQYzVvsbFuoGcSDaYGK74VaRDsIJ/i8u03Kq5M98RYjqxAIkFK3yVPAf2Ua878RpjS9eCTh6rmJ0Jysg6SzdpXbFIRxtwOTySoEZesOTBhTGdy+uP8b79MsbbdPFaRJoUMeq1bFrIVLDH+al+PZUn7/DJTlIG/JkD7YRTDoEYeHnnsuvSGEg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:32 +0100 Message-Id: <5acef77483178b4ab6b63dfaf63f4737fc376a20.1513342045.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 v2 04/32] 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 Reviewed-by: Eric Blake --- 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 ff793fc532..c2a85b80b8 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; @@ -411,7 +410,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; @@ -426,7 +425,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; } @@ -446,7 +445,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 09:32:30 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513343440787718.3836314298558; Fri, 15 Dec 2017 05:10:40 -0800 (PST) Received: from localhost ([::1]:46144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpkr-0006GJ-48 for importer@patchew.org; Fri, 15 Dec 2017 08:10:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVG-0000Wf-CS for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003IU-Q6 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:14 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CL-Un; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-000847-HL; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004Cg-De; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=T0jRWdxcaV633csyCjqJ4HaXYO9bobPOwB7kH4vyA5o=; b=Q2jgvJOYQSOmxyQxDWQdpzXhhf8Mkp2Byq7EHlhwGwwS5HYptRxgAqJgl5Uh5LJdNx90f6lwSLqehCVXI7plKdX8vG37o8MyNAXV5tU7dnumRuSODAh57wbkRUE2G3LmDrDnaxZWzR5Lnpz9OfHiEViJpXrAl8IEu9dGJmv/EdbcVu5O87zmYHiCb+wcUnywNWIVUAtR6WMBi1YMiEnLIiErqI2y6D5aKkW4IFVfC+driauPC3V46CFzFO0uP75VjO4aWUbqktC1n2HRtt2QODMZfYMUMDqaFhlcfQEUCEYpyQrODtX9BVilCUFtT+XwC9PE+exb/QO0U7ztdxR0nw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:33 +0100 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 v2 05/32] 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_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 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 Reviewed-by: Eric Blake --- 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 c2a85b80b8..3deded348c 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -71,8 +71,7 @@ static inline const char *qcow2_cache_get_name(BDRVQcow2S= tate *s, Qcow2Cache *c) } } =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 @@ -114,7 +113,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 @@ -306,7 +305,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 @@ -453,5 +452,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 09:32:30 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 1513344055678368.45334564295376; Fri, 15 Dec 2017 05:20:55 -0800 (PST) Received: from localhost ([::1]:46306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpuu-000718-UD for importer@patchew.org; Fri, 15 Dec 2017 08:20:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVH-0000Wr-9X for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003HO-6u for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:15 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48109) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CX-Uy; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-000848-Hw; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004Cj-ET; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=lXgfRAUaWXGv1iCpn+RIk9h349JDvzrdg2BXwGHzbJ0=; b=rj1+rcLNAxDO8monSPJeJGAyQNf19PXuEoIz/88sHZQjDLtYiKr57WUjbaJ2NVd2PrJEjYazR8aQsri3VKjgXOdPB4NMjHXpH/2NxLgm3Lf5CwCryoiiJ4Zp6InQDofEHTWJT22pPbaIoQaAJ9miepe2sQ8yQMqNwr62s7a9BmmRoZM+DIkmyHfp/zyoK2sNdS8nmJ0lCz+KU1QITFT2IGRbe10L7Ub9E9F2y6F6u2jphnt9owJ5WXx9k+kraK27uZxgSPP4m0uUUarKQ03unOwxnDnt5PAa9V2nGmRlVmrFCdEcWSV58C14wzW36fpvoLc/15FAJBJGi/D3725vsw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:34 +0100 Message-Id: <3c5596196fac576592433452622c3fb8ce45979c.1513342045.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 v2 06/32] 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_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 Reviewed-by: Eric Blake --- 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 3deded348c..7b4c502908 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -421,8 +421,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 8163983d28..1f279a9151 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -325,7 +325,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; @@ -766,7 +766,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 @@ -938,7 +938,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++) { @@ -1679,7 +1679,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 { @@ -1775,7 +1775,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); @@ -1984,7 +1984,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 3de1ab51ba..75b1472fc8 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -421,7 +421,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; @@ -623,7 +623,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; @@ -656,7 +656,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 @@ -845,8 +845,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); @@ -1316,8 +1315,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 @@ -3134,7 +3132,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 6f0ff15dd0..caab8630d9 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -642,8 +642,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 09:32:30 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 1513343176283549.8882983787062; Fri, 15 Dec 2017 05:06:16 -0800 (PST) Received: from localhost ([::1]:46113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpgl-0002Ki-Fd for importer@patchew.org; Fri, 15 Dec 2017 08:06:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVJ-0000YG-8X for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003In-Sk for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:16 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48080) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CJ-RJ; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-000849-Ic; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004Cm-FJ; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=Abz2VXXgVaha60V4WClyxJ1V5G9rxffrP9n95tqJIWw=; b=Z2ssqGbGLnB3kbX+bXYLAZpeXmrEBhUUYpIBeYW7aWelHbcvbCdlbd90aMYVz5sx4ogg7En1aAUsHVzXWPd2WOUj1XNAd0xHYOxO/JMrWaYzV7KUGZJe5peOwbnkBmoXEMW0o+cP4z6H6gzhqLuz11hIxGy36xhbORfTmZDj7WhbQ5Md6aJPFj6Ll6Et89obYGf1dOpiFhwxNPpZZ8IZ8d5SrVmLp8BZwgxe776OfMgi/lfgagDgyndr93vtgjEK0l+hH2+F5qosuJHIBBMUkg+U7m+DAOUD1M2bgLoitBUvziwjijQtVwKMHTWtqcSj5nRmLkyt6HLRl9mfJ8x5Pg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:35 +0100 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 v2 07/32] 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 Reviewed-by: Eric Blake --- 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 7b4c502908..10f0b7fa87 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -407,7 +407,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 1f279a9151..4a7b46038b 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -318,7 +318,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 */ @@ -346,7 +346,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) { @@ -620,7 +620,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 @@ -638,7 +638,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 @@ -745,13 +745,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 @@ -768,7 +768,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; } @@ -957,7 +957,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. @@ -1175,7 +1175,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 */ @@ -1334,7 +1334,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 */ @@ -1690,7 +1690,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; } @@ -1784,7 +1784,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; } @@ -1987,7 +1987,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, @@ -2018,7 +2018,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 75b1472fc8..2c37492b4d 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; } @@ -449,7 +449,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 @@ -501,7 +501,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; } @@ -660,7 +660,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); @@ -836,7 +836,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) { @@ -874,7 +874,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 @@ -897,7 +897,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 /* @@ -1319,7 +1319,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 >> @@ -1347,7 +1347,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; @@ -2801,7 +2801,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 @@ -2814,7 +2814,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; @@ -2835,7 +2835,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; @@ -3127,14 +3127,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; @@ -3187,7 +3187,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 caab8630d9..e78d0c2316 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -656,7 +656,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 09:32:30 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 1513343111014275.25535400271565; Fri, 15 Dec 2017 05:05:11 -0800 (PST) Received: from localhost ([::1]:46107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpfh-0001Pk-5v for importer@patchew.org; Fri, 15 Dec 2017 08:05:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVG-0000Wk-Oq for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003HC-5c for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:14 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48066) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CD-Ue; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-00084A-JL; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004Cp-GD; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=NS1tCW5TU75P+PnT/s4quKBYIPrmgPQaqe+DkXDG6a8=; b=m23RNw9EPOJN00/BfNscK70nWAeXZQBt8nVm1elvLOz0OoceIGcDLRhrJJwVkazQAGG26nNUDX5n1Hf4xdaAcbn6DA7WWS1Of4AaLjs84CahhrKEYEX1zvPdyewIoi4TjNSYB9s0Mdx+J5xdg6pNotkFERBvM6izYxx5xIoppo0t828u60G7AFUPtvPx4RUVfVblnbSH02qI6p7qOMF0l2nnWd5Jl+anJt2Kc4MFMlKESFpXoRxi8PmEdR/bx/f5X7vHeS+VnwUDEbnr87EyURSGXg4xcQfqxmsEpTdhqOVurHzDynzmCx3N5x/X/zot18IR5l0Iwb94I8dZkcpopA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:36 +0100 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 v2 08/32] 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 Reviewed-by: Eric Blake --- 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 10f0b7fa87..49f43d304a 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -142,7 +142,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 1914a940e5..32a2fb15db 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1034,10 +1034,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; @@ -1063,10 +1063,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); } @@ -1504,10 +1504,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); @@ -2090,8 +2090,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 e78d0c2316..a9a6a1c0b5 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -640,7 +640,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 09:32:30 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 151334343976592.95967985048048; Fri, 15 Dec 2017 05:10:39 -0800 (PST) Received: from localhost ([::1]:46145 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpkr-0006GW-SW for importer@patchew.org; Fri, 15 Dec 2017 08:10:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVG-0000Wn-S5 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003JV-Tz for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:14 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48073) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CF-US; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-00084B-KW; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004Cs-H7; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=DQ/A7bAOFz0dGbiFBr9ccEKn8hgsTXr8L8SrqBuhZwk=; b=BaiILmci1b2G18NKLNKhEpvUI9Xa+5CodIulOw64le+c7PpZzv5rvMlazfEfQHU6bNa9xyYKurFRRrmxVIv0lFUvlLITWY9mpFho62p9HASovqj4gvnuwvNaDqjrExIJHhP/CecL/v1QflxFUHBl1Xq8WYrkrfAmTh8I8Mp+q1ml3Og49PYey8ZczmlNrYvfed3uQvkIuFfyUSz1RyKfH48GEP9iCdclsxv+uJp78PmUQV3C0xA6LiMs7KuxXjUDG3/wQ5FY2URxoBHTSqnxrHnPbLpI3R4jT6iJXEFaC3gvSFh0vCTgo72qIaPPYk8YONqYWGmL6nqmzB/M788pSA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:37 +0100 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 v2 09/32] 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 Reviewed-by: Eric Blake --- 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 49f43d304a..402ae952e0 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -93,7 +93,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 32a2fb15db..bdac1c156f 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -696,8 +696,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 a9a6a1c0b5..a9d619576a 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -649,7 +649,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 09:32:30 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 1513343928848897.1664599576304; Fri, 15 Dec 2017 05:18:48 -0800 (PST) Received: from localhost ([::1]:46237 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpsl-00053J-QC for importer@patchew.org; Fri, 15 Dec 2017 08:18:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVI-0000XP-M3 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVE-0003Mi-PH for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:16 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48195) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVE-0003KH-5h; Fri, 15 Dec 2017 07:54:12 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-000845-R2; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004Cv-I1; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=1zRO/Exc7QBfBXbpWqbUHaLze8KR/2kv7LpoZw8Wak4=; b=WjGdrvCdWp4imXoemDogJ96O7xe+nAj6yDBUtb17m6V+DH4eScwj2XXdC3f1daVg/yb3a5GS2MVk45WoQGe3V/RDpwVf1UirR7mceP7fkDxFEIDqEJUpwoQqOidIi2kVHW0f3R+VCpZ7Fz46GOqCfM+FmWElMlxZCTrt7SYmlsTAtBXW0rNePglF/EFzzwcYWPHzki0+ErAgPeiQAxv8LzOGUIbwU8byQM15LUv99KSLKOP8+HdyGXfqdLArR/Gqmmv850JKSlqtVIuVyG3/8hIe4rkz4MqsqvwudZN3iN/OMPgiFH0CfQDsJkGy57FK0HoQr+sBoIAvTgOtFibnPA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:38 +0100 Message-Id: <8512f9f7a0afd366b2e951617cf553b1f16e8be6.1513342045.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 v2 10/32] 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 Reviewed-by: Eric Blake --- 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 402ae952e0..1cf7915871 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -441,7 +441,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 2c37492b4d..d3a0f7a274 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -875,12 +875,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]) { @@ -3144,7 +3144,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 a9d619576a..64354b6589 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -659,7 +659,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 09:32:30 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 1513343281898743.4833493955157; Fri, 15 Dec 2017 05:08:01 -0800 (PST) Received: from localhost ([::1]:46125 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpiQ-0003tA-12 for importer@patchew.org; Fri, 15 Dec 2017 08:07:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVI-0000X3-0a for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVE-0003Lw-KO for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:15 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48191) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVE-0003K5-56; Fri, 15 Dec 2017 07:54:12 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-000843-Od; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004Cy-J6; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=cOV5I/K4t/YgnEp4rhZtp5x/hKgFeBTDW+jwdH3/pvk=; b=S4/qps8zfkn7GmpCQMQO8oEMac6D5SBj5y0pv51dRWI+0X21UjFpg7Jq2psN7Yd7V+CRNBRUAjOz5hll0R3Ahyj4tQE9vmpMwOkqTOimc/9vwCCtaRIdWxVK7m8LwybzmGoewrmt3Fy0sE4qG8Z3FjhuWzsLn3Fk+gOoGEbxfKGHqVQi/VJeBtYWtx58/ZwBZrS185bk1TkCqnkhTN34ji8rH63b65ooTgIW5hWAK4S4xUYvuQC4ahmVLb3y+gD8/Wssq3mlVXsE2uol1cG9O2/enH4Fd2b5txDM4I2eVLVlcD4s8Vzkof8kczVPfzj/obbNrTxrdRGminzNdtF+RQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:39 +0100 Message-Id: <4007dce42901324c3d129917d555d3fec4fb82a2.1513342045.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 v2 11/32] 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 Reviewed-by: Eric Blake --- 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 1cf7915871..2fcecbd7a8 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -428,8 +428,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 d3a0f7a274..51094fbcfb 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -871,14 +871,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); } @@ -3140,7 +3140,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 64354b6589..dce355521f 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -657,8 +657,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 09:32:30 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 1513344165748211.9488386330935; Fri, 15 Dec 2017 05:22:45 -0800 (PST) Received: from localhost ([::1]:46341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpwk-0000Fp-2Z for importer@patchew.org; Fri, 15 Dec 2017 08:22:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVI-0000XL-LO for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVE-0003MF-Mw for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:16 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVE-0003K7-52; Fri, 15 Dec 2017 07:54:12 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-000842-Pp; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004D1-Ju; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=NKngp6R5qWVzYEciW+QhLva9jzGnKOTLmlRiZnAGx4U=; b=qL8IvYBUfcevxlva/m7seJ77Dk1NaBd6p2G4S5gyvvqON8S2jyqINZEdqVJ15aEcrp84Mz5djj7hvbPWvm3E73doIWRDpky3mQgXI3CSQTOZ/fGC8XBuUL7i9RmFTCI/HacudqllqnZ/P3piEyqhbyRtIbkN6ls9sC1rRROFhBZmrR1HqteiU40mDzWRrxfHuS4FifuHlYcMFTO4nCX1DuPqxRM0sIffmNoq0/6H0spbynOLwsPtA5JiNgUUovoTharyOWhk+d1em2huPIzDptEo9JomILLFm8v8ZEKcwm7qCjL/Pi9pnOy7uJmjVq8tW9IGK7p3j/+zcwoGDXM83A==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:40 +0100 Message-Id: <7f36799a9e28207fc4b78ea96447b5668147b7f9.1513342045.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 v2 12/32] 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 Reviewed-by: Eric Blake --- 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 4a7b46038b..6369a74efe 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -541,7 +541,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; @@ -664,7 +664,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 dce355521f..b9510827bb 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 09:32:30 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 151334259630664.08584672450695; Fri, 15 Dec 2017 04:56:36 -0800 (PST) Received: from localhost ([::1]:46058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpXG-00020I-ND for importer@patchew.org; Fri, 15 Dec 2017 07:56:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVE-0000WR-ED for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003Gq-4b for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:12 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48102) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CN-UA; Fri, 15 Dec 2017 07:54:09 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-000847-SK; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004D4-L3; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=RMdahYNO9zQB7WFYof+d4e0FLXucgDHMoekY2vBGvQI=; b=QdmAiEQb/G65wdH0WxXdca/gf9knTj+XhDRywYknkotU5zz5qmoQ6E5JXQtd10e/+7MY6E+AY4wtww9/GM/qXVvOo7WP1+PJf+Zxbj8aEfFDV8oDDYEJGUNY77rSw5ylTjaStp16HaaP9a0irYUwG5i0IWuC1/EMpbBsEVZQQyQ2NSQJfW9f7x+u11EKxlgNmyKstgJYLUXbYJVVpUZgmpx9NgQzSNvMuYJMYtolu65xLxJHBvzjGL0sDGydtA4Ph2MzTh5Q4qWDavomK0CODvmWoR+HgDmVI5lTLZiVbIlSoFOrp36ulcep4Vxy0P9vP/jl6LNjXoFUPJuBVEF7fg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:41 +0100 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 v2 13/32] 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_6 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 Reviewed-by: Eric Blake --- block/qcow2.c | 3 +++ block/qcow2.h | 1 + 2 files changed, 4 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index bdac1c156f..c1e4bab391 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -797,6 +797,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]; @@ -878,6 +879,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) { @@ -1041,6 +1043,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 b9510827bb..2435fd786f 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 09:32:30 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 1513342749753140.37350251932298; Fri, 15 Dec 2017 04:59:09 -0800 (PST) Received: from localhost ([::1]:46070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpZq-0004YX-3q for importer@patchew.org; Fri, 15 Dec 2017 07:58:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVE-0000WN-Dw for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVB-0003G6-Oh for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:12 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48068) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CE-Ra; Fri, 15 Dec 2017 07:54:09 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-000849-Sj; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004DC-NO; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=ODCWYL+ORTBmYEu6Ibx4edM6OTSCT1/GpPPZtp6IfOs=; b=qkSGCUlDucyLJ7JhaWEFZ58Z7sVy7L5yRAIN4Xuvcjy4u5Y0JSvQEscsorsFQ2SF9LMtmclWY7q1dRnHWpLJfu0SuJYfKwRexsQERuR3sv09Cqu2x6KDpcA4qrh5p6XUqeYeGmTVXm/ZIgGSzukL679ApMYnHllUYazCFYEqpd6+IhxlpKEYpUawT7eeo8s10wEQA4LiDdEMZji4uFuD9eX6TbmGhPWQB5V5vuyv5sO3ZWaMCqBMh+eHEl6F3Af7OYFr8ngAwloK8zWddAjTzr44q8wTt240Z7QUYXklF75xWW3/yuxjfDwom6iXYoC28RQf/rxlb58XytOKBMymhw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:42 +0100 Message-Id: <91f760c0f3fd28e4baddf20c9bc7a9b9775eb593.1513342045.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 v2 14/32] 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 Reviewed-by: Eric Blake --- block/qcow2.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/qcow2.h b/block/qcow2.h index 2435fd786f..1894d1d028 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 09:32:30 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 1513343106584152.47448270871575; Fri, 15 Dec 2017 05:05:06 -0800 (PST) Received: from localhost ([::1]:46105 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpfa-0001K0-Dn for importer@patchew.org; Fri, 15 Dec 2017 08:04:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVE-0000WV-Gt for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVB-0003GK-QA for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:12 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48088) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CO-RP; Fri, 15 Dec 2017 07:54:09 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-000843-UH; Fri, 15 Dec 2017 13:54:05 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004DJ-ON; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=TRbrQuWXzOsiyGOb5dLqZFoewtE77cZmAsx/ByITjFo=; b=Miyg+qdMgfO8F3OOLifr/Kv7pUKiaNQQRhyFV4Y+yYvZPcBUPLqjw8R9g4/Hb3GTtBwNsjUv1sysMiTgScyB1UM5Wc8HsGY6mtQdz3M2uJTDU34zgMTi90cnMlJl+x8ChH89oboRMaSnDn/Vq7K9E75rGZ+juOGI95iFHFxrebpwiAsgZimApNhh49RC9Q8YtGAIWChZmgbevaBzqGr23XqnKqKfId0wSxqFAxYjJTYRVR9sC4Pl+ED+8LTMHDIiD4aGdIzQhnBUlo0mpWkkiFfiJ+hO3cBoVwYzCvSHc8twnsMF5eZpQWfrrRXmZafJ80clxqViwZegv+b9FV9Lgg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:43 +0100 Message-Id: <967bbc1a89d1d7afd169350c5e61da19ee0166ec.1513342045.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 v2 15/32] 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 Reviewed-by: Eric Blake --- 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 6369a74efe..8d92d623d8 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 /* @@ -562,7 +568,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; } @@ -685,7 +691,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 09:32:30 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 1513343757069267.8048402974666; Fri, 15 Dec 2017 05:15:57 -0800 (PST) Received: from localhost ([::1]:46187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePppz-0002kA-Mf for importer@patchew.org; Fri, 15 Dec 2017 08:15:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVH-0000Wq-9T for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003J3-Sr for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:15 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48078) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CK-Tx; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-000842-0o; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004DR-Pw; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=i1nhdyyRnroOYXv40nGktn/NAs4EGCgxepkjujlACS4=; b=i5lb28T8HeTVRbwosLjkVwJbZUjaBT8lIKZwyZvKUdHD7vdoefHZa1xUQ5voH8g0UGfNphK8KGpKPGzK9T0S+j0sv8M4p1+sWAlQBwTAze3VVs2/BIzyVmRPaMLl11FB8jw/ioAaDjdLUMXSxxFp5y7DZTAiI1PqDzZYW/ROpz63tIClB4DCMr887LWLXlK8hdY6T8sIVS4DmnAwr1RVBKGBfdlyH7bSaCvuba6Lbse/3PkMpvkq19P56D//ZBGh8MVUe+qCFvetXKEST1PAiBIysVxVZDSDsYO76e+2ZqdL4YjmTzM6mUlQ4bl9EL+LW4mr+My3lLaE/IxNDfbfqg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:44 +0100 Message-Id: <192986ad741749064e855bc67916a11460911992.1513342045.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 v2 16/32] 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 8d92d623d8..ecb75b6be6 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 @@ -299,42 +300,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 */ @@ -345,14 +354,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) { @@ -696,8 +704,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 09:32:30 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 1513343274719686.8426406354951; Fri, 15 Dec 2017 05:07:54 -0800 (PST) Received: from localhost ([::1]:46124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpiL-0003ov-Pa for importer@patchew.org; Fri, 15 Dec 2017 08:07:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVG-0000Wi-NJ for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003J1-SX for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:14 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48064) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CB-Tq; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV7-00084Y-Vy; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004DV-RR; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=XB5CZIBf93SIUs4TYBCEtHlnQAa0dDZ3hXcv+g25aH0=; b=KTkrAeUHAvXE7LKDeW681p5gbHzTMhJIG58LSD1nmU+6c6xn7S+zTZap085yrKXQJj5hNu/4e2vt9EzxjhIvvKRR16wgvinOc9KZxi3YsyP5znC8Q01jOhKlhnpKGxHA1fX/bES8ArpoDdTgrgZwlv+MfThAzOawEM1gU/pJ0xF4xSsmQsJQCz2orRwNzXOnKnaDM7pKowhGqTpOiadODXigzmPpy+SBDDpIhTuAzfhl/i+IolixucaQBstVxgixVzeZ2RXzaXypI1G+pG/zOX9lbpyapXNEc018GJTDVqo1RwllL9gkAJuuhmLaLFNXBd6H+1BTDAFPWYCxJ7l8hw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:45 +0100 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 v2 17/32] 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 Reviewed-by: Eric Blake --- 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 ecb75b6be6..3d43dc2307 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -660,20 +660,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 */ @@ -695,11 +695,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; } @@ -714,8 +714,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; } @@ -729,9 +729,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 09:32:30 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 1513344281889320.8428772062033; Fri, 15 Dec 2017 05:24:41 -0800 (PST) Received: from localhost ([::1]:46404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpyX-0001dt-NS for importer@patchew.org; Fri, 15 Dec 2017 08:24:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVJ-0000YI-8t for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVF-0003NE-3l for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:17 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48199) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVE-0003Kb-GE; Fri, 15 Dec 2017 07:54:12 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084b-0z; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004Db-Sv; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=8idYWhfypPy8bdVU30y/f0ghALrT0DdF8x7xXEs0k+0=; b=Bz/jTGxOU5T5ojxYtO7xfwZ3nrxavkXLP8mny/XDhyJXJ2pb64U6E2f7CHP+PPWuwNtOm2v4YAuXvcHvlc2GJMGIeaUzR6RTcuk5Q/0YqaqnOEo7IBx36Uaa+XZN194HE2GQL/4hLtNA54lwz4LIhFMh7h9XHKZAeICFPfa1nV3CQDkAHZWVyvnlBbBn2zjtLR3F0VNbzJqzuMweX2SZwrKq7EZhMzhaSbrN2ppcxY73X1CnIQ7uacuA6V27mEqOcOZ9N0WAyYS5+CIClrnOhfnkHO+bQ45tHwAJrMD44NlaPLTU/wO6icUuPb4JGpDWsBWLl89uhfGzl/s6FIIlng==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:46 +0100 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 v2 18/32] 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 Reviewed-by: Eric Blake --- block/qcow2-cluster.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 3d43dc2307..f167bb6336 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -530,8 +530,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; @@ -540,12 +540,12 @@ 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 + ((uint64_t) (s->l2_slice_size - offset_to_l2_slice_index(s, offset= ))) + << s->cluster_bits; =20 if (bytes_needed > bytes_available) { bytes_needed =3D bytes_available; @@ -574,17 +574,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 @@ -611,14 +611,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, @@ -634,7 +634,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 @@ -652,7 +652,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 09:32:30 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513343435933296.7370860260436; Fri, 15 Dec 2017 05:10:35 -0800 (PST) Received: from localhost ([::1]:46146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpkx-0006LV-3t for importer@patchew.org; Fri, 15 Dec 2017 08:10:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVJ-0000YH-8i for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVF-0003N2-15 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:17 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48197) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVE-0003KZ-FW; Fri, 15 Dec 2017 07:54:12 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084c-22; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004Dg-To; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=BQra+cNkWGgSAcRxXzjvwnLZvNmN2vQU6V6e+n9UCOo=; b=Y2+RIVNbeBChY4c7r05S/w/2hNoyOzcj/Ne677jWEjHkXDPR+Gba7hjck0OsF/RhFO2g5Gp+2FuZ5/sMggFSjDKFnAlxKUyJRHSqvjDxietKVYts2C3umCFt2cH6s6P+OBi1k/9uaoaCaeKaot5H3OhWkTFCxQMcp1OqhaW6lUEDSEQFgW1i2Wp2zVIYgI02IwsUCZvMQisCmy9vARAhz98TEpkv3tRPjcX8eEx5gHzjxBEnU4syGumnpuAQQ7kJGpLvsheclaHcA+MYJBxxFJ4DVKNMqPcrOzDl/lWUpYkvmConage6obw4uOJwy7+6d2Pwy0KxrGetKf3RRgHl4A==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:47 +0100 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 v2 19/32] 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_6 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 Reviewed-by: Eric Blake --- 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 f167bb6336..f8c22ca2be 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -931,7 +931,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); @@ -958,13 +958,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. @@ -972,16 +972,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 09:32:30 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 1513342748629873.7318836228526; Fri, 15 Dec 2017 04:59:08 -0800 (PST) Received: from localhost ([::1]:46073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpZt-0004bC-RE for importer@patchew.org; Fri, 15 Dec 2017 07:59:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVE-0000WT-Gc for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVB-0003G0-ON for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:12 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CS-RX; Fri, 15 Dec 2017 07:54:09 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084f-5O; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004Dk-Uy; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=Vrh47RDHI0ZSBMzobheVrd23Wmh6g4xz5j+SeFiGEZs=; b=P/tTONQzEFok9PUPK3bSGQcUpspQCcAz6p3hpZ7iNW/zIw71DGNnWth37f/CQ5xaqpbC5iTogjW6zrCvdm3DaMjBZJ5stmDoCC4BhsWK6ptkumwiDOm3k0rT3fMkvWhfQ3L+ssf6joinv8FGeCEoW99s2uuFo7NCF9ndZFW5j5icgIaYVQKDMRmycfwTPCwynl3714cNNQF7U4z/qxe8TwI80hIcYeK/e+Jeqaanf9LlLntG74JbWIsxu40sheZxRo3sNih5cVJ8Kj5uFpPIssaNyD7mNOR3RHaLwW1tifz46ucMcvIRtm8voKF2ac4d5PmLgUQhZhNFNqbPjREMKg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:48 +0100 Message-Id: <0cfc3621612922be4fb61894118ef982a61a23d7.1513342045.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 v2 20/32] 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 Reviewed-by: Eric Blake --- 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 f8c22ca2be..09b6dc984f 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1128,7 +1128,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; @@ -1140,23 +1140,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 @@ -1184,7 +1184,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 @@ -1199,7 +1199,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 09:32:30 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 1513343757082705.4699649644159; Fri, 15 Dec 2017 05:15:57 -0800 (PST) Received: from localhost ([::1]:46184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePppw-0002gj-Eb for importer@patchew.org; Fri, 15 Dec 2017 08:15:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVG-0000Wl-Qa for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003Hb-9y for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:14 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48104) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CU-RS; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084i-55; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV7-0004Dn-Vo; Fri, 15 Dec 2017 14:54:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=3spTMx+2bEmTClshxBrEMirYDuCrk3g8eUSK0e4u3mw=; b=EaoeXm3Pp+Ou7omwiSpBUyBB1tPd7zEP0ZqL+PhYTKH4juMv73mRh7mbxKNuei+QizNNzr9SFTLVhqukpSQY5AsdjzqCJAqu6ovpP/p/L7zN16wgCbz6oFQ3PDUR0PojV3ItCCGLnzu2v1efWTx/LmPS7QvPv51dzbZ6Teim89khI4xj1cmngDCJEPsEVCZx0ijo+Fy9SRRNtZo5RGO3IT6C+QJBqwogNsdKpXGsx6fHTV09+3mUjGbtpDffY6B4VZYXBvc5JnI2KHk9bWeKiowKhuy1Yh3h5zESFeNlksaqbpm2ylOcCBaWMCGiDobr/3k0rCyR9G0XbeCG5WP1WQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:49 +0100 Message-Id: <976f6bac137cdbdf45e5aafe140aad5833db087f.1513342045.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 v2 21/32] 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 Reviewed-by: Eric Blake --- 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 09b6dc984f..0d126581bd 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1283,7 +1283,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; @@ -1296,29 +1296,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 @@ -1347,7 +1347,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, * nb_clusters already to a range of COW clusters */ 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; @@ -1358,7 +1358,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 09:32:30 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 1513342745401995.0170183074025; Fri, 15 Dec 2017 04:59:05 -0800 (PST) Received: from localhost ([::1]:46071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpZq-0004Yy-Ot for importer@patchew.org; Fri, 15 Dec 2017 07:58:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVE-0000WP-E5 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003Gi-54 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:12 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48110) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CY-Uc; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084l-5U; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV8-0004Dq-0Q; Fri, 15 Dec 2017 14:54:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=dFhpDmWIAORXuMOM5fP/1LGpxY1YThW3ApzXNVld4Xw=; b=cskSvzI0pF3IBo6JsoIW97L+fCrKE26l4c0No+AfNXSvyIJcGLY0xwp+IQ1ntcBk+hLafZkKGrjWLWDvRrxNi63B9hnAMWdd6MazE92zJmbu3SrjbyTGHecZzJObdFscGZiS9Lslenf1zAmN2A1WeuCQ+remUa5f5LvC7T2hbcMAbM7TYfP30suLW6iPVRkLPlnWgmDVXyoLqq/ZUhfSDotttxRifTWVadBw4zAQU8Np3zxXzJDcw9qmWvwISEUF2nLSwGrOSIMIn7TFjIDZN0MLDVYbBSX02nrceYw+NX7s+lplULMy8B9QQ1246RBAD3XnwlcwSgw27gF5v8tUOA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:50 +0100 Message-Id: <8f5a1687d5999f3eecb989dd25b57144cc850b28.1513342045.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 v2 22/32] 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 Reviewed-by: Eric Blake --- 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 0d126581bd..3be8478c75 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1640,7 +1640,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, @@ -1648,24 +1648,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 @@ -1703,18 +1703,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 09:32:30 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 1513342924844655.5278588515941; Fri, 15 Dec 2017 05:02:04 -0800 (PST) Received: from localhost ([::1]:46093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpcg-000774-6t for importer@patchew.org; Fri, 15 Dec 2017 08:01:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVF-0000WY-EE for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003Gy-4z for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:13 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48075) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CG-Uw; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084m-6L; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV8-0004Dt-1F; Fri, 15 Dec 2017 14:54:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=4Sw/HndWrE5LXCTRcKmtPET8c0DB9Jco7slEg0Gobq0=; b=hPikDAcLzX/fRbZjmDILW9pg17bA3NOy79cSiDyIM82/JD4DDrFheQT3Xog/2fHmOQgd8Nr+NfwIFbJYQLOhUBfyXp2bICZxwkCrp1MiYcBIW+VHXm9SWZkgjTYJuj++H5Vu4zZQLMVhoN9kBFBH0nyRzOQl+WYUTw6SRYx6wKiFFO23ET49pazJ8pfvrKRG/ALVYSPVeGqsseUIi2APgVoZeDlGN/1/zxtoAYsB2pFu2AZeE5Q1596zr/RSThEgig4mD6+Zk6M1Az+x7ignZRDYbVE0bmc4Z2ye16mZH2UWRtDimPxsOkt0jwUq5p+oSZbNeN3XvWTv8mhqGFYvhg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:51 +0100 Message-Id: <6884a0a3917beeb854eede711b0d88acb0960ff5.1513342045.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 v2 23/32] 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 Reviewed-by: Eric Blake --- 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 3be8478c75..8f7a04ba7d 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1761,33 +1761,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 @@ -1799,16 +1799,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 09:32:30 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 1513343588082785.5175400965919; Fri, 15 Dec 2017 05:13:08 -0800 (PST) Received: from localhost ([::1]:46161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpnU-0000OZ-8a for importer@patchew.org; Fri, 15 Dec 2017 08:13:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVH-0000Wp-1N for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003J5-SV for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:15 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48077) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CI-UE; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084n-72; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV8-0004Dw-20; Fri, 15 Dec 2017 14:54:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=odlRpW5Y0jby/rx93hE9IMopOeXgpSoh2By9u2fT7V0=; b=l0LJdRw2bnYEDJ5j/S2+E/KKth8sxVbqaboT8oJ/XtxCjOZ8LP4oG2AiLEgrgHm4IDN+LRyncZbV2sahcylV0+readoSI/uyFEszFkowKzyCmz1VXaoQpwzbhMEmRZ7g0xaweO2Fr7hPIFSgX4+DczI774YYruAXgOhFK2C0iiPtMfIfDuNBFpd+ie/jl2asAmWAplXezrNN/ULyyNaCbJsSV0gcu2Ah0BE8TAUdLK6NBdAla2nC3pdp2ni0LzbarNJot7PH9H3XxvndTg5fZl356pBB0JbD6aAOref8EpImHGF9RiK+tYuLxPC4Gv0sdsLCy05hR4XXNnT0UDDbbA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:52 +0100 Message-Id: <192f0a4a1888e7e18cb7cec9fdbeadad5417b4ef.1513342045.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 v2 24/32] 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 Reviewed-by: Eric Blake --- 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 51094fbcfb..45c7bb0ff6 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1183,18 +1183,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 @@ -1236,91 +1240,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, @@ -1346,8 +1356,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 09:32:30 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 1513344055691269.2655571432497; Fri, 15 Dec 2017 05:20:55 -0800 (PST) Received: from localhost ([::1]:46307 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpuz-00076A-Oc for importer@patchew.org; Fri, 15 Dec 2017 08:20:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVI-0000X9-7T for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003JZ-U3 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:16 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48103) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CP-UM; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084p-78; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV8-0004Dz-2s; Fri, 15 Dec 2017 14:54:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=KOuG6P+9ZqSK4YpZtPhsle6zxVA8JP7YMARjW8b1dQk=; b=BuUwjzQZx4hfC8tnu4D7LeaJl97xRP6iYsLBEBnojcibe+rOV3TVDf5I7xi1GgZOWr4ejWq5yE6prqwdx4RcgW41GL9UcGn2QWhi7xdFAMlnGzYgXH9GdK4ZOZ9ssKFLiVZE9rtQQnCGGSBcE1riHycov96DGJqG9Pw74dK71ww0bxhfmOuyh4GZg5MGTH88MyMHick7LEVEjT2R5msM2Nsa6bICZORxJEuMG60npjiMqV/io2RP+UCQedqVql4sAtEgbOgGalfWkQLScFLi4NRezuILhhybWmIdBPfdKadkidUsv6A16z6/RESbr1achLcGtc2dJp1q5jmOyjesBA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:53 +0100 Message-Id: <1fb1816d471d712f2001ca3ce42c6682273c7daf.1513342045.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 v2 25/32] 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 8f7a04ba7d..ab840a449f 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1872,15 +1872,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; } } @@ -1907,124 +1911,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; + } } } } @@ -2038,11 +2051,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 09:32:30 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 1513342596517257.58844968341543; Fri, 15 Dec 2017 04:56:36 -0800 (PST) Received: from localhost ([::1]:46060 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpXJ-00022U-VD for importer@patchew.org; Fri, 15 Dec 2017 07:56:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVF-0000Wa-V2 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003IB-N2 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:13 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48126) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003Cq-RF; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084i-Oc; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV8-0004E2-3g; Fri, 15 Dec 2017 14:54:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=DyzQ31ozk3mPE077jk2gRz8G2lCq6hKy0YcTcf1NJog=; b=ElAIPox5gKzNGcjto3joTGOaUZ7FnoMqMcSCTbwqjvXBqeaoenvJYObvUFQxLYc72qDk5bY+4PCHsBhYOCX355X1tt0iNIguP3x3+iB+i+CS+t5JCBEAdYegF2GhDNv0Z6JmPUqp3fbUxrie0PxAvujfjxbzZzOOpJx9v2j5rh/SRrnU96AqKnANKLZQ3yO+EDC6ydaDoRy4Axm3Gjq0saccJ0ibIpsOXiQxEq5cm7lCnduFqNLD7GqFvVeDUSdTjm9z/FRhI76cRm9ky+pTwzyDt8LGi/ViG9oAxcodgPEr/muxFE/s69hn8LNw3xfYlBDq5yLqEP8Ix8LvCYXvSw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:54 +0100 Message-Id: <43f6f21c8f42204c23efce2755d6f53272ebb51a.1513342045.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 v2 26/32] 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_6 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 Reviewed-by: Eric Blake --- block/qcow2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index c1e4bab391..38c2ccf210 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3288,8 +3288,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 09:32:30 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 1513342598898627.7029489182333; Fri, 15 Dec 2017 04:56:38 -0800 (PST) Received: from localhost ([::1]:46061 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpXL-00024g-Bf for importer@patchew.org; Fri, 15 Dec 2017 07:56:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVG-0000Wb-2O for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003H6-5T for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:14 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48118) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003Cf-Uq; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-000842-BI; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV8-0004E5-4c; Fri, 15 Dec 2017 14:54:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=4CVtzjRyu6OIG9xQn86PTNn+8ci63CKQ0DlX+eL3iBg=; b=FcBd0c7+RqQ9JSG9MDn37wXmMx6rr4GWzh9ScyXdc6OK3CyQO4F1GTOkeVSxzQvEciBbvWxk00gbEGUzalNJbJVMvDPaRgwIPY2elXTgsUeUCTifjlIES3MyTvBeBq4R3UrkXx1Nt2+w6/oGBwGnCdXoNkl6mp7EYu0CQmf7UJIAzHtc0DZ2AP0YOo68Dovu/EQs+I5EyRM/04zo6Jaoa33lVV/0f4e8Qw4xDjWv1jUMgQgrvFjL+kbEL57xLxprQ6rqvUY3fY1XYyw9sL5BMm6kwLc2SH4KmUTKUhbhvmMhVFkywpjlCMNk8nljdUkR4r3XJHDLgwz+f+pp53ovWg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:55 +0100 Message-Id: <6e65a6dad8d2b486224d814b160a10d6dede7bfe.1513342045.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 v2 27/32] 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_6 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 Reviewed-by: Eric Blake --- 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 ab840a449f..0afe4eda13 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -756,26 +756,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 @@ -790,9 +790,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 09:32:30 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 1513343269944645.6373965576576; Fri, 15 Dec 2017 05:07:49 -0800 (PST) Received: from localhost ([::1]:46123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpiI-0003iQ-Cw for importer@patchew.org; Fri, 15 Dec 2017 08:07:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVG-0000Wg-GT for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003JJ-TJ for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:14 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48091) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CM-TZ; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084Y-CH; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV8-0004E8-5X; Fri, 15 Dec 2017 14:54:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=LTsmrnxQabVo35oVdbx/clc+f3cmn1tQ/AO1BIWOCtU=; b=JfzKn31QBQ7oV6gDrqhbEJZAhCnOGbKO1A6pOKycyZPUOV9N0EgQMfux9WguUnbnkRS+EBeZBSQGkop6Octba8PEOhAAYhJvuU/LsyCcuGYVgS3RuY4AnHSsozQ29Ffw/9NCh2fZNK8TX2D86AQEAAAPJrz393zhLyG3MLn6WYH3HPbcK5HL9xx1UzL0ty+8V5MA+5xAI+2jvLzlYXY0IYmF7wvFN0nKb3urraXXAbGOiLpUn5tE8BUsDpoAW1Vz+7f3mk2/RAzmYdUI0TWFNMaBUVk3uAGRmNUBBikuUVGXoQY5RwyzhR8S4Yb8bGsIHB9C0vAQtze4KabhxAvSUA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:56 +0100 Message-Id: <93ac7be373e194f4dfcc73c0bea96bd1c00209da.1513342045.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 v2 28/32] 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 Reviewed-by: Eric Blake --- 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 0afe4eda13..3deb132fa4 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -371,19 +371,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) { @@ -396,7 +396,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 09:32:30 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513343115412721.3714977518717; Fri, 15 Dec 2017 05:05:15 -0800 (PST) Received: from localhost ([::1]:46106 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpfe-0001Mu-CR for importer@patchew.org; Fri, 15 Dec 2017 08:04:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVG-0000We-5E for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003Ig-St for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:14 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48115) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003Cc-Un; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084b-Cw; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV8-0004EB-6Z; Fri, 15 Dec 2017 14:54:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=FjGLSgRoEqHTc0gLTy4mslIwyx2y3UhhRRxbNR4B4aA=; b=MKmZcZbWak9c7WorsQoZu4g1wO2OzUrta6RRbI89f2dwu1RvSN20JxH6v8DssM2OrUX+rAhsqpm+Uts+MnPlNajAR/qHsRcM+EHOJpNFhn2sVaERwgUwePK2d/R0ICVu43RdXcnpqQTBKPw0Xey/SwbHm7hlbXVHvQKnBkOu8zjYIofVRNWlumJKKOK0cqBI5Aah+nEgRN/I7425UImAcms/pZOpWIvXtJeJbomVyRnG1k4atBZC+EaMrOj7+jVMhCuXJfBxmZKhEfFa2pVVv22jW1/R7+xtlbWTQqfDM1CECUElYHEYuiTvSBIuXLI9GlpREc3G9z2qgnk30KbXgg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:57 +0100 Message-Id: <8149f6ab70fda930585b8ee38a583a006343730c.1513342045.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 v2 29/32] 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_6 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 Reviewed-by: Eric Blake --- 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 3deb132fa4..b40a2e32e0 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -407,10 +407,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; @@ -418,7 +418,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 09:32:30 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 1513342917787542.7445103938969; Fri, 15 Dec 2017 05:01:57 -0800 (PST) Received: from localhost ([::1]:46092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpcc-000737-Mi for importer@patchew.org; Fri, 15 Dec 2017 08:01:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVE-0000WS-FH for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVB-0003GF-PR for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:12 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48124) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003Co-Rw; Fri, 15 Dec 2017 07:54:09 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084m-O3; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV8-0004EE-7o; Fri, 15 Dec 2017 14:54:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=CTiXKLDjrFEsLiwJtLqV28XHMRQwcEKYvy9TJM6mFpQ=; b=Nd+WbdtXJhsZvquEe4Hu0fgiFqSZmyz0gVzvy/yUVOKJYhKpCTIEbpMWYbyLBY+0boI88WeDSV13dudMfYR5oYG0+LnreRdABoGjbp5nALNWMkQN48Ze4CWC71R9aLDadLXH4MNkQsfLQB3dH2kpzSOJu6JU0JMFJB+iT1cY+jdcO4S7D6taoId8SQknRBNAHJc8/tBlwczNyigchiomjd1j+Mtr7T/vZ4VzC+iDXIAp0eUdvKgyozbpwogMAPeu+Y9W73YGIU/2P4NQsSQBiLXSRXSjxqQsIW3wzPdccBqebzzU5udxXz6nonEpEp4SXy9kxr9EiQwkvfEuoW5IWA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:58 +0100 Message-Id: <9848848136be0af6e4c2c7a51effd88fbd8e6126.1513342045.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 v2 30/32] 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 Reviewed-by: Eric Blake --- 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 b40a2e32e0..d3be86afa4 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1008,12 +1008,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 09:32:30 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 1513343596525113.7487146880693; Fri, 15 Dec 2017 05:13:16 -0800 (PST) Received: from localhost ([::1]:46163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpnY-0000Vy-Jp for importer@patchew.org; Fri, 15 Dec 2017 08:13:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVI-0000X8-4u for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003Hm-BI for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:16 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48092) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003CR-UO; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084c-Dp; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV8-0004EL-8z; Fri, 15 Dec 2017 14:54:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=8h6EBMkS76CgSJuSuY0kq9MzsJBIwzXRgUs4AIiz+eI=; b=MdgZW74Ug93Y519+WZxVMKnYhIjiyfGi5Y8KLrzb46LVQBMnA2ot8KwrWd3TcOWSA25Nuz26ZWj+0rBQkXoKD78JRWkaRIo/Fy7ZWRUXyuVKfwmskR5wmnXOpNLikReRouiRB1Cni2vN2JRF/VzSD9YZqzJWDaAbwK5VyCgVznefR+Z+ggZArTcETvU/TkJ21rAJsUVhyc/buxSBxLUp2ii2poLS60jDjF7E4FznJms8ltUMrUcG4bhhPPJm9sVpWM0WX2t0J55vvU17i1QfEwY4Ui0s6HMyxhTbCIIN+Ic+QRcDrgGa/orOJtuwg+Bvu/ydT6A3aR3TITqXk+j9Bg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:53:59 +0100 Message-Id: <8525e16caa2fecac537aa62a449ea8626f5c7e36.1513342045.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 v2 31/32] 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 2fcecbd7a8..fe58d1ec70 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -120,14 +120,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 38c2ccf210..fb6b352c66 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -666,6 +666,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", @@ -737,6 +742,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; @@ -792,6 +798,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 { @@ -814,7 +831,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; @@ -833,8 +850,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; @@ -879,9 +896,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 1894d1d028..1f5f0d56a6 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 @@ -650,7 +651,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 From nobody Sat Apr 20 09:32:30 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 1513343588031586.9043576122407; Fri, 15 Dec 2017 05:13:08 -0800 (PST) Received: from localhost ([::1]:46160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpnR-0000LU-1j for importer@patchew.org; Fri, 15 Dec 2017 08:13:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePpVG-0000Wm-Rn for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePpVC-0003Io-Rw for qemu-devel@nongnu.org; Fri, 15 Dec 2017 07:54:14 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:48122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePpVA-0003Cn-U2; Fri, 15 Dec 2017 07:54:10 -0500 Received: from [192.168.12.179] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ePpV8-00084n-Mt; Fri, 15 Dec 2017 13:54:06 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ePpV8-0004ES-AI; Fri, 15 Dec 2017 14:54:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=zXsnoeZSzV6L71n95mCAdk7JYTE5JsSqEMQFJVEysHs=; b=BMFrQNygeYZb3y6iSBh5EYHNdZLhTGTlhUXxCiXVYqXpAmrCfSBmoRMYoqWR2k1D/91jeiOdtUSoYcQP3nhqzqStEMd0mR/bLH9hwzaHAQQEZfNyvb63V0i0UJQpn3X7mgWJhEnTpldOn7YfTQV0QK2yZfw/T2p11823nLl69o12eEupWHsRMYmLtXhI9sEmjevW7Hq6X7Vl9B2BVDCT2OK3NsgvNCah+anjQwyT1IX/2Vdq+zw9Y26tnZikAp1B3Sl0alTnLMwcRT3Yf7wcZ+gC1vumc4E2GSPXW0u/dWuINwH1bqbQRbB2a39gh0Twc2ZYSQFrYDGiKu/18r+qzw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 15 Dec 2017 13:54:00 +0100 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 v2 32/32] iotests: Add test for l2-cache-entry-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" The l2-cache-entry-size setting can only contain values that are powers of two between 512 and the cluster size. Signed-off-by: Alberto Garcia --- tests/qemu-iotests/103 | 17 +++++++++++++++++ tests/qemu-iotests/103.out | 3 +++ 2 files changed, 20 insertions(+) diff --git a/tests/qemu-iotests/103 b/tests/qemu-iotests/103 index ecbd8ebd71..6d9aab986b 100755 --- a/tests/qemu-iotests/103 +++ b/tests/qemu-iotests/103 @@ -64,6 +64,14 @@ $QEMU_IO -c "open -o cache-size=3D1M,refcount-cache-size= =3D2M $TEST_IMG" 2>&1 \ $QEMU_IO -c "open -o cache-size=3D0,l2-cache-size=3D0,refcount-cache-size= =3D0 $TEST_IMG" \ 2>&1 | _filter_testdir | _filter_imgfmt =20 +# Invalid cache entry sizes +$QEMU_IO -c "open -o l2-cache-entry-size=3D256 $TEST_IMG" \ + 2>&1 | _filter_testdir | _filter_imgfmt +$QEMU_IO -c "open -o l2-cache-entry-size=3D300 $TEST_IMG" \ + 2>&1 | _filter_testdir | _filter_imgfmt +$QEMU_IO -c "open -o l2-cache-entry-size=3D128k $TEST_IMG" \ + 2>&1 | _filter_testdir | _filter_imgfmt + echo echo '=3D=3D=3D Testing valid option combinations =3D=3D=3D' echo @@ -92,6 +100,15 @@ $QEMU_IO -c "open -o l2-cache-size=3D1M,refcount-cache-= size=3D0.25M $TEST_IMG" \ -c 'read -P 42 0 64k' \ | _filter_qemu_io =20 +# Valid cache entry sizes +$QEMU_IO -c "open -o l2-cache-entry-size=3D512 $TEST_IMG" \ + 2>&1 | _filter_testdir | _filter_imgfmt +$QEMU_IO -c "open -o l2-cache-entry-size=3D16k $TEST_IMG" \ + 2>&1 | _filter_testdir | _filter_imgfmt +$QEMU_IO -c "open -o l2-cache-entry-size=3D64k $TEST_IMG" \ + 2>&1 | _filter_testdir | _filter_imgfmt + + echo echo '=3D=3D=3D Testing minimal L2 cache and COW =3D=3D=3D' echo diff --git a/tests/qemu-iotests/103.out b/tests/qemu-iotests/103.out index b7aaadf89a..bd45d3875a 100644 --- a/tests/qemu-iotests/103.out +++ b/tests/qemu-iotests/103.out @@ -9,6 +9,9 @@ can't open device TEST_DIR/t.IMGFMT: cache-size, l2-cache-s= ize and refcount-cach can't open device TEST_DIR/t.IMGFMT: l2-cache-size may not exceed cache-si= ze can't open device TEST_DIR/t.IMGFMT: refcount-cache-size may not exceed ca= che-size can't open device TEST_DIR/t.IMGFMT: cache-size, l2-cache-size and refcoun= t-cache-size may not be set the same time +can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power o= f two between 512 and the cluster size (65536) +can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power o= f two between 512 and the cluster size (65536) +can't open device TEST_DIR/t.IMGFMT: L2 cache entry size must be a power o= f two between 512 and the cluster size (65536) =20 =3D=3D=3D Testing valid option combinations =3D=3D=3D =20 --=20 2.11.0