From nobody Thu May 2 02:48:10 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 151698034857741.76391767045527; Fri, 26 Jan 2018 07:25:48 -0800 (PST) Received: from localhost ([::1]:33256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5sx-00031f-Na for importer@patchew.org; Fri, 26 Jan 2018 10:25:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5o4-0007kt-AO for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:20:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5o0-00014i-8M for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:20:44 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54273) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5nz-00013l-V0; Fri, 26 Jan 2018 10:20:40 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5UT-0007gz-Sc; Fri, 26 Jan 2018 16:00:30 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UG-00086N-K5; Fri, 26 Jan 2018 17:00:16 +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=4AA6d/5mchJq+K3AM6cvX8SA7+oetehwzw/Ag11+QSc=; b=pMB5KD61vT1RXmPdnfmo5HSsvd4YXJJNJb8slQzHICQQTva5/WA8cFCHdB0kHdeu+A/bescKInwVpbQbOchvYFcOkE5KQMMyH1oHFuWDyUIuDUE6VEjfwd/c5dP8AJsOARc4eW4g8ic1kof2a61WFXugxvw4aFQVJgHdmyDUWszhMTMxsqK+GIxwt/DvYvruOhNxKcawxDTaxCR93YqP2Ju0PBjTjWEBjXRZlj/Dn82YjgikUezhn09wGGpyqSELcPjJ4uZEaPlCVYRIuwwaN2V1N4k7nrCPoVKdhG/HbOxNCfmUMG6MrrP0srjCfFjkQc3W3JAXhni3Gzqm1tf9ug==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:28 +0200 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 v3 01/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This function has not been returning the offset of the L2 table since commit 3948d1d4876065160583e79533bf604481063833 Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- 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 Thu May 2 02:48:10 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 1516979003232116.47161359739198; Fri, 26 Jan 2018 07:03:23 -0800 (PST) Received: from localhost ([::1]:60429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5XF-0004iv-PY for importer@patchew.org; Fri, 26 Jan 2018 10:03:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5VD-0003ag-5x for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5V7-0005Sn-Ae for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:15 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:50526) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5V6-00055y-Uo; Fri, 26 Jan 2018 10:01:09 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5UT-0007gx-SJ; Fri, 26 Jan 2018 16:00:30 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UG-00086Q-LO; Fri, 26 Jan 2018 17:00:16 +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=5JIfAScAJ7+jNf9/yHUNpPsZgYSDA5QkhR8p+RisHuI=; b=PZFj7372WLB3drDFhTQKJ6CEAZkUZ0pseF87vRIr50hPQKmF8jGMBILkcFknxHnNZS29EKl39EKBI3BLrfY2hq4Qs2hqz83BqlJj7O43PvUChwvnOWhzW0xouxJso2o8rbbhNdDWZtOzatLYd9dhTQGk2PqmtEdn7XMGHGA/dy1mmVbcGBOHnOU1MqWzJcr7+m+ZDsNrc+Lx2lIv8MTXiQndOQ3zhuwKEy/CsAF/XnRW0yYBN18Kvq4gC9tOA7D+ahla93brzBA86XQcjNRICrvP1jZcsvb448iMq9HhfGQfifXjK5UjDdMHhkCN5ZQsFC8PHkir54nDSqHS8O98Vg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:29 +0200 Message-Id: <344e6913766e24ed55592a84ceb8fad3ee59028b.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 02/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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..38c03770b4 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 (!QEMU_IS_ALIGNED(offset, c->table_size)) { 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 Thu May 2 02:48:10 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 1516979488399560.2537749505128; Fri, 26 Jan 2018 07:11:28 -0800 (PST) Received: from localhost ([::1]:60840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5ew-0001l6-MH for importer@patchew.org; Fri, 26 Jan 2018 10:11:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5VY-0003ra-0s for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5VT-0005mn-7F for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:36 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:50881) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5VS-0005lt-VC; Fri, 26 Jan 2018 10:01:31 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5VR-0007gy-FO; Fri, 26 Jan 2018 16:01:29 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UG-00086S-MU; Fri, 26 Jan 2018 17:00:16 +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=bmohJQEjDeTXOew2FHHHT/tbVPv/Jvf2O9p3KMb5Vd0=; b=Dj8AoLhll+qCg2a3mzOdFG7Y4qGccOUCHNDDsmpGUUamCmKxbzWAQGq9PhOWEZroMXpsINhA8edZe0L21sGiznFsieZPUD4Sd63pwQ86TPAx+mNLKmFKc4Xsdv3NF+uknCxQ5z+QtCOYwhEKxiFq4SGzZe/qiHlXpvaQgCe+GoH9/Yopm6BJSfiS0Ufb6nELgEiIY2TY0kfTg82WerLeRK7L59G6/GsUfXyfCVdyd+h698xq1eDW1n5WMZE3KKSEzESHvsKylR5CBRW2K1q8d5p+dDPkTjmhuH+PXApxKEewZnvCz3MF7G38ssPZESsQ6WZV6lXpBbXPvnuAjXfV0Q==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:30 +0200 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 v3 03/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 38c03770b4..a481ef499a 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 Thu May 2 02:48:10 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 1516980332069655.4195945447639; Fri, 26 Jan 2018 07:25:32 -0800 (PST) Received: from localhost ([::1]:33252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5se-0002nv-QT for importer@patchew.org; Fri, 26 Jan 2018 10:25:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5no-0007VQ-49 for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:20:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5nn-0000tA-37 for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:20:28 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54240) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5nm-0000sk-KZ; Fri, 26 Jan 2018 10:20:26 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5UT-0007gw-Ra; Fri, 26 Jan 2018 16:00:29 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UG-00086U-Ny; Fri, 26 Jan 2018 17:00:16 +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=g5irMEdLDeYN93zgiGhQIqPefAasWexcyljT41J0s4U=; b=RbBHynFGI2K34kIgZAYmN4+687I0TEDXdzgAwBTrUWRuOTo9CafUDYnXT6lXSkanPACtxeaFYRCHBS+hwryCl+QCsbD1iX+2bMdfkcE3RfLc6K9nGvGfhGS02HgH7CAWDg/r+WJBq5Z7TvsDYCO5RKhMTU66kWuqLXjOaHyKZOUpMjMYoJCHmEFVfgUpYFKcYIyvEQi5fHpZlsDENR+d4+ayv6kUSmWID15l75THbuwEfqcLvkmqrTrE2HyyYancqTxk8wNeNC5P1Km2tbNvGIM+B6fQPe9JvDyKw8MtOky/x52GLnTe180szUCYa9HuCA2bjGpixQFB8k3A931rFQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:31 +0200 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 v3 04/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 a481ef499a..3749d55595 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 Thu May 2 02:48:10 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 1516984389572981.7323276365332; Fri, 26 Jan 2018 08:33:09 -0800 (PST) Received: from localhost ([::1]:37050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6w8-0002Yf-OS for importer@patchew.org; Fri, 26 Jan 2018 11:33:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6qu-00079p-Dw for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6qt-0004GN-FG for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:44 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38577) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6qt-0004Fo-5U; Fri, 26 Jan 2018 11:27:43 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5UT-0007gy-Qc; Fri, 26 Jan 2018 16:00:29 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UG-00086X-P9; Fri, 26 Jan 2018 17:00:16 +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=ndelUrJWiYLdkYnRMTpqGXXys/XispKbZqBDzDS4vUg=; b=YfzB8U/6wiSgvaX++q1Twt78CiF+IbszsL0vjsfdbo7x7yA55MWJc3+RvPyMuPEwv+sPDXB2l6F2TElKPUedFuoMBuLuQKr6pqgMmpLdjsYcoKJTCE7wEjau0rA1anC97rd8fD2udc2PkGOsqZPvERqru02uI7YCdlDK2xz60noJ1Fe5vHYHYuaZ9YnwjJZ0rGXEEUfoJnKBhitK5wY9mnEL8QJwPM4ZYxEOR7x36ywtMuDTeicPnlL0vRHmWOLAsfyXdMcmkr7nt1xpXlmQl/pAgCZhku4l0q5uq1ztHJhRgH85b/H84hzZggrANph+6uUHnOu2ONLCJy+pJ1wzcQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:32 +0200 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 v3 05/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 3749d55595..5ff2cbf5c5 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 Thu May 2 02:48:10 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 1516980696992953.1984056084368; Fri, 26 Jan 2018 07:31:36 -0800 (PST) Received: from localhost ([::1]:33558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5yX-0008CT-3P for importer@patchew.org; Fri, 26 Jan 2018 10:31:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5pz-0000w3-R9 for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5pw-00032C-L4 for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:43 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54707) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5pw-00031X-6y; Fri, 26 Jan 2018 10:22:40 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5UT-0007h0-U1; Fri, 26 Jan 2018 16:00:30 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UG-00086a-QH; Fri, 26 Jan 2018 17:00:16 +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=pQUjTZYukfMPd1e8AnQzOn1wMx6GnaMM0lsd7C3r6Aw=; b=VNTjoRU51xYzEuGkfJ7/uZDPRlige/PQelmGDBCnyChRsmcx4Sa4sEon+DF5HwFR317KTxlbDUp5j9kPp7FRZVs/XRMiZPoDFDh/yoE+CKZiAt9q+ugrw5pXFMHEXVpYIBhV93kvfUAaJHofN2vyddIKWyV0nSYyZrULXsEtEbT0b1hfxcBea8uTQTQtE5ucBTsbGUHGIQhZsjPSp1/5FTV+VmL9IN0Ehi6jAnVF6mb+ct27qZE2n5n0bLMek1d7GXxA1C+b+HD1Emk7GkX+7/Z02BPMIApEcjxMknlrHb7aD3bVErdOR/iairrFvLQEuJkAZa1YK3ZulVthMI9bVw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:33 +0200 Message-Id: <97a2e764d1fb53ce7a25e1d0699114c01d8042d2.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 06/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 5ff2cbf5c5..07603e6b15 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 92701ab7af..5434e7d4c8 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 @@ -3180,7 +3178,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 46c8cf44ec..ad332ed380 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -639,8 +639,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 Thu May 2 02:48:10 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 1516982397173972.9726274055386; Fri, 26 Jan 2018 07:59:57 -0800 (PST) Received: from localhost ([::1]:35265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6Pz-00016H-GN for importer@patchew.org; Fri, 26 Jan 2018 10:59:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6Nr-00081D-Hc for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:57:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6Nn-0005aJ-IB for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:57:43 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:33039) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6Nn-0005Zj-62; Fri, 26 Jan 2018 10:57:39 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5VR-0007gx-RA; Fri, 26 Jan 2018 16:01:30 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UG-00086f-RS; Fri, 26 Jan 2018 17:00:16 +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=RfQbOuuVSJgYbU3/Ylb5rLURvYEjqf/WfQPpYikz2zc=; b=jiaDBFKtV6H8YrFNUsVar8KbGHZuvXVd2nN1M7EaK2eOSe0+xFGcEkVEFaKhrUAwaSD4d9N+oIDrcEdOfTVIf3GRapDEsl66mwJRNRiKfWAm8VFZSGp78QnKlkW1bQzvoHNdCVY2J49yVE9TRnOv0HjBVzHQTwCaHYKklrB3obodMkMBOApzAT/VLpSt/F/vNwhiTEbGxLU1JrOxEIRPWs6slQGLZcRqUijNkOZ/CBpQwDzP309DHWOWqp41lCIQqXdQ/nk9euyQA3TC7SWA5Wg1nr3uRgWIb3qgQ+fyjBLn0fCjh+QnFHQ+N7PuVXTN4ShkfiaWl2OZSPpbkFGeQQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:34 +0200 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 v3 07/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 07603e6b15..3b55f39afb 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 5434e7d4c8..65af05dd23 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; @@ -2847,7 +2847,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 @@ -2860,7 +2860,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; @@ -2881,7 +2881,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; @@ -3173,14 +3173,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; @@ -3233,7 +3233,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 ad332ed380..96626d151f 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -653,7 +653,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 Thu May 2 02:48:10 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 1516980887733558.5914764244668; Fri, 26 Jan 2018 07:34:47 -0800 (PST) Received: from localhost ([::1]:33603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef61Y-0001n3-JA for importer@patchew.org; Fri, 26 Jan 2018 10:34:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5zD-0000VU-OC for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:32:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5zC-00021s-Or for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:32:15 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:56424) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5zC-00021D-GK; Fri, 26 Jan 2018 10:32:14 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5VI-0007h0-0t; Fri, 26 Jan 2018 16:01:20 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UG-00086i-Se; Fri, 26 Jan 2018 17:00:16 +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=BBwaZwYmA6yMCfi6boqlMVd/n+FRm+mQ+jvjPRkqBwQ=; b=I3gFedoQYKHMNpGHA8QE1V9up+LRMsbNE8+wdAtD3yp89hSo8jZxLPbeQd7AABtqZGyg2CdtYCTwhQ+aWQ7Ktf2VOOLy5Y8PRvACD1p4coKR1yzZrG8Qb/DcSYVlyPl65tTYzoazZe1Jgox+AzflZPYlI9yQCv6x+d+JBFeQtVB3pG2FG1NMVANIuTccz/guSh/ylD38qxzbB9hBrCPQJ1t1YNFtf1JfYdLWW5R5wvuOy32ueiU0nui5TftoamifxIaWEpbQ8ZyB6kLAV/fE+WMMRvoV2gegQkQ4h+TO/I20AYbuBhGa1HNUiXLxWvYpoPDcRs3raFNzsaTgonRPOQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:35 +0200 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 v3 08/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This function was never using the BlockDriverState parameter so it can be safely removed. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- 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 3b55f39afb..6f17a28635 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 1f80961e1b..8e64c12605 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1042,10 +1042,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; @@ -1071,10 +1071,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); } @@ -1512,10 +1512,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); @@ -2063,8 +2063,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 96626d151f..e0c429aef2 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -637,7 +637,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 Thu May 2 02:48:10 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 1516980900657802.292207183065; Fri, 26 Jan 2018 07:35:00 -0800 (PST) Received: from localhost ([::1]:33605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef61r-00022I-E6 for importer@patchew.org; Fri, 26 Jan 2018 10:34:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47876) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5zX-0000mU-9A for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:32:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5zW-0002C5-DK for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:32:35 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:56527) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5zW-0002Bn-4d; Fri, 26 Jan 2018 10:32:34 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5VH-0007gv-TN; Fri, 26 Jan 2018 16:01:20 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UG-00086m-U4; Fri, 26 Jan 2018 17:00:16 +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=yktN/RKZOfo0+bwww2LHqVVjT37bWe9GnC1U2ymwrxQ=; b=VrCGOyBvPXobuTAmIOiRVR6kHaa79tL1ndrf92ZaR4sVFF1iy7KrjyaEiKmVu+8kXjN/0UWhQTw2vBocrQ+Kpge3fi3ge4w5RU2eCtz9/oxPvUapU0G1qONUgFMPWzZJXD/WbG6XFkGD8NKdQOGODCF0stVEisNPElt1Gr2p5doDF7be5txAAK67wRzjqhhqsRCW6XIJgbvns670SOTW5KqAQfBOcQFl9OlCXBNdF1BYLZvFQWZzP+7zwSh8d7SlwY5NkXA1YNpAjSlIOviMlRexVFZzdXTFC+QuPXEP1+eVm+566zWIP7iJ4t94OnCea0U2hnFt78sIiRUN6gv/3w==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:36 +0200 Message-Id: <9373dc21083ea85c3fded0edd717ad4f61fb68dc.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 09/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 6f17a28635..03b3e03c6c 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 8e64c12605..e2d4bf7ad5 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -704,8 +704,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 e0c429aef2..7e2781ffa4 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -646,7 +646,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 Thu May 2 02:48:10 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 1516980549293745.8003871450379; Fri, 26 Jan 2018 07:29:09 -0800 (PST) Received: from localhost ([::1]:33386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5w7-00068R-8o for importer@patchew.org; Fri, 26 Jan 2018 10:29:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5qB-00016G-1F for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5qA-00037k-1x for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:55 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54727) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5q9-000373-NQ; Fri, 26 Jan 2018 10:22:53 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5VH-0007gw-OB; Fri, 26 Jan 2018 16:01:19 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UG-00086p-VI; Fri, 26 Jan 2018 17:00:16 +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=mfsKtIMQVwvtwMVocJ4qDS/ycO/lGQwwAfYqLlZn0nc=; b=Id4p1fuu97BeS9K1jH5iOXMrzAKOSEBiLVSj3jsHXVgyVz189W2kZkSH68Mr5OmKOAgYt1q4r8XiT0RKGH2IG/dyhMNjp23QkLWF5i66ryG6MljWuN2K4tZXLIuNb5bIocYbvh4X463V7pa9HqzZhxN7uXt8nefR1MFD7aTRbdH8JcjowB5h/m7nbOh4DcaEsrWPgqau+vEpYWCJrPhc5iGrcDHnifbYO3DOLVuLfTfU/Jhc9kZ315+iPmxWjxTy/LDYo0PAXCq4TP2TdSD1C1KXtJz8igbNGKinZtlDVdaYS8WJ/FFFL83pK3kENfGDyqsaWen9tg5tjlZjnrM2tQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:37 +0200 Message-Id: <4a7de8aa1edebbb18e7ee0eeafc5bf2ddd51ebd9.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 10/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 03b3e03c6c..8d0b65e671 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 65af05dd23..361b39d5cc 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]) { @@ -3190,7 +3190,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 7e2781ffa4..f6552fe9c3 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -656,7 +656,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 Thu May 2 02:48:10 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 151698128506939.47306058718982; Fri, 26 Jan 2018 07:41:25 -0800 (PST) Received: from localhost ([::1]:34140 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef682-0007Lz-5G for importer@patchew.org; Fri, 26 Jan 2018 10:41:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5zf-0000tO-Fn for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:32:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5ze-0002E3-Dz for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:32:43 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:56540) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5ze-0002Dq-55; Fri, 26 Jan 2018 10:32:42 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5V8-0007h0-20; Fri, 26 Jan 2018 16:01:10 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00086t-06; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=ZJR6amiK3HMIKu2oN4dAKjBX7FiLMfVA8/h7GssOQnc=; b=ZZrUuY0ASXvUWVTGqlLEX1QWiT65B0ZUImHGkcrWJ8tuBcy8tLK/IjItEpsCW0L4hEh6TFR6WXU4SRf7KTOaqL20PynSf09/Ml8Zugg8WNA/EW64pYvsl4Yk+5FN72drwE9tWHgAPyDLJCVxa9tto0VLt5jzqhkQSwpme3bDlRLuuaHw8Zckd0M1cmad1+56Ui7KjxmYXQ8bzMHUrSysksQ5dIRsCWb0VcvbM+lWyINB6c1PEoRFdnqv7dcbpVIv0UST4a2F+4kiKNPKHa3Sgy8jg7/JNyvJm/DBQaKJgiPWdlivDBhJBFiuQ4DHYfnmY4jPrkooJOYdBQPoB5G4rw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:38 +0200 Message-Id: <245ecc9693e29fa6398d20ac5a90ef8dcdc23cda.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 11/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 8d0b65e671..b1aa42477e 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 361b39d5cc..9df380d52c 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); } @@ -3186,7 +3186,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 f6552fe9c3..cb8dd784fa 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -654,8 +654,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 Thu May 2 02:48:10 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 1516979399730236.3203453232312; Fri, 26 Jan 2018 07:09:59 -0800 (PST) Received: from localhost ([::1]:60773 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5de-0000tX-VU for importer@patchew.org; Fri, 26 Jan 2018 10:09:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5VY-0003rc-1W for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5VT-0005n0-FG for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:36 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:50885) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5VT-0005mD-6z; Fri, 26 Jan 2018 10:01:31 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5VR-0007gv-RU; Fri, 26 Jan 2018 16:01:29 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00086y-1C; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=VgcRl0YsbjvIrggdjlIt3eLG5uJpdsfmHz2VhSrzGW0=; b=XoQRfYS4aegelsT9B1E8kjlZ8EjZuhYaFzGoThwgcbS6OF3Q/8N1fcDFQW5SajWfIYDvJiWrizcgPZoWCMsIuizLN1j4qeZTjFGXO2pJ3+uPrctWj51B2JHC3Lkh80rJQQXlixBm76WO+wZhnedvLKcHuTBRXK3449KeLjXZsQFZg059zVLFo/Z3vKdpxPEjDn2hRnatsB7JBlFmNtQ+gDtAaYwxgW2v8GEAnhjDUuMg4DLbZkULK6Q7fBmK8ChWZi/VZQkh27KYSn3+NshiSJ3PDtgo/epU2kWtxuSHecxLfOQyJQex1YcJKQ93zldNHFY/j/DWIxUU5zQH1Jrd2w==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:39 +0200 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 v3 12/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 cb8dd784fa..0559afbc63 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 Thu May 2 02:48:10 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 1516981149525189.12470496510127; Fri, 26 Jan 2018 07:39:09 -0800 (PST) Received: from localhost ([::1]:33832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef65s-0005Tt-LI for importer@patchew.org; Fri, 26 Jan 2018 10:39:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5zR-0000hR-IK for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:32:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5zL-00028R-NA for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:32:29 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:56492) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5zL-00027y-CW; Fri, 26 Jan 2018 10:32:23 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5VH-0007gx-Tt; Fri, 26 Jan 2018 16:01:20 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-000871-2J; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=lkrX81jnuGFpt6SgO5erSt5NSjQmJ0tkgQt+MdgZxCg=; b=LkgQiYwoyK1VnEsT8qcFlpymg7YFplfqAbyKBmlv70hg9tVUQdFgxJChS+AqkghKLJIxIBca9HmHEEsxjl3Y4l9/18gKvEKLZR2UgbsSrBpy6XqcPxg2jZsCU/EG1j8BZy50hUB9BEtiyV3actljVkaa/Awr0jJN7bSH02L+K2agq4ZY85M7TJNf7aMDBhfXeiH9CAw9KSWDsEdp8+iqx38xDNMaJmpoWmz9y7yLDnO92fULvwUCWRGUAdZtheUjeZuaz3bn1wZZybdb8qgFG1vBKIaPzztESK2opTs5UrzpWZL+W1yKstsTlmG+nBKD/6B84CzuaUNqFey6fADiSg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:40 +0200 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 v3 13/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- block/qcow2.c | 3 +++ block/qcow2.h | 1 + 2 files changed, 4 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index e2d4bf7ad5..78f067cae7 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -805,6 +805,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; /* Number of entries in a slice of the L2 table */ bool use_lazy_refcounts; int overlap_check; bool discard_passthrough[QCOW2_DISCARD_MAX]; @@ -886,6 +887,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) { @@ -1049,6 +1051,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 0559afbc63..e0aee88811 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 Thu May 2 02:48:10 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 1516984192665290.1199404597169; Fri, 26 Jan 2018 08:29:52 -0800 (PST) Received: from localhost ([::1]:36989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6sx-0008QP-Ni for importer@patchew.org; Fri, 26 Jan 2018 11:29:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6qt-00078R-4A for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6qo-00048U-7p for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:43 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38567) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6qn-000456-Un; Fri, 26 Jan 2018 11:27:38 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5VH-0007gy-Ja; Fri, 26 Jan 2018 16:01:19 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-000874-4E; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=5FlK1T3PA30G5bDf2mj1tdU9vNdIOTin6KOq2/LBVok=; b=hR8djKROJSwub8J2606PxGQaxOJwIj6oMAQFKfj6JInU8Nlw0+RIzeQ4jr0jyOB1QchxSm10EI2QlvknuJBMGliPo1zM2HoEI9gvRPNt8ybehw/nXGF+U35LtkvJcPrL7ewxgYhM36QK1UMpfirJ+7Uh8rbP3CAxhhzPKd9B7fam0/rpcnrrtAnM4DCWUmMVetv2QfQ3GC6uImIK/xgpF2XfAsWIzosmMsAkl4lqM1BxX2ly685cuGxORtNIx26sW1OttCHguiaseKaLsC8sPGrMos9fPlf+uNpOqfFwvV0cwiKW8hH1rEOCjwG77UoBv+kZpaIBrPNkm2zdnNoclA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:41 +0200 Message-Id: <1bf8f7ede9cfebffd11fb9e30c6e497d441b89cf.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 14/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- block/qcow2.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/qcow2.h b/block/qcow2.h index e0aee88811..87b5c4063e 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 Thu May 2 02:48:10 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 1516979020632102.45786404610294; Fri, 26 Jan 2018 07:03:40 -0800 (PST) Received: from localhost ([::1]:60438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5XV-0004vA-4R for importer@patchew.org; Fri, 26 Jan 2018 10:03:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5VJ-0003gu-Ot for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5V9-0005UI-Rv for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:21 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:50719) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5V9-0005TC-De; Fri, 26 Jan 2018 10:01:11 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5V7-0007gv-Vl; Fri, 26 Jan 2018 16:01:10 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-000877-5Z; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=uqw0nefTZ38lsqY8ji7JnkWvem3jtSOxYwQuWv/4kjE=; b=AEtwsL0wxCvbiLjolo7oK0IQTrRF/Ka31qRdTB22uz/6B7DPDhivN4H3FChomO44GYPRth+tp5br3RxjteMeW3w1WpxtCb5N/qvsRzwrahfv1lhiwKe5Xh+UuRVJTHfbXzumdanpB8MJ3dElgZbDtchpBoSrBJx8nEphhkAtsiBqyn8EoNCL9aeN60qu/rtt8F7TPz51WF51niiJ3JO1vPkVXfRk3wchieLLZfHuE6/WZL95Lwa/fqeE/NyFd2S7uTFHbRTlM3118Lwk/jdn9zf4dg0B15+rj6B3inq6bjbama+p9SPUGEWn6OaPgmH5zkQR5FzRcv3cFbvOG+nE4A==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:42 +0200 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 v3 15/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 Thu May 2 02:48:10 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 1516979271328357.56749125203555; Fri, 26 Jan 2018 07:07:51 -0800 (PST) Received: from localhost ([::1]:60609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5ba-0007oT-IB for importer@patchew.org; Fri, 26 Jan 2018 10:07:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5VC-0003Zg-5L for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5V9-0005UG-RO for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:14 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:50720) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5V9-0005TF-DW; Fri, 26 Jan 2018 10:01:11 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5V7-0007gw-RN; Fri, 26 Jan 2018 16:01:10 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087B-6Z; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=wMM6RX/1t6MV7nzkH4gqCc0RPd4aeZOjEMMDswmNa6w=; b=mt4C4lwM3iBVU/bHOcnyDkNsKtR4YQuq+m4YisnRiDYnbMR0+YMuTqWpqS8yezko+ga1jbTXbT6LKjmms5e4MxfX6VwksIu7knCRQ2oWSMSnjEN3XOfFya7svnjd4Gk1e5/fHcsIBhIByd0ZCudKS45cV9Xzq+Ri7lkolBbHr2ls6VucNdTP5NrBNmtdC1TByhb9CNWC5SqT/B3VpoLHkKm7MwnsQaKYjQ4bGxHNVLX77aq37/pUhqk25EUy2/VnFniYEiAvNni9t0tzOwZ/IFd0Gwt0y2R6GT28QF3BdRjw1UlpSrwTc9ZZ4VCIullSeQTza9k2CytGM/A4P5qtnA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:43 +0200 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 v3 16/39] qcow2: Prepare l2_allocate() for adding L2 slice support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Adding support for L2 slices to l2_allocate() needs (among other things) an extra loop that iterates over all slices of a new L2 table. Putting all changes in one patch would make it hard to read because all semantic changes would be mixed with pure indentation changes. To make things easier this patch simply creates a new block and changes the indentation of all lines of code inside it. Thus, all modifications in this patch are cosmetic. There are no semantic changes and no variables are renamed yet. The next patch will take care of that. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2-cluster.c | 55 ++++++++++++++++++++++++++++-------------------= ---- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 8d92d623d8..57349928a9 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -300,38 +300,43 @@ static int l2_allocate(BlockDriverState *bs, int l1_i= ndex, uint64_t **table) /* allocate a new entry in the l2 cache */ =20 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); + { + ret =3D qcow2_cache_get_empty(bs, s->l2_table_cache, + l2_offset, + (void **) table); if (ret < 0) { goto fail; } =20 - memcpy(l2_table, old_table, s->cluster_size); + l2_table =3D *table; =20 - qcow2_cache_put(s->l2_table_cache, (void **) &old_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); + if (ret < 0) { + goto fail; + } + + memcpy(l2_table, old_table, s->cluster_size); + + qcow2_cache_put(s->l2_table_cache, (void **) &old_table); + } + + /* 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_table); } =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_table); ret =3D qcow2_cache_flush(bs, s->l2_table_cache); if (ret < 0) { goto fail; --=20 2.11.0 From nobody Thu May 2 02:48:10 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 1516980558041717.5291528423822; Fri, 26 Jan 2018 07:29:18 -0800 (PST) Received: from localhost ([::1]:33390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5wL-0006L7-4G for importer@patchew.org; Fri, 26 Jan 2018 10:29:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5o2-0007k7-Sp for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:20:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5ny-00013Q-Sm for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:20:42 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54272) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5ny-00012N-K3; Fri, 26 Jan 2018 10:20:38 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5VR-0007gw-Oj; Fri, 26 Jan 2018 16:01:29 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087E-7g; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=kGCPlyewNv9J6Di+/CUD5SKPeT6ouDwhu8IbwGQeEw0=; b=pRPlGwN9l7Ksz/B3PyMhGt6FiMWe8L6WpfxVsXh1HuBCIRSDjWD1PyHCzogTZDoqrm7xHZLxfiXVQ3UX06dt1gpNp58lYSiJ885rNsD+/UZby1OYB0mwY0a52FI3ZQcI1KYKALaMu22Lwb1XkVHRsiLvzRa8Sc/N/bLECDtfHqxXRqNSdpa7YtNzjhbbFYC9Uxlt6MxJbtWMiSYA0qStvsIVYNUWN9zyc292iH9BmU6bDKH1r/eWiSUAdtPtEHmtmuUJkamiZNXBGBGz1CIh5OmeKAy1NRH/PkPzUFH3UEmIMyvVE09UlZFasDXsSQbjQ/JCniB+Z478VaLwKGMVjg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:44 +0200 Message-Id: <07a984cef4f1c97dcca44e365aa90ba5b6881e09.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 17/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2-cluster.c | 56 +++++++++++++++++++++++++++++++----------------= ---- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 57349928a9..2a53c1dc5f 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_size2, n_slices; int64_t l2_offset; int ret; =20 @@ -299,42 +300,45 @@ static int l2_allocate(BlockDriverState *bs, int l1_i= ndex, uint64_t **table) =20 /* allocate a new entry in the l2 cache */ =20 + slice_size2 =3D s->l2_slice_size * sizeof(uint64_t); + n_slices =3D s->cluster_size / slice_size2; + trace_qcow2_l2_allocate_get_empty(bs, l1_index); - { + for (slice =3D 0; slice < n_slices; slice++) { ret =3D qcow2_cache_get_empty(bs, s->l2_table_cache, - l2_offset, - (void **) table); + l2_offset + slice * slice_size2, + (void **) &l2_slice); if (ret < 0) { goto fail; } =20 - 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)); + /* if there was no old l2 table, clear the new slice */ + memset(l2_slice, 0, slice_size2); } else { - uint64_t *old_table; + uint64_t *old_slice; + uint64_t old_l2_slice_offset =3D + (old_l2_offset & L1E_OFFSET_MASK) + slice * slice_size2; =20 - /* if there was an old l2 table, read it from the disk */ + /* 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_offset & L1E_OFFSET_MASK, - (void **) &old_table); + ret =3D qcow2_cache_get(bs, s->l2_table_cache, old_l2_slice_of= fset, + (void **) &old_slice); if (ret < 0) { goto fail; } =20 - memcpy(l2_table, old_table, s->cluster_size); + memcpy(l2_slice, old_slice, slice_size2); =20 - qcow2_cache_put(s->l2_table_cache, (void **) &old_table); + qcow2_cache_put(s->l2_table_cache, (void **) &old_slice); } =20 - /* write the l2 table to the file */ + /* write the l2 slice to the file */ BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE); =20 trace_qcow2_l2_allocate_write_l2(bs, l1_index); - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } =20 ret =3D qcow2_cache_flush(bs, s->l2_table_cache); @@ -350,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) { @@ -702,7 +705,7 @@ static int get_cluster_table(BlockDriverState *bs, uint= 64_t offset, } } else { /* 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; } @@ -712,6 +715,15 @@ static int get_cluster_table(BlockDriverState *bs, uin= t64_t offset, qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_= t), QCOW2_DISCARD_OTHER); } + + /* Get the offset of the newly-allocated l2 table */ + l2_offset =3D s->l1_table[l1_index] & L1E_OFFSET_MASK; + assert(offset_into_cluster(s, l2_offset) =3D=3D 0); + /* Load the l2 table in memory */ + ret =3D l2_load(bs, offset, l2_offset, &l2_table); + if (ret < 0) { + return ret; + } } =20 /* find the cluster offset for the given disk offset */ --=20 2.11.0 From nobody Thu May 2 02:48:10 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 1516979288711444.9507540404337; Fri, 26 Jan 2018 07:08:08 -0800 (PST) Received: from localhost ([::1]:60613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5br-0007zp-Ta for importer@patchew.org; Fri, 26 Jan 2018 10:08:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5VP-0003kv-IY for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5VJ-0005dt-O9 for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:01:27 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:50824) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5VJ-0005cI-CR; Fri, 26 Jan 2018 10:01:21 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5VH-0007gz-Um; Fri, 26 Jan 2018 16:01:20 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087H-8o; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=/Lzl7qXGe01ubUPUCmVZkgGNh0e5TgZpokHzZ90SRl4=; b=nz37vQK7yYKHPb+Yna6QY662OP2v7gez+i41N8+sfvIKVzyHEpWoP2fG/TUGXoFA/R0YsRMz8Xj6S0axcVfU2kuznbK8NC7Zy9sJasBxZA1s4Wc1vQesh0hWicinhZ2mIaDCd9xHcTc5XlPkrInkHwp4l2G7nK4jilKcCWmVn9M2DHvA45lFD5JM/6zUiNcXmc2pwd/70NNAR5p+1jv/P02T7iyMpVzm0IXxnoZp6H+wC8fff2iQHurkOFb2uO/DdYg3dptnVlnRk5mUZlP24IBsipUyOoHD9/Zekf0BAfYwitI3Ze6q9ata0rrzV5nNltp4dB+H7ffrlRueImSIaw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:45 +0200 Message-Id: <5e98f636670e1741b9bafae624efb0052d9d0b71.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 18/39] qcow2: Refactor get_cluster_table() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" After the previous patch we're now always using l2_load() in get_cluster_table() regardless of whether a new L2 table has to be allocated or not. This patch refactors that part of the code to use one single l2_load() call. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2-cluster.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 2a53c1dc5f..0c0cab85e8 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -695,15 +695,7 @@ static int get_cluster_table(BlockDriverState *bs, uin= t64_t offset, return -EIO; } =20 - /* seek the l2 table of the given l2 offset */ - - if (s->l1_table[l1_index] & QCOW_OFLAG_COPIED) { - /* load the l2 table in memory */ - ret =3D l2_load(bs, offset, l2_offset, &l2_table); - if (ret < 0) { - return ret; - } - } else { + if (!(s->l1_table[l1_index] & QCOW_OFLAG_COPIED)) { /* First allocate a new L2 table (and do COW if needed) */ ret =3D l2_allocate(bs, l1_index); if (ret < 0) { @@ -719,11 +711,12 @@ static int get_cluster_table(BlockDriverState *bs, ui= nt64_t offset, /* Get the offset of the newly-allocated l2 table */ l2_offset =3D s->l1_table[l1_index] & L1E_OFFSET_MASK; assert(offset_into_cluster(s, l2_offset) =3D=3D 0); - /* Load the l2 table in memory */ - ret =3D l2_load(bs, offset, l2_offset, &l2_table); - if (ret < 0) { - return ret; - } + } + + /* load the l2 table in memory */ + ret =3D l2_load(bs, offset, l2_offset, &l2_table); + if (ret < 0) { + return ret; } =20 /* find the cluster offset for the given disk offset */ --=20 2.11.0 From nobody Thu May 2 02:48:10 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 1516980203758344.65976927275926; Fri, 26 Jan 2018 07:23:23 -0800 (PST) Received: from localhost ([::1]:33176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5qc-0000wC-TK for importer@patchew.org; Fri, 26 Jan 2018 10:23:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5nJ-000713-DC for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:19:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5nF-0000cJ-EW for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:19:57 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54086) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5nF-0000bs-5h; Fri, 26 Jan 2018 10:19:53 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5V7-0007gx-WF; Fri, 26 Jan 2018 16:01:10 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087K-Ag; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=18rXIdkl9iX/0aVFHsGxXfd1/PSBfGjM5vUwSsSPqrg=; b=E7QkH13SX57bRbYalBGoGcxa43TnPV9Rdv1gmV0KAuvGeVkq7tEp/ANNFVAdQLkod/1yh3z9Wd1N8ievvZLylvrVc6xG9PKc67ddtssj1iDaz9U2IqT0jhLwTOd8m8SPTlnHLGa+SLFZ+Uks8sBPRruRY8FaXphiyNZCtGIJi04eoL9zYNcz4A2jTnls09V3YQwSxfesctdBt1CgpPI0JmZnNsG4zd9oKtNeklYzywqI+iNeyufYVMjjse024MSwIei1kobb+qDQ77cTmT7OkKVPT8XToqtMc2tTmm3tau6S7q8TVlalZGruztGE+gHSEBTX1uqC208XEzVBi7XBfQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:46 +0200 Message-Id: <9c3d818ac202b776dbe73080d017e2c179c5babd.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 19/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 0c0cab85e8..416d48fa77 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 appropriate 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 */ @@ -713,17 +713,17 @@ static int get_cluster_table(BlockDriverState *bs, ui= nt64_t offset, assert(offset_into_cluster(s, l2_offset) =3D=3D 0); } =20 - /* 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; } =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 Thu May 2 02:48:10 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 1516980554726733.3381413377336; Fri, 26 Jan 2018 07:29:14 -0800 (PST) Received: from localhost ([::1]:33387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5wC-0006Ds-3K for importer@patchew.org; Fri, 26 Jan 2018 10:29:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5pY-0000aA-M9 for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5pW-0002m2-Bc for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:16 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54575) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5pW-0002kU-2C; Fri, 26 Jan 2018 10:22:14 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5V7-0007gz-Vf; Fri, 26 Jan 2018 16:01:10 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087N-C8; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=pyZV8koNJMlDPjjUZ8yh9q6Rip0NeECRTUsL+5JOPnY=; b=dQrmf4VLtLPyNTugBnQbrzdn/lAEtvAD5QL5KZZjH3b2xoLQLutPn5lmaLJ04MjUey56m+oJ1Z0TiShZ8vAFI0gPOTBjRNGt/rqxHYV6A5YSwV37srxuvgh4hrbhXqd3cmLkEq3226KG7PkYx+fjw4+hkLkQWPvbYqu7v8iRdxzNGOJEF7PZQjILvbxvbLqSr4R7HuW4S/yZEjedcrZISetzsGbG4zYGf/ydt7J1IaNbRg7AirKZDwr3NkIHyJSeVXPVXPtoim5m9+kO7inDZzT2JwURZ4LqpmJXmPrYC19hDFfBNFsjL0DB1jmSv4dx9n2O/rnY8pnDRINm8B1Lmw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:47 +0200 Message-Id: <2b46336dbc0958554ef7883d95a61de88533337d.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 20/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. One consequence of this is that with small L2 slices operations such as 'qemu-img map' will need to iterate in more steps because each qcow2_get_cluster_offset() call will potentially return a smaller number. However the code is already prepared for that so this doesn't break semantics. 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 Reviewed-by: Max Reitz --- 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 416d48fa77..128a82dc5a 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 Thu May 2 02:48:10 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 1516984598706713.0453137199501; Fri, 26 Jan 2018 08:36:38 -0800 (PST) Received: from localhost ([::1]:37077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6zW-00057v-0C for importer@patchew.org; Fri, 26 Jan 2018 11:36:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6qt-00078S-4G for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6qp-0004B4-Gv for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:43 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38573) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6qp-000496-7F; Fri, 26 Jan 2018 11:27:39 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5V7-0007gy-ND; Fri, 26 Jan 2018 16:01:09 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087Q-E1; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=bbJRURIN4H77B1HFD36DM+52aCzNK/wdgheAS2M68ak=; b=cRsFClhpLI4vabv+Ho4UzVJQOajaclgsag80TvfY0GjHd+5XSgDtq0lfRFdelum4UXPaxJpYH+yE58fOdeE74Yc/AiQU9c7w3G257M2OrwvblTcbCfpijHgK61zo82RKjYWzvItEbbihvvDjT4A6ytJhNzKVFj7rcqjp0OPs6z3vJRLZqN1cijGDCAsB8ZZe6eurtOga3A0yW2tW7FKtQ6drKRpNL+q1ZJpl+shq+5294SAMvjIgOg6wAG0fWUy8onaZ4y5twFoy/Wk/TnR4mTqmmg1vai9mL+K7+0eD1Z68WzEPSPIuqRTU5h4UWxAYk+3NQkNQd0DSrgdn8JvnlA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:48 +0200 Message-Id: <6799e51bdf50179b3632adf20c768cf22c260e8c.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 21/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 128a82dc5a..abc9e3ed6a 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -923,7 +923,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); @@ -950,13 +950,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. @@ -964,16 +964,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 Thu May 2 02:48:10 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 1516984392873557.7609366864974; Fri, 26 Jan 2018 08:33:12 -0800 (PST) Received: from localhost ([::1]:37051 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6wB-0002ba-Kt for importer@patchew.org; Fri, 26 Jan 2018 11:33:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6qt-00078W-6H for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6qs-0004Fe-4v for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:43 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38576) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6qr-0004EP-Rt; Fri, 26 Jan 2018 11:27:42 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Ux-0007h0-Ro; Fri, 26 Jan 2018 16:01:00 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087T-G5; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=u7l4jraMwoyR7OU1ST5gH2eRDXJNbObvdw1ELeaCunI=; b=gF7ZPCD1a0X6v2DkfZl9a7gjm3FVrwjBV2Ku1kGfJi6pF/njI4UEXGscUlh2BhjiQhL1yxqvaOC5zziConfUJEeWG1UR4d0CJIl2DgZRgDQqMGilCj5dAmpon9MrSYr3zHnMpOsUTKbXNdIlrx/EVHuQmJDv4stUtsJhr3ic1HNDiy4WzMsK34z7bmQ8gT1MiLBzYldLjNhgdJTene5+We6Tmi0sONxq9D39TUfp83qDnDgPcVzJrjIaclv+1jrclMOA3/NoasYcMbmKfEZnyDGtGivU45aJmj5d928w+jIzhvhZZ83R95bTHo7enx2IZYvnTbeZhP4oR1Yi0Q/ZGw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:49 +0200 Message-Id: <2d458349144f49c68b903e77d383c18071e4cdae.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 22/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 abc9e3ed6a..ac23776b2a 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1120,7 +1120,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; @@ -1132,23 +1132,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 @@ -1176,7 +1176,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 @@ -1191,7 +1191,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 Thu May 2 02:48:10 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 1516984582692967.3745275311688; Fri, 26 Jan 2018 08:36:22 -0800 (PST) Received: from localhost ([::1]:37069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6zF-0004wT-KV for importer@patchew.org; Fri, 26 Jan 2018 11:36:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6qy-0007FJ-LK for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6qx-0004RZ-Mz for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:48 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38614) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6qx-0004Og-CY; Fri, 26 Jan 2018 11:27:47 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Ux-0007gz-SY; Fri, 26 Jan 2018 16:01:00 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087W-H8; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=yKkiGX5dZIQu6WPhncVzfh53D84VK3Ye45h/WQ0NjrY=; b=Zxj5bVKNTaTEje6HVh3NTcYut7Tu/DFYZtlf/aoE+niMsMt1pB6GJQ2Xxn+K6Nm/dTvZRJKTKAf6uVHpyagyR0541WgjUepHKHS4YoilZmmtRMWp65WxXry3jccGbxJvDDk5D8jJg1Nd6jIk9Cp4DCgsGxj04G11r/GAu9pzLze3SYc8AkkxMBA/Lw1m7YCJoCBQ/a9yHYBvLNa6nl5lf1VK6+k2wGPpt0pl08QRorPYhsVTwQzq90hI47REpKdz6yp5iVu/sGjVrmkUPHb0vX9daRll6I3nH2Vzj3DaOu1CxF/LFsVgBQpz8F3l9FlreWsiBk8qdsFNYysBwyNSVA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:50 +0200 Message-Id: <5d8899a6633484768bc66823d9cb30823620fda4.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 23/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 ac23776b2a..aa374f9928 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1275,7 +1275,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; @@ -1288,29 +1288,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 @@ -1339,7 +1339,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; @@ -1350,7 +1350,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 Thu May 2 02:48:10 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 1516984263908706.0737588088822; Fri, 26 Jan 2018 08:31:03 -0800 (PST) Received: from localhost ([::1]:37001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6u5-0000wu-RZ for importer@patchew.org; Fri, 26 Jan 2018 11:31:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6qt-00078T-4I for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6qq-0004Dw-S6 for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:43 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38575) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6qq-0004Bn-Ii; Fri, 26 Jan 2018 11:27:40 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Ux-0007gv-Rr; Fri, 26 Jan 2018 16:01:00 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087Z-IL; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=zG0rJZbKZaGjhenhdnajagDAJhpDZLfZ8UZw9YCwBpY=; b=QdN6ef1keX6SM+CYKs0eeSVN5IZHxKd5lMut9whd4mtCjW++uaSh+5bhRFOKCcCza7mO4YCAZeB/K1JzdUxaQyCYND96EXSGHaTKNNAeqkuJ/BpwcbywxpQPvueVSaah8a0nU3LRKqVA+3FseY/Z3wGd17t+17bxmunOYpOxOVSKUCDqQVySnyBabNmhz0RjrVAZu+XSGSInk/5hLlkBCkPosuMGUwsabVzysFWe9IZIFJop+QkeepLg5bhvjA9mFC651JZt4vUG8YjzUr0D3KuLnSEvUPr8SbKcRwVedTF0fTvhwYLZyWgcKncvHCBAPbneLI5AEy0mkZH1mU4e6g==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:51 +0200 Message-Id: <395d808b99997ca8718bba951c5a2eebe6794650.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 24/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 aa374f9928..fd1bf5d093 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1632,7 +1632,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, @@ -1640,24 +1640,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 @@ -1695,18 +1695,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 Thu May 2 02:48:10 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 1516982592889715.0662931065152; Fri, 26 Jan 2018 08:03:12 -0800 (PST) Received: from localhost ([::1]:35487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6TA-0007Or-3K for importer@patchew.org; Fri, 26 Jan 2018 11:03:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6Nr-00081H-IZ for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:57:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6No-0005bV-TZ for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:57:43 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:33040) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6No-0005aV-L2; Fri, 26 Jan 2018 10:57:40 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Ux-0007gx-Rt; Fri, 26 Jan 2018 16:01:00 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087c-K1; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=4Evxl+8CdC55cuqe+5Unf+Pz0beWV6rrFAeY9p+R9E8=; b=b7u2MvQlchWTFD59/rDI94eLe72UeNxkoqQDpOQLBbYBmmdQ8LgPZmmu2CmcSjuv4/snEv2qXBeuUXoT/mjGs914acXA2zEC0/5uyBIJo2bxBALgDg1v+QZKJfZHN6IqeokVBUB//iCQHnmG1ywkWDe/mDbXZuaIxgi8TwTr4BsdzJ5Ph9+j5FcJzvRoyTPhEi5GcKi1+tZgf+LQOyizb/k14ml3ozPWl7CAnGad/jFVlyWXQeGkZ52daW84BNL5821wYSL6E4ZG+7U4jbMxbn2cdaJuGrAqigaS1MXfySZ/6kYP/j+ZpF90I1fr2cRVUYhKxCzALBE1kcL6GRNDAQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:52 +0200 Message-Id: <32d91890c42f980c6d2e494a28bc7c66a84f1469.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 25/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 fd1bf5d093..e13f8f2f14 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1753,33 +1753,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 @@ -1791,16 +1791,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 Thu May 2 02:48:10 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 1516984781531197.38578078918306; Fri, 26 Jan 2018 08:39:41 -0800 (PST) Received: from localhost ([::1]:37269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef72S-0007Qp-Lt for importer@patchew.org; Fri, 26 Jan 2018 11:39:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6r4-0007Kl-3Y for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6qz-0004Uy-3v for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:54 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38620) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6qy-0004SI-Nq; Fri, 26 Jan 2018 11:27:49 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Ux-0007gw-Pn; Fri, 26 Jan 2018 16:00:59 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087f-L6; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=/WTlBAj1n2xIiGdTQL46C8+6E7SApl7d9DlhkkezOhQ=; b=P3iAStxXZrq4Eery4ROjiX6s0oFy9BZw/lDAe8Xjw1d4K31U6oYHeEGEBBzg1NMnjPoZJUWrr9booLiB3YtjsU6YG5UtwR4UHvszlFuiwvdgHJ3nLdOilSl1koMxc1tOJuK4ug2Lqd9vBRYDzYsyFYeKt0fpwSPPkm7voLDMtBkVHRN0N/iG/4ov8cfE2P7XKGPrUQ7hgZ+sH5SXseGc66NvfZmlSpSsNtVUX5zc4L3wC5zGU9hLll98DMAkqN1enfXVpL4DX6w9JGov8uA+ZXTFNMY6+2ZQaH7Wr6TmAye2BpdVaDnDDRpzViTZlTgMKPXTVZRL1H/4k7A4qNov/g==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:53 +0200 Message-Id: <0c81220cf2141a5b720629fb6eaff04f833e77a4.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 26/39] qcow2: Prepare qcow2_update_snapshot_refcount() for adding L2 slice support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Adding support for L2 slices to qcow2_update_snapshot_refcount() needs (among other things) an extra loop that iterates over all slices of each L2 table. Putting all changes in one patch would make it hard to read because all semantic changes would be mixed with pure indentation changes. To make things easier this patch simply creates a new block and changes the indentation of all lines of code inside it. Thus, all modifications in this patch are cosmetic. There are no semantic changes and no variables are renamed yet. The next patch will take care of that. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2-refcount.c | 140 ++++++++++++++++++++++++++-------------------= ---- 1 file changed, 73 insertions(+), 67 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 9df380d52c..dfa28301c4 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1236,91 +1236,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; - } + { + ret =3D qcow2_cache_get(bs, s->l2_table_cache, + l2_offset, + (void **) &l2_table); + 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_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_table[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)) { + qcow2_signal_corruption( + bs, true, -1, -1, "Cluster " + "allocation offset %#" PRIx64 + " unaligned (L2 offset: %#" + PRIx64 ", L2 index: %#x)", + offset, l2_offset, j); + ret =3D -EIO; 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)) { - 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; - } =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); + 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; + } + } + + 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_table[j] =3D cpu_to_be64(entry); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, + l2_table); } - 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_table); + } =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, --=20 2.11.0 From nobody Thu May 2 02:48:10 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 1516980162767647.6009752868652; Fri, 26 Jan 2018 07:22:42 -0800 (PST) Received: from localhost ([::1]:33174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5px-0000Mq-OK for importer@patchew.org; Fri, 26 Jan 2018 10:22:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5nk-0007Pg-5S for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:20:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5nf-0000lp-UR for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:20:23 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5nX-0000j9-Sd; Fri, 26 Jan 2018 10:20:19 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Ux-0007gy-O4; Fri, 26 Jan 2018 16:00:59 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087i-NJ; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=9pf3ogAqK5Ft6wS2orAsD4qLHkrBrJO6BJ5+TEty4zA=; b=Ilzpv3ltveqIl1mqh/DCNBoQ5tPRO+prt5lQGagGDfbKz6AKnl+Gxu/DThLfwIPEZo0al6pmx2G+XXUDxNWjf384L4REGH2hHqhQb/orScngwOfHMPp8Ri43CVzj7/DWz0/Sl8g1iKnRYfEe7XtBA6PD1pN916S/WZKbiK9ukMSI+eP/WPw8+BTYzPXZrO/EhchhOArooT/6KZSiQ70dcdX9lbpo+21hrAJFg+eB8T6BlYpYR6ZRmubfNTVHWiJS9UkXYi8GRjLhCJmiTUOz1TKvk9/AmZlCMsH5GY5dUP9KuMKZyuQQwxGDNOsdI3mfEk1tJO3K7iqx78+oxZW55w==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:54 +0200 Message-Id: <0c07738db12f556285f8db01d68c5d6b4304bde9.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 27/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- block/qcow2-refcount.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index dfa28301c4..60b521cb89 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1183,17 +1183,20 @@ 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_size2, 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); + slice_size2 =3D s->l2_slice_size * sizeof(uint64_t); + n_slices =3D s->cluster_size / slice_size2; =20 s->cache_discards =3D true; =20 @@ -1236,19 +1239,19 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, goto fail; } =20 - { + for (slice =3D 0; slice < n_slices; slice++) { ret =3D qcow2_cache_get(bs, s->l2_table_cache, - l2_offset, - (void **) &l2_table); + l2_offset + slice * slice_size2, + (void **) &l2_slice); if (ret < 0) { goto fail; } =20 - for (j =3D 0; j < s->l2_size; j++) { + 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]); + entry =3D be64_to_cpu(l2_slice[j]); old_entry =3D entry; entry &=3D ~QCOW_OFLAG_COPIED; offset =3D entry & L2E_OFFSET_MASK; @@ -1273,12 +1276,13 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, 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, j); + offset, l2_offset, l2_index); ret =3D -EIO; goto fail; } @@ -1317,14 +1321,13 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, qcow2_cache_set_dependency(bs, s->l2_table_cac= he, s->refcount_block_c= ache); } - l2_table[j] =3D cpu_to_be64(entry); + l2_slice[j] =3D cpu_to_be64(entry); qcow2_cache_entry_mark_dirty(s->l2_table_cache, - l2_table); + l2_slice); } } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); - + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } =20 if (addend !=3D 0) { @@ -1352,8 +1355,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 Thu May 2 02:48:10 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 15169808825691012.0332217984013; Fri, 26 Jan 2018 07:34:42 -0800 (PST) Received: from localhost ([::1]:33602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef61V-0001kq-8j for importer@patchew.org; Fri, 26 Jan 2018 10:34:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5q9-000141-1b for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5q7-00036X-Em for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:53 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54723) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5q7-00035z-5b; Fri, 26 Jan 2018 10:22:51 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Un-0007h0-TU; Fri, 26 Jan 2018 16:00:50 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087l-Ok; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=dOHlLKq7+2YIwQsMx8J7WqD+KPdFKtR5qLVxqZ49Zdw=; b=Ap3hT5Fb9qZpwtqcNf+dd1GgdCU0TOpxw1WQJGPyASxwxQO7zcnj/ZGxolrazmeXPpwv7bWpisy5B9RbRD/kSR0bSnr43DlpvWXEdeI44+mE6DXAuOr2Pqm+p+93CoP40FpQbB8YsS63Ww+Qqkpc7jiikoevUEGb+rzUk6q4sZRIq0pBhwUXZwDY6UZEmo4Z9JrrDiLFMYu3xXbZx1x4s5XggUdo79ubJRC0TWv6C6KLmlSvSd1bsylLMeGuS3+sqRTacbUmSsu2gsoN0s4gGxUeoer3UfYjcfoiVpqd/zU1EXPkDpwblXzYoypCDhTbCw1A/Nc0z9GQMwDuE/zKJQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:55 +0200 Message-Id: <4bd645eb4a81eb2009fab318dfca6d47e657655c.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 28/39] qcow2: Read refcount before L2 table in expand_zero_clusters_in_l1() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" At the moment it doesn't really make a difference whether we call qcow2_get_refcount() before of after reading the L2 table, but if we want to support L2 slices we'll need to read the refcount first. This patch simply changes the order of those two operations to prepare for that. The patch with the actual semantic changes will be easier to read because of this. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2-cluster.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index e13f8f2f14..1338485184 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1899,6 +1899,12 @@ static int expand_zero_clusters_in_l1(BlockDriverSta= te *bs, uint64_t *l1_table, goto fail; } =20 + ret =3D qcow2_get_refcount(bs, l2_offset >> s->cluster_bits, + &l2_refcount); + if (ret < 0) { + goto fail; + } + if (is_active_l1) { /* get active L2 tables from cache */ ret =3D qcow2_cache_get(bs, s->l2_table_cache, l2_offset, @@ -1912,12 +1918,6 @@ static int expand_zero_clusters_in_l1(BlockDriverSta= te *bs, uint64_t *l1_table, goto fail; } =20 - ret =3D qcow2_get_refcount(bs, l2_offset >> s->cluster_bits, - &l2_refcount); - if (ret < 0) { - goto fail; - } - 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; --=20 2.11.0 From nobody Thu May 2 02:48:10 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 1516984379638806.8066054892638; Fri, 26 Jan 2018 08:32:59 -0800 (PST) Received: from localhost ([::1]:37035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6vy-0002OO-QB for importer@patchew.org; Fri, 26 Jan 2018 11:32:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6qx-0007EG-RL for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6qw-0004Nh-CX for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:47 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38609) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6qv-0004KK-Vt; Fri, 26 Jan 2018 11:27:46 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Un-0007gz-QP; Fri, 26 Jan 2018 16:00:49 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087o-QU; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=1MyIEDKlXFtA0TLQOP6tf3Y6hCWxffvDBGfWWEZ1qUo=; b=XTNCjTpOqHay8O9SBYe2IScM8r6Exsq8WTLil4JkjT7MzOUJ4sN2vb9d8aR3EyvpjlhSI/R6dQslHM9OuNLVR5RGHOkUAYX28Dwm5xp1dpcEeOe44+MnhpKybVzQ34QJXqzOtNHOkS5bO4bqf40KV95r1YRjQwNX/q/iF5HMnwjanI58Ym9cakrr/r7bKNVYpTr5dqLoYmq7bCgZ+TDTt9SgLTn050DfM2JPZcPCkGCQLwkvu6ppCXCrSdnl8KscLX973sZFpYse/6jdhTaSkAP146lTl9CoBz2YNOVD3zt3C65CkE9a9Shi7FOVulDsXkj4qxqPhmbP7/cOMDfXkg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:56 +0200 Message-Id: <4a4cf18c47fbbd1147fb8e425d23157bb205e0fe.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 29/39] qcow2: Prepare expand_zero_clusters_in_l1() for adding L2 slice support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Adding support for L2 slices to expand_zero_clusters_in_l1() needs (among other things) an extra loop that iterates over all slices of each L2 table. Putting all changes in one patch would make it hard to read because all semantic changes would be mixed with pure indentation changes. To make things easier this patch simply creates a new block and changes the indentation of all lines of code inside it. Thus, all modifications in this patch are cosmetic. There are no semantic changes and no variables are renamed yet. The next patch will take care of that. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2-cluster.c | 187 ++++++++++++++++++++++++++--------------------= ---- 1 file changed, 96 insertions(+), 91 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 1338485184..6042ec69e3 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1905,118 +1905,123 @@ 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; - } - - 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; + { + 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; + } + + 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_entry); =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; + 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_table[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)) { + 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_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_table[j] =3D cpu_to_be64(offset | QCOW_OFLAG_COPIED= ); + } else { + l2_table[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_tab= le); + qcow2_cache_depends_on_flush(s->l2_table_cache); + } + qcow2_cache_put(s->l2_table_cache, (void **) &l2_table); } 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, + l2_offset, s->cluster_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, l2_offset / BDRV_SECTOR_S= IZE, + (void *)l2_table, s->cluster_sectors); + if (ret < 0) { + goto fail; + } } } } --=20 2.11.0 From nobody Thu May 2 02:48:10 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 1516982571904670.6768922169132; Fri, 26 Jan 2018 08:02:51 -0800 (PST) Received: from localhost ([::1]:35473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6So-00054a-QV for importer@patchew.org; Fri, 26 Jan 2018 11:02:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6Nw-00086L-PJ for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:57:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6Nv-0005hP-Kk for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:57:48 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:33059) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6Nv-0005gE-80; Fri, 26 Jan 2018 10:57:47 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Un-0007gv-Pl; Fri, 26 Jan 2018 16:00:49 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087r-Ri; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=Ejnnh5x6/5HT/V/pIxsZgav71Qib2PZZw3714AI8O9M=; b=BZh8W0Il6BsJzg8Gfm5g9sBmRvcLxFlwZu9LJoJsxmmw7G6dc6+/S6c+QFR75FrnABP47pFZI6zZiSoqSC7rz5ppEKwMQYMcHmUu1NFXzs9fomY9M0K2Xx4J0SqjaEwXnNtjWLjqnxPlbUOT7SuuiHkNCW6/3IAv/Dm3dUmhIq99UoD+K3+Z+9VRBVXDQXGeV2OtPnDu76Jzla4NoUWXK1AHk/Z73NJMmgW04D5cu1q46196bkzOedTfzL/JEzmluO26NbatWx8PPxyOmaOVfh9daIdzM6w/RABgbsN/iHJFj1eHTyswzJxhcDAtRGH19WmeYOB/lpCtk7pnUt6tPQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:57 +0200 Message-Id: <7d8d80bfde60d29e8a0abe04db8241b754714329.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 30/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. 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. Finally, and since we have to touch the bdrv_read() / bdrv_write() calls anyway, this patch takes the opportunity to replace them with the byte-based bdrv_pread() / bdrv_pwrite(). Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2-cluster.c | 52 ++++++++++++++++++++++++++++-------------------= ---- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 6042ec69e3..659830ad4d 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1864,22 +1864,25 @@ 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_size2, n_slices; int ret; int i, j; =20 + slice_size2 =3D s->l2_slice_size * sizeof(uint64_t); + n_slices =3D s->cluster_size / slice_size2; + 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_size2); + if (l2_slice =3D=3D NULL) { return -ENOMEM; } } =20 for (i =3D 0; i < l1_size; i++) { uint64_t l2_offset =3D l1_table[i] & L1E_OFFSET_MASK; - bool l2_dirty =3D false; uint64_t l2_refcount; =20 if (!l2_offset) { @@ -1905,22 +1908,24 @@ static int expand_zero_clusters_in_l1(BlockDriverSt= ate *bs, uint64_t *l1_table, goto fail; } =20 - { + for (slice =3D 0; slice < n_slices; slice++) { + uint64_t slice_offset =3D l2_offset + slice * slice_size2; + bool l2_dirty =3D false; 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); + 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, l2_offset / BDRV_SECTOR_SIZE, - (void *)l2_table, s->cluster_sectors); + ret =3D bdrv_pread(bs->file, slice_offset, + (void *)l2_slice, slice_size2); } 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]); + 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); @@ -1934,7 +1939,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, if (!bs->backing) { /* not backed; therefore we can simply deallocate = the * cluster */ - l2_table[j] =3D 0; + l2_slice[j] =3D 0; l2_dirty =3D true; continue; } @@ -1961,12 +1966,13 @@ static int expand_zero_clusters_in_l1(BlockDriverSt= ate *bs, uint64_t *l1_table, } =20 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, j); + l2_offset, l2_index); if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); @@ -1995,30 +2001,30 @@ static int expand_zero_clusters_in_l1(BlockDriverSt= ate *bs, uint64_t *l1_table, } =20 if (l2_refcount =3D=3D 1) { - l2_table[j] =3D cpu_to_be64(offset | QCOW_OFLAG_COPIED= ); + l2_slice[j] =3D cpu_to_be64(offset | QCOW_OFLAG_COPIED= ); } else { - l2_table[j] =3D cpu_to_be64(offset); + l2_slice[j] =3D cpu_to_be64(offset); } l2_dirty =3D true; } =20 if (is_active_l1) { if (l2_dirty) { - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_tab= le); + 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_table); + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); } else { if (l2_dirty) { ret =3D qcow2_pre_write_overlap_check( bs, QCOW2_OL_INACTIVE_L2 | QCOW2_OL_ACTIVE_L2, - l2_offset, s->cluster_size); + slice_offset, slice_size2); if (ret < 0) { goto fail; } =20 - ret =3D bdrv_write(bs->file, l2_offset / BDRV_SECTOR_S= IZE, - (void *)l2_table, s->cluster_sectors); + ret =3D bdrv_pwrite(bs->file, slice_offset, + (void *)l2_slice, slice_size2); if (ret < 0) { goto fail; } @@ -2035,11 +2041,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 Thu May 2 02:48:10 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 1516981093951140.2034690548037; Fri, 26 Jan 2018 07:38:13 -0800 (PST) Received: from localhost ([::1]:33812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef64z-0004gD-4J for importer@patchew.org; Fri, 26 Jan 2018 10:38:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5q9-000142-20 for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5q6-00035o-4g for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:53 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54718) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5q5-00035O-T4; Fri, 26 Jan 2018 10:22:50 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Un-0007gx-Pl; Fri, 26 Jan 2018 16:00:49 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-00087x-Tl; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=stn8t0SMR9FZGYYxBzcYvFvmkQVwz6+Hw0AFsxlKybs=; b=Fjc7HXIEMrND7zF2nmveBHFcE4VDINA/1wwD1kf8xyV2i6PMvxy86tTaxOP1XopES/rRRlG0fmGrQyxEouKC3bGi++Djl5jGc1w9fmpi/8qxXJf8DUuLWtoW0heQlSESUf1I1PAfR5bPwQEPd5jK1Ep1NLFapVPmvERRDOgiRxnpvBke/PqrubQFsXZSe12mHGSKrHK6fMDIgy9JXTF/zz5jhnf84hUblIIv0cBO2KuTP+uRwlaURPrdhR09HdYL2AC9Wdyb6HSb1GOykfBFKJPmsTAb81sjwf1fgwUmXNapO/Umzn+nOitOFp1QnLBEIw9T4tv7lqnE3oAjuSq/PQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:58 +0200 Message-Id: <896a464d5933927db49c968682de8c2b6e59635f.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 31/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- block/qcow2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 78f067cae7..529becfa30 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3261,8 +3261,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 Thu May 2 02:48:10 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 1516980692779371.4297264716329; Fri, 26 Jan 2018 07:31:32 -0800 (PST) Received: from localhost ([::1]:33557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5yV-0008BW-Kr for importer@patchew.org; Fri, 26 Jan 2018 10:31:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5pl-0000lb-UK for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5pi-0002v8-Of for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:29 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54673) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5pi-0002u4-FZ; Fri, 26 Jan 2018 10:22:26 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Un-0007gw-Ny; Fri, 26 Jan 2018 16:00:49 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UH-000880-VV; Fri, 26 Jan 2018 17:00:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=eO+Mosk1XU5/oz3d3xH7sLSMp1DczV5Fz5uEwlA+9nw=; b=QcqNNIAP55loXs/vYGWvakD6GjDzoKCj3BZqM67/j3D1UqK6nII2II3bWPRX+QtNc4LthQ0rwbEvxjI2eoDWPjJRykut5lgi5wqvKm0YJzjM5OJoH8FXR+fRq1azBGEsUDHRhSDbM6o6ofhzyE4I8oUdj80Gbwkxv0FoMD/S5DIRufv9kgOU8C986iht47mBo9Qi5zbD3fFXfdnqIrOJ5x+J+zMLqzupMZpU9fW+PJH+ibF0Qqlg/ymu0HWU12MprbPOY/JvZ5rLCfTgRkjZjpairD5SOOewY5FzfSAp7RHdT9gU/t+oplda8oQJkCMa7oAjVow5po97xqNjh6aYMg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 16:59:59 +0200 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 v3 32/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This function doesn't need any changes to support L2 slices, but since it's now dealing with slices instead of full tables, the l2_table variable is renamed for clarity. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- 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 659830ad4d..2d46927dc5 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -748,26 +748,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 @@ -782,9 +782,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 Thu May 2 02:48:10 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 1516984597259325.8869037151885; Fri, 26 Jan 2018 08:36:37 -0800 (PST) Received: from localhost ([::1]:37071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6zO-00054h-5T for importer@patchew.org; Fri, 26 Jan 2018 11:36:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6qv-0007Ba-Un for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6qv-0004Jl-09 for qemu-devel@nongnu.org; Fri, 26 Jan 2018 11:27:45 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38580) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6qu-0004Gq-Jm; Fri, 26 Jan 2018 11:27:44 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Un-0007gy-Mf; Fri, 26 Jan 2018 16:00:49 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UI-000883-0I; Fri, 26 Jan 2018 17:00:18 +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=u2sWAp4SSGnWGtzDjHAxzn0XlO7v3MAIq0vna7RvvnM=; b=UPSVLWyKlo5hSbxpS+QuPO3IOMntkwCJwslBD9kwPhx0fcZUtEeBo5dvdf5+QDlg7hqYWTFuC49QR88xwq1EWSaSg8cET5UxxrkVtpUJIBfrMvePIRoxF+sOQDrUx21NGJtrEq5hPCfRAI+6cXqRHNChhdt7n8hiBBMnuIjxx0GwHrRfC/ORyieHkzMOSMarI36FYO1LmrXje856V51yhsT2j0AWOK/ChhVjmvIKWTOuJVMUbnHff56j3Yw00fnBJlC1miSNW/zEq3uEcv9lZ6kb+EGT7TndDqG4r5jmg24b584Sn0MxinsAeArKM22x3mBYkNzbYo6CMhcQthOPtg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 17:00:00 +0200 Message-Id: <8ad7c315825732f819cae7d1460e856a04d095a5.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 33/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 2d46927dc5..60c38a71f1 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 Thu May 2 02:48:10 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 1516980387233696.3722805094793; Fri, 26 Jan 2018 07:26:27 -0800 (PST) Received: from localhost ([::1]:33260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5ta-0003jB-Bm for importer@patchew.org; Fri, 26 Jan 2018 10:26:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5o4-0007ku-BK for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:20:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5o2-00017Y-Sw for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:20:44 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54284) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5o2-00016S-JE; Fri, 26 Jan 2018 10:20:42 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Ud-0007h0-Tp; Fri, 26 Jan 2018 16:00:40 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UI-000886-20; Fri, 26 Jan 2018 17:00:18 +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=rX1jFZUUU7eBsKyvGQlmYgOo7LRjJaMSqt8tFjYXNL4=; b=FX2+MLbpntqrCtVfHuAqq7GCiLEbKKQcHmu66g6HMrAJXvTcvv4LgYnRLuIn3ebCK0a1d6vht1KuHQq7Qha8/SQ0jJl4+G2y8ytgd68Fc/g7IF6Ryv1vKi3TuX6P18TgOTID4g8oS/W2kuoHSLyyaRJ+SnP7rXn0SoE0PhrcRyQf+kj1feSVdlkxRHCyXdutGOnXtUurklz0zpVfHHGrTkwj6shnTgGidOmd00qe76uH1Z8PwEOUII7GF8/JIZYrrSRBpXOHNZFNbiMM+rJvOaWTHJT0GY/H0yex66ZiUDRCCHO11yxVAHNs/W95ezmhK/R/T+Yzf7SpzF6IKLYjRQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 17:00:01 +0200 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 v3 34/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 60c38a71f1..5422c202fb 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 Thu May 2 02:48:10 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 1516980341930232.28703209481102; Fri, 26 Jan 2018 07:25:41 -0800 (PST) Received: from localhost ([::1]:33254 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5sq-0002wc-Bi for importer@patchew.org; Fri, 26 Jan 2018 10:25:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5q5-00010j-OV for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5q4-00035D-U7 for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:49 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54717) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5q4-00034x-L1; Fri, 26 Jan 2018 10:22:48 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Ud-0007gv-R1; Fri, 26 Jan 2018 16:00:39 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UI-000889-36; Fri, 26 Jan 2018 17:00:18 +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=FK4s5PfX9GYHXVXy+H/E2p+QSociLe5LwvewxPXrLHs=; b=KI+sa2xFhtFR8/lm0lZjRw4TVEaYNTAnyffYlv2Z5J7DdzEnWFwksGhFQlKL3OG833ZF3it28hIKxyIPlkcJgbxcvcw/wbTn0UOe8esDtkHCqfyxgr4TcAIxr8LIN9Qlp5RpMMVKZ0bvRmJULrYdRx6dTinggHHJG+V1QjXtl0skRTcmP6bl5Sgdjjsz2waa+jGbiKdIMfgMq4oJiPwbd0N/7xGbZmQs+kLe9CoN9Ur5SKwP0nk1mj6c/c4/lDtZhC/BT80V3i6lxzd9eA+2oPwORqGfkrfM6JnVWcokZhtAR0eJp1QQJ8zkG2oUVisWjyWW2PcKDt952ZeuZ1W+ug==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 17:00:02 +0200 Message-Id: <39c501933ab5eda5c439d082d182f0b1f571eba0.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 35/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Max Reitz --- 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 5422c202fb..efa56a1608 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1000,12 +1000,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 Thu May 2 02:48:10 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 1516982726015814.5701643096144; Fri, 26 Jan 2018 08:05:26 -0800 (PST) Received: from localhost ([::1]:35658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6VJ-0003dr-11 for importer@patchew.org; Fri, 26 Jan 2018 11:05:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef6Nu-00084B-Nq for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:57:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef6Ns-0005em-UL for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:57:46 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:33050) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef6Ns-0005dZ-H6; Fri, 26 Jan 2018 10:57:44 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Ud-0007gz-Rb; Fri, 26 Jan 2018 16:00:40 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UI-00088C-4L; Fri, 26 Jan 2018 17:00:18 +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=JKY99IAhagtIp/NHJq9e7K45qnYPwaFtnw8XnVljiLA=; b=Y1HtTunp1w5cpta3MqCW4NOS0779PGuTT2QbnVSwsR2lQ6fzjU7XHYbNgyKnYjO+5FHP2aha7zk2qQ/z0X6awlAACH6bsUnTpFv4h4ra3SB2tsb67ptQeCR3YBYifQnJkc+/UdxE0ZxbN963QShWMSPvUJIM8+CDjwdGl5xzdBSdA4p7e6uZLQBdJRWuOeirEwmo42W/5x3buCzYWfWaS9HxhP2Qk0Kv3RPAnlrVhBa/TYx8Z+7Fz1v/4Pe2LEh5ceRGSSxT9B66dFiVfDXgzn42drTdPYua2Eu/6zLLaVPfxar7LSto+tKf9amPuecsm4KC0xkeMq26DifLCZFRvQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 17:00:03 +0200 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 v3 36/39] 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. Now that the cache entry size is not necessarily equal to the cluster size we need to reflect that in the MIN_L2_CACHE_SIZE documentation. That minimum value is a requirement of the COW algorithm: we need to read two L2 slices (and not two L2 tables) in order to do COW, see l2_allocate() for the actual code. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2-cache.c | 10 ++++++++-- block/qcow2.c | 34 +++++++++++++++++++++++++++------- block/qcow2.h | 6 ++++-- qapi/block-core.json | 6 ++++++ 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index b1aa42477e..d9dafa31e5 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 529becfa30..98762433a0 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -674,6 +674,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", @@ -745,6 +750,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; @@ -760,6 +766,9 @@ static void read_cache_sizes(BlockDriverState *bs, Qemu= Opts *opts, *refcount_cache_size =3D qemu_opt_get_size(opts, QCOW2_OPT_REFCOUNT_CACHE_SIZE= , 0); =20 + *l2_cache_entry_size =3D qemu_opt_get_size( + opts, QCOW2_OPT_L2_CACHE_ENTRY_SIZE, s->cluster_size); + if (combined_cache_size_set) { if (l2_cache_size_set && refcount_cache_size_set) { error_setg(errp, QCOW2_OPT_CACHE_SIZE ", " QCOW2_OPT_L2_CACHE_= SIZE @@ -800,6 +809,15 @@ static void read_cache_sizes(BlockDriverState *bs, Qem= uOpts *opts, / DEFAULT_L2_REFCOUNT_SIZE_RATIO; } } + + 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 { @@ -822,7 +840,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; @@ -841,15 +859,15 @@ static int qcow2_update_options_prepare(BlockDriverSt= ate *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; goto fail; } =20 - l2_cache_size /=3D s->cluster_size; + l2_cache_size /=3D l2_cache_entry_size; if (l2_cache_size < MIN_L2_CACHE_SIZE) { l2_cache_size =3D MIN_L2_CACHE_SIZE; } @@ -887,9 +905,11 @@ 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= ); + 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 87b5c4063e..d20753f140 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -68,7 +68,7 @@ #define MAX_CLUSTER_BITS 21 =20 /* Must be at least 2 to cover COW */ -#define MIN_L2_CACHE_SIZE 2 /* clusters */ +#define MIN_L2_CACHE_SIZE 2 /* cache entries */ =20 /* Must be at least 4 to cover all cases of refcount table growth */ #define MIN_REFCOUNT_CACHE_SIZE 4 /* clusters */ @@ -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 @@ -647,7 +648,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); diff --git a/qapi/block-core.json b/qapi/block-core.json index 8225308904..8556123cf4 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2507,6 +2507,11 @@ # @l2-cache-size: the maximum size of the L2 table cache in # bytes (since 2.2) # +# @l2-cache-entry-size: the size of each entry in the L2 cache in +# bytes. It must be a power of two between 512 +# and the cluster size. The default value is +# the cluster size (since 2.12) +# # @refcount-cache-size: the maximum size of the refcount block cache # in bytes (since 2.2) # @@ -2528,6 +2533,7 @@ '*overlap-check': 'Qcow2OverlapChecks', '*cache-size': 'int', '*l2-cache-size': 'int', + '*l2-cache-entry-size': 'int', '*refcount-cache-size': 'int', '*cache-clean-interval': 'int', '*encrypt': 'BlockdevQcow2Encryption' } } --=20 2.11.0 From nobody Thu May 2 02:48:10 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 1516980137586112.50342338150733; Fri, 26 Jan 2018 07:22:17 -0800 (PST) Received: from localhost ([::1]:33172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5pR-0008OY-Jp for importer@patchew.org; Fri, 26 Jan 2018 10:22:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5nK-00071Z-9K for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:19:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5nJ-0000dp-Ct for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:19:58 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54107) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5nJ-0000dN-3c; Fri, 26 Jan 2018 10:19:57 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Ud-0007gx-Pu; Fri, 26 Jan 2018 16:00:39 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UI-00088F-5g; Fri, 26 Jan 2018 17:00:18 +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=LrKiN6DIv0g0RIYF1pQKg6AdoT82RxjewnIS64Xh3K0=; b=MIDampqe/FUgfnbIoFO1qO5pvXLQ05B6HqiGMcnnz0Pf9pRjhbJnJs+vwr3ZGFAgS4gQJB7E8dFoqOs/uqdFlVCzY89ZlXNZOHCYbTef5rcTRGqgnytoCufwLma08CLBdx3+3wqjz357R3ld60tvjmzPjQIHp86gdhVGmvRxZ5g9coKdyCQSw73ewOPnLeG6PmjaZJVvDLKbTL9tidPO3jQIZsyeb8NI/o+ZMN93gXRNNxygLBiIhKoSqfmSmr+RSbxEu6K52nP52LiasbTAxRI0FnWngRluqPl5L6YuUkBCvn+jONruAZzbdpQ/hZKuaBNpeCB++mD2nUV5GTjX7A==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 17:00:04 +0200 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 v3 37/39] iotests: Test valid values of 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- 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 d0cfab8844..7a2ca22803 100755 --- a/tests/qemu-iotests/103 +++ b/tests/qemu-iotests/103 @@ -66,6 +66,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 @@ -94,6 +102,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 From nobody Thu May 2 02:48:10 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 1516980897864410.3014308199763; Fri, 26 Jan 2018 07:34:57 -0800 (PST) Received: from localhost ([::1]:33604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef61j-0001vd-VD for importer@patchew.org; Fri, 26 Jan 2018 10:34:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5q4-0000zl-Ob for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5q3-00034p-KT for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:22:48 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54716) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5q3-00034N-7s; Fri, 26 Jan 2018 10:22:47 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Ud-0007gw-Pg; Fri, 26 Jan 2018 16:00:39 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UI-00088I-6m; Fri, 26 Jan 2018 17:00:18 +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=K9U7gr1sZ2mc0aXjI5LZPz92+iXzx3h80gi//q2xuUQ=; b=ERXOYGEoIF8yYJXD+9u2jUYrXCiXvFfecpFJD1RhMt4H37ZKJ99LOHgv1XcnkxY/EHjDxyYE0hgs1dfyAA+jmH3rf4+ScFIdA36qGC4FE7LxXVoLbtuhETblVFUW1fa42v+LrhEBPPGwKCC7bGoww9JtIOjj8wkwCFvbR1HVs0P5YUplYrWYsTUjfg2ep1h/0YVR694K9EhqkC7fR5M4tIpEicgMFS0ylmFnzVl4mckMZf+4hjHe2X6DmS67uAYTPq6LbKHWLxty405vVUZ1EQQTtJ2a3RK9p5SHQoztSmZ9wcamruRHwbTKchocWs4l54Equ6n9zQLT2UW1OU8Vig==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 17:00:05 +0200 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 v3 38/39] iotests: Test downgrading an image using a small 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 , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" expand_zero_clusters_in_l1() is used when downgrading qcow2 images from v3 to v2 (compat=3D0.10). This is one of the functions that needed more changes to support L2 slices, so this patch extends iotest 061 to test downgrading a qcow2 image using a smaller slice size. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- tests/qemu-iotests/061 | 16 ++++++++++++ tests/qemu-iotests/061.out | 61 ++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 77 insertions(+) diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 index f5678b10c9..911b6f2894 100755 --- a/tests/qemu-iotests/061 +++ b/tests/qemu-iotests/061 @@ -54,6 +54,22 @@ $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qem= u_io _check_test_img =20 echo +echo "=3D=3D=3D Testing version downgrade with zero expansion and 4K cache= entries =3D=3D=3D" +echo +IMGOPTS=3D"compat=3D1.1,lazy_refcounts=3Don" _make_test_img 64M +$QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -z 32M 128k" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io +$PYTHON qcow2.py "$TEST_IMG" dump-header +$QEMU_IMG amend -o "compat=3D0.10" --image-opts \ + driver=3Dqcow2,file.filename=3D$TEST_IMG,l2-cache-entry-size=3D4= 096 +$PYTHON qcow2.py "$TEST_IMG" dump-header +$QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 0 32M 128k" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io +_check_test_img + +echo echo "=3D=3D=3D Testing dirty version downgrade =3D=3D=3D" echo IMGOPTS=3D"compat=3D1.1,lazy_refcounts=3Don" _make_test_img 64M diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out index 942485de99..e857ef9a7d 100644 --- a/tests/qemu-iotests/061.out +++ b/tests/qemu-iotests/061.out @@ -52,6 +52,67 @@ read 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) No errors were found on the image. =20 +=3D=3D=3D Testing version downgrade with zero expansion and 4K cache entri= es =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +wrote 131072/131072 bytes at offset 0 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 33554432 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +128 KiB (0x20000) bytes allocated at offset 0 bytes (0x0) +31.875 MiB (0x1fe0000) bytes not allocated at offset 128 KiB (0x20000) +128 KiB (0x20000) bytes allocated at offset 32 MiB (0x2000000) +31.875 MiB (0x1fe0000) bytes not allocated at offset 32.125 MiB (0x2020000) +magic 0x514649fb +version 3 +backing_file_offset 0x0 +backing_file_size 0x0 +cluster_bits 16 +size 67108864 +crypt_method 0 +l1_size 1 +l1_table_offset 0x30000 +refcount_table_offset 0x10000 +refcount_table_clusters 1 +nb_snapshots 0 +snapshot_offset 0x0 +incompatible_features 0x0 +compatible_features 0x1 +autoclear_features 0x0 +refcount_order 4 +header_length 104 + +Header extension: +magic 0x6803f857 +length 144 +data + +magic 0x514649fb +version 2 +backing_file_offset 0x0 +backing_file_size 0x0 +cluster_bits 16 +size 67108864 +crypt_method 0 +l1_size 1 +l1_table_offset 0x30000 +refcount_table_offset 0x10000 +refcount_table_clusters 1 +nb_snapshots 0 +snapshot_offset 0x0 +incompatible_features 0x0 +compatible_features 0x0 +autoclear_features 0x0 +refcount_order 4 +header_length 72 + +read 131072/131072 bytes at offset 0 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 131072/131072 bytes at offset 33554432 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +64 MiB (0x4000000) bytes not allocated at offset 0 bytes (0x0) +No errors were found on the image. + =3D=3D=3D Testing dirty version downgrade =3D=3D=3D =20 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 --=20 2.11.0 From nobody Thu May 2 02:48:10 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 1516980150759466.13747933899333; Fri, 26 Jan 2018 07:22:30 -0800 (PST) Received: from localhost ([::1]:33173 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5ph-0000Ab-L3 for importer@patchew.org; Fri, 26 Jan 2018 10:22:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ef5nW-0007BK-Pe for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:20:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ef5nS-0000hm-Pl for qemu-devel@nongnu.org; Fri, 26 Jan 2018 10:20:10 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:54127) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ef5nS-0000hI-Fp; Fri, 26 Jan 2018 10:20:06 -0500 Received: from 88-114-101-230.elisa-laajakaista.fi ([88.114.101.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ef5Ud-0007gy-Oq; Fri, 26 Jan 2018 16:00:39 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ef5UI-00088L-87; Fri, 26 Jan 2018 17:00:18 +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=V/z26WkzT/KJWFCd9k21skyNut3LCXuHx0uK/mg6vwA=; b=geoL9hOS3yP3nXmc+/E17iQ/iWBpx1i3bOA1hh6Ijo1ABTQYFyZZiinr6nBRCXK2PpnDh34JvLY/8XV5aLQtu0jh6HG5At5z0JA6fwOfEB0aHjksHNN8/V0pZjXqNWsZp6TBgr/uUZY+Qj/m6NtXKbDsl3edaKERqR3AFHvCmgiTlB/6SAwY4SytKrVQ0k1ktuoEGAfN0mQ9OUlI0/3geP4rkG26N+yfe6hfuXyt4diStuVcrzc1uMlGhrDHFzxEtzrpP5ugIcX0Iok67Uacaldwp73DNQMeeTdqcTWJpr1/O9ltVMtSAGOTsYQBRqQX1siN4FuLbYmOu2dSvkOJfA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 26 Jan 2018 17:00:06 +0200 Message-Id: <9f551b36d688079dcda4838c788f41a190b5219c.1516978645.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 39/39] iotests: Add l2-cache-entry-size to iotest 137 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Anton Nefedov , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , "Denis V . Lunev" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This test tries reopening a qcow2 image with valid and invalid options. This patch adds l2-cache-entry-size to the set. Signed-off-by: Alberto Garcia --- tests/qemu-iotests/137 | 5 +++++ tests/qemu-iotests/137.out | 2 ++ 2 files changed, 7 insertions(+) diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 index 5a01250005..87965625d8 100755 --- a/tests/qemu-iotests/137 +++ b/tests/qemu-iotests/137 @@ -83,6 +83,9 @@ $QEMU_IO \ -c "reopen -o overlap-check.inactive-l2=3Doff" \ -c "reopen -o cache-size=3D1M" \ -c "reopen -o l2-cache-size=3D512k" \ + -c "reopen -o l2-cache-entry-size=3D512" \ + -c "reopen -o l2-cache-entry-size=3D4k" \ + -c "reopen -o l2-cache-entry-size=3D64k" \ -c "reopen -o refcount-cache-size=3D128k" \ -c "reopen -o cache-clean-interval=3D5" \ -c "reopen -o cache-clean-interval=3D0" \ @@ -107,6 +110,8 @@ $QEMU_IO \ -c "reopen -o cache-size=3D1M,l2-cache-size=3D2M" \ -c "reopen -o cache-size=3D1M,refcount-cache-size=3D2M" \ -c "reopen -o l2-cache-size=3D256T" \ + -c "reopen -o l2-cache-entry-size=3D33k" \ + -c "reopen -o l2-cache-entry-size=3D128k" \ -c "reopen -o refcount-cache-size=3D256T" \ -c "reopen -o overlap-check=3Dconstant,overlap-check.template=3Dall" \ -c "reopen -o overlap-check=3Dblubb" \ diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out index 05efd74d17..e28e1eadba 100644 --- a/tests/qemu-iotests/137.out +++ b/tests/qemu-iotests/137.out @@ -20,6 +20,8 @@ cache-size, l2-cache-size and refcount-cache-size may not= be set the same time l2-cache-size may not exceed cache-size refcount-cache-size may not exceed cache-size L2 cache size too big +L2 cache entry size must be a power of two between 512 and the cluster siz= e (65536) +L2 cache entry size must be a power of two between 512 and the cluster siz= e (65536) L2 cache size too big Conflicting values for qcow2 options 'overlap-check' ('constant') and 'ove= rlap-check.template' ('all') Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are an= y of the following: none, constant, cached, all --=20 2.11.0