From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153221; cv=none; d=zoho.com; s=zohoarc; b=IuAXeduKG98MJFVHdb3x631f7foO3A1/iAjnie35/G146/SDbCAIw+aY2czyvN1uFIpqxQ5P/7Q1bTDznbt/ccvKG+Ud8jre5HkgUe6uX4zHXq/jMrZLm0ZxYK1DEHwxB0Meer4q+juUPlJMZoC5P5BoFZXF8LL2w9aNPa8qBNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153221; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8hTqzhXCwSm+pnn+u/HHCmoHotoRRBHUylfmlt5TL7Y=; b=VYq5ATVh+qO/C5CIABjJIdCj5lKCftCA5PVNFgo0i5tkRzBDB/obRZm2UrSUGFWcyfv6lBwl5OVKs5lwGxQ/utKc6QDLPjAI9myHZZWsIT98ITBbTbqYWqCVt1kC5u9pmyHamhFBlyu8InjDaKH1XYpfl1Q3h/hH9e1iLg6IY4g= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571153220460297.03782369283954; Tue, 15 Oct 2019 08:27:00 -0700 (PDT) Received: from localhost ([::1]:48692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOit-00057s-QY for importer@patchew.org; Tue, 15 Oct 2019 11:26:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48082) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOgy-0002ku-7a for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOgw-0003fX-R2 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:56 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47099) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOgw-0003Z7-Ct; Tue, 15 Oct 2019 11:24:54 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOgd-0003aN-W9; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-000615-GQ; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=8hTqzhXCwSm+pnn+u/HHCmoHotoRRBHUylfmlt5TL7Y=; b=B0OEIY5DHZpNmhFoZ8Q68Z5+5FnefWRcaPktAFNDPOFJE+7CH4n6pdL42MJactzJgZn0q8mfR1Kabe8/fJBDEpdCYOW62yJCybHVIkKVh0Ev+JNdymVn4ZZ6VUiaQ+dt1bTpZp/c48ZuyizfDh+0BtF+hx3yk9utQjsWbRmPTxTbTf2/L0nyUvAN0sQH+IUmMvoHLTVdTbHta5H0ouZ5+WE9NvX2BOGq08NxuvR40DlmcJ1SfNs2jPo7D5gDQDtnuzJFrB1zhSb/TDncKyBtr1Is6YeuDI0MaBR5YyZiwrcIfluo60SyJRETTj2rfWKnUHRtTixxBrLOOe+8bR/1fQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 01/23] qcow2: Add calculate_l2_meta() Date: Tue, 15 Oct 2019 18:23:12 +0300 Message-Id: <9a83358cfa0bf36b6fd7d6bb207511edee0260bc.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" handle_alloc() creates a QCowL2Meta structure in order to update the image metadata and perform the necessary copy-on-write operations. This patch moves that code to a separate function so it can be used from other places. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 76 +++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 24 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 8d5fa1539c..fe2523ed66 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1019,6 +1019,55 @@ void qcow2_alloc_cluster_abort(BlockDriverState *bs,= QCowL2Meta *m) QCOW2_DISCARD_NEVER); } =20 +/* + * For a given write request, create a new QCowL2Meta structure and + * add it to @m. + * + * @host_offset points to the beginning of the first cluster. + * + * @guest_offset and @bytes indicate the offset and length of the + * request. + * + * If @keep_old is true it means that the clusters were already + * allocated and will be overwritten. If false then the clusters are + * new and we have to decrease the reference count of the old ones. + */ +static void calculate_l2_meta(BlockDriverState *bs, uint64_t host_offset, + uint64_t guest_offset, uint64_t bytes, + QCowL2Meta **m, bool keep_old) +{ + BDRVQcow2State *s =3D bs->opaque; + unsigned cow_start_from =3D 0; + unsigned cow_start_to =3D offset_into_cluster(s, guest_offset); + unsigned cow_end_from =3D cow_start_to + bytes; + unsigned cow_end_to =3D ROUND_UP(cow_end_from, s->cluster_size); + unsigned nb_clusters =3D size_to_clusters(s, cow_end_from); + QCowL2Meta *old_m =3D *m; + + *m =3D g_malloc0(sizeof(**m)); + **m =3D (QCowL2Meta) { + .next =3D old_m, + + .alloc_offset =3D host_offset, + .offset =3D start_of_cluster(s, guest_offset), + .nb_clusters =3D nb_clusters, + + .keep_old_clusters =3D keep_old, + + .cow_start =3D { + .offset =3D cow_start_from, + .nb_bytes =3D cow_start_to - cow_start_from, + }, + .cow_end =3D { + .offset =3D cow_end_from, + .nb_bytes =3D cow_end_to - cow_end_from, + }, + }; + + qemu_co_queue_init(&(*m)->dependent_requests); + QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight); +} + /* * Returns the number of contiguous clusters that can be used for an alloc= ating * write, but require COW to be performed (this includes yet unallocated s= pace, @@ -1414,35 +1463,14 @@ static int handle_alloc(BlockDriverState *bs, uint6= 4_t guest_offset, uint64_t requested_bytes =3D *bytes + offset_into_cluster(s, guest_off= set); int avail_bytes =3D MIN(INT_MAX, nb_clusters << s->cluster_bits); int nb_bytes =3D MIN(requested_bytes, avail_bytes); - QCowL2Meta *old_m =3D *m; - - *m =3D g_malloc0(sizeof(**m)); - - **m =3D (QCowL2Meta) { - .next =3D old_m, - - .alloc_offset =3D alloc_cluster_offset, - .offset =3D start_of_cluster(s, guest_offset), - .nb_clusters =3D nb_clusters, - - .keep_old_clusters =3D keep_old_clusters, - - .cow_start =3D { - .offset =3D 0, - .nb_bytes =3D offset_into_cluster(s, guest_offset), - }, - .cow_end =3D { - .offset =3D nb_bytes, - .nb_bytes =3D avail_bytes - nb_bytes, - }, - }; - qemu_co_queue_init(&(*m)->dependent_requests); - QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight); =20 *host_offset =3D alloc_cluster_offset + offset_into_cluster(s, guest_o= ffset); *bytes =3D MIN(*bytes, nb_bytes - offset_into_cluster(s, guest_offset)= ); assert(*bytes !=3D 0); =20 + calculate_l2_meta(bs, alloc_cluster_offset, guest_offset, *bytes, + m, keep_old_clusters); + return 1; =20 fail: --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571154040; cv=none; d=zoho.com; s=zohoarc; b=FGVrZPDz+mKOSJN4Dwnb2One+pRIRNcTofUp70xHd+fEV6iZ7gGiy4//mGOykiXNLEwgr4Yeqgh8P7MBpuvoLPeRdL9xsPQXuNpqAvAwKuobZRXWOU9qxdfscJDhPfUaBp41FW5owiJl8AsndPo3iKFVOPj7eliLeY0ehtoP6NU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571154040; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bb9ZdIeCIRGrOfF/Mvuj63LkDtjmwPtW8KRNa7nr2EA=; b=jRLxv8TVRcFAiZ7dn88XiJeZoZGYfb2IiOWNjYMzYLp32XSJ27ncJ45OSXY2V0T5NvES+ncWseKKzb2gzAZbN74vOjhXoeE8JMl+XXY5C3KsRrEVwk0QS2z21N4HrYnDqwA3AVT5ElJPHqIXr520YXvZKoIb01yghxzcY5pekDM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571154040076963.334589089221; Tue, 15 Oct 2019 08:40:40 -0700 (PDT) Received: from localhost ([::1]:48970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOw8-0004Mr-Gg for importer@patchew.org; Tue, 15 Oct 2019 11:40:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48482) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOhL-0003LR-2n for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOhJ-0003rO-P1 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:18 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47175) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOhJ-0003c8-DC; Tue, 15 Oct 2019 11:25:17 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003aP-1Z; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-000617-He; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=bb9ZdIeCIRGrOfF/Mvuj63LkDtjmwPtW8KRNa7nr2EA=; b=ZnB3GS9FiAAEAz+z0kO0/S3Xl30LqcrPzQID/+Jr1WXL2mWhpTnOOULPUr93ZXvUBFvB/pPM1hrlc7j3Q/Yx/C471QX37h8c6P/i5S7VzXoofZZ2YWkIxEuytwT2U7ByKjZWUve5Gj1nauDHWlVh0naw5eVq+cOmOZw88aklTLpClszrd8oHcF7dDw89lRuCAfyyFwtJGyiomyX7xfhVEGrQGjyTJXoQeVqHQXlZbBWEZFeMq0GCb7siWvqcmlq5a3JaK6nX6+EwblczLFgmehGHNrW/i8PgDEewT2u4S/jTHe7GtQEU2xtceKrxnqmUJsqQPTUXhqbMtCg7pvnJPA==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 02/23] qcow2: Split cluster_needs_cow() out of count_cow_clusters() Date: Tue, 15 Oct 2019 18:23:13 +0300 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" We are going to need it in other places. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index fe2523ed66..f462e169c0 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1068,6 +1068,24 @@ static void calculate_l2_meta(BlockDriverState *bs, = uint64_t host_offset, QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight); } =20 +/* Returns true if writing to a cluster requires COW */ +static bool cluster_needs_cow(BlockDriverState *bs, uint64_t l2_entry) +{ + switch (qcow2_get_cluster_type(bs, l2_entry)) { + case QCOW2_CLUSTER_NORMAL: + if (l2_entry & QCOW_OFLAG_COPIED) { + return false; + } + case QCOW2_CLUSTER_UNALLOCATED: + case QCOW2_CLUSTER_COMPRESSED: + case QCOW2_CLUSTER_ZERO_PLAIN: + case QCOW2_CLUSTER_ZERO_ALLOC: + return true; + default: + abort(); + } +} + /* * Returns the number of contiguous clusters that can be used for an alloc= ating * write, but require COW to be performed (this includes yet unallocated s= pace, @@ -1080,25 +1098,11 @@ static int count_cow_clusters(BlockDriverState *bs,= int nb_clusters, =20 for (i =3D 0; i < nb_clusters; i++) { uint64_t l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); - QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(bs, l2_en= try); - - switch(cluster_type) { - case QCOW2_CLUSTER_NORMAL: - if (l2_entry & QCOW_OFLAG_COPIED) { - goto out; - } + if (!cluster_needs_cow(bs, l2_entry)) { break; - case QCOW2_CLUSTER_UNALLOCATED: - case QCOW2_CLUSTER_COMPRESSED: - case QCOW2_CLUSTER_ZERO_PLAIN: - case QCOW2_CLUSTER_ZERO_ALLOC: - break; - default: - abort(); } } =20 -out: assert(i <=3D nb_clusters); return i; } --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153738; cv=none; d=zoho.com; s=zohoarc; b=opXl7q7+uFO7bpizA2wOrV2vFVxEg/75oCv+VxG+X0v28Oi7qH07336ZrvyW0hyDwmbhbQbZ/xaLIxhBU83CWqb7EyQ3dz44Ru6XaA+ujq6nXUtaSG1kTFKYnpdmC6rrnz1YB/Ct1XbI/E03HESONhkbKEOuSQbjjQJuYN/iJX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153738; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JKZDe4shtXRU+8kUbCZNNXhzpqNAhsbhejqfg2Rzb1c=; b=CW0UCU4dXS7mvkR4zYHAFG/96VNpRtcxX1n8GwA+vQA3IH2zE35k1TZQmA9Dla8hOgDoMpusssgKGGnHuT30WWecdsoQN61za4u2Secvinmw3HY0JSGhWBH3EispODU37SPGKHrsbD/76TTRFFYx9Y7jFHXEtCHoB6pPiS/f7RA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571153738923672.9283907072373; Tue, 15 Oct 2019 08:35:38 -0700 (PDT) Received: from localhost ([::1]:48848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOrD-0005HF-Eo for importer@patchew.org; Tue, 15 Oct 2019 11:35:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48130) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOgz-0002l1-7I for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOgw-0003gH-Tj for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:57 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOgw-0003ZH-54; Tue, 15 Oct 2019 11:24:54 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOgd-0003aQ-OM; Tue, 15 Oct 2019 17:24:35 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-000619-J7; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=JKZDe4shtXRU+8kUbCZNNXhzpqNAhsbhejqfg2Rzb1c=; b=YgFiOy3u9KJ3uA3nWPf1sAMBQNTLQwSLEAxc8LmKTjivhwhAKPpIQPeVvsHK5d0pXGvEMecTLI7knrG3fkcfYt4h8NOi7elgXaOsWmU/DMlW/q3QlWDKPPOB1M/sUDPP2mkLwN24+eNF4mXkvgLeTfpu20md2r088U+yko7cXca3sG3uklz4IfZ5KCRBMmnbOaezufIO+mpUGFx3LslCQkljvXmTkQKkzMIlBIdsYhFyjJu/hFtD4OfQq2TXxHkrQsWsCawt1VxdYE1V+ueuGlkHbKRPjznewaZ1mpUWEcDi0VYzP8sb3rJtO25t5nP5O9l5ySthkRRIwnaksUaj5A==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 03/23] qcow2: Process QCOW2_CLUSTER_ZERO_ALLOC clusters in handle_copied() Date: Tue, 15 Oct 2019 18:23:14 +0300 Message-Id: <21379e61f052c9f8c2f4d13eb0c079195f4531d2.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" When writing to a qcow2 file there are two functions that take a virtual offset and return a host offset, possibly allocating new clusters if necessary: - handle_copied() looks for normal data clusters that are already allocated and have a reference count of 1. In those clusters we can simply write the data and there is no need to perform any copy-on-write. - handle_alloc() looks for clusters that do need copy-on-write, either because they haven't been allocated yet, because their reference count is !=3D 1 or because they are ZERO_ALLOC clusters. The ZERO_ALLOC case is a bit special because those are clusters that are already allocated and they could perfectly be dealt with in handle_copied() (as long as copy-on-write is performed when required). In fact, there is extra code specifically for them in handle_alloc() that tries to reuse the existing allocation if possible and frees them otherwise. This patch changes the handling of ZERO_ALLOC clusters so the semantics of these two functions are now like this: - handle_copied() looks for clusters that are already allocated and which we can overwrite (NORMAL and ZERO_ALLOC clusters with a reference count of 1). - handle_alloc() looks for clusters for which we need a new allocation (all other cases). One importante difference after this change is that clusters found in handle_copied() may now require copy-on-write, but this will be anyway necessary once we add support for subclusters. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 177 +++++++++++++++++++++++------------------- 1 file changed, 96 insertions(+), 81 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index f462e169c0..70b2e32f7e 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1021,7 +1021,8 @@ void qcow2_alloc_cluster_abort(BlockDriverState *bs, = QCowL2Meta *m) =20 /* * For a given write request, create a new QCowL2Meta structure and - * add it to @m. + * add it to @m. If the write request does not need copy-on-write or + * changes to the L2 metadata then this function does nothing. * * @host_offset points to the beginning of the first cluster. * @@ -1034,15 +1035,51 @@ void qcow2_alloc_cluster_abort(BlockDriverState *bs= , QCowL2Meta *m) */ static void calculate_l2_meta(BlockDriverState *bs, uint64_t host_offset, uint64_t guest_offset, uint64_t bytes, - QCowL2Meta **m, bool keep_old) + uint64_t *l2_slice, QCowL2Meta **m, bool kee= p_old) { BDRVQcow2State *s =3D bs->opaque; - unsigned cow_start_from =3D 0; + int l2_index =3D offset_to_l2_slice_index(s, guest_offset); + uint64_t l2_entry; + unsigned cow_start_from, cow_end_to; unsigned cow_start_to =3D offset_into_cluster(s, guest_offset); unsigned cow_end_from =3D cow_start_to + bytes; - unsigned cow_end_to =3D ROUND_UP(cow_end_from, s->cluster_size); unsigned nb_clusters =3D size_to_clusters(s, cow_end_from); QCowL2Meta *old_m =3D *m; + QCow2ClusterType type; + + /* Return if there's no COW (all clusters are normal and we keep them)= */ + if (keep_old) { + int i; + for (i =3D 0; i < nb_clusters; i++) { + l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); + if (qcow2_get_cluster_type(bs, l2_entry) !=3D QCOW2_CLUSTER_NO= RMAL) { + break; + } + } + if (i =3D=3D nb_clusters) { + return; + } + } + + /* Get the L2 entry from the first cluster */ + l2_entry =3D be64_to_cpu(l2_slice[l2_index]); + type =3D qcow2_get_cluster_type(bs, l2_entry); + + if (type =3D=3D QCOW2_CLUSTER_NORMAL && keep_old) { + cow_start_from =3D cow_start_to; + } else { + cow_start_from =3D 0; + } + + /* Get the L2 entry from the last cluster */ + l2_entry =3D be64_to_cpu(l2_slice[l2_index + nb_clusters - 1]); + type =3D qcow2_get_cluster_type(bs, l2_entry); + + if (type =3D=3D QCOW2_CLUSTER_NORMAL && keep_old) { + cow_end_to =3D cow_end_from; + } else { + cow_end_to =3D ROUND_UP(cow_end_from, s->cluster_size); + } =20 *m =3D g_malloc0(sizeof(**m)); **m =3D (QCowL2Meta) { @@ -1068,18 +1105,18 @@ static void calculate_l2_meta(BlockDriverState *bs,= uint64_t host_offset, QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight); } =20 -/* Returns true if writing to a cluster requires COW */ +/* Returns true if the cluster is unallocated or has refcount > 1 */ static bool cluster_needs_cow(BlockDriverState *bs, uint64_t l2_entry) { switch (qcow2_get_cluster_type(bs, l2_entry)) { case QCOW2_CLUSTER_NORMAL: + case QCOW2_CLUSTER_ZERO_ALLOC: if (l2_entry & QCOW_OFLAG_COPIED) { return false; } case QCOW2_CLUSTER_UNALLOCATED: case QCOW2_CLUSTER_COMPRESSED: case QCOW2_CLUSTER_ZERO_PLAIN: - case QCOW2_CLUSTER_ZERO_ALLOC: return true; default: abort(); @@ -1087,20 +1124,34 @@ static bool cluster_needs_cow(BlockDriverState *bs,= uint64_t l2_entry) } =20 /* - * Returns the number of contiguous clusters that can be used for an alloc= ating - * write, but require COW to be performed (this includes yet unallocated s= pace, - * which must copy from the backing file) + * Returns the number of contiguous clusters that can be written to + * using one single write request, starting from @l2_index. + * At most @nb_clusters are checked. + * + * If @want_cow is true this counts clusters that are either + * unallocated, or allocated but with refcount > 1. + * + * If @want_cow is false this counts clusters that are already + * allocated and can be written to using their current locations + * (including QCOW2_CLUSTER_ZERO_ALLOC). */ static int count_cow_clusters(BlockDriverState *bs, int nb_clusters, - uint64_t *l2_slice, int l2_index) + uint64_t *l2_slice, int l2_index, bool want_= cow) { + BDRVQcow2State *s =3D bs->opaque; + uint64_t l2_entry =3D be64_to_cpu(l2_slice[l2_index]); + uint64_t expected_offset =3D l2_entry & L2E_OFFSET_MASK; int i; =20 for (i =3D 0; i < nb_clusters; i++) { - uint64_t l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); - if (!cluster_needs_cow(bs, l2_entry)) { + l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); + if (cluster_needs_cow(bs, l2_entry) !=3D want_cow) { break; } + if (!want_cow && expected_offset !=3D (l2_entry & L2E_OFFSET_MASK)= ) { + break; + } + expected_offset +=3D s->cluster_size; } =20 assert(i <=3D nb_clusters); @@ -1228,18 +1279,17 @@ static int handle_copied(BlockDriverState *bs, uint= 64_t guest_offset, =20 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(bs, cluster_offset) =3D=3D QCOW2_CLUSTER_NO= RMAL - && (cluster_offset & QCOW_OFLAG_COPIED)) - { + if (!cluster_needs_cow(bs, cluster_offset)) { /* If a specific host_offset is required, check it */ bool offset_matches =3D (cluster_offset & L2E_OFFSET_MASK) =3D=3D *host_offset; =20 if (offset_into_cluster(s, cluster_offset & L2E_OFFSET_MASK)) { - qcow2_signal_corruption(bs, true, -1, -1, "Data cluster offset= " + qcow2_signal_corruption(bs, true, -1, -1, "%s cluster offset " "%#llx unaligned (guest offset: %#" PR= Ix64 - ")", cluster_offset & L2E_OFFSET_MASK, + ")", cluster_offset & QCOW_OFLAG_ZERO ? + "Preallocated zero" : "Data", + cluster_offset & L2E_OFFSET_MASK, guest_offset); ret =3D -EIO; goto out; @@ -1252,15 +1302,17 @@ static int handle_copied(BlockDriverState *bs, uint= 64_t guest_offset, } =20 /* We keep all QCOW_OFLAG_COPIED clusters */ - keep_clusters =3D - count_contiguous_clusters(bs, nb_clusters, s->cluster_size, - &l2_slice[l2_index], - QCOW_OFLAG_COPIED | QCOW_OFLAG_ZERO); + keep_clusters =3D count_cow_clusters(bs, nb_clusters, l2_slice, + l2_index, false); assert(keep_clusters <=3D nb_clusters); =20 *bytes =3D MIN(*bytes, keep_clusters * s->cluster_size - offset_into_cluster(s, guest_offset)); + assert(*bytes !=3D 0); + + calculate_l2_meta(bs, cluster_offset & L2E_OFFSET_MASK, guest_offs= et, + *bytes, l2_slice, m, true); =20 ret =3D 1; } else { @@ -1361,12 +1413,10 @@ static int handle_alloc(BlockDriverState *bs, uint6= 4_t guest_offset, BDRVQcow2State *s =3D bs->opaque; int l2_index; uint64_t *l2_slice; - uint64_t entry; uint64_t nb_clusters; int ret; - bool keep_old_clusters =3D false; =20 - uint64_t alloc_cluster_offset =3D INV_OFFSET; + uint64_t alloc_cluster_offset; =20 trace_qcow2_handle_alloc(qemu_coroutine_self(), guest_offset, *host_of= fset, *bytes); @@ -1389,67 +1439,31 @@ static int handle_alloc(BlockDriverState *bs, uint6= 4_t guest_offset, return ret; } =20 - entry =3D be64_to_cpu(l2_slice[l2_index]); - nb_clusters =3D count_cow_clusters(bs, nb_clusters, l2_slice, l2_index= ); + nb_clusters =3D count_cow_clusters(bs, nb_clusters, l2_slice, l2_index= , true); =20 /* This function is only called when there were no non-COW clusters, s= o if * we can't find any unallocated or COW clusters either, something is * wrong with our code. */ assert(nb_clusters > 0); =20 - if (qcow2_get_cluster_type(bs, entry) =3D=3D QCOW2_CLUSTER_ZERO_ALLOC = && - (entry & QCOW_OFLAG_COPIED) && - (*host_offset =3D=3D INV_OFFSET || - start_of_cluster(s, *host_offset) =3D=3D (entry & L2E_OFFSET_MASK= ))) - { - int preallocated_nb_clusters; - - if (offset_into_cluster(s, entry & L2E_OFFSET_MASK)) { - qcow2_signal_corruption(bs, true, -1, -1, "Preallocated zero " - "cluster offset %#llx unaligned (guest= " - "offset: %#" PRIx64 ")", - entry & L2E_OFFSET_MASK, guest_offset); - ret =3D -EIO; - goto fail; - } - - /* Try to reuse preallocated zero clusters; contiguous normal clus= ters - * would be fine, too, but count_cow_clusters() above has limited - * nb_clusters already to a range of COW clusters */ - preallocated_nb_clusters =3D - count_contiguous_clusters(bs, nb_clusters, s->cluster_size, - &l2_slice[l2_index], QCOW_OFLAG_COPI= ED); - assert(preallocated_nb_clusters > 0); - - nb_clusters =3D preallocated_nb_clusters; - alloc_cluster_offset =3D entry & L2E_OFFSET_MASK; - - /* We want to reuse these clusters, so qcow2_alloc_cluster_link_l2= () - * should not free them. */ - keep_old_clusters =3D true; + /* Allocate, if necessary at a given offset in the image file */ + alloc_cluster_offset =3D *host_offset =3D=3D INV_OFFSET ? INV_OFFSET : + start_of_cluster(s, *host_offset); + ret =3D do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_offse= t, + &nb_clusters); + if (ret < 0) { + goto out; } =20 - qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); - - if (alloc_cluster_offset =3D=3D INV_OFFSET) { - /* Allocate, if necessary at a given offset in the image file */ - alloc_cluster_offset =3D *host_offset =3D=3D INV_OFFSET ? INV_OFFS= ET : - start_of_cluster(s, *host_offset); - ret =3D do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_o= ffset, - &nb_clusters); - if (ret < 0) { - goto fail; - } - - /* Can't extend contiguous allocation */ - if (nb_clusters =3D=3D 0) { - *bytes =3D 0; - return 0; - } - - assert(alloc_cluster_offset !=3D INV_OFFSET); + /* Can't extend contiguous allocation */ + if (nb_clusters =3D=3D 0) { + *bytes =3D 0; + ret =3D 0; + goto out; } =20 + assert(alloc_cluster_offset !=3D INV_OFFSET); + /* * Save info needed for meta data update. * @@ -1472,13 +1486,14 @@ static int handle_alloc(BlockDriverState *bs, uint6= 4_t guest_offset, *bytes =3D MIN(*bytes, nb_bytes - offset_into_cluster(s, guest_offset)= ); assert(*bytes !=3D 0); =20 - calculate_l2_meta(bs, alloc_cluster_offset, guest_offset, *bytes, - m, keep_old_clusters); + calculate_l2_meta(bs, alloc_cluster_offset, guest_offset, *bytes, l2_s= lice, + m, false); =20 - return 1; + ret =3D 1; =20 -fail: - if (*m && (*m)->nb_clusters > 0) { +out: + qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); + if (ret < 0 && *m && (*m)->nb_clusters > 0) { QLIST_REMOVE(*m, next_in_flight); } return ret; --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153480; cv=none; d=zoho.com; s=zohoarc; b=SZjnS4xiqT6PDbflWwAEjxzno/D5ZenvYgzyzWJCQozTq/GAdojr6V0WhbyWMHfIb1ms7ys4FWnuBXVc5ZcdwMgpC0DKoyTd9b7u8pmcqLI9X2LvVBLcQBirV0a8lTol+JsBfLaZiWM3VJcx3kKSJAd0tdiSg0j75JDMMElDJC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153480; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/Pe2iqA+jw28mS9SLE2x2DloDl65uPfegnR7tvwEAgQ=; b=FMsch5GjcjHAGjERJv7Y2sCGMMlDQDIttsh6cDMU6Q2FsSjc9PDJ+S++bJO6rQImdRtTzbzQJ6Dm0QXmzKzQlXpuOp1W5oq5cmb293WoL15sVI+lZHNRmgZ1+/dnYiLdP2R56GzZnYUBNVcq+Sl4+FJMxUH6qLYdEiIFTK2FxAA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571153480737353.8570152415922; Tue, 15 Oct 2019 08:31:20 -0700 (PDT) Received: from localhost ([::1]:48762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOn8-00018X-OV for importer@patchew.org; Tue, 15 Oct 2019 11:31:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48135) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOgz-0002l3-F2 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOgw-0003gA-Vl for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:57 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47101) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOgw-0003ZA-4y; Tue, 15 Oct 2019 11:24:54 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOgd-0003aR-R4; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-00061B-K9; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=/Pe2iqA+jw28mS9SLE2x2DloDl65uPfegnR7tvwEAgQ=; b=lp4TeZRDKUP6Vwd6svZA/UDBs7OSKjwot6JC26D2wiyUbzFLG0eXCh5Pc6SihBfea2ZIPrff6F6FsQxvd/p2xq9cbUn5cscmCu8spuUnsU7pjO4E5wUJhTgAjf9Z2ubyysKgoxVd7+b0WXCzapHSvLr3qurdxW+zB1ClrJxwUbOFKzS+w0vxAaPwNa8XFs3W72b4PcTF6vl6aNfKhOcw9UoC5z1RS/3AZcZg8YQ7KB7KmyITGSNFoiRfyFhgKYWAFbUJsb/88eUs3hudIbv1RHmmi9/Yzpl+Scx1y+ABZv6DsG0MunSHd1l4ga5SOwsLoEBG9uKtEe754qwOIXvOHg==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 04/23] qcow2: Add get_l2_entry() and set_l2_entry() Date: Tue, 15 Oct 2019 18:23:15 +0300 Message-Id: <0cec82bdb0fff9eacc022a826979cc3d17aa194b.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" The size of an L2 entry is 64 bits, but if we want to have subclusters we need extended L2 entries. This means that we have to access L2 tables and slices differently depending on whether an image has extended L2 entries or not. This patch replaces all l2_slice[] accesses with calls to get_l2_entry() and set_l2_entry(). Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 65 ++++++++++++++++++++++-------------------- block/qcow2-refcount.c | 17 +++++------ block/qcow2.h | 12 ++++++++ 3 files changed, 55 insertions(+), 39 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 70b2e32f7e..b2045d51bf 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -379,12 +379,13 @@ fail: * cluster which may require a different handling) */ static int count_contiguous_clusters(BlockDriverState *bs, int nb_clusters, - int cluster_size, uint64_t *l2_slice, uint64_t stop_flags) + int cluster_size, uint64_t *l2_slice, int l2_index, uint64_t stop_= flags) { + BDRVQcow2State *s =3D bs->opaque; 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_slice[0]); + uint64_t first_entry =3D get_l2_entry(s, l2_slice, l2_index); uint64_t offset =3D first_entry & mask; =20 first_cluster_type =3D qcow2_get_cluster_type(bs, first_entry); @@ -397,7 +398,7 @@ static int count_contiguous_clusters(BlockDriverState *= bs, int nb_clusters, 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_slice[i]) & mask; + uint64_t l2_entry =3D get_l2_entry(s, l2_slice, l2_index + i) & ma= sk; if (offset + (uint64_t) i * cluster_size !=3D l2_entry) { break; } @@ -413,14 +414,16 @@ static int count_contiguous_clusters(BlockDriverState= *bs, int nb_clusters, static int count_contiguous_clusters_unallocated(BlockDriverState *bs, int nb_clusters, uint64_t *l2_slice, + int l2_index, QCow2ClusterType wanted_t= ype) { + BDRVQcow2State *s =3D bs->opaque; int i; =20 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_slice[i]); + uint64_t entry =3D get_l2_entry(s, l2_slice, l2_index + i); QCow2ClusterType type =3D qcow2_get_cluster_type(bs, entry); =20 if (type !=3D wanted_type) { @@ -566,7 +569,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, /* find the cluster offset for the given disk offset */ =20 l2_index =3D offset_to_l2_slice_index(s, offset); - *cluster_offset =3D be64_to_cpu(l2_slice[l2_index]); + *cluster_offset =3D get_l2_entry(s, 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 @@ -601,14 +604,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(bs, nb_clusters, - &l2_slice[l2_index], typ= e); + l2_slice, l2_index, type= ); *cluster_offset =3D 0; break; case QCOW2_CLUSTER_ZERO_ALLOC: case QCOW2_CLUSTER_NORMAL: /* how many allocated clusters ? */ c =3D count_contiguous_clusters(bs, nb_clusters, s->cluster_size, - &l2_slice[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, @@ -761,7 +764,7 @@ int qcow2_alloc_compressed_cluster_offset(BlockDriverSt= ate *bs, =20 /* Compression can't overwrite anything. Fail if the cluster was alrea= dy * allocated. */ - cluster_offset =3D be64_to_cpu(l2_slice[l2_index]); + cluster_offset =3D get_l2_entry(s, l2_slice, l2_index); if (cluster_offset & L2E_OFFSET_MASK) { qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); return -EIO; @@ -786,7 +789,7 @@ int qcow2_alloc_compressed_cluster_offset(BlockDriverSt= ate *bs, =20 BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); - l2_slice[l2_index] =3D cpu_to_be64(cluster_offset); + set_l2_entry(s, l2_slice, l2_index, cluster_offset); qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 *host_offset =3D cluster_offset & s->cluster_offset_mask; @@ -978,12 +981,12 @@ 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_slice[l2_index + i] !=3D 0) { - old_cluster[j++] =3D l2_slice[l2_index + i]; + if (get_l2_entry(s, l2_slice, l2_index + i) !=3D 0) { + old_cluster[j++] =3D get_l2_entry(s, l2_slice, l2_index + i); } =20 - l2_slice[l2_index + i] =3D cpu_to_be64((cluster_offset + - (i << s->cluster_bits)) | QCOW_OFLAG_COPIED); + set_l2_entry(s, l2_slice, l2_index + i, QCOW_OFLAG_COPIED | + (cluster_offset + (i << s->cluster_bits))); } =20 =20 @@ -997,8 +1000,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, = QCowL2Meta *m) */ if (!m->keep_old_clusters && j !=3D 0) { for (i =3D 0; i < j; i++) { - qcow2_free_any_clusters(bs, be64_to_cpu(old_cluster[i]), 1, - QCOW2_DISCARD_NEVER); + qcow2_free_any_clusters(bs, old_cluster[i], 1, QCOW2_DISCARD_N= EVER); } } =20 @@ -1051,7 +1053,7 @@ static void calculate_l2_meta(BlockDriverState *bs, u= int64_t host_offset, if (keep_old) { int i; for (i =3D 0; i < nb_clusters; i++) { - l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); + l2_entry =3D get_l2_entry(s, l2_slice, l2_index + i); if (qcow2_get_cluster_type(bs, l2_entry) !=3D QCOW2_CLUSTER_NO= RMAL) { break; } @@ -1062,7 +1064,7 @@ static void calculate_l2_meta(BlockDriverState *bs, u= int64_t host_offset, } =20 /* Get the L2 entry from the first cluster */ - l2_entry =3D be64_to_cpu(l2_slice[l2_index]); + l2_entry =3D get_l2_entry(s, l2_slice, l2_index); type =3D qcow2_get_cluster_type(bs, l2_entry); =20 if (type =3D=3D QCOW2_CLUSTER_NORMAL && keep_old) { @@ -1072,7 +1074,7 @@ static void calculate_l2_meta(BlockDriverState *bs, u= int64_t host_offset, } =20 /* Get the L2 entry from the last cluster */ - l2_entry =3D be64_to_cpu(l2_slice[l2_index + nb_clusters - 1]); + l2_entry =3D get_l2_entry(s, l2_slice, l2_index + nb_clusters - 1); type =3D qcow2_get_cluster_type(bs, l2_entry); =20 if (type =3D=3D QCOW2_CLUSTER_NORMAL && keep_old) { @@ -1139,12 +1141,12 @@ static int count_cow_clusters(BlockDriverState *bs,= int nb_clusters, uint64_t *l2_slice, int l2_index, bool want_= cow) { BDRVQcow2State *s =3D bs->opaque; - uint64_t l2_entry =3D be64_to_cpu(l2_slice[l2_index]); + uint64_t l2_entry =3D get_l2_entry(s, l2_slice, l2_index); uint64_t expected_offset =3D l2_entry & L2E_OFFSET_MASK; int i; =20 for (i =3D 0; i < nb_clusters; i++) { - l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); + l2_entry =3D get_l2_entry(s, l2_slice, l2_index + i); if (cluster_needs_cow(bs, l2_entry) !=3D want_cow) { break; } @@ -1277,7 +1279,7 @@ static int handle_copied(BlockDriverState *bs, uint64= _t guest_offset, return ret; } =20 - cluster_offset =3D be64_to_cpu(l2_slice[l2_index]); + cluster_offset =3D get_l2_entry(s, l2_slice, l2_index); =20 if (!cluster_needs_cow(bs, cluster_offset)) { /* If a specific host_offset is required, check it */ @@ -1655,7 +1657,7 @@ static int discard_in_l2_slice(BlockDriverState *bs, = uint64_t offset, for (i =3D 0; i < nb_clusters; i++) { uint64_t old_l2_entry; =20 - old_l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); + old_l2_entry =3D get_l2_entry(s, l2_slice, l2_index + i); =20 /* * If full_discard is false, make sure that a discarded area reads= back @@ -1695,9 +1697,9 @@ static int discard_in_l2_slice(BlockDriverState *bs, = uint64_t offset, /* First remove L2 entries */ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); if (!full_discard && s->qcow_version >=3D 3) { - l2_slice[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); + set_l2_entry(s, l2_slice, l2_index + i, QCOW_OFLAG_ZERO); } else { - l2_slice[l2_index + i] =3D cpu_to_be64(0); + set_l2_entry(s, l2_slice, l2_index + i, 0); } =20 /* Then decrease the refcount */ @@ -1777,7 +1779,7 @@ static int zero_in_l2_slice(BlockDriverState *bs, uin= t64_t offset, uint64_t old_offset; QCow2ClusterType cluster_type; =20 - old_offset =3D be64_to_cpu(l2_slice[l2_index + i]); + old_offset =3D get_l2_entry(s, l2_slice, l2_index + i); =20 /* * Minimize L2 changes if the cluster already reads back as @@ -1791,10 +1793,11 @@ static int zero_in_l2_slice(BlockDriverState *bs, u= int64_t offset, =20 qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); if (cluster_type =3D=3D QCOW2_CLUSTER_COMPRESSED || unmap) { - l2_slice[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); + set_l2_entry(s, l2_slice, l2_index + i, QCOW_OFLAG_ZERO); qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUE= ST); } else { - l2_slice[l2_index + i] |=3D cpu_to_be64(QCOW_OFLAG_ZERO); + uint64_t entry =3D get_l2_entry(s, l2_slice, l2_index + i); + set_l2_entry(s, l2_slice, l2_index + i, entry | QCOW_OFLAG_ZER= O); } } =20 @@ -1932,7 +1935,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, } =20 for (j =3D 0; j < s->l2_slice_size; j++) { - uint64_t l2_entry =3D be64_to_cpu(l2_slice[j]); + uint64_t l2_entry =3D get_l2_entry(s, l2_slice, j); int64_t offset =3D l2_entry & L2E_OFFSET_MASK; QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(bs, l2_entry); @@ -1946,7 +1949,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_slice[j] =3D 0; + set_l2_entry(s, l2_slice, j, 0); l2_dirty =3D true; continue; } @@ -2009,9 +2012,9 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, } =20 if (l2_refcount =3D=3D 1) { - l2_slice[j] =3D cpu_to_be64(offset | QCOW_OFLAG_COPIED= ); + set_l2_entry(s, l2_slice, j, offset | QCOW_OFLAG_COPIE= D); } else { - l2_slice[j] =3D cpu_to_be64(offset); + set_l2_entry(s, l2_slice, j, offset); } l2_dirty =3D true; } diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index ef965d7895..14f71df7da 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1309,7 +1309,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, uint64_t cluster_index; uint64_t offset; =20 - entry =3D be64_to_cpu(l2_slice[j]); + entry =3D get_l2_entry(s, l2_slice, j); old_entry =3D entry; entry &=3D ~QCOW_OFLAG_COPIED; offset =3D entry & L2E_OFFSET_MASK; @@ -1383,7 +1383,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, qcow2_cache_set_dependency(bs, s->l2_table_cac= he, s->refcount_block_c= ache); } - l2_slice[j] =3D cpu_to_be64(entry); + set_l2_entry(s, l2_slice, j, entry); qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); } @@ -1616,7 +1616,7 @@ static int check_refcounts_l2(BlockDriverState *bs, B= drvCheckResult *res, =20 /* Do the actual checks */ for(i =3D 0; i < s->l2_size; i++) { - l2_entry =3D be64_to_cpu(l2_table[i]); + l2_entry =3D get_l2_entry(s, l2_table, i); =20 switch (qcow2_get_cluster_type(bs, l2_entry)) { case QCOW2_CLUSTER_COMPRESSED: @@ -1685,7 +1685,7 @@ static int check_refcounts_l2(BlockDriverState *bs, B= drvCheckResult *res, QCOW2_OL_INACTIVE_L2; =20 l2_entry =3D QCOW_OFLAG_ZERO; - l2_table[i] =3D cpu_to_be64(l2_entry); + set_l2_entry(s, l2_table, i, l2_entry); ret =3D qcow2_pre_write_overlap_check(bs, ign, l2e_offset, sizeof(uint64_t), false); if (ret < 0) { @@ -1913,7 +1913,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, } =20 for (j =3D 0; j < s->l2_size; j++) { - uint64_t l2_entry =3D be64_to_cpu(l2_table[j]); + uint64_t l2_entry =3D get_l2_entry(s, l2_table, j); uint64_t data_offset =3D l2_entry & L2E_OFFSET_MASK; QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(bs, l= 2_entry); =20 @@ -1936,9 +1936,10 @@ static int check_oflag_copied(BlockDriverState *bs, = BdrvCheckResult *res, "l2_entry=3D%" PRIx64 " refcount=3D%" PRIu64 "= \n", repair ? "Repairing" : "ERROR", l2_entry, refc= ount); if (repair) { - l2_table[j] =3D cpu_to_be64(refcount =3D=3D 1 - ? l2_entry | QCOW_OFLAG_COPIED - : l2_entry & ~QCOW_OFLAG_COPIED); + set_l2_entry(s, l2_table, j, + refcount =3D=3D 1 ? + l2_entry | QCOW_OFLAG_COPIED : + l2_entry & ~QCOW_OFLAG_COPIED); l2_dirty++; } } diff --git a/block/qcow2.h b/block/qcow2.h index a488d761ff..0b68c55c01 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -485,6 +485,18 @@ typedef enum QCow2MetadataOverlap { =20 #define INV_OFFSET (-1ULL) =20 +static inline uint64_t get_l2_entry(BDRVQcow2State *s, uint64_t *l2_slice, + int idx) +{ + return be64_to_cpu(l2_slice[idx]); +} + +static inline void set_l2_entry(BDRVQcow2State *s, uint64_t *l2_slice, + int idx, uint64_t entry) +{ + l2_slice[idx] =3D cpu_to_be64(entry); +} + static inline bool has_data_file(BlockDriverState *bs) { BDRVQcow2State *s =3D bs->opaque; --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153441; cv=none; d=zoho.com; s=zohoarc; b=RXWbT/Q2IcZAv/5MY2DUIBZ0frZbw9UrSq5MUZOg1HrblQ6ph/jAKiieOQSrwDDvphvnT/1B0PXOmcdTbwFC4JttKjeoBMruJ4XugZvYa39NSMYKzbdK8LDWCaGzs6GU93zTjTgFF5NQcQ0GjnWa1IBVSL2Iby0U5/On7g/TwQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153441; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HiUDYygHbreOJ4VpTqnZuGeG1uwk96nU2SwXCxyXjEw=; b=D/Q6AIxM2+YxVCRCRAsyhv+OuAMKR0+KQf8SkYPyO6GI4nduTwzmEVhH0zBpWjyuo4EK5aYwnRvm/63cZtg/ho7h+kUEveAL4/KgQoEIAwoYALrEYoRDD4b0mKsMnYyrKPafghbM0wf4PrRmODoEiH4inLXaBS3Lqp4LAXyxxFY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571153441705128.60304014552628; Tue, 15 Oct 2019 08:30:41 -0700 (PDT) Received: from localhost ([::1]:48750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOmV-0000dN-NS for importer@patchew.org; Tue, 15 Oct 2019 11:30:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48147) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOgz-0002lP-Q7 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOgw-0003gR-WB for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:57 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47110) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOgw-0003ZK-55; Tue, 15 Oct 2019 11:24:54 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003aS-0M; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-00061D-LK; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=HiUDYygHbreOJ4VpTqnZuGeG1uwk96nU2SwXCxyXjEw=; b=GM8lRN7GlBcjwR0bAORQ/FSQrrl06UyeaGjA8qRVVXkZHf8LWYYhnj9g4Vsfvs9tdUF1kQ509zhmB75Yl8kNR3NAUsmLt0TqvJM85n4NBWAOJXUFUev3bmsRlPcgJ5mNrcn8C2SS3a2wXZmmHqpHj1jWyVelSVLp3kGNc4eCx+yXPdHpqdUP24M7nZBdll+xxAWDF8IBvS5Td98apySozRlTCI7iTmTUgq9mQ2Tghb2biEkx7ULNxQCfLlIvyXD5Q9XPbnmiGD+tE2MPnQAV8gBl+2eDUMto9NPnpIM3ZPicCLmGaQBYqKh/r6mjiCxXM7/OMBjlpOHaZbhjCbtRDg==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 05/23] qcow2: Document the Extended L2 Entries feature Date: Tue, 15 Oct 2019 18:23:16 +0300 Message-Id: <819a808e5a238208d3d86a5bd1ac20e99cde9e20.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" Subcluster allocation in qcow2 is implemented by extending the existing L2 table entries and adding additional information to indicate the allocation status of each subcluster. This patch documents the changes to the qcow2 format and how they affect the calculation of the L2 cache size. Signed-off-by: Alberto Garcia --- docs/interop/qcow2.txt | 68 ++++++++++++++++++++++++++++++++++++++++-- docs/qcow2-cache.txt | 19 +++++++++++- 2 files changed, 83 insertions(+), 4 deletions(-) diff --git a/docs/interop/qcow2.txt b/docs/interop/qcow2.txt index af5711e533..d34261f955 100644 --- a/docs/interop/qcow2.txt +++ b/docs/interop/qcow2.txt @@ -39,6 +39,9 @@ The first cluster of a qcow2 image contains the file head= er: as the maximum cluster size and won't be able to open = images with larger cluster sizes. =20 + Note: if the image has Extended L2 Entries then cluste= r_bits + must be at least 14 (i.e. 16384 byte clusters). + 24 - 31: size Virtual disk size in bytes. =20 @@ -109,7 +112,12 @@ in the description of a field. An External Data File Name header extensio= n may be present if this bit is set. =20 - Bits 3-63: Reserved (set to 0) + Bit 3: Extended L2 Entries. If this bit is set t= hen + L2 table entries use an extended format th= at + allows subcluster-based allocation. See the + Extended L2 Entries section for more detai= ls. + + Bits 4-63: Reserved (set to 0) =20 80 - 87: compatible_features Bitmask of compatible features. An implementation can @@ -437,7 +445,7 @@ cannot be relaxed without an incompatible layout change= ). Given an offset into the virtual disk, the offset into the image file can = be obtained as follows: =20 - l2_entries =3D (cluster_size / sizeof(uint64_t)) + l2_entries =3D (cluster_size / sizeof(uint64_t)) [*] =20 l2_index =3D (offset / cluster_size) % l2_entries l1_index =3D (offset / cluster_size) / l2_entries @@ -447,6 +455,8 @@ obtained as follows: =20 return cluster_offset + (offset % cluster_size) =20 + [*] this changes if Extended L2 Entries are enabled, see next section + L1 table entry: =20 Bit 0 - 8: Reserved (set to 0) @@ -487,7 +497,8 @@ Standard Cluster Descriptor: nor is data read from the backing file if the cluster = is unallocated. =20 - With version 2, this is always 0. + With version 2 or with extended L2 entries (see the ne= xt + section), this is always 0. =20 1 - 8: Reserved (set to 0) =20 @@ -524,6 +535,57 @@ file (except if bit 0 in the Standard Cluster Descript= or is set). If there is no backing file or the backing file is smaller than the image, they shall = read zeros for all parts that are not covered by the backing file. =20 +=3D=3D Extended L2 Entries =3D=3D + +An image uses Extended L2 Entries if bit 3 is set on the incompatible_feat= ures +field of the header. + +In these images standard data clusters are divided into 32 subclusters of = the +same size. They are contiguous and start from the beginning of the cluster. +Subclusters can be allocated independently and the L2 entry contains infor= mation +indicating the status of each one of them. Compressed data clusters don't = have +subclusters so they are treated like in images without this feature. + +The size of an extended L2 entry is 128 bits so the number of entries per = table +is calculated using this formula: + + l2_entries =3D (cluster_size / (2 * sizeof(uint64_t))) + +The first 64 bits have the same format as the standard L2 table entry desc= ribed +in the previous section, with the exception of bit 0 of the standard clust= er +descriptor. + +The last 64 bits contain a subcluster allocation bitmap with this format: + +Subcluster Allocation Bitmap (for standard clusters): + + Bit 0 - 31: Allocation status (one bit per subcluster) + + 1: the subcluster is allocated. In this case the + host cluster offset field must contain a valid + offset. + 0: the subcluster is not allocated. In this case + read requests shall go to the backing file or + return zeros if there is no backing file data. + + Bits are assigned starting from the most significant o= ne. + (i.e. bit x is used for subcluster 31 - x) + + 32 - 63 Subcluster reads as zeros (one bit per subcluster) + + 1: the subcluster reads as zeros. In this case the + allocation status bit must be unset. The host + cluster offset field may or may not be set. + 0: no effect. + + Bits are assigned starting from the most significant o= ne. + (i.e. bit x is used for subcluster 63 - x) + +Subcluster Allocation Bitmap (for compressed clusters): + + Bit 0 - 63: Reserved (set to 0) + Compressed clusters don't have subclusters, + so this field is not used. =20 =3D=3D Snapshots =3D=3D =20 diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt index d57f409861..04eb4ce2f1 100644 --- a/docs/qcow2-cache.txt +++ b/docs/qcow2-cache.txt @@ -1,6 +1,6 @@ qcow2 L2/refcount cache configuration =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -Copyright (C) 2015, 2018 Igalia, S.L. +Copyright (C) 2015, 2018-2019 Igalia, S.L. Author: Alberto Garcia =20 This work is licensed under the terms of the GNU GPL, version 2 or @@ -222,3 +222,20 @@ support this functionality, and is 0 (disabled) on oth= er platforms. This functionality currently relies on the MADV_DONTNEED argument for madvise() to actually free the memory. This is a Linux-specific feature, so cache-clean-interval is not supported on other systems. + + +Extended L2 Entries +------------------- +All numbers shown in this document are valid for qcow2 images with normal +64-bit L2 entries. + +Images with extended L2 entries need twice as much L2 metadata, so the L2 +cache size must be twice as large for the same disk space. + + disk_size =3D l2_cache_size * cluster_size / 16 + +i.e. + + l2_cache_size =3D disk_size * 16 / cluster_size + +Refcount blocks are not affected by this. --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153440; cv=none; d=zoho.com; s=zohoarc; b=KrNH1R6P2w5500M4BSlO/R9o6a77kgs2NfXrLHnsyeArvFbZ/Nogw/A3Qvl1MFHO0XEatDiZWiKlSlhCpS7miVgAwoJDDqm5pce8t5KaSht2KcpBbl5GskuaQS7CY8ks0511PSs1kyPy+xL8UlNPSTpSUBoK9Ikh8fm9SoZxXVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153440; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qmKlb9gHAF5qikvg/hwissybNRQvWCJ71g22MpPxHjc=; b=UAglsHOmQl3DNjcpDZpKE8JiKJ663t2LzMM40EZISBJliO1RJCOCZeDVkLMtHra5QhnTvyoyeUlYPfZ04xoUInC+iA1qbQJEgNBmNSNrl2oKRFcGMyBacBgR+uss+qrTknNMw+saWDWxOHqZxG8VR1Vuud6q+PGaGf7yvIaU4cg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571153440729348.99535559053425; Tue, 15 Oct 2019 08:30:40 -0700 (PDT) Received: from localhost ([::1]:48744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOmU-0000Yc-PR for importer@patchew.org; Tue, 15 Oct 2019 11:30:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48080) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOgy-0002kt-6t for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOgw-0003g3-Vd for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:55 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47111) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOgw-0003ZJ-4z; Tue, 15 Oct 2019 11:24:54 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003aT-0P; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-00061H-MH; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=qmKlb9gHAF5qikvg/hwissybNRQvWCJ71g22MpPxHjc=; b=NmCcZq0crz+5FjZf34+YAiQRwllhnm/Fs+JDtxiYL2iP8X/Igcw3/Y5kOLJr0PCvAphezFbuke2WkGRSE+qVB038T90IxgJ65fTzmEAfqo1wp3HlYJnzGTOdLU1Aog1kMv/pz8PTIZ6xUUKNeLDfUhJP/7YDwckHRQ3CTC+FgTsph/Evl+gUx4KHIa6Tre7n1jF1J1LPL4l8b9crb91RBNhXzcLQuSbXlKm30gTgbciR2zoJ26d5Dej5K96MKvXjgJ97r0cM6nvGmv5Pwa8Uz9bQ+v8hHIkFsXMrnnh/ZAxU88EEYaz1rQoOr0Eo2OLXI2pn4CEsM1NY/2abeq+XQA==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 06/23] qcow2: Add dummy has_subclusters() function Date: Tue, 15 Oct 2019 18:23:17 +0300 Message-Id: <8acb804dd496964d07460f59ef39bdc63156c809.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" This function will be used by the qcow2 code to check if an image has subclusters or not. At the moment this simply returns false. Once all patches needed for subcluster support are ready then QEMU will be able to create and read images with subclusters and this function will return the actual value. Signed-off-by: Alberto Garcia --- block/qcow2.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/qcow2.h b/block/qcow2.h index 0b68c55c01..6d6fc57f41 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -485,6 +485,12 @@ typedef enum QCow2MetadataOverlap { =20 #define INV_OFFSET (-1ULL) =20 +static inline bool has_subclusters(BDRVQcow2State *s) +{ + /* FIXME: Return false until this feature is complete */ + return false; +} + static inline uint64_t get_l2_entry(BDRVQcow2State *s, uint64_t *l2_slice, int idx) { --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571154070; cv=none; d=zoho.com; s=zohoarc; b=IKWlmfKIl3nGg9roVn+YQCa7xmbT6e6KknNFAxJzp13NT9bHB3T9B1HtGU5Nu/zOTjGOYR1TuURWYFn9FaVedh/r6QmBjXUTS4akJFMjBbujGzUrzBHliKAFsHeGC3UtaPEHiL32Q+zFdVSE10IR5v9QeLY15T6w2iSL+hTx2yU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571154070; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1UUCR8PSkwTlRN0aVmtsJXO2y0bDQeQnKmM1wEB3Tf4=; b=gZCz8BPDISPFntBMmS2DRO/P5pbnZyyQqAz9oJsaUTaktYZJCnEbb6oqL7rPFag5tstDym7ttlPIrYEdtKEj4FPS6UIAn2215ZgPRd5mAHlSfJDj+ktZM4fmJ+hSfMMlHdLxWaGrM7eBgTlCZK1FipLUXWZFX2ZXrWHJbKt5h5I= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571154070917329.4570706058862; Tue, 15 Oct 2019 08:41:10 -0700 (PDT) Received: from localhost ([::1]:48982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOwf-0005IL-9g for importer@patchew.org; Tue, 15 Oct 2019 11:41:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48495) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOhL-0003M0-Dq for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOhK-0003rz-2Q for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:19 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOhJ-0003cP-GB; Tue, 15 Oct 2019 11:25:17 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003aU-33; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-00061J-NF; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=1UUCR8PSkwTlRN0aVmtsJXO2y0bDQeQnKmM1wEB3Tf4=; b=SH2tQ03tYiI4tvMPeMFTOebZrpMznuEZNqBRkgzZuu9GoZJTuHA63+dholqPOiWJJJG8iS7nvVu9lPhLt9l2WH5aBnCiVff/yPGnXEV76tD1vH0f70KFPnvb+PYfdpWizFZLK07GY9N72yJUsSZtD0QjDVMzs0ny+UjgJ7ZLQmbzk4VkTNEnfscW2Jwvqe4v6KIbb+cO32IsWpNSNWn1BchD4gWaXuVgu7fxzR8IxK8nA7U0OcuWr0ZHphAV9Cnm6HwW7Wr06mT1ceHeuEgdCxqTSHpfSM34INsTBJVWKFXpqkVs/IrG2swGh5LY2wW4jyP3VvjrZFUnLDfEZlVpGw==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 07/23] qcow2: Add subcluster-related fields to BDRVQcow2State Date: Tue, 15 Oct 2019 18:23:18 +0300 Message-Id: <3adac2cac3deb983375cb3a2b611bd438041712d.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" This patch adds the following new fields to BDRVQcow2State: - subclusters_per_cluster: Number of subclusters in a cluster - subcluster_size: The size of each subcluster, in bytes - subcluster_bits: No. of bits so 1 << subcluster_bits =3D subcluster_size Images without subclusters are treated as if they had exactly one, with subcluster_size =3D cluster_size. Signed-off-by: Alberto Garcia --- block/qcow2.c | 5 +++++ block/qcow2.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 4d16393e61..be9854c5ea 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1341,6 +1341,11 @@ static int coroutine_fn qcow2_do_open(BlockDriverSta= te *bs, QDict *options, } } =20 + s->subclusters_per_cluster =3D + has_subclusters(s) ? QCOW_MAX_SUBCLUSTERS_PER_CLUSTER : 1; + s->subcluster_size =3D s->cluster_size / s->subclusters_per_cluster; + s->subcluster_bits =3D ctz32(s->subcluster_size); + /* Check support for various header values */ if (header.refcount_order > 6) { error_setg(errp, "Reference count entry width too large; may not " diff --git a/block/qcow2.h b/block/qcow2.h index 6d6fc57f41..e6486a2cf8 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -72,6 +72,8 @@ /* The cluster reads as all zeros */ #define QCOW_OFLAG_ZERO (1ULL << 0) =20 +#define QCOW_MAX_SUBCLUSTERS_PER_CLUSTER 32 + #define MIN_CLUSTER_BITS 9 #define MAX_CLUSTER_BITS 21 =20 @@ -274,6 +276,9 @@ typedef struct BDRVQcow2State { int cluster_bits; int cluster_size; int l2_slice_size; + int subcluster_bits; + int subcluster_size; + int subclusters_per_cluster; int l2_bits; int l2_size; int l1_size; --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153910; cv=none; d=zoho.com; s=zohoarc; b=ixkDdg+hZxfcytUdSNyVu5igMFUnGwCJtJYn1Ajr7eN/QV9krDGn2poqZpOcdftAIhsYuea20C5DSghCDFLx8HJrU+nWsw0NKQ2loQ8dVmSvA72z9Ad9Gwt837fOOnQINRdh0zpmOAHaMBToMFie9tbtI/BoM9Hsp7I4UKiVQlc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153910; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=E3ZU1iFbE5HW1AIiBPqXlRoGatUOAMOrN4ipcn9TfgY=; b=DMoqciHZBFPzpGsG5MDNIKWVJrscG3Hk4SrmKZvkKJvdU7UUYeG1zByC0THZO/Fe8oSbBDXBJvgYvDuzXlfrY+zOAj/rbXSDWkjcWcFN1vNNMUBB/XJuxPl1MzZ2JI2bkURLpRP4gYeRBRnV8V7QvxAcobzzNywvWS2kLeOu0qs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157115391035618.4993788999833; Tue, 15 Oct 2019 08:38:30 -0700 (PDT) Received: from localhost ([::1]:48930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOu4-0001FA-Uu for importer@patchew.org; Tue, 15 Oct 2019 11:38:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48397) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOhI-0003H3-Q3 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOhH-0003qQ-Pd for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:16 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47106) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOhH-0003ZG-Gr; Tue, 15 Oct 2019 11:25:15 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003aV-1i; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-00061M-Oa; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=E3ZU1iFbE5HW1AIiBPqXlRoGatUOAMOrN4ipcn9TfgY=; b=ZdDtiuxMd1JdhWPQgT5IRKEtIITUgFIqBm/PRsGyhIq3YWq17SGQj4Ekbz48btSzglFr8EOHSr0Hpqhh6Bd64oM4cg4u755wt5dNOOeAK145uHBqJOTENLZwi8zZNKv2jpYmeVVej+oTqHfFRjvNooa41zwhpxuUmx+NNgJS5E9kyVcya97gK1na5dn305TWe5kUW4+6L2LaG5zaUrzTmbXB0LBYE1qm+xvmKJIuGOvYY3CTeAhxwbKI6xdsI+eDZBmXaUKIvaAIKTOvgTFKegKXZPt7er3djQAPg+r43uIYL5zK4hqE1TOOoBmLYOBVzhEQETiddY7NuXNm5OOGiw==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 08/23] qcow2: Add offset_to_sc_index() Date: Tue, 15 Oct 2019 18:23:19 +0300 Message-Id: <9fce39a724a96ddd217ef2bed26eb9c4a6ef30df.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" For a given offset, return the subcluster number within its cluster (i.e. with 32 subclusters per cluster it returns a number between 0 and 31). Signed-off-by: Alberto Garcia --- block/qcow2.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/qcow2.h b/block/qcow2.h index e6486a2cf8..c450267c88 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -556,6 +556,11 @@ static inline int offset_to_l2_slice_index(BDRVQcow2St= ate *s, int64_t offset) return (offset >> s->cluster_bits) & (s->l2_slice_size - 1); } =20 +static inline int offset_to_sc_index(BDRVQcow2State *s, int64_t offset) +{ + return (offset >> s->subcluster_bits) & (s->subclusters_per_cluster - = 1); +} + static inline int64_t qcow2_vm_state_offset(BDRVQcow2State *s) { return (int64_t)s->l1_vm_state_index << (s->cluster_bits + s->l2_bits); --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153447; cv=none; d=zoho.com; s=zohoarc; b=mapvEOQ2/7IkR+PMqnUY0BY2OhPcDzbMIFl7vZYZNzmKtJhrheTo2pbZIXn+BIXhDhKyHJ2VijMbldl4ciB+L3rYLD9B8u8I3MlhMebYy2CU74Z95FMSD3+/5iMKXaQAzNbM8WEU3Xew4NMnbKQ3zYHs528HEO1PowN2I1m1li4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153447; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MCh4cj/PDH0sL50R3ezSp3eAK5YCZ3thZ6xakPajqio=; b=fg+W8BOH8+0M8hiGbZ0LyuFF400ahODnS8zhw2fZ9u6J8EwciLxAKmBOMz+sycbZmD/VnQkzjp+lFoo3jAYU+NQTB86LRQFzMLvfjyzsaRKeaT/i0knsbzSgvABMsgi46AxIAQIBOOFuvqGNjKS2bMctM/6mFO5WK4DqK7OAHu4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571153447630299.2303123602352; Tue, 15 Oct 2019 08:30:47 -0700 (PDT) Received: from localhost ([::1]:48748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOmc-0000dF-3i for importer@patchew.org; Tue, 15 Oct 2019 11:30:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48099) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOgy-0002kw-NC for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOgw-0003fy-Uj for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:56 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47089) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOgw-0003Z5-59; Tue, 15 Oct 2019 11:24:54 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003aW-2I; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-00061P-Pc; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=MCh4cj/PDH0sL50R3ezSp3eAK5YCZ3thZ6xakPajqio=; b=XfYB02dUM15GeDzbwjiKQytQFwTS6hkL4C8AZfvlMoLAtKHHc+vxiVbINhnLfsZNCPawDo4KLtV87pRq9TvuTM+9odAiGVUhVb+VjdLuzK30z8k2/CuICUJuRfT7jbiNza4EVb4obADB7qkNyj5j1CXcqCvSCBbD3WICdJWazctnNhKpVqiW5KB6zcjAxx6DOCTKQtVUvdOMRHz/XCG6i0JvJopolKzF1aGCRAQnFJgb7Y7DqB53vIK5MCaQ94jUAzK2amaMOO3aBWH+DS6bpOSooy0cRdMkhbFkhuMui8/7vWiEcpzmn/Rmcj7KG5mEyQ7L96GUWKeHjw5B9B2jCA==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 09/23] qcow2: Add l2_entry_size() Date: Tue, 15 Oct 2019 18:23:20 +0300 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" qcow2 images with subclusters have 128-bit L2 entries. The first 64 bits contain the same information as traditional images and the last 64 bits form a bitmap with the status of each individual subcluster. Because of that we cannot assume that L2 entries are sizeof(uint64_t) anymore. This function returns the proper value for the image. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 12 ++++++------ block/qcow2-refcount.c | 14 ++++++++------ block/qcow2.c | 6 +++--- block/qcow2.h | 5 +++++ 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index b2045d51bf..67f90e415d 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -209,7 +209,7 @@ static int l2_load(BlockDriverState *bs, uint64_t offse= t, uint64_t l2_offset, uint64_t **l2_slice) { BDRVQcow2State *s =3D bs->opaque; - int start_of_slice =3D sizeof(uint64_t) * + int start_of_slice =3D l2_entry_size(s) * (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 + start_of_sli= ce, @@ -277,7 +277,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_ind= ex) =20 /* allocate a new l2 entry */ =20 - l2_offset =3D qcow2_alloc_clusters(bs, s->l2_size * sizeof(uint64_t)); + l2_offset =3D qcow2_alloc_clusters(bs, s->l2_size * l2_entry_size(s)); if (l2_offset < 0) { ret =3D l2_offset; goto fail; @@ -301,7 +301,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_ind= ex) =20 /* allocate a new entry in the l2 cache */ =20 - slice_size2 =3D s->l2_slice_size * sizeof(uint64_t); + slice_size2 =3D s->l2_slice_size * l2_entry_size(s); n_slices =3D s->cluster_size / slice_size2; =20 trace_qcow2_l2_allocate_get_empty(bs, l1_index); @@ -365,7 +365,7 @@ fail: } s->l1_table[l1_index] =3D old_l2_offset; if (l2_offset > 0) { - qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t), + qcow2_free_clusters(bs, l2_offset, s->l2_size * l2_entry_size(s), QCOW2_DISCARD_ALWAYS); } return ret; @@ -708,7 +708,7 @@ static int get_cluster_table(BlockDriverState *bs, uint= 64_t offset, =20 /* Then decrease the refcount of the old table */ if (l2_offset) { - qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_= t), + qcow2_free_clusters(bs, l2_offset, s->l2_size * l2_entry_size(= s), QCOW2_DISCARD_OTHER); } =20 @@ -1880,7 +1880,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, int ret; int i, j; =20 - slice_size2 =3D s->l2_slice_size * sizeof(uint64_t); + slice_size2 =3D s->l2_slice_size * l2_entry_size(s); n_slices =3D s->cluster_size / slice_size2; =20 if (!is_active_l1) { diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 14f71df7da..a2c4d36378 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1253,7 +1253,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, 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); + slice_size2 =3D s->l2_slice_size * l2_entry_size(s); n_slices =3D s->cluster_size / slice_size2; =20 s->cache_discards =3D true; @@ -1604,7 +1604,7 @@ static int check_refcounts_l2(BlockDriverState *bs, B= drvCheckResult *res, int i, l2_size, nb_csectors, ret; =20 /* Read L2 table from disk */ - l2_size =3D s->l2_size * sizeof(uint64_t); + l2_size =3D s->l2_size * l2_entry_size(s); l2_table =3D g_malloc(l2_size); =20 ret =3D bdrv_pread(bs->file, l2_offset, l2_table, l2_size); @@ -1679,15 +1679,16 @@ static int check_refcounts_l2(BlockDriverState *bs,= BdrvCheckResult *res, fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", offset); if (fix & BDRV_FIX_ERRORS) { + int idx =3D i * (l2_entry_size(s) / sizeof(uint64_= t)); uint64_t l2e_offset =3D - l2_offset + (uint64_t)i * sizeof(uint64_t); + l2_offset + (uint64_t)i * l2_entry_size(s); int ign =3D active ? QCOW2_OL_ACTIVE_L2 : QCOW2_OL_INACTIVE_L2; =20 l2_entry =3D QCOW_OFLAG_ZERO; set_l2_entry(s, l2_table, i, l2_entry); ret =3D qcow2_pre_write_overlap_check(bs, ign, - l2e_offset, sizeof(uint64_t), false); + l2e_offset, l2_entry_size(s), false); if (ret < 0) { fprintf(stderr, "ERROR: Overlap check failed\n= "); res->check_errors++; @@ -1697,7 +1698,8 @@ static int check_refcounts_l2(BlockDriverState *bs, B= drvCheckResult *res, } =20 ret =3D bdrv_pwrite_sync(bs->file, l2e_offset, - &l2_table[i], sizeof(uint64= _t)); + &l2_table[idx], + l2_entry_size(s)); if (ret < 0) { fprintf(stderr, "ERROR: Failed to overwrite L2= " "table entry: %s\n", strerror(-ret)); @@ -1904,7 +1906,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, } =20 ret =3D bdrv_pread(bs->file, l2_offset, l2_table, - s->l2_size * sizeof(uint64_t)); + s->l2_size * l2_entry_size(s)); if (ret < 0) { fprintf(stderr, "ERROR: Could not read L2 table: %s\n", strerror(-ret)); diff --git a/block/qcow2.c b/block/qcow2.c index be9854c5ea..131711d6fa 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -831,7 +831,7 @@ static void read_cache_sizes(BlockDriverState *bs, Qemu= Opts *opts, uint64_t max_l2_entries =3D DIV_ROUND_UP(virtual_disk_size, s->cluster= _size); /* An L2 table is always one cluster in size so the max cache size * should be a multiple of the cluster size. */ - uint64_t max_l2_cache =3D ROUND_UP(max_l2_entries * sizeof(uint64_t), + uint64_t max_l2_cache =3D ROUND_UP(max_l2_entries * l2_entry_size(s), s->cluster_size); =20 combined_cache_size_set =3D qemu_opt_get(opts, QCOW2_OPT_CACHE_SIZE); @@ -992,7 +992,7 @@ static int qcow2_update_options_prepare(BlockDriverStat= e *bs, } } =20 - r->l2_slice_size =3D l2_cache_entry_size / sizeof(uint64_t); + r->l2_slice_size =3D l2_cache_entry_size / l2_entry_size(s); 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, @@ -1386,7 +1386,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, bs->encrypted =3D true; } =20 - s->l2_bits =3D s->cluster_bits - 3; /* L2 is always one cluster */ + s->l2_bits =3D s->cluster_bits - ctz32(l2_entry_size(s)); s->l2_size =3D 1 << s->l2_bits; /* 2^(s->refcount_order - 3) is the refcount width in bytes */ s->refcount_block_bits =3D s->cluster_bits - (s->refcount_order - 3); diff --git a/block/qcow2.h b/block/qcow2.h index c450267c88..9a7648af47 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -496,6 +496,11 @@ static inline bool has_subclusters(BDRVQcow2State *s) return false; } =20 +static inline size_t l2_entry_size(BDRVQcow2State *s) +{ + return has_subclusters(s) ? sizeof(uint64_t) * 2 : sizeof(uint64_t); +} + static inline uint64_t get_l2_entry(BDRVQcow2State *s, uint64_t *l2_slice, int idx) { --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153225; cv=none; d=zoho.com; s=zohoarc; b=KtaFiPYz53Fg2NV75MWgPo6TL1dsm9rZr8flpL4QNpvQDjLsUqODNsyaPCutAGMdqHH/PEAkpbjzLNCDaOynyCDcn270B+hWpM7zlQSgPig+TG8XllvdX3+mtWTWKPyDjfD7SnpojOpgqA9H2iJUzocJjSp/qbMtHjjGSReY+Zg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153225; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZuMPHi1KYaqkC4W5yuor+8zm/GN+VGAvoGOgcDmCAz8=; b=f/6n4zsP5i5YFC9AZEUKVG7vZi4ga5Gw+d3I3SAc+mtKsgTmhSIMH6v4iicn1QjoEsqvVS03pcZCQx0ZcsV4kNnqOnDoeNbnkku/mg5LPTE1aitGLtZ5LnDHjhv6QBQlo2t0Xj/z1X2zFormpfx5n5hvOfY8Bte/yn+qTOBkgmU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571153225229255.43067454987477; Tue, 15 Oct 2019 08:27:05 -0700 (PDT) Received: from localhost ([::1]:48696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOiu-0005BZ-JS for importer@patchew.org; Tue, 15 Oct 2019 11:26:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48079) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOgy-0002ks-6k for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOgw-0003fi-Rm for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:55 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47098) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOgw-0003Z9-4w; Tue, 15 Oct 2019 11:24:54 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003aX-1v; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-00061R-Qa; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=ZuMPHi1KYaqkC4W5yuor+8zm/GN+VGAvoGOgcDmCAz8=; b=pQHnjDI/n7NKdIoYUz0wW2+4YcThL9XK4rM7jhBTegPKIGzTyT49B3DJVuPZEXSw8bLA3l72U3A5QjlxnR5eWShydQYD44M30t4q5KWHSoFN9S0HWiZEoiblHsPE5LGXVI5WpWI25k9+zpb3R73p7ZKRMSWHXDnvf/DBBCxRM0yUGL0enlWVQ0E0t00fgqw44iOyyTROJocDTgEC4NnxjZHAGho3PXPbm6NnUuX719cj7UoWG8NOHYXiUI66zNylkDnfeb61fBUuNsQX6tJOmmDUz61v61JV5Mfo7PUDUz9+Z4W1051uia/CO5iMxiIGKZ7BudJeVCRIEtEh6Im4ow==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 10/23] qcow2: Update get/set_l2_entry() and add get/set_l2_bitmap() Date: Tue, 15 Oct 2019 18:23:21 +0300 Message-Id: <6b1597b199313afeb001790d63ea12b48688154c.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" Extended L2 entries are 128-bit wide: 64 bits for the entry itself and 64 bits for the subcluster allocation bitmap. In order to support them correctly get/set_l2_entry() need to be updated so they take the entry width into account in order to calculate the correct offset. This patch also adds the get/set_l2_bitmap() functions that are used to access the bitmaps. For convenience, these functions are no-ops when used in traditional qcow2 images. Signed-off-by: Alberto Garcia --- block/qcow2.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/block/qcow2.h b/block/qcow2.h index 9a7648af47..d9fe883fe0 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -504,15 +504,37 @@ static inline size_t l2_entry_size(BDRVQcow2State *s) static inline uint64_t get_l2_entry(BDRVQcow2State *s, uint64_t *l2_slice, int idx) { + idx *=3D l2_entry_size(s) / sizeof(uint64_t); return be64_to_cpu(l2_slice[idx]); } =20 +static inline uint64_t get_l2_bitmap(BDRVQcow2State *s, uint64_t *l2_slice, + int idx) +{ + if (has_subclusters(s)) { + idx *=3D l2_entry_size(s) / sizeof(uint64_t); + return be64_to_cpu(l2_slice[idx + 1]); + } else { + return 0; + } +} + static inline void set_l2_entry(BDRVQcow2State *s, uint64_t *l2_slice, int idx, uint64_t entry) { + idx *=3D l2_entry_size(s) / sizeof(uint64_t); l2_slice[idx] =3D cpu_to_be64(entry); } =20 +static inline void set_l2_bitmap(BDRVQcow2State *s, uint64_t *l2_slice, + int idx, uint64_t bitmap) +{ + if (has_subclusters(s)) { + idx *=3D l2_entry_size(s) / sizeof(uint64_t); + l2_slice[idx + 1] =3D cpu_to_be64(bitmap); + } +} + static inline bool has_data_file(BlockDriverState *bs) { BDRVQcow2State *s =3D bs->opaque; --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153731; cv=none; d=zoho.com; s=zohoarc; b=kgcR6kcbuj70VYZOHie3HPdA1dkrF/QXzH3/PGiMkkQ2z/SX46ni0AHJLggowyviU7c3TvCVZPJnue8x75f6jt/aRqoh9/8xaIt+ng2mXdWm0D81vx/vNgH4YwG3dTTjYYSCFJMWFPvDKrjQL2xNkctaRzpfPpc/5Ha2DrT8mFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153731; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kALB3wZJBo7sh2ZPgeIIj7Aso3rnUuxVKnq2S4x/FbY=; b=nXpeyvWP6rrebtQVHCy6YXdfgLa+FoCI/1lez7xMxupuMTBgCNRpx4EJyku6oEXDQ4VUMhcz6z4WLIdYSORCYg+Co93a969QgzFW5f0nDMPk2A6GqB8mRpSY09XiXGu2KFVwdPg2FuK+FT0sN43SGV1UQE6YKyquN4WQbErOurM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571153731962520.3044515780811; Tue, 15 Oct 2019 08:35:31 -0700 (PDT) Received: from localhost ([::1]:48844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOrC-0005DU-Hp for importer@patchew.org; Tue, 15 Oct 2019 11:35:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48388) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOhI-0003G6-A8 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOhG-0003ps-PX for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:16 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47093) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOhG-0003Z4-Ga; Tue, 15 Oct 2019 11:25:14 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003aY-0j; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-00061V-Re; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=kALB3wZJBo7sh2ZPgeIIj7Aso3rnUuxVKnq2S4x/FbY=; b=lRc97TzctbWpFuLiImYu7mZ4x4Mn9Hl8SZGtrkaHvKGPiWxdw629mHKGFKsCmuBBqkRJCR9wCQbz7q+oQ6YkE7INxLo3lFKIgJK3nRAFbptehdTQIMPM6ZzmONeg4h+dbe9dPKDG9brBHj4Pvqpvc/+w0J4/nPAEG+NqlzTBI3XLYv0+EyOJKVmj9IhWOF1+hZBpr5mJo0IoLx2Ev00GyKEpYJbbRPkBo2WrTbjK3k5D0OnPuWFtQ1756kyyzfGKe4BafBg7EigvxF7NmKu5qpg75/g+YQ3HBNBypPuS/dGAMpkRPtbfKPs7WqTOx8ELUDxIUOnV9VlyEwWsquNg4A==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 11/23] qcow2: Add qcow2_get_subcluster_type() Date: Tue, 15 Oct 2019 18:23:22 +0300 Message-Id: <574a36d3e22089745ea3d05503163ab5c93addf0.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" This function returns the type of an individual subcluster. If an image does not have subclusters then this returns the exact same value as qcow2_get_cluster_type(). The information in standard and extended L2 entries is encoded in a slightly different way, but all existing QCow2ClusterType values are also valid for subclusters and have the same meanings (although they typically only apply to the requested subcluster). There are two important exceptions to this: a) QCOW2_CLUSTER_COMPRESSED means that the whole cluster is compressed. We do not support compression at the subcluster level. b) QCOW2_CLUSTER_UNALLOCATED means that the cluster is unallocated, that is, the offset field of the L2 entry does not point to a host cluster. All subclusters are obviously unallocated too but any of them could be of type QCOW2_CLUSTER_ZERO_PLAIN. In addition to that, extended L2 entries allow one new scenario where the cluster is normally allocated but an individual subcluster is not. This is very different from (b) and because of that this patch adds a new value called QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER. As a last thing, this patch adds QCOW2_CLUSTER_INVALID to detect the cases where an L2 entry has a value that violates the spec. The caller is responsible for handling these situations. To prevent compatibility problems with images that have invalid values but are currently being read by QEMU without causing side effects, QCOW2_CLUSTER_INVALID is only returned for images with extended L2 entries. Signed-off-by: Alberto Garcia --- block/qcow2.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/block/qcow2.h b/block/qcow2.h index d9fe883fe0..60e4bf963e 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -74,6 +74,15 @@ =20 #define QCOW_MAX_SUBCLUSTERS_PER_CLUSTER 32 =20 +/* The subcluster X [0..31] reads as zeroes */ +#define QCOW_OFLAG_SUB_ZERO(X) ((1ULL << 63) >> (X)) +/* The subcluster X [0..31] is allocated */ +#define QCOW_OFLAG_SUB_ALLOC(X) ((1ULL << 31) >> (X)) +/* L2 entry bitmap with all "read as zeroes" bits set */ +#define QCOW_L2_BITMAP_ALL_ZEROES 0xFFFFFFFF00000000ULL +/* L2 entry bitmap with all allocation bits set */ +#define QCOW_L2_BITMAP_ALL_ALLOC 0x00000000FFFFFFFFULL + #define MIN_CLUSTER_BITS 9 #define MAX_CLUSTER_BITS 21 =20 @@ -435,10 +444,12 @@ typedef struct QCowL2Meta =20 typedef enum QCow2ClusterType { QCOW2_CLUSTER_UNALLOCATED, + QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER, QCOW2_CLUSTER_ZERO_PLAIN, QCOW2_CLUSTER_ZERO_ALLOC, QCOW2_CLUSTER_NORMAL, QCOW2_CLUSTER_COMPRESSED, + QCOW2_CLUSTER_INVALID, } QCow2ClusterType; =20 typedef enum QCow2MetadataOverlap { @@ -618,6 +629,57 @@ static inline QCow2ClusterType qcow2_get_cluster_type(= BlockDriverState *bs, } } =20 +/* In an image without subsclusters this returns the same value as + * qcow2_get_cluster_type() */ +static inline int qcow2_get_subcluster_type(BlockDriverState *bs, + uint64_t l2_entry, + uint64_t l2_bitmap, + unsigned sc_index) +{ + BDRVQcow2State *s =3D bs->opaque; + QCow2ClusterType type =3D qcow2_get_cluster_type(bs, l2_entry); + assert(sc_index < s->subclusters_per_cluster); + + if (has_subclusters(s)) { + bool sc_zero =3D l2_bitmap & QCOW_OFLAG_SUB_ZERO(sc_index); + bool sc_alloc =3D l2_bitmap & QCOW_OFLAG_SUB_ALLOC(sc_index); + switch (type) { + case QCOW2_CLUSTER_COMPRESSED: + if (l2_bitmap !=3D 0) { + return QCOW2_CLUSTER_INVALID; + } + break; + case QCOW2_CLUSTER_ZERO_PLAIN: + case QCOW2_CLUSTER_ZERO_ALLOC: + return QCOW2_CLUSTER_INVALID; + case QCOW2_CLUSTER_NORMAL: + if (!sc_zero && !sc_alloc) { + return QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER; + } else if (!sc_zero && sc_alloc) { + return QCOW2_CLUSTER_NORMAL; + } else if (sc_zero && !sc_alloc) { + return QCOW2_CLUSTER_ZERO_ALLOC; + } else { /* sc_zero && sc_alloc */ + return QCOW2_CLUSTER_INVALID; + } + case QCOW2_CLUSTER_UNALLOCATED: + if (!sc_zero && !sc_alloc) { + return QCOW2_CLUSTER_UNALLOCATED; + } else if (!sc_zero && sc_alloc) { + return QCOW2_CLUSTER_INVALID; + } else if (sc_zero && !sc_alloc) { + return QCOW2_CLUSTER_ZERO_PLAIN; + } else { /* sc_zero && sc_alloc */ + return QCOW2_CLUSTER_INVALID; + } + default: + g_assert_not_reached(); + } + } + + return type; +} + /* Check whether refcounts are eager or lazy */ static inline bool qcow2_need_accurate_refcounts(BDRVQcow2State *s) { --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153221; cv=none; d=zoho.com; s=zohoarc; b=JVNI7DtrDr/LxHNEWLV3dWzRP/THW78Mo1K4vgg4WKubMygQ1DERFx8TfNezNEYEOSIjg01khlHDZwEPR9ghktO0kDtlSaJwcFpqIrHSF/be5hN5cFM72ePsguQdX6sy8FPaDKbBOf1GCmX901CLAnPElbpY9u7+Z/LGeP3390M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153221; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a2mTbc627t9UKAi10n490pisgpIRFjrG/m1w0Nm1L2I=; b=XIFdipnTsdF+C+D17Z3cUL8Yg6oaa6vVhd85UeF3Q0JWNFMDxhTY9k+/KxL4ikTFPcQGr4zWo5GkwRW9M3BehBtvZHya/Fx1gIZ0a7ofwRMcMICfHTN/6dYYGn4KW4SwEz4MndjKg29l92SZo/rs+Mz+BfYVLkXTi+kulxDRCcM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157115322061460.66906158461336; Tue, 15 Oct 2019 08:27:00 -0700 (PDT) Received: from localhost ([::1]:48704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOix-0005Em-5p for importer@patchew.org; Tue, 15 Oct 2019 11:26:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48078) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOgy-0002kr-6c for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOgw-0003fg-RR for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:55 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47097) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOgw-0003Z6-5D; Tue, 15 Oct 2019 11:24:54 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003aZ-2Q; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-00061X-Sl; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=a2mTbc627t9UKAi10n490pisgpIRFjrG/m1w0Nm1L2I=; b=MfEfjXlk7SUEXfgQX2te6J+ZkpdLniViBoDUFRzqQonB0r8i4ukvk/n6M6pkp/yKdtHS5oahVcLwRZRHAH1vGVDDuxlyaJdAxthVrfLOJD3sGrvtJjTy4V1f1zGFMnNZtGjTP22kknFHx9SB3mYQiCtgiEf13oi4qUtWjb9K5tyfPHBr30NryQzeBh2Zhu3hNT4yBSDCulSQ7onEB0oE9V+q1PyYFrH6YSZxMU25Mq30ap6l5HUz3lpsLfpDA6UDlPJ3RoRYyM4Q5kJc4HCtvle/mQNEGOYD3HBNpjrpmORfqtGuOG/EgM6hWn2VS+vkPOVW+jrM6ShMhIhS0wNPkg==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 12/23] qcow2: Handle QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER Date: Tue, 15 Oct 2019 18:23:23 +0300 Message-Id: <29a81b7a903d90e3a2f1a2758514fa7b2723fcf2.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" In the previous patch we added a new QCow2ClusterType named QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER. There is a couple of places where this new value needs to be handled, and that is what this patch does. Signed-off-by: Alberto Garcia --- block/qcow2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 131711d6fa..c222cd261d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1922,8 +1922,8 @@ static int coroutine_fn qcow2_co_block_status(BlockDr= iverState *bs, =20 *pnum =3D bytes; =20 - if ((ret =3D=3D QCOW2_CLUSTER_NORMAL || ret =3D=3D QCOW2_CLUSTER_ZERO_= ALLOC) && - !s->crypto) { + if ((ret =3D=3D QCOW2_CLUSTER_NORMAL || ret =3D=3D QCOW2_CLUSTER_ZERO_= ALLOC || + ret =3D=3D QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER) && !s->crypto) { index_in_cluster =3D offset & (s->cluster_size - 1); *map =3D cluster_offset | index_in_cluster; *file =3D s->data_file->bs; @@ -1931,7 +1931,8 @@ static int coroutine_fn qcow2_co_block_status(BlockDr= iverState *bs, } if (ret =3D=3D QCOW2_CLUSTER_ZERO_PLAIN || ret =3D=3D QCOW2_CLUSTER_ZE= RO_ALLOC) { status |=3D BDRV_BLOCK_ZERO; - } else if (ret !=3D QCOW2_CLUSTER_UNALLOCATED) { + } else if (ret !=3D QCOW2_CLUSTER_UNALLOCATED && + ret !=3D QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER) { status |=3D BDRV_BLOCK_DATA; } if (s->metadata_preallocation && (status & BDRV_BLOCK_DATA) && @@ -2009,6 +2010,7 @@ static coroutine_fn int qcow2_co_preadv_part(BlockDri= verState *bs, =20 switch (ret) { case QCOW2_CLUSTER_UNALLOCATED: + case QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER: =20 if (bs->backing) { BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); @@ -3542,6 +3544,7 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockD= riverState *bs, nr =3D s->cluster_size; ret =3D qcow2_get_cluster_offset(bs, offset, &nr, &off); if (ret !=3D QCOW2_CLUSTER_UNALLOCATED && + ret !=3D QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER && ret !=3D QCOW2_CLUSTER_ZERO_PLAIN && ret !=3D QCOW2_CLUSTER_ZERO_ALLOC) { qemu_co_mutex_unlock(&s->lock); @@ -3612,6 +3615,7 @@ qcow2_co_copy_range_from(BlockDriverState *bs, =20 switch (ret) { case QCOW2_CLUSTER_UNALLOCATED: + case QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER: if (bs->backing && bs->backing->bs) { int64_t backing_length =3D bdrv_getlength(bs->backing->bs); if (src_offset >=3D backing_length) { --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571154520; cv=none; d=zoho.com; s=zohoarc; b=GQpZ7A2BZc1/bWKFcZMR1PXwAAPG/nRW7hDZflDPJUJ0dwl3BFW2oRgc51u9QCU0YW7hrEqBXZxAtvEdrDMHoW8Xafdic+16hDlpHMp8wWiSyzpLaNAauGaCvdTUm8PuM3ua0Ja7oN4yzQhUVD3SA745NHhr5FkaPl9ayJEXM64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571154520; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LyRBVk6DPKgZU3xdCKP6t9qXcnMtdtrOc91PUHA4dPc=; b=VhO+I9xnYwsIUcLv+y23NFKeJ9JWq575ejb8A7jIpm8PRxgyEw3gV1rt5kT5WaFy7AGVQC3afWKF+elFt9ppNwuKD1EZCdu4gu8uVmQfcIVujqHQeq6IDqPZqdnhk8b6nkR8fRloU6A+tT1P5O5nnXJ4d/tc2MC8Rl5V7VVptYY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571154520521304.8490355080585; Tue, 15 Oct 2019 08:48:40 -0700 (PDT) Received: from localhost ([::1]:49326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKP3u-0005Qy-3a for importer@patchew.org; Tue, 15 Oct 2019 11:48:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48570) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOhN-0003Ov-51 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOhK-0003sX-6G for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:20 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOhJ-0003cN-E1; Tue, 15 Oct 2019 11:25:18 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003aa-21; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-00061b-Te; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=LyRBVk6DPKgZU3xdCKP6t9qXcnMtdtrOc91PUHA4dPc=; b=N5+CnfJTTXGuI+IyvQKw6z2MrrVDoy6tA4UmRfQ1srOdw3CmNtCZV43sI9AYN5vQd82WLcGvPRDluvB/oBUM1DSHSCxBm9JZ7TjaVX5UU4bG97qmVGphOK9Xy7EYy5qsJTbHw7BbO5De0rhp0ujQzGNjOGlcfbJ5FHklmG4Q2eJueLCwcn0FY+H0+VVhcDVE6z3z6mqvE8bx1L6eDHry4ztXAYqlrllV/8Z56GbPN/lcKuVImELWON93OdKNqoibV83H8rj8uyFYVFEoLBmoFUYpcI53MA1rgz6fceQEOYnTf1MDpoce1icFIhtIqUzm4cnI67y0AIDiUyvmVJe0HQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 13/23] qcow2: Add subcluster support to calculate_l2_meta() Date: Tue, 15 Oct 2019 18:23:24 +0300 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" If an image has subclusters then there are more copy-on-write scenarios that we need to consider. Let's say we have a write request from the middle of subcluster #3 until the end of the cluster: - If the cluster is new, then subclusters #0 to #3 from the old cluster must be copied into the new one. - If the cluster is new but the old cluster was unallocated, then only subcluster #3 needs copy-on-write. #0 to #2 are marked as unallocated in the bitmap of the new L2 entry. - If we are overwriting an old cluster and subcluster #3 is unallocated or has the all-zeroes bit set then we need copy-on-write on subcluster #3. - If we are overwriting an old cluster and subcluster #3 was allocated then there is no need to copy-on-write. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 136 +++++++++++++++++++++++++++++++++--------- 1 file changed, 108 insertions(+), 28 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 67f90e415d..8df0f67316 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1034,14 +1034,16 @@ void qcow2_alloc_cluster_abort(BlockDriverState *bs= , QCowL2Meta *m) * If @keep_old is true it means that the clusters were already * allocated and will be overwritten. If false then the clusters are * new and we have to decrease the reference count of the old ones. + * + * Returns 1 on success, -errno on failure. */ -static void calculate_l2_meta(BlockDriverState *bs, uint64_t host_offset, - uint64_t guest_offset, uint64_t bytes, - uint64_t *l2_slice, QCowL2Meta **m, bool kee= p_old) +static int calculate_l2_meta(BlockDriverState *bs, uint64_t host_offset, + uint64_t guest_offset, uint64_t bytes, + uint64_t *l2_slice, QCowL2Meta **m, bool keep= _old) { BDRVQcow2State *s =3D bs->opaque; - int l2_index =3D offset_to_l2_slice_index(s, guest_offset); - uint64_t l2_entry; + int sc_index, l2_index =3D offset_to_l2_slice_index(s, guest_offset); + uint64_t l2_entry, l2_bitmap; unsigned cow_start_from, cow_end_to; unsigned cow_start_to =3D offset_into_cluster(s, guest_offset); unsigned cow_end_from =3D cow_start_to + bytes; @@ -1049,38 +1051,108 @@ static void calculate_l2_meta(BlockDriverState *bs= , uint64_t host_offset, QCowL2Meta *old_m =3D *m; QCow2ClusterType type; =20 - /* Return if there's no COW (all clusters are normal and we keep them)= */ + /* Return if there's no COW (all subclusters are normal and we are + * keeping the clusters) */ if (keep_old) { + unsigned first_sc =3D cow_start_to / s->subcluster_size; + unsigned last_sc =3D (cow_end_from - 1) / s->subcluster_size; int i; - for (i =3D 0; i < nb_clusters; i++) { - l2_entry =3D get_l2_entry(s, l2_slice, l2_index + i); - if (qcow2_get_cluster_type(bs, l2_entry) !=3D QCOW2_CLUSTER_NO= RMAL) { + for (i =3D first_sc; i <=3D last_sc; i++) { + unsigned c =3D i / s->subclusters_per_cluster; + unsigned sc =3D i % s->subclusters_per_cluster; + l2_entry =3D get_l2_entry(s, l2_slice, l2_index + c); + l2_bitmap =3D get_l2_bitmap(s, l2_slice, l2_index + c); + type =3D qcow2_get_subcluster_type(bs, l2_entry, l2_bitmap, sc= ); + if (type =3D=3D QCOW2_CLUSTER_INVALID) { + l2_index +=3D c; /* Point to the invalid entry */ + goto fail; + } + if (type !=3D QCOW2_CLUSTER_NORMAL) { break; } } - if (i =3D=3D nb_clusters) { - return; + if (i =3D=3D last_sc + 1) { + return 1; } } =20 /* Get the L2 entry from the first cluster */ l2_entry =3D get_l2_entry(s, l2_slice, l2_index); - type =3D qcow2_get_cluster_type(bs, l2_entry); + l2_bitmap =3D get_l2_bitmap(s, l2_slice, l2_index); + sc_index =3D offset_to_sc_index(s, guest_offset); + type =3D qcow2_get_subcluster_type(bs, l2_entry, l2_bitmap, sc_index); =20 - if (type =3D=3D QCOW2_CLUSTER_NORMAL && keep_old) { - cow_start_from =3D cow_start_to; + if (type =3D=3D QCOW2_CLUSTER_INVALID) { + goto fail; + } + + if (!keep_old) { + switch (type) { + case QCOW2_CLUSTER_NORMAL: + case QCOW2_CLUSTER_COMPRESSED: + case QCOW2_CLUSTER_ZERO_ALLOC: + case QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER: + cow_start_from =3D 0; + break; + case QCOW2_CLUSTER_ZERO_PLAIN: + case QCOW2_CLUSTER_UNALLOCATED: + cow_start_from =3D sc_index << s->subcluster_bits; + break; + default: + g_assert_not_reached(); + } } else { - cow_start_from =3D 0; + switch (type) { + case QCOW2_CLUSTER_NORMAL: + cow_start_from =3D cow_start_to; + break; + case QCOW2_CLUSTER_ZERO_ALLOC: + case QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER: + cow_start_from =3D sc_index << s->subcluster_bits; + break; + default: + g_assert_not_reached(); + } } =20 /* Get the L2 entry from the last cluster */ - l2_entry =3D get_l2_entry(s, l2_slice, l2_index + nb_clusters - 1); - type =3D qcow2_get_cluster_type(bs, l2_entry); + l2_index +=3D nb_clusters - 1; + l2_entry =3D get_l2_entry(s, l2_slice, l2_index); + l2_bitmap =3D get_l2_bitmap(s, l2_slice, l2_index); + sc_index =3D offset_to_sc_index(s, guest_offset + bytes - 1); + type =3D qcow2_get_subcluster_type(bs, l2_entry, l2_bitmap, sc_index); =20 - if (type =3D=3D QCOW2_CLUSTER_NORMAL && keep_old) { - cow_end_to =3D cow_end_from; + if (type =3D=3D QCOW2_CLUSTER_INVALID) { + goto fail; + } + + if (!keep_old) { + switch (type) { + case QCOW2_CLUSTER_NORMAL: + case QCOW2_CLUSTER_COMPRESSED: + case QCOW2_CLUSTER_ZERO_ALLOC: + case QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER: + cow_end_to =3D ROUND_UP(cow_end_from, s->cluster_size); + break; + case QCOW2_CLUSTER_ZERO_PLAIN: + case QCOW2_CLUSTER_UNALLOCATED: + cow_end_to =3D ROUND_UP(cow_end_from, s->subcluster_size); + break; + default: + g_assert_not_reached(); + } } else { - cow_end_to =3D ROUND_UP(cow_end_from, s->cluster_size); + switch (type) { + case QCOW2_CLUSTER_NORMAL: + cow_end_to =3D cow_end_from; + break; + case QCOW2_CLUSTER_ZERO_ALLOC: + case QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER: + cow_end_to =3D ROUND_UP(cow_end_from, s->subcluster_size); + break; + default: + g_assert_not_reached(); + } } =20 *m =3D g_malloc0(sizeof(**m)); @@ -1105,6 +1177,18 @@ static void calculate_l2_meta(BlockDriverState *bs, = uint64_t host_offset, =20 qemu_co_queue_init(&(*m)->dependent_requests); QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight); + +fail: + if (type =3D=3D QCOW2_CLUSTER_INVALID) { + uint64_t l1_index =3D offset_to_l1_index(s, guest_offset); + uint64_t l2_offset =3D s->l1_table[l1_index] & L1E_OFFSET_MASK; + qcow2_signal_corruption(bs, true, -1, -1, "Invalid cluster entry f= ound " + " (L2 offset: %#" PRIx64 ", L2 index: %#x)= ", + l2_offset, l2_index); + return -EIO; + } + + return 1; } =20 /* Returns true if the cluster is unallocated or has refcount > 1 */ @@ -1313,10 +1397,8 @@ static int handle_copied(BlockDriverState *bs, uint6= 4_t guest_offset, - offset_into_cluster(s, guest_offset)); assert(*bytes !=3D 0); =20 - calculate_l2_meta(bs, cluster_offset & L2E_OFFSET_MASK, guest_offs= et, - *bytes, l2_slice, m, true); - - ret =3D 1; + ret =3D calculate_l2_meta(bs, cluster_offset & L2E_OFFSET_MASK, + guest_offset, *bytes, l2_slice, m, true); } else { ret =3D 0; } @@ -1488,10 +1570,8 @@ static int handle_alloc(BlockDriverState *bs, uint64= _t guest_offset, *bytes =3D MIN(*bytes, nb_bytes - offset_into_cluster(s, guest_offset)= ); assert(*bytes !=3D 0); =20 - calculate_l2_meta(bs, alloc_cluster_offset, guest_offset, *bytes, l2_s= lice, - m, false); - - ret =3D 1; + ret =3D calculate_l2_meta(bs, alloc_cluster_offset, guest_offset, *byt= es, + l2_slice, m, false); =20 out: qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571154276; cv=none; d=zoho.com; s=zohoarc; b=lEIWGCLJKJ2S4yjHUWZXX1Wot95jMvXN9QJYDdzjr3kQC0vA5ZtH09GN5yQ9J8iNae6CwkLUr+w6ubVRgwMsRDia0akry3MHxu0Kn8S/RSAA3y1uQA69uf4haHr1/oRR/Vd1BXTLjYraUEoBSyvZSmGS5uq79c7sn2AsVtVzRjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571154276; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ycigQtKkStyehK0msuNh3djRKyIrwTwJCSeAivPHn2U=; b=BmyNvnmejRxctKD+K/raKBAbwkWzznew9q5Vc9CVClCMkIqwvV9g0wBXrYtpWmNYG7gwSgpbdSrZMPmKneLPPI1+FisH5fehPNW19bG30MulOgSH+VbuTlsKeP0gFTtwIp55NqW4BlRUFBoRrLS3/0P2MTStaKY8/YrKTN7l06E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571154276175375.1332276380789; Tue, 15 Oct 2019 08:44:36 -0700 (PDT) Received: from localhost ([::1]:49158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOzy-0000kD-Ii for importer@patchew.org; Tue, 15 Oct 2019 11:44:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48558) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOhM-0003O3-N1 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOhK-0003sF-4s for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:20 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47176) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOhJ-0003cE-GA; Tue, 15 Oct 2019 11:25:17 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003ab-2o; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-00061d-Ud; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=ycigQtKkStyehK0msuNh3djRKyIrwTwJCSeAivPHn2U=; b=RI1bPtXvPWwMl9r9Okk5vgfZdoZMNz/iNVDdNc5/KqwenkB+6tpaU4GIVmOhbSn8VerAJGdKKz6loyLLNoclsaLRvTjLXSaS1pKhFzvZGnUVIxhJP4G2LsPfnUtqoxUGouwv+5QogRwgVoGJ+o9QqUAv6Y0NAdZ+MNRpOuaN06wJwP7CQ4O7p/QPrx4EooU0rNEAL73vZqdhn653aGtx85QCQSmuCdU2XIDw9vWnk3stfSH3Ey3AiC9PfOudp5cy6bQOLOE/TofX3GeU6+INrYV0l+TZVqdKUGHzffkSY3izjMoS0MS8670u3yh5yCVGT/QdEyLph292MCuax07/tQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 14/23] qcow2: Add subcluster support to qcow2_get_cluster_offset() Date: Tue, 15 Oct 2019 18:23:25 +0300 Message-Id: <67505c246d62df44cdc5e4fc3e0d5716047586b4.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" The logic of this function remains pretty much the same, except that it uses count_contiguous_subclusters(), which combines the logic of count_contiguous_clusters() / count_contiguous_clusters_unallocated() and checks individual subclusters. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 111 ++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 59 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 8df0f67316..71d4cc518a 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -372,66 +372,51 @@ fail: } =20 /* - * 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) + * Return the number of contiguous subclusters of the exact same type + * in a given L2 slice, starting from cluster @l2_index, subcluster + * @sc_index. At most @nb_clusters are checked. Allocated clusters are + * also required to be contiguous in the image file. */ -static int count_contiguous_clusters(BlockDriverState *bs, int nb_clusters, - int cluster_size, uint64_t *l2_slice, int l2_index, uint64_t stop_= flags) +static int count_contiguous_subclusters(BlockDriverState *bs, int nb_clust= ers, + unsigned sc_index, uint64_t *l2_sl= ice, + int l2_index) { BDRVQcow2State *s =3D bs->opaque; - int i; - QCow2ClusterType first_cluster_type; - uint64_t mask =3D stop_flags | L2E_OFFSET_MASK | QCOW_OFLAG_COMPRESSED; - uint64_t first_entry =3D get_l2_entry(s, l2_slice, l2_index); - uint64_t offset =3D first_entry & mask; - - first_cluster_type =3D qcow2_get_cluster_type(bs, first_entry); - if (first_cluster_type =3D=3D QCOW2_CLUSTER_UNALLOCATED) { - return 0; + int i, j, count =3D 0; + uint64_t l2_entry =3D get_l2_entry(s, l2_slice, l2_index); + uint64_t l2_bitmap =3D get_l2_bitmap(s, l2_slice, l2_index); + uint64_t expected_offset =3D l2_entry & L2E_OFFSET_MASK; + bool check_offset =3D true; + QCow2ClusterType type =3D + qcow2_get_subcluster_type(bs, l2_entry, l2_bitmap, sc_index); + + assert(type !=3D QCOW2_CLUSTER_INVALID); /* The caller should check th= is */ + + if (type =3D=3D QCOW2_CLUSTER_COMPRESSED) { + return 1; /* Compressed clusters are always counted one by one */ } =20 - /* must be allocated */ - assert(first_cluster_type =3D=3D QCOW2_CLUSTER_NORMAL || - first_cluster_type =3D=3D QCOW2_CLUSTER_ZERO_ALLOC); - - for (i =3D 0; i < nb_clusters; i++) { - uint64_t l2_entry =3D get_l2_entry(s, l2_slice, l2_index + i) & ma= sk; - if (offset + (uint64_t) i * cluster_size !=3D l2_entry) { - break; - } + if (type =3D=3D QCOW2_CLUSTER_UNALLOCATED || type =3D=3D QCOW2_CLUSTER= _ZERO_PLAIN) { + check_offset =3D false; } =20 - return i; -} - -/* - * Checks how many consecutive unallocated clusters in a given L2 - * slice have the same cluster type. - */ -static int count_contiguous_clusters_unallocated(BlockDriverState *bs, - int nb_clusters, - uint64_t *l2_slice, - int l2_index, - QCow2ClusterType wanted_t= ype) -{ - BDRVQcow2State *s =3D bs->opaque; - int i; - - 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 get_l2_entry(s, l2_slice, l2_index + i); - QCow2ClusterType type =3D qcow2_get_cluster_type(bs, entry); - - if (type !=3D wanted_type) { - break; + l2_entry =3D get_l2_entry(s, l2_slice, l2_index + i); + l2_bitmap =3D get_l2_bitmap(s, l2_slice, l2_index + i); + if (check_offset && expected_offset !=3D (l2_entry & L2E_OFFSET_MA= SK)) { + goto out; + } + for (j =3D (i =3D=3D 0) ? sc_index : 0; j < s->subclusters_per_clu= ster; j++) { + if (qcow2_get_subcluster_type(bs, l2_entry, l2_bitmap, j) !=3D= type) { + goto out; + } + count++; } + expected_offset +=3D s->cluster_size; } =20 - return i; +out: + return count; } =20 static int coroutine_fn do_perform_cow_read(BlockDriverState *bs, @@ -514,8 +499,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, unsigned int *bytes, uint64_t *cluster_offset) { BDRVQcow2State *s =3D bs->opaque; - unsigned int l2_index; - uint64_t l1_index, l2_offset, *l2_slice; + unsigned int l2_index, sc_index; + uint64_t l1_index, l2_offset, *l2_slice, l2_bitmap; int c; unsigned int offset_in_cluster; uint64_t bytes_available, bytes_needed, nb_clusters; @@ -569,7 +554,9 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, /* find the cluster offset for the given disk offset */ =20 l2_index =3D offset_to_l2_slice_index(s, offset); + sc_index =3D offset_to_sc_index(s, offset); *cluster_offset =3D get_l2_entry(s, l2_slice, l2_index); + l2_bitmap =3D get_l2_bitmap(s, 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 @@ -577,7 +564,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, * true */ assert(nb_clusters <=3D INT_MAX); =20 - type =3D qcow2_get_cluster_type(bs, *cluster_offset); + type =3D qcow2_get_subcluster_type(bs, *cluster_offset, l2_bitmap, sc_= index); if (s->qcow_version < 3 && (type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN || type =3D=3D QCOW2_CLUSTER_ZERO_ALLOC)) { qcow2_signal_corruption(bs, true, -1, -1, "Zero cluster entry foun= d" @@ -587,6 +574,13 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uin= t64_t offset, goto fail; } switch (type) { + case QCOW2_CLUSTER_INVALID: + qcow2_signal_corruption(bs, true, -1, -1, "Invalid cluster entry f= ound " + " (L2 offset: %#" PRIx64 ", L2 index: %#x)= ", + l2_offset, l2_index); + ret =3D -EIO; + goto fail; + break; case QCOW2_CLUSTER_COMPRESSED: if (has_data_file(bs)) { qcow2_signal_corruption(bs, true, -1, -1, "Compressed cluster " @@ -602,16 +596,15 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, ui= nt64_t offset, break; case QCOW2_CLUSTER_ZERO_PLAIN: case QCOW2_CLUSTER_UNALLOCATED: - /* how many empty clusters ? */ - c =3D count_contiguous_clusters_unallocated(bs, nb_clusters, - l2_slice, l2_index, type= ); + c =3D count_contiguous_subclusters(bs, nb_clusters, sc_index, + l2_slice, l2_index); *cluster_offset =3D 0; break; case QCOW2_CLUSTER_ZERO_ALLOC: case QCOW2_CLUSTER_NORMAL: - /* how many allocated clusters ? */ - c =3D count_contiguous_clusters(bs, nb_clusters, s->cluster_size, - l2_slice, l2_index, QCOW_OFLAG_ZERO); + case QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER: + c =3D count_contiguous_subclusters(bs, nb_clusters, sc_index, + l2_slice, l2_index); *cluster_offset &=3D L2E_OFFSET_MASK; if (offset_into_cluster(s, *cluster_offset)) { qcow2_signal_corruption(bs, true, -1, -1, @@ -640,7 +633,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, =20 qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 - bytes_available =3D (int64_t)c * s->cluster_size; + bytes_available =3D ((int64_t)c + sc_index) * s->subcluster_size; =20 out: if (bytes_available > bytes_needed) { --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571154062; cv=none; d=zoho.com; s=zohoarc; b=a1NPNN/dx2AjzVkkKbAmPYunEnBgWX3YKFN+GS1l+uerlfNBUwBlWq5OFNafkwQI2A0cTSalLht8TZ4QYd0mr0Q7oVhqA1KqdYrPHHjatKXUdly2rhWoGpQ2o+A2UQApxBauzoZjq/5oypCc8fbC2y/OKKyA6NV28pyEWGBWiAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571154062; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eum2qUhwDIOULIJujs+UXiB00bNfmxdH6fSBjv2smuk=; b=MP7aMUIH3fl0KcUtNZikrba9cpULDTyCNsejBF5cmebMK94dHIkXAU2VMg+s4L71IYL54Jsmap6Lm3HfgpJ7lXqAbDcfV+xB2H+XfS+lGfpRYMGQOuviz+Mhk6yiis61lMIBGWwaX0zu/t0SOA87lLvm2/nbaOyrXitDq1B8OU0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571154062320738.2448120262372; Tue, 15 Oct 2019 08:41:02 -0700 (PDT) Received: from localhost ([::1]:48978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOwW-00050C-R0 for importer@patchew.org; Tue, 15 Oct 2019 11:41:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48487) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOhL-0003Le-7o for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOhJ-0003rV-PY for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:18 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47172) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOhJ-0003cA-DA; Tue, 15 Oct 2019 11:25:17 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003ac-3E; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfm-00061g-VW; Tue, 15 Oct 2019 18:23:42 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=eum2qUhwDIOULIJujs+UXiB00bNfmxdH6fSBjv2smuk=; b=WV+hVDj6OxCe7cwziL1P46Io6lLbe7+swiSnau3hMfZIj7luCI8NSmcczKW7TT8o/ZCt+mQOWHIIt7cn0Rlv0Rx/dE1hehYlAUyqdR3+g+4+l5YSJN7q1g7crXw4NlwCeqXFT/B6lKd37D46o+nWw9wiboqkSamZsRAJigzWej0mfvwlp3IBje1ncZX3c07eJxSVhktP/skZFZobErQVdQ9cXiwC9WQobqu4jEKqN9LnbBW7DB3JHkiR1tUkfH7AAzjHenhYTYF2d6f9spDykeQTF5hniLz7uxPD3Rg/spW42bfkDYI6e1eKwUoyJkSmj2I5hAR68XBb5zmigf2k0A==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 15/23] qcow2: Add subcluster support to zero_in_l2_slice() Date: Tue, 15 Oct 2019 18:23:26 +0300 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" Setting the QCOW_OFLAG_ZERO bit of the L2 entry is forbidden if an image has subclusters. Instead, the individual 'all zeroes' bits must be used. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 71d4cc518a..c554b1a88c 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1849,7 +1849,7 @@ static int zero_in_l2_slice(BlockDriverState *bs, uin= t64_t offset, assert(nb_clusters <=3D INT_MAX); =20 for (i =3D 0; i < nb_clusters; i++) { - uint64_t old_offset; + uint64_t old_offset, l2_entry =3D 0; QCow2ClusterType cluster_type; =20 old_offset =3D get_l2_entry(s, l2_slice, l2_index + i); @@ -1866,12 +1866,18 @@ static int zero_in_l2_slice(BlockDriverState *bs, u= int64_t offset, =20 qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); if (cluster_type =3D=3D QCOW2_CLUSTER_COMPRESSED || unmap) { - set_l2_entry(s, l2_slice, l2_index + i, QCOW_OFLAG_ZERO); qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUE= ST); } else { - uint64_t entry =3D get_l2_entry(s, l2_slice, l2_index + i); - set_l2_entry(s, l2_slice, l2_index + i, entry | QCOW_OFLAG_ZER= O); + l2_entry =3D get_l2_entry(s, l2_slice, l2_index + i); } + + if (has_subclusters(s)) { + set_l2_bitmap(s, l2_slice, l2_index + i, QCOW_L2_BITMAP_ALL_ZE= ROES); + } else { + l2_entry |=3D QCOW_OFLAG_ZERO; + } + + set_l2_entry(s, l2_slice, l2_index + i, l2_entry); } =20 qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153222; cv=none; d=zoho.com; s=zohoarc; b=h6J5iz44ji+6nKbQfk/SHf3251RSmdy2ON1V2pxkwy09GDXydJP1jlw/+U6EzwsGS4hRH3RcN8AYYoos4/mCkdu892JStXwJxLocGn/9W9jbMS90VwczuIXngr+IVJDUWGmHrPDxvFZPQkRkVZN66E3w/fVaGr7oBlokWymNf2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153222; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PwQd/y4S0FBQizWvZQAHM2WnDJ0t7VTyKQq0iYWEjWI=; b=Vv4qr2DjPBiZ49pPftstjN0bKOakr56vQuqt9gUugwHD5SCvBeQ9q+z/4e3fHaNBZTuYnDx8RwbBBt6utL1/cL99KOwoSN8w2DXL+59QmBL8kVhRVdeD/KBcR6BJQ57aOEKJ9ea5H+wkRt1HNSXpDdcOOcbHBHt7eo0uLphM6jU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571153222271984.0374395935147; Tue, 15 Oct 2019 08:27:02 -0700 (PDT) Received: from localhost ([::1]:48700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOiy-0005Dk-Im for importer@patchew.org; Tue, 15 Oct 2019 11:27:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48075) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOgy-0002kq-7e for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOgw-0003fP-Qn for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:24:55 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47105) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOgw-0003ZF-4w; Tue, 15 Oct 2019 11:24:54 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003ad-1k; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfn-00061j-09; Tue, 15 Oct 2019 18:23:43 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=PwQd/y4S0FBQizWvZQAHM2WnDJ0t7VTyKQq0iYWEjWI=; b=eZ4srQEvncVNHcdLWXmHguaadSgn3/Obl2xjqHZmSuv0usdICsMdamij6aekLQiWzOGxlTk3C9eEg0rnh0u5uU93Qh4gRuxqPgdE1tG2KRPssNy5YCTt6p/XiY0MZ+cUXHO6FHvYOfUzDLlOIvf6Iab1XC7Q8ZGrFWejyy3FKdD8A13fJ32Kwy8PYwXHNHoirvkUjG5IKGLtTiQ59rLRx7Z8KseSt3XPEcH/uhYxSi0k6LbGYeiz3gKAQbp4ZRGfspfe+40YsT6qb94JMNrgLnkKhBAOtIz/9uwZ8EzjQS8Z11bdYpjeFUvEPRFJ3Dg6YCOHVw+4iGfLeiI3nYS4lg==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 16/23] qcow2: Add subcluster support to discard_in_l2_slice() Date: Tue, 15 Oct 2019 18:23:27 +0300 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" Setting the QCOW_OFLAG_ZERO bit of the L2 entry is forbidden if an image has subclusters. Instead, the individual 'all zeroes' bits must be used. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index c554b1a88c..bf32447d18 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1769,7 +1769,11 @@ static int discard_in_l2_slice(BlockDriverState *bs,= uint64_t offset, =20 /* First remove L2 entries */ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); - if (!full_discard && s->qcow_version >=3D 3) { + if (has_subclusters(s)) { + set_l2_entry(s, l2_slice, l2_index + i, 0); + set_l2_bitmap(s, l2_slice, l2_index + i, + full_discard ? 0 : QCOW_L2_BITMAP_ALL_ZEROES); + } else if (!full_discard && s->qcow_version >=3D 3) { set_l2_entry(s, l2_slice, l2_index + i, QCOW_OFLAG_ZERO); } else { set_l2_entry(s, l2_slice, l2_index + i, 0); --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571154263; cv=none; d=zoho.com; s=zohoarc; b=U5hGEHSUJ4LeMQbZPqLODqgTLCV+B+Pa7n4YKZSw5L2HcWq0aJmuXag9/m6KYQ9AoLIhinRspzoyZ/AeysXl1QZtL1OhC7x6UwGRR9BF4JPNQGFz1IN6AdRfbvslDbZ+GdyCX5b86QjeNggYuEPlS/X13Jz8pkdX9U9wOzxYHhI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571154263; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jf2nTCfP7xp/3co8utd/6PUlpREmZM5Pk/mq5bNfDRA=; b=iCJrevev6boAXcMEMMbWfckIB+OwSkTTcVqCVI7cI8NVPX7k90xpaO/iG0nBAvhUp3Ordr50a2WP+yLUSIk/sMVnsJrm2Kj8vC3SV/qGGH8pN+h/8s2Iz2TmoNqLfeTbnxtkMz263h7K8hGeoltBMMT4pFR2OCINAvBA6u6/BEY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571154263479404.75279268803126; Tue, 15 Oct 2019 08:44:23 -0700 (PDT) Received: from localhost ([::1]:49154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOzl-0000OY-OY for importer@patchew.org; Tue, 15 Oct 2019 11:44:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48552) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOhM-0003Ns-J9 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOhK-0003sS-3e for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:20 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOhJ-0003cI-GB; Tue, 15 Oct 2019 11:25:17 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003ae-4u; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfn-00061m-1D; Tue, 15 Oct 2019 18:23:43 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=jf2nTCfP7xp/3co8utd/6PUlpREmZM5Pk/mq5bNfDRA=; b=l92F+cBNDvwWmlfeC70bQ6NJvjfBjybAzGKlTIgGzfXa5TX4ug663GQbfHr3gnyJ4gFOWyzRasnecHk5GwON4/p6dlQjcFcUS+SLDpNrMKC8Z/u79NR8r6ZV+0A7kMQFfCNZE7j86PTOh5s0uiKnbNGWTu9kNl1I02BVC48AH+qZLE4n9K4N37N7FcpQWgdZ8FlcMIX0orDRAcvhpgNBOSqBqJI5kKZu1CRJ6iv+ZscoFJsoam2iGq8SN9TCAY8og3+19u1gQE3VElFDAKrvCCJOdB1WAnRqXF0O872JR5rk8+TCUN53+p/NCNNA3sYPvlT9qvvqHV8fza9DM7BQiQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 17/23] qcow2: Add subcluster support to check_refcounts_l2() Date: Tue, 15 Oct 2019 18:23:28 +0300 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" Setting the QCOW_OFLAG_ZERO bit of the L2 entry is forbidden if an image has subclusters. Instead, the individual 'all zeroes' bits must be used. Signed-off-by: Alberto Garcia --- block/qcow2-refcount.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index a2c4d36378..3eda523e25 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1685,8 +1685,13 @@ static int check_refcounts_l2(BlockDriverState *bs, = BdrvCheckResult *res, int ign =3D active ? QCOW2_OL_ACTIVE_L2 : QCOW2_OL_INACTIVE_L2; =20 - l2_entry =3D QCOW_OFLAG_ZERO; - set_l2_entry(s, l2_table, i, l2_entry); + if (has_subclusters(s)) { + set_l2_entry(s, l2_table, i, 0); + set_l2_bitmap(s, l2_table, i, + QCOW_L2_BITMAP_ALL_ZEROES); + } else { + set_l2_entry(s, l2_table, i, QCOW_OFLAG_ZERO); + } ret =3D qcow2_pre_write_overlap_check(bs, ign, l2e_offset, l2_entry_size(s), false); if (ret < 0) { --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153905; cv=none; d=zoho.com; s=zohoarc; b=SeNAve/bBLzUG6ZRzxKkPxTLqeboPmpMy94PXSaqlNnpt4T8W890t/RYj8w3+5ofXH71xsRBPTyiIIn9Z84b5SrKpw0IocMIKK3A5uYzFjFekXPcBbiJ1otFSTWfiJ8r1TvosaiKryQaSWV9S40p4ytPctwE1vo2NeorVPV9+fw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153905; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ALYCPxryLvhmZ8GEEyTrPtMyD7kVHTkvn2pb/zgUGkM=; b=FVGEgMHCf7bwpv7w0lBZfN25vdedWu2y31eULba+zVBTPPRGcaA/njYHpRzjLL0C9vahohuvSblraKfxV5NPvyao+nZzHsIeNPO1t4knFRP5hwyeUr5j0YUKZMs+pTU9xQAEjMvj6KF+qzA/Sjq4cao2PYLQk8jqodxRHrcL0o8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571153905021941.1858307373723; Tue, 15 Oct 2019 08:38:25 -0700 (PDT) Received: from localhost ([::1]:48926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOtz-00014M-LM for importer@patchew.org; Tue, 15 Oct 2019 11:38:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48478) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOhK-0003LG-Ti for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOhJ-0003ra-Pi for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:18 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47181) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOhJ-0003cD-Cu; Tue, 15 Oct 2019 11:25:17 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003af-4H; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfn-00061p-28; Tue, 15 Oct 2019 18:23:43 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=ALYCPxryLvhmZ8GEEyTrPtMyD7kVHTkvn2pb/zgUGkM=; b=jO14fM1zd5KrqiF+SeYOwlDFCeMY+cHial+dyNEDEiFSWanHgbuT9N8gOR0elwRXPE4HWCIKVhEaCTbefF2Mz3KE73UqAoMsZrv8g2lcNv/kUxBkjrwBO4wMbXRDdfF72+8IY1mIq75WUSYqcfskiLfCJL0KRgYHqd1DxWY2mGSHBd5nrx/cTQ21vjrTMYZIrOQMgbtDBic3ZG7aGafEPuyOXzeheK/3TjfFeV+RDiULNUFn8ZElSLg5YdJCw8TDeU3I38o78ra9KF3UZEVTCNEApFLBlmhJ/dFYQsmrUiaIxHoKZKzrJ72mO4D0OQCcXDYwa2QPA/MfLjEYJb0wjA==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 18/23] qcow2: Add subcluster support to expand_zero_clusters_in_l1() Date: Tue, 15 Oct 2019 18:23:29 +0300 Message-Id: <0cb50763f0b1d32cc9e1be9b4eb77a6dc3f461d1.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" Two changes are needed in order to add subcluster support to this function: deallocated clusters must have their bitmaps cleared, and expanded clusters must have all the "subcluster allocated" bits set. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index bf32447d18..dc72f0e595 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -2033,6 +2033,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, /* not backed; therefore we can simply deallocate = the * cluster */ set_l2_entry(s, l2_slice, j, 0); + set_l2_bitmap(s, l2_slice, j, 0); l2_dirty =3D true; continue; } @@ -2099,6 +2100,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, } else { set_l2_entry(s, l2_slice, j, offset); } + set_l2_bitmap(s, l2_slice, j, QCOW_L2_BITMAP_ALL_ALLOC); l2_dirty =3D true; } =20 --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571154058; cv=none; d=zoho.com; s=zohoarc; b=jzdxQFsRGDNcaKvrgCandsRMVf87rcuuFUwrlQBsAivMNDxiQzQ9PCHBKTDLQ7gXHUKIt/0uklZ8lFM61t5TKE0jad6EH5jbcVNacx46FVZekWhDxt4QBYQtRe1rXQszK4aoIqssDJZzmAnHRVf4dP9Lrrse4QGCSpB1PQDeWcs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571154058; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lTwe5L6tkrphvOujsjpMEe2kl6IeFgukQZj+3XdsYfc=; b=N8JNzpX/WJXfzSPGbY+5ME/EXlJlM+e8yGvyqmuBaL8ZdKLH7eRWVm8XpZQFJnBueadfLLPqVItbNA1ConXIGTVTBXn1fCwSNq8mYzVECBoHzzKOILOZQVaMOHHlxoYiKzsTExuccui7VcX54EI6QuFsfOOHS6JCcLqD4Ueah9s= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571154058151623.7342470468948; Tue, 15 Oct 2019 08:40:58 -0700 (PDT) Received: from localhost ([::1]:48974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOwS-0004rW-JW for importer@patchew.org; Tue, 15 Oct 2019 11:40:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48483) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOhL-0003LT-3D for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOhJ-0003rn-V1 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:18 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47189) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOhJ-0003cO-Ed; Tue, 15 Oct 2019 11:25:17 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003ag-6s; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfn-00061t-3A; Tue, 15 Oct 2019 18:23:43 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=lTwe5L6tkrphvOujsjpMEe2kl6IeFgukQZj+3XdsYfc=; b=C2Falpd6Ql/0ANCSvsmHSJoGsluJldaysj5EzhmvEa2SEwbYxWoFLz0ejOXDb5EdwsAZ6rVE9er6wRZWcMwbkz4j6Y0kL1Jvf1fo00Ch8/QUXPLPXyljddQJLuPedFZMJc7fW6x2no70Ztfjl7AEvq9iDOMOEXHVWwKm53rVOGC0eqNyaZGGU3+OW4cttDwNIr6bGPjmaI2XrCHc+CdCDFsijkuHQBC6jOjFHtW8cJMTMCzw1P7Q0xUoDC+80VNwo2qn/lKDYY/0MuuvhV/BvsADBmg1YOFUl+EZ6JKXLep7lzsVFmZek+CULuk/7XbR+d7Js/6xBVIOM6i80qtnSA==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 19/23] qcow2: Fix offset calculation in handle_dependencies() Date: Tue, 15 Oct 2019 18:23:30 +0300 Message-Id: <846c6f37fea8f824887d2dcf62062041f6419ae1.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" l2meta_cow_start() and l2meta_cow_end() are not necessarily cluster-aligned if the image has subclusters, so update the calculation of old_start and old_end to guarantee that no two requests try to write on the same cluster. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index dc72f0e595..75579c1470 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1262,8 +1262,8 @@ static int handle_dependencies(BlockDriverState *bs, = uint64_t guest_offset, =20 uint64_t start =3D guest_offset; uint64_t end =3D start + bytes; - uint64_t old_start =3D l2meta_cow_start(old_alloc); - uint64_t old_end =3D l2meta_cow_end(old_alloc); + uint64_t old_start =3D start_of_cluster(s, l2meta_cow_start(old_al= loc)); + uint64_t old_end =3D ROUND_UP(l2meta_cow_end(old_alloc), s->cluste= r_size); =20 if (end <=3D old_start || start >=3D old_end) { /* No intersection */ --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153897; cv=none; d=zoho.com; s=zohoarc; b=E+kTlzEec3kpN6DQM3tMl+zTOOz4Smq4LnuzlgBW9I8yu2NOsODuxnpqHZBQoylmQq27njCZuJq+Ia3iWn06WlffjcpAHB6s+4BQGPdQaKR6D0dUxnqwpq2HVPXlXKNM2wv1Ot1+xU1B8djTXOD3Hs/+xaezWxgtqKZBtP62SF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153897; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qXgsAald1HN18K4PjYyZkFp86Cdh28uAfxzOQSyjqE4=; b=Xno11CL/i6lmN37bWtJRfnbOGbcIIQ61rvcwnfb/PMKgKcxU3iYekpFDBZPY6OYq60/mWhWJAY7S0vfCNLi/4khkFDJBSfacuhvWx+pr7GRJ2EjQW6xOzxFnPC3yJLpB7AFl4o/iZs4uUzen9qGO124IpATorZAsN3VC2JHAXu0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571153897131527.3284742336002; Tue, 15 Oct 2019 08:38:17 -0700 (PDT) Received: from localhost ([::1]:48914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOtr-0000rv-Ud for importer@patchew.org; Tue, 15 Oct 2019 11:38:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48491) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOhL-0003Lr-AT for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOhK-0003sK-4S for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:19 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47178) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOhJ-0003cG-Fq; Tue, 15 Oct 2019 11:25:17 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003ah-7B; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfn-00061v-42; Tue, 15 Oct 2019 18:23:43 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=qXgsAald1HN18K4PjYyZkFp86Cdh28uAfxzOQSyjqE4=; b=TXRRh3pYjsNeCxnDCncAgJHmrZiuSoIs6hR9ORd/ZYgnQBaxMa6pNS5f6iNvm4Yinry9G7AQ+85yTP0aRdv0gd98crvQHhvZsVs9MKjuA5CrG+M1UU6T0juJfCAeeMs6fTFjP8dSMiVkRE+zzXjgjEg8vqE5MwjVlGbUIk7eIeVFLxBU58Qkw+I5RUHX2sdXQGKVa8IHEYayVhMvJKkZto0EYEwKfcy0T5xFSk6DPBdRnFg+4rIFKW7Heq0vFtzsIWlUhIWu8ZinyAKgbyG1Mqgr69DZcAd1pemTP8YaZZJFeeK4fYzHPhRcA4xuYlPzUxU527/bs0I432jmnrzV9w==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 20/23] qcow2: Update L2 bitmap in qcow2_alloc_cluster_link_l2() Date: Tue, 15 Oct 2019 18:23:31 +0300 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" The L2 bitmap needs to be updated after each write to indicate what new subclusters are now allocated. This needs to happen even if the cluster was already allocated and the L2 entry was otherwise valid. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 75579c1470..9a4bf672b3 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -980,6 +980,22 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, = QCowL2Meta *m) =20 set_l2_entry(s, l2_slice, l2_index + i, QCOW_OFLAG_COPIED | (cluster_offset + (i << s->cluster_bits))); + + /* Update bitmap with the subclusters that were just written */ + if (has_subclusters(s)) { + uint64_t written_from =3D m->cow_start.offset; + uint64_t written_to =3D m->cow_end.offset + m->cow_end.nb_byte= s; + uint64_t l2_bitmap =3D get_l2_bitmap(s, l2_slice, l2_index + i= ); + int sc; + for (sc =3D 0; sc < s->subclusters_per_cluster; sc++) { + uint64_t sc_off =3D i * s->cluster_size + sc * s->subclust= er_size; + if (sc_off >=3D written_from && sc_off < written_to) { + l2_bitmap |=3D QCOW_OFLAG_SUB_ALLOC(sc); + l2_bitmap &=3D ~QCOW_OFLAG_SUB_ZERO(sc); + } + } + set_l2_bitmap(s, l2_slice, l2_index + i, l2_bitmap); + } } =20 =20 --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571154468; cv=none; d=zoho.com; s=zohoarc; b=agxwvlOEwkSH/PLUDEPOfEADzv4Qq1z3NcZL7z0ew6Q7YcWxUTvfF0JW2KfpUw6FPJ26Vc3rkJDc/ut8nbyCMRKSywyFEJSjXicgQaRnQ755ukdAiufaCLEV3kmWumyjJiwWojyla0HDwFuHAEp2Oi6q604QP9MCOH18GUlRhI8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571154468; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=noSUEGZeNw8217mG2J5pHPHq6mQwE2+cTlviu1AduTY=; b=N1p/vluLKIWfm6cgSDQr9lIl1y4XRb7KfCtiKQkwsoV0oyZCXOw++PwfQBiT6OTO7ruhOx2mOcLwb3TyOvmokKktAjc6qQvIsm0cgnrXv3C+VHLGF70t6eqRaabtW+WBFAaRux9dNpWaEa4pTwjyULzt+Wrw4T4mYar25ulZwVQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571154468595388.3647782262832; Tue, 15 Oct 2019 08:47:48 -0700 (PDT) Received: from localhost ([::1]:49322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKP32-0004Aq-T6 for importer@patchew.org; Tue, 15 Oct 2019 11:47:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48501) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOhL-0003MK-L4 for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOhK-0003sJ-4n for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:19 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47184) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOhJ-0003cJ-HV; Tue, 15 Oct 2019 11:25:17 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003ai-5h; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfn-00061z-5A; Tue, 15 Oct 2019 18:23:43 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=noSUEGZeNw8217mG2J5pHPHq6mQwE2+cTlviu1AduTY=; b=IbXVAIORUqWRfVRMjda2CpGohsz/mkZb217fALgCqTuRj12QIK9VMlJ6a7btEUkID8bUmsVbSfIdWpCvLhMUWTRSgdSEh7QO7gvNhRMIN9/Gyv3TFCI+Q3SDLtoqEh+Q4sw57jVIgF07iDYV3yCP5prN2Ds0MJv/oFYpSrwK2ampN5O9CyUqDLi9oPHdwKZGybZQvm7+9KLp8HYKPQDXaLD1avWz05vuluMHodWFspmC06znX8MgmWHWQPJoI6gt5CNPPbi93UjjX9BVWzqtBO32buFrU1xlv5Qfmbzcq/bTPe1lylX3yszmSWf6AUNRUA3jZnGUuDH07vS06Bo19Q==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 21/23] qcow2: Add subcluster support to handle_alloc_space() Date: Tue, 15 Oct 2019 18:23:32 +0300 Message-Id: <0645d1ee1f3a0cecb66c5fdde1c4fe1704bf40b1.1571152571.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" The bdrv_co_pwrite_zeroes() call here fills complete clusters with zeroes, but it can happen that some subclusters are not part of the write request or the copy-on-write. This patch makes sure that only the affected subclusters are overwritten. A potential improvement would be to also fill with zeroes the other subclusters if we can guarantee that we are not overwriting existing data. However this would waste more disk space, so we should first evaluate if it's really worth doing. Signed-off-by: Alberto Garcia --- block/qcow2.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index c222cd261d..c54278ab0b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2194,6 +2194,9 @@ static int handle_alloc_space(BlockDriverState *bs, Q= CowL2Meta *l2meta) =20 for (m =3D l2meta; m !=3D NULL; m =3D m->next) { int ret; + uint64_t start_offset =3D m->alloc_offset + m->cow_start.offset; + uint64_t nb_bytes =3D m->cow_end.offset + m->cow_end.nb_bytes - + m->cow_start.offset; =20 if (!m->cow_start.nb_bytes && !m->cow_end.nb_bytes) { continue; @@ -2208,16 +2211,14 @@ static int handle_alloc_space(BlockDriverState *bs,= QCowL2Meta *l2meta) * efficiently zero out the whole clusters */ =20 - ret =3D qcow2_pre_write_overlap_check(bs, 0, m->alloc_offset, - m->nb_clusters * s->cluster_si= ze, + ret =3D qcow2_pre_write_overlap_check(bs, 0, start_offset, nb_byte= s, true); if (ret < 0) { return ret; } =20 BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_ALLOC_SPACE); - ret =3D bdrv_co_pwrite_zeroes(s->data_file, m->alloc_offset, - m->nb_clusters * s->cluster_size, + ret =3D bdrv_co_pwrite_zeroes(s->data_file, start_offset, nb_bytes, BDRV_REQ_NO_FALLBACK); if (ret < 0) { if (ret !=3D -ENOTSUP && ret !=3D -EAGAIN) { --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571154225; cv=none; d=zoho.com; s=zohoarc; b=F/Qyj1n+TiP1U0y3nLNvTNEJssGe1SsieARJ5uCITlPmU+CMigu8hPTFL24OBdZV+ZeawLtSrg7lYY8bB27fZFryjC4FO2M1rbgiKc19Jn3yH3/u26bBj5O6i3A8JBTi3aqw7Ju02hg2JmxZIZWLzhZg7TwS0vVpDQif9s0ncas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571154225; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WMEj70ZX2RLuhYE9pIQSlcYumVwSBk1BVgAACnG2Mkc=; b=dUJpVT+4mAyeYhPy1i1GzKz/pot/HVaSr2LO8N25R/V2zR3UkRzVWgTkZfFzQh7J1fB7PnmE7llTGamEupA5rbgdvsPDROmcSP94FxVobmpw6enCQ89iDqLBGB6L9bv1S/lkNeBlP1I8KjkvAzwz7655kUXZf5L8E0P5x9csNYY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571154225988679.239656019908; Tue, 15 Oct 2019 08:43:45 -0700 (PDT) Received: from localhost ([::1]:49098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOzA-0008GJ-OA for importer@patchew.org; Tue, 15 Oct 2019 11:43:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48492) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOhL-0003Lt-Cr for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOhK-0003s5-3Y for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:19 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47191) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOhJ-0003cQ-F0; Tue, 15 Oct 2019 11:25:17 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003aj-5j; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfn-000622-6A; Tue, 15 Oct 2019 18:23:43 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=WMEj70ZX2RLuhYE9pIQSlcYumVwSBk1BVgAACnG2Mkc=; b=PFdGFuqteWPgavtyy/+6FUhFP8C7+nlkvJGB4E07hWZsLLDW+g+dlBuV1ZB0sP+4aFPYDG7+bQoq4JEFBq5O2ZFhhdFl4vWeCEhicS4ARTfDENo+DE5+hvBIj29voB/3Ap1IjA6l031hDdE+Fok2QCo+Dk0U7hM2R3HGMd6KtQCSPdZQjXYPLDCO8X75er0VPOpLpfXTxQddjlkQ+v0JT11xlZum5cfKc6B+XZU5yNj/ZsOE3N6eJKplPB8257sxEBLQsOi7SsPx0nox4xC68DIuw7lmUVNANhfVemoi9l47EHQMciyYwO3x+R0Bk4FmM5KycZnYOh1N9xZeaMHKSQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 22/23] qcow2: Restrict qcow2_co_pwrite_zeroes() to full clusters only Date: Tue, 15 Oct 2019 18:23:33 +0300 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" Ideally it should be possible to zero individual subclusters using this function, but this is currently not implemented. Signed-off-by: Alberto Garcia --- block/qcow2.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index c54278ab0b..2eb032aed7 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3544,6 +3544,12 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(Block= DriverState *bs, bytes =3D s->cluster_size; nr =3D s->cluster_size; ret =3D qcow2_get_cluster_offset(bs, offset, &nr, &off); + /* TODO: allow zeroing separate subclusters, we only allow + * zeroing full clusters at the moment. */ + if (nr !=3D bytes) { + qemu_co_mutex_unlock(&s->lock); + return -ENOTSUP; + } if (ret !=3D QCOW2_CLUSTER_UNALLOCATED && ret !=3D QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER && ret !=3D QCOW2_CLUSTER_ZERO_PLAIN && --=20 2.20.1 From nobody Sun May 5 12:10:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571153799; cv=none; d=zoho.com; s=zohoarc; b=RM9hBKHFI/SfeonYScfiJl/7Af1t1gXFAEh4W+K6nzacRahxIcFvSHjicZ0PRGbsG8t0TXDaN+ULlOZ+tdE5mmbawvE4k51FCsQYNMLVC8NAfglabMszcEide8taUvOckozrCvyzrQZlpoKWyu/TfAh5ZNj9Wj1+FyA4hDXjvi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153799; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=O4fy8FargCi2U/HerDbTqcNPKt5RmsOwm/Tj6pOFIqU=; b=FFFsM4W3Xh2cCaeurkPAjZfLBKEeG3pL6x/OPcVpWtkfmL2JGCdKIZ2zNglVwjP+Q/7ppOap0kD0pJXzlBQUtHazuSvYgc5Iqs06ABr2Zg57xc0g5iXnJISN6eskyCCo6H902FNiYMg9+QtEGcoIbF0vPXBh7wSgaCRKxyWnIeA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571153799900591.1638102344767; Tue, 15 Oct 2019 08:36:39 -0700 (PDT) Received: from localhost ([::1]:48860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOsI-0006xa-8e for importer@patchew.org; Tue, 15 Oct 2019 11:36:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48299) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKOh5-0002tF-RS for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKOgx-0003gZ-1V for qemu-devel@nongnu.org; Tue, 15 Oct 2019 11:25:03 -0400 Received: from fanzine.igalia.com ([178.60.130.6]:47107) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKOgw-0003ZE-52; Tue, 15 Oct 2019 11:24:54 -0400 Received: from 82-181-115-92.bb.dnainternet.fi ([82.181.115.92] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iKOge-0003ak-6b; Tue, 15 Oct 2019 17:24:36 +0200 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iKOfn-000625-7I; Tue, 15 Oct 2019 18:23:43 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=O4fy8FargCi2U/HerDbTqcNPKt5RmsOwm/Tj6pOFIqU=; b=K0NUdq3jnokCyNWqOgTWGE9iCY0TeIy+b5d3XpLZDxIKaLjhQvbX3xL4Vvp+bl8uzOcETOe0E+rzk9PcsDrHsp3T9+GdZm83eoYzQlx6JMwWe05hofVFuRoMun95GWSESTVTNs3sdZNLd2kLEFUa8Ka+2YmgtiW5YrJdiyxVYkNZDqpNLYe3GGwef3Nl8ciFPvjNcuavnR0g/PFYm/qz6y7EY5+op8uiss3AZp/L4MRYOLedUHvAK+91di2zg/c3lbkSVbknoFsdK2pi3jKLJoVUrfQtmIG9gt8MVZkidbmfIo7IE/ZYvkBeMX18f5U89il1Kj9B76jgLwFal8idAw==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH 23/23] qcow2: Add the 'extended_l2' option and the QCOW2_INCOMPAT_EXTL2 bit Date: Tue, 15 Oct 2019 18:23:34 +0300 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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) Content-Type: text/plain; charset="utf-8" Now that the implementation of subclusters is complete we can finally add the necessary options to create and read images with this feature, which we call "extended L2 entries". Signed-off-by: Alberto Garcia --- block/qcow2.c | 47 ++++++++++++++ block/qcow2.h | 8 ++- include/block/block_int.h | 1 + qapi/block-core.json | 2 + tests/qemu-iotests/031.out | 8 +-- tests/qemu-iotests/036.out | 4 +- tests/qemu-iotests/049.out | 102 +++++++++++++++---------------- tests/qemu-iotests/060.out | 1 + tests/qemu-iotests/061.out | 20 +++--- tests/qemu-iotests/065 | 18 ++++-- tests/qemu-iotests/082.out | 48 ++++++++++++--- tests/qemu-iotests/085.out | 38 ++++++------ tests/qemu-iotests/144.out | 4 +- tests/qemu-iotests/182.out | 2 +- tests/qemu-iotests/185.out | 8 +-- tests/qemu-iotests/198.out | 2 + tests/qemu-iotests/206.out | 4 ++ tests/qemu-iotests/242.out | 5 ++ tests/qemu-iotests/255.out | 8 +-- tests/qemu-iotests/common.filter | 1 + 20 files changed, 221 insertions(+), 110 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 2eb032aed7..44d97d30b1 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1346,6 +1346,12 @@ static int coroutine_fn qcow2_do_open(BlockDriverSta= te *bs, QDict *options, s->subcluster_size =3D s->cluster_size / s->subclusters_per_cluster; s->subcluster_bits =3D ctz32(s->subcluster_size); =20 + if (s->subcluster_size < (1 << MIN_CLUSTER_BITS)) { + error_setg(errp, "Unsupported subcluster size: %d", s->subcluster_= size); + ret =3D -EINVAL; + goto fail; + } + /* Check support for various header values */ if (header.refcount_order > 6) { error_setg(errp, "Reference count entry width too large; may not " @@ -2646,6 +2652,11 @@ int qcow2_update_header(BlockDriverState *bs) .bit =3D QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR, .name =3D "lazy refcounts", }, + { + .type =3D QCOW2_FEAT_TYPE_INCOMPATIBLE, + .bit =3D QCOW2_INCOMPAT_EXTL2_BITNR, + .name =3D "extended L2 entries", + }, }; =20 ret =3D header_ext_add(buf, QCOW2_EXT_MAGIC_FEATURE_TABLE, @@ -3138,6 +3149,27 @@ qcow2_co_create(BlockdevCreateOptions *create_option= s, Error **errp) goto out; } =20 + if (!qcow2_opts->has_extended_l2) { + qcow2_opts->extended_l2 =3D false; + } + if (qcow2_opts->extended_l2) { + unsigned min_cluster_size =3D + (1 << MIN_CLUSTER_BITS) * QCOW_MAX_SUBCLUSTERS_PER_CLUSTER; + if (version < 3) { + error_setg(errp, "Extended L2 entries are only supported with " + "compatibility level 1.1 and above (use version=3Dv= 3 or " + "greater)"); + ret =3D -EINVAL; + goto out; + } + if (cluster_size < min_cluster_size) { + error_setg(errp, "Extended L2 entries are only supported with " + "cluster sizes of at least %u bytes", min_cluster_s= ize); + ret =3D -EINVAL; + goto out; + } + } + if (!qcow2_opts->has_refcount_bits) { qcow2_opts->refcount_bits =3D 16; } @@ -3232,6 +3264,11 @@ qcow2_co_create(BlockdevCreateOptions *create_option= s, Error **errp) cpu_to_be64(QCOW2_AUTOCLEAR_DATA_FILE_RAW); } =20 + if (qcow2_opts->extended_l2) { + header->incompatible_features |=3D + cpu_to_be64(QCOW2_INCOMPAT_EXTL2); + } + ret =3D blk_pwrite(blk, 0, header, cluster_size, 0); g_free(header); if (ret < 0) { @@ -3409,6 +3446,7 @@ static int coroutine_fn qcow2_co_create_opts(const ch= ar *filename, QemuOpts *opt { BLOCK_OPT_BACKING_FMT, "backing-fmt" }, { BLOCK_OPT_CLUSTER_SIZE, "cluster-size" }, { BLOCK_OPT_LAZY_REFCOUNTS, "lazy-refcounts" }, + { BLOCK_OPT_EXTL2, "extended-l2" }, { BLOCK_OPT_REFCOUNT_BITS, "refcount-bits" }, { BLOCK_OPT_ENCRYPT, BLOCK_OPT_ENCRYPT_FORMAT }, { BLOCK_OPT_COMPAT_LEVEL, "version" }, @@ -4612,6 +4650,9 @@ static ImageInfoSpecific *qcow2_get_specific_info(Blo= ckDriverState *bs, .corrupt =3D s->incompatible_features & QCOW2_INCOMPAT_CORRUPT, .has_corrupt =3D true, + .has_extended_l2 =3D true, + .extended_l2 =3D s->incompatible_features & + QCOW2_INCOMPAT_EXTL2, .refcount_bits =3D s->refcount_bits, .has_bitmaps =3D !!bitmaps, .bitmaps =3D bitmaps, @@ -5205,6 +5246,12 @@ static QemuOptsList qcow2_create_opts =3D { .help =3D "Postpone refcount updates", .def_value_str =3D "off" }, + { + .name =3D BLOCK_OPT_EXTL2, + .type =3D QEMU_OPT_BOOL, + .help =3D "Extended L2 tables", + .def_value_str =3D "off" + }, { .name =3D BLOCK_OPT_REFCOUNT_BITS, .type =3D QEMU_OPT_NUMBER, diff --git a/block/qcow2.h b/block/qcow2.h index 60e4bf963e..ea76f51cb0 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -217,13 +217,16 @@ enum { QCOW2_INCOMPAT_DIRTY_BITNR =3D 0, QCOW2_INCOMPAT_CORRUPT_BITNR =3D 1, QCOW2_INCOMPAT_DATA_FILE_BITNR =3D 2, + QCOW2_INCOMPAT_EXTL2_BITNR =3D 3, QCOW2_INCOMPAT_DIRTY =3D 1 << QCOW2_INCOMPAT_DIRTY_BITNR, QCOW2_INCOMPAT_CORRUPT =3D 1 << QCOW2_INCOMPAT_CORRUPT_BITNR, QCOW2_INCOMPAT_DATA_FILE =3D 1 << QCOW2_INCOMPAT_DATA_FILE_BITN= R, + QCOW2_INCOMPAT_EXTL2 =3D 1 << QCOW2_INCOMPAT_EXTL2_BITNR, =20 QCOW2_INCOMPAT_MASK =3D QCOW2_INCOMPAT_DIRTY | QCOW2_INCOMPAT_CORRUPT - | QCOW2_INCOMPAT_DATA_FILE, + | QCOW2_INCOMPAT_DATA_FILE + | QCOW2_INCOMPAT_EXTL2, }; =20 /* Compatible feature bits */ @@ -503,8 +506,7 @@ typedef enum QCow2MetadataOverlap { =20 static inline bool has_subclusters(BDRVQcow2State *s) { - /* FIXME: Return false until this feature is complete */ - return false; + return s->incompatible_features & QCOW2_INCOMPAT_EXTL2; } =20 static inline size_t l2_entry_size(BDRVQcow2State *s) diff --git a/include/block/block_int.h b/include/block/block_int.h index 0422acdf1c..cfcc32d1c7 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -57,6 +57,7 @@ #define BLOCK_OPT_REFCOUNT_BITS "refcount_bits" #define BLOCK_OPT_DATA_FILE "data_file" #define BLOCK_OPT_DATA_FILE_RAW "data_file_raw" +#define BLOCK_OPT_EXTL2 "extended_l2" =20 #define BLOCK_PROBE_BUF_SIZE 512 =20 diff --git a/qapi/block-core.json b/qapi/block-core.json index e6edd641f1..72e04a47d1 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -85,6 +85,7 @@ 'compat': 'str', '*data-file': 'str', '*data-file-raw': 'bool', + '*extended-l2': 'bool', '*lazy-refcounts': 'bool', '*corrupt': 'bool', 'refcount-bits': 'int', @@ -4315,6 +4316,7 @@ 'data': { 'file': 'BlockdevRef', '*data-file': 'BlockdevRef', '*data-file-raw': 'bool', + '*extended-l2': 'bool', 'size': 'size', '*version': 'BlockdevQcow2Version', '*backing-file': 'str', diff --git a/tests/qemu-iotests/031.out b/tests/qemu-iotests/031.out index 68a74d03b9..614950be56 100644 --- a/tests/qemu-iotests/031.out +++ b/tests/qemu-iotests/031.out @@ -117,7 +117,7 @@ header_length 104 =20 Header extension: magic 0x6803f857 -length 192 +length 240 data =20 Header extension: @@ -150,7 +150,7 @@ header_length 104 =20 Header extension: magic 0x6803f857 -length 192 +length 240 data =20 Header extension: @@ -164,7 +164,7 @@ No errors were found on the image. =20 magic 0x514649fb version 3 -backing_file_offset 0x178 +backing_file_offset 0x1a8 backing_file_size 0x17 cluster_bits 16 size 67108864 @@ -188,7 +188,7 @@ data 'host_device' =20 Header extension: magic 0x6803f857 -length 192 +length 240 data =20 Header extension: diff --git a/tests/qemu-iotests/036.out b/tests/qemu-iotests/036.out index e489b44386..c7e6512b43 100644 --- a/tests/qemu-iotests/036.out +++ b/tests/qemu-iotests/036.out @@ -58,7 +58,7 @@ header_length 104 =20 Header extension: magic 0x6803f857 -length 192 +length 240 data =20 =20 @@ -86,7 +86,7 @@ header_length 104 =20 Header extension: magic 0x6803f857 -length 192 +length 240 data =20 *** done diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out index 6b505408dd..ba4b42fd58 100644 --- a/tests/qemu-iotests/049.out +++ b/tests/qemu-iotests/049.out @@ -4,90 +4,90 @@ QA output created by 049 =3D=3D 1. Traditional size parameter =3D=3D =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024b -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1k -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1K -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1048576 cluster_size=3D6= 5536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1048576 cluster_size=3D6= 5536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1G -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1073741824 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1073741824 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1T -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1099511627776 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1099511627776 cluster_si= ze=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024.0 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024.0b -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5k -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1536 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1536 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5K -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1536 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1536 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1572864 cluster_size=3D6= 5536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1572864 cluster_size=3D6= 5536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5G -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1610612736 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1610612736 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5T -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1649267441664 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1649267441664 cluster_si= ze=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 =3D=3D 2. Specifying size via -o =3D=3D =20 qemu-img create -f qcow2 -o size=3D1024 TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1024b TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1k TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1K TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1M TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1048576 cluster_size=3D6= 5536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1048576 cluster_size=3D6= 5536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1G TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1073741824 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1073741824 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1T TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1099511627776 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1099511627776 cluster_si= ze=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1024.0 TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1024.0b TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1.5k TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1536 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1536 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1.5K TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1536 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1536 cluster_size=3D6553= 6 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1.5M TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1572864 cluster_size=3D6= 5536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1572864 cluster_size=3D6= 5536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1.5G TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1610612736 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1610612736 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1.5T TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1649267441664 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1649267441664 cluster_si= ze=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 =3D=3D 3. Invalid sizes =3D=3D =20 @@ -124,84 +124,84 @@ and exabytes, respectively. =3D=3D Check correct interpretation of suffixes for cluster size =3D=3D =20 qemu-img create -f qcow2 -o cluster_size=3D1024 TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D1024b TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D1k TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D1K TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D1M TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1048576 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1048576 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D1024.0 TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D1024.0b TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D0.5k TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 512 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 512 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D0.5K TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 512 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 512 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D0.5M TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 524288 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 524288 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 =3D=3D Check compat level option =3D=3D =20 qemu-img create -f qcow2 -o compat=3D0.10 TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.10 c= luster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.10 c= luster_size=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D= 16 =20 qemu-img create -f qcow2 -o compat=3D1.1 TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D1.1 cl= uster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D1.1 cl= uster_size=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o compat=3D0.42 TEST_DIR/t.qcow2 64M qemu-img: TEST_DIR/t.qcow2: Invalid parameter '0.42' -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.42 c= luster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.42 c= luster_size=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D= 16 =20 qemu-img create -f qcow2 -o compat=3Dfoobar TEST_DIR/t.qcow2 64M qemu-img: TEST_DIR/t.qcow2: Invalid parameter 'foobar' -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3Dfoobar= cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3Dfoobar= cluster_size=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits= =3D16 =20 =3D=3D Check preallocation option =3D=3D =20 qemu-img create -f qcow2 -o preallocation=3Doff TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 65536 preallocation=3Doff lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 65536 preallocation=3Doff lazy_refcounts=3Doff extended_l2=3Doff refcount_b= its=3D16 =20 qemu-img create -f qcow2 -o preallocation=3Dmetadata TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 65536 preallocation=3Dmetadata lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 65536 preallocation=3Dmetadata lazy_refcounts=3Doff extended_l2=3Doff refco= unt_bits=3D16 =20 qemu-img create -f qcow2 -o preallocation=3D1234 TEST_DIR/t.qcow2 64M qemu-img: TEST_DIR/t.qcow2: Invalid parameter '1234' -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 65536 preallocation=3D1234 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 65536 preallocation=3D1234 lazy_refcounts=3Doff extended_l2=3Doff refcount_= bits=3D16 =20 =3D=3D Check encryption option =3D=3D =20 qemu-img create -f qcow2 -o encryption=3Doff TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 encryption=3Dof= f cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 encryption=3Dof= f cluster_size=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits= =3D16 =20 qemu-img create -f qcow2 --object secret,id=3Dsec0,data=3D123456 -o encryp= tion=3Don,encrypt.key-secret=3Dsec0 TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 encryption=3Don= encrypt.key-secret=3Dsec0 cluster_size=3D65536 lazy_refcounts=3Doff refcou= nt_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 encryption=3Don= encrypt.key-secret=3Dsec0 cluster_size=3D65536 lazy_refcounts=3Doff extend= ed_l2=3Doff refcount_bits=3D16 =20 =3D=3D Check lazy_refcounts option (only with v3) =3D=3D =20 qemu-img create -f qcow2 -o compat=3D1.1,lazy_refcounts=3Doff TEST_DIR/t.q= cow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D1.1 cl= uster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D1.1 cl= uster_size=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o compat=3D1.1,lazy_refcounts=3Don TEST_DIR/t.qc= ow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D1.1 cl= uster_size=3D65536 lazy_refcounts=3Don refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D1.1 cl= uster_size=3D65536 lazy_refcounts=3Don extended_l2=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o compat=3D0.10,lazy_refcounts=3Doff TEST_DIR/t.= qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.10 c= luster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.10 c= luster_size=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D= 16 =20 qemu-img create -f qcow2 -o compat=3D0.10,lazy_refcounts=3Don TEST_DIR/t.q= cow2 64M qemu-img: TEST_DIR/t.qcow2: Lazy refcounts only supported with compatibili= ty level 1.1 and above (use version=3Dv3 or greater) -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.10 c= luster_size=3D65536 lazy_refcounts=3Don refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.10 c= luster_size=3D65536 lazy_refcounts=3Don extended_l2=3Doff refcount_bits=3D16 =20 *** done diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out index 0f6b0658a1..1f6ae50027 100644 --- a/tests/qemu-iotests/060.out +++ b/tests/qemu-iotests/060.out @@ -20,6 +20,7 @@ Format specific information: lazy refcounts: false refcount bits: 16 corrupt: true + extended l2: false qemu-io: can't open device TEST_DIR/t.IMGFMT: IMGFMT: Image is corrupt; ca= nnot be opened read/write no file open, try 'help open' read 512/512 bytes at offset 0 diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out index d6a7c2af95..96a6933554 100644 --- a/tests/qemu-iotests/061.out +++ b/tests/qemu-iotests/061.out @@ -26,7 +26,7 @@ header_length 104 =20 Header extension: magic 0x6803f857 -length 192 +length 240 data =20 magic 0x514649fb @@ -84,7 +84,7 @@ header_length 104 =20 Header extension: magic 0x6803f857 -length 192 +length 240 data =20 magic 0x514649fb @@ -140,7 +140,7 @@ header_length 104 =20 Header extension: magic 0x6803f857 -length 192 +length 240 data =20 ERROR cluster 5 refcount=3D0 reference=3D1 @@ -195,7 +195,7 @@ header_length 104 =20 Header extension: magic 0x6803f857 -length 192 +length 240 data =20 magic 0x514649fb @@ -264,7 +264,7 @@ header_length 104 =20 Header extension: magic 0x6803f857 -length 192 +length 240 data =20 read 65536/65536 bytes at offset 44040192 @@ -298,7 +298,7 @@ header_length 104 =20 Header extension: magic 0x6803f857 -length 192 +length 240 data =20 ERROR cluster 5 refcount=3D0 reference=3D1 @@ -327,7 +327,7 @@ header_length 104 =20 Header extension: magic 0x6803f857 -length 192 +length 240 data =20 read 131072/131072 bytes at offset 0 @@ -496,6 +496,7 @@ Format specific information: data file: TEST_DIR/t.IMGFMT.data data file raw: false corrupt: false + extended l2: false No errors were found on the image. =20 =3D=3D=3D Try changing the external data file =3D=3D=3D @@ -516,6 +517,7 @@ Format specific information: data file: foo data file raw: false corrupt: false + extended l2: false =20 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'data-file' is required for = this image image: TEST_DIR/t.IMGFMT @@ -528,6 +530,7 @@ Format specific information: refcount bits: 16 data file raw: false corrupt: false + extended l2: false =20 =3D=3D=3D Clearing and setting data-file-raw =3D=3D=3D =20 @@ -543,6 +546,7 @@ Format specific information: data file: TEST_DIR/t.IMGFMT.data data file raw: true corrupt: false + extended l2: false No errors were found on the image. image: TEST_DIR/t.IMGFMT file format: IMGFMT @@ -555,6 +559,7 @@ Format specific information: data file: TEST_DIR/t.IMGFMT.data data file raw: false corrupt: false + extended l2: false No errors were found on the image. qemu-img: data-file-raw cannot be set on existing images image: TEST_DIR/t.IMGFMT @@ -568,5 +573,6 @@ Format specific information: data file: TEST_DIR/t.IMGFMT.data data file raw: false corrupt: false + extended l2: false No errors were found on the image. *** done diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065 index 5b21eb96bd..7d3a137434 100755 --- a/tests/qemu-iotests/065 +++ b/tests/qemu-iotests/065 @@ -95,17 +95,21 @@ class TestQCow3NotLazy(TestQemuImgInfo): '''Testing a qcow2 version 3 image with lazy refcounts disabled''' img_options =3D 'compat=3D1.1,lazy_refcounts=3Doff' json_compare =3D { 'compat': '1.1', 'lazy-refcounts': False, - 'refcount-bits': 16, 'corrupt': False } + 'refcount-bits': 16, 'corrupt': False, + 'extended-l2': False } human_compare =3D [ 'compat: 1.1', 'lazy refcounts: false', - 'refcount bits: 16', 'corrupt: false' ] + 'refcount bits: 16', 'corrupt: false', + 'extended l2: false' ] =20 class TestQCow3Lazy(TestQemuImgInfo): '''Testing a qcow2 version 3 image with lazy refcounts enabled''' img_options =3D 'compat=3D1.1,lazy_refcounts=3Don' json_compare =3D { 'compat': '1.1', 'lazy-refcounts': True, - 'refcount-bits': 16, 'corrupt': False } + 'refcount-bits': 16, 'corrupt': False, + 'extended-l2': False } human_compare =3D [ 'compat: 1.1', 'lazy refcounts: true', - 'refcount bits: 16', 'corrupt: false' ] + 'refcount bits: 16', 'corrupt: false', + 'extended l2: false' ] =20 class TestQCow3NotLazyQMP(TestQMP): '''Testing a qcow2 version 3 image with lazy refcounts disabled, openi= ng @@ -113,7 +117,8 @@ class TestQCow3NotLazyQMP(TestQMP): img_options =3D 'compat=3D1.1,lazy_refcounts=3Doff' qemu_options =3D 'lazy-refcounts=3Don' compare =3D { 'compat': '1.1', 'lazy-refcounts': False, - 'refcount-bits': 16, 'corrupt': False } + 'refcount-bits': 16, 'corrupt': False, + 'extended-l2': False } =20 =20 class TestQCow3LazyQMP(TestQMP): @@ -122,7 +127,8 @@ class TestQCow3LazyQMP(TestQMP): img_options =3D 'compat=3D1.1,lazy_refcounts=3Don' qemu_options =3D 'lazy-refcounts=3Doff' compare =3D { 'compat': '1.1', 'lazy-refcounts': True, - 'refcount-bits': 16, 'corrupt': False } + 'refcount-bits': 16, 'corrupt': False, + 'extended-l2': False } =20 TestImageInfoSpecific =3D None TestQemuImgInfo =3D None diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out index 9d4ed4dc9d..2a01e8bac2 100644 --- a/tests/qemu-iotests/082.out +++ b/tests/qemu-iotests/082.out @@ -3,14 +3,14 @@ QA output created by 082 =3D=3D=3D create: Options specified more than once =3D=3D=3D =20 Testing: create -f foo -f qcow2 TEST_DIR/t.qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 128 MiB (134217728 bytes) cluster_size: 65536 =20 Testing: create -f qcow2 -o cluster_size=3D4k -o lazy_refcounts=3Don TEST_= DIR/t.qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D4096 lazy_refcounts=3Don refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D4096 lazy_refcounts=3Don extended_l2=3Doff refcount_bits=3D16 image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 128 MiB (134217728 bytes) @@ -20,9 +20,10 @@ Format specific information: lazy refcounts: true refcount bits: 16 corrupt: false + extended l2: false =20 Testing: create -f qcow2 -o cluster_size=3D4k -o lazy_refcounts=3Don -o cl= uster_size=3D8k TEST_DIR/t.qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D8192 lazy_refcounts=3Don refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D8192 lazy_refcounts=3Don extended_l2=3Doff refcount_bits=3D16 image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 128 MiB (134217728 bytes) @@ -32,9 +33,10 @@ Format specific information: lazy refcounts: true refcount bits: 16 corrupt: false + extended l2: false =20 Testing: create -f qcow2 -o cluster_size=3D4k,cluster_size=3D8k TEST_DIR/t= .qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D8192 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D8192 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 128 MiB (134217728 bytes) @@ -59,6 +61,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -82,6 +85,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -105,6 +109,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -128,6 +133,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -151,6 +157,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -174,6 +181,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -197,6 +205,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -220,6 +229,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -227,10 +237,10 @@ Supported options: size=3D - Virtual disk size =20 Testing: create -f qcow2 -u -o backing_file=3DTEST_DIR/t.qcow2,,help TEST_= DIR/t.qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 backing_file= =3DTEST_DIR/t.qcow2,,help cluster_size=3D65536 lazy_refcounts=3Doff refcoun= t_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 backing_file= =3DTEST_DIR/t.qcow2,,help cluster_size=3D65536 lazy_refcounts=3Doff extende= d_l2=3Doff refcount_bits=3D16 =20 Testing: create -f qcow2 -u -o backing_file=3DTEST_DIR/t.qcow2,,? TEST_DIR= /t.qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 backing_file= =3DTEST_DIR/t.qcow2,,? cluster_size=3D65536 lazy_refcounts=3Doff refcount_b= its=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 backing_file= =3DTEST_DIR/t.qcow2,,? cluster_size=3D65536 lazy_refcounts=3Doff extended_l= 2=3Doff refcount_bits=3D16 =20 Testing: create -f qcow2 -o backing_file=3DTEST_DIR/t.qcow2, -o help TEST_= DIR/t.qcow2 128M qemu-img: Invalid option list: backing_file=3DTEST_DIR/t.qcow2, @@ -258,6 +268,7 @@ Supported qcow2 options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits @@ -279,7 +290,7 @@ qemu-img: Format driver 'bochs' does not support image = creation =3D=3D=3D convert: Options specified more than once =3D=3D=3D =20 Testing: create -f qcow2 TEST_DIR/t.qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 Testing: convert -f foo -f qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base image: TEST_DIR/t.IMGFMT.base @@ -302,6 +313,7 @@ Format specific information: lazy refcounts: true refcount bits: 16 corrupt: false + extended l2: false =20 Testing: convert -O qcow2 -o cluster_size=3D4k -o lazy_refcounts=3Don -o c= luster_size=3D8k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base image: TEST_DIR/t.IMGFMT.base @@ -313,6 +325,7 @@ Format specific information: lazy refcounts: true refcount bits: 16 corrupt: false + extended l2: false =20 Testing: convert -O qcow2 -o cluster_size=3D4k,cluster_size=3D8k TEST_DIR/= t.qcow2 TEST_DIR/t.qcow2.base image: TEST_DIR/t.IMGFMT.base @@ -339,6 +352,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -362,6 +376,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -385,6 +400,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -408,6 +424,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -431,6 +448,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -454,6 +472,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -477,6 +496,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -500,6 +520,7 @@ Supported options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -538,6 +559,7 @@ Supported qcow2 options: encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits @@ -582,6 +604,7 @@ Format specific information: lazy refcounts: true refcount bits: 16 corrupt: false + extended l2: false =20 Testing: amend -f qcow2 -o size=3D130M -o lazy_refcounts=3Doff TEST_DIR/t.= qcow2 image: TEST_DIR/t.IMGFMT @@ -593,6 +616,7 @@ Format specific information: lazy refcounts: false refcount bits: 16 corrupt: false + extended l2: false =20 Testing: amend -f qcow2 -o size=3D8M -o lazy_refcounts=3Don -o size=3D132M= TEST_DIR/t.qcow2 image: TEST_DIR/t.IMGFMT @@ -604,6 +628,7 @@ Format specific information: lazy refcounts: true refcount bits: 16 corrupt: false + extended l2: false =20 Testing: amend -f qcow2 -o size=3D4M,size=3D148M TEST_DIR/t.qcow2 image: TEST_DIR/t.IMGFMT @@ -630,6 +655,7 @@ Creation options for 'qcow2': encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits @@ -654,6 +680,7 @@ Creation options for 'qcow2': encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits @@ -678,6 +705,7 @@ Creation options for 'qcow2': encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits @@ -702,6 +730,7 @@ Creation options for 'qcow2': encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits @@ -726,6 +755,7 @@ Creation options for 'qcow2': encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits @@ -750,6 +780,7 @@ Creation options for 'qcow2': encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits @@ -774,6 +805,7 @@ Creation options for 'qcow2': encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits @@ -798,6 +830,7 @@ Creation options for 'qcow2': encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits @@ -839,6 +872,7 @@ Creation options for 'qcow2': encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) + extended_l2=3D - Extended L2 tables lazy_refcounts=3D - Postpone refcount updates preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out index 2a5f256cd3..62e7fd82a7 100644 --- a/tests/qemu-iotests/085.out +++ b/tests/qemu-iotests/085.out @@ -11,7 +11,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D13421= 7728 =20 =3D=3D=3D Create a single snapshot on virtio0 =3D=3D=3D =20 -Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/t.qcow2.1 backing_fmt=3Dqcow2 cluster_size=3D65536 la= zy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/t.qcow2.1 backing_fmt=3Dqcow2 cluster_size=3D65536 la= zy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} =20 =3D=3D=3D Invalid command - missing device and nodename =3D=3D=3D @@ -25,32 +25,32 @@ Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=3Dqcow2 = size=3D134217728 backing_file =20 =3D=3D=3D Create several transactional group snapshots =3D=3D=3D =20 -Formatting 'TEST_DIR/2-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/1-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 -Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/t.qcow2.2 backing_fmt=3Dqcow2 cluster_size=3D65536 la= zy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/2-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/1-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/t.qcow2.2 backing_fmt=3Dqcow2 cluster_size=3D65536 la= zy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} -Formatting 'TEST_DIR/3-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/2-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 -Formatting 'TEST_DIR/3-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/2-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/3-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/2-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/3-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/2-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} -Formatting 'TEST_DIR/4-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/3-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 -Formatting 'TEST_DIR/4-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/3-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/4-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/3-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/4-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/3-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} -Formatting 'TEST_DIR/5-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/4-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 -Formatting 'TEST_DIR/5-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/4-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/5-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/4-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/5-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/4-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} -Formatting 'TEST_DIR/6-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/5-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 -Formatting 'TEST_DIR/6-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/5-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/6-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/5-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/6-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/5-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} -Formatting 'TEST_DIR/7-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/6-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 -Formatting 'TEST_DIR/7-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/6-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/7-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/6-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/7-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/6-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} -Formatting 'TEST_DIR/8-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/7-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 -Formatting 'TEST_DIR/8-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/7-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/8-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/7-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/8-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/7-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} -Formatting 'TEST_DIR/9-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/8-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 -Formatting 'TEST_DIR/9-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/8-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/9-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/8-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/9-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/8-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} -Formatting 'TEST_DIR/10-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 b= acking_file=3DTEST_DIR/9-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 -Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 b= acking_file=3DTEST_DIR/9-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/10-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 b= acking_file=3DTEST_DIR/9-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 b= acking_file=3DTEST_DIR/9-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} =20 =3D=3D=3D Create a couple of snapshots using blockdev-snapshot =3D=3D=3D diff --git a/tests/qemu-iotests/144.out b/tests/qemu-iotests/144.out index a9a8216bea..7bf05253cc 100644 --- a/tests/qemu-iotests/144.out +++ b/tests/qemu-iotests/144.out @@ -7,7 +7,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D5368709= 12 =3D=3D=3D Performing Live Snapshot 1 =3D=3D=3D =20 {"return": {}} -Formatting 'TEST_DIR/tmp.qcow2', fmt=3Dqcow2 size=3D536870912 backing_file= =3DTEST_DIR/t.qcow2 backing_fmt=3Dqcow2 cluster_size=3D65536 lazy_refcounts= =3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/tmp.qcow2', fmt=3Dqcow2 size=3D536870912 backing_file= =3DTEST_DIR/t.qcow2 backing_fmt=3Dqcow2 cluster_size=3D65536 lazy_refcounts= =3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} =20 =3D=3D=3D Performing block-commit on active layer =3D=3D=3D @@ -26,6 +26,6 @@ Formatting 'TEST_DIR/tmp.qcow2', fmt=3Dqcow2 size=3D53687= 0912 backing_file=3DTEST_DIR/ =20 =3D=3D=3D Performing Live Snapshot 2 =3D=3D=3D =20 -Formatting 'TEST_DIR/tmp2.qcow2', fmt=3Dqcow2 size=3D536870912 backing_fil= e=3DTEST_DIR/t.qcow2 backing_fmt=3Dqcow2 cluster_size=3D65536 lazy_refcount= s=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/tmp2.qcow2', fmt=3Dqcow2 size=3D536870912 backing_fil= e=3DTEST_DIR/t.qcow2 backing_fmt=3Dqcow2 cluster_size=3D65536 lazy_refcount= s=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} *** done diff --git a/tests/qemu-iotests/182.out b/tests/qemu-iotests/182.out index ffef23e32b..78e2d51761 100644 --- a/tests/qemu-iotests/182.out +++ b/tests/qemu-iotests/182.out @@ -10,7 +10,7 @@ Is another process using the image [TEST_DIR/t.qcow2]? =20 {"return": {}} {"return": {}} -Formatting 'TEST_DIR/t.qcow2.overlay', fmt=3Dqcow2 size=3D197120 backing_f= ile=3DTEST_DIR/t.qcow2 backing_fmt=3Dfile cluster_size=3D65536 lazy_refcoun= ts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2.overlay', fmt=3Dqcow2 size=3D197120 backing_f= ile=3DTEST_DIR/t.qcow2 backing_fmt=3Dfile cluster_size=3D65536 lazy_refcoun= ts=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} {"return": {}} {"return": {}} diff --git a/tests/qemu-iotests/185.out b/tests/qemu-iotests/185.out index ddfbf3c765..eaab057fed 100644 --- a/tests/qemu-iotests/185.out +++ b/tests/qemu-iotests/185.out @@ -7,12 +7,12 @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D= 67108864 =20 =3D=3D=3D Creating backing chain =3D=3D=3D =20 -Formatting 'TEST_DIR/t.qcow2.mid', fmt=3Dqcow2 size=3D67108864 backing_fil= e=3DTEST_DIR/t.qcow2.base backing_fmt=3Dqcow2 cluster_size=3D65536 lazy_ref= counts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2.mid', fmt=3Dqcow2 size=3D67108864 backing_fil= e=3DTEST_DIR/t.qcow2.base backing_fmt=3Dqcow2 cluster_size=3D65536 lazy_ref= counts=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} wrote 4194304/4194304 bytes at offset 0 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 backing_file=3D= TEST_DIR/t.qcow2.mid backing_fmt=3Dqcow2 cluster_size=3D65536 lazy_refcount= s=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 backing_file=3D= TEST_DIR/t.qcow2.mid backing_fmt=3Dqcow2 cluster_size=3D65536 lazy_refcount= s=3Doff extended_l2=3Doff refcount_bits=3D16 {"return": {}} =20 =3D=3D=3D Start commit job and exit qemu =3D=3D=3D @@ -37,7 +37,7 @@ Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D6710886= 4 backing_file=3DTEST_DIR/t.q =3D=3D=3D Start mirror job and exit qemu =3D=3D=3D =20 {"return": {}} -Formatting 'TEST_DIR/t.qcow2.copy', fmt=3Dqcow2 size=3D67108864 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2.copy', fmt=3Dqcow2 size=3D67108864 cluster_si= ze=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} {"return": {}} @@ -48,7 +48,7 @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=3Dqcow2 size=3D67= 108864 cluster_size=3D65536 l =3D=3D=3D Start backup job and exit qemu =3D=3D=3D =20 {"return": {}} -Formatting 'TEST_DIR/t.qcow2.copy', fmt=3Dqcow2 size=3D67108864 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/t.qcow2.copy', fmt=3Dqcow2 size=3D67108864 cluster_si= ze=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} {"return": {}} diff --git a/tests/qemu-iotests/198.out b/tests/qemu-iotests/198.out index e86b175e39..e46dccdb08 100644 --- a/tests/qemu-iotests/198.out +++ b/tests/qemu-iotests/198.out @@ -72,6 +72,7 @@ Format specific information: key offset: 1810432 payload offset: 2068480 master key iters: 1024 + extended l2: false =20 =3D=3D checking image layer =3D=3D image: json:{"encrypt.key-secret": "sec1", "driver": "IMGFMT", "file": {"d= river": "file", "filename": "TEST_DIR/t.IMGFMT"}} @@ -115,4 +116,5 @@ Format specific information: key offset: 1810432 payload offset: 2068480 master key iters: 1024 + extended l2: false *** done diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out index 61e7241e0b..d2efc0394a 100644 --- a/tests/qemu-iotests/206.out +++ b/tests/qemu-iotests/206.out @@ -21,6 +21,7 @@ Format specific information: lazy refcounts: false refcount bits: 16 corrupt: false + extended l2: false =20 =3D=3D=3D Successful image creation (inline blockdev-add, explicit default= s) =3D=3D=3D =20 @@ -43,6 +44,7 @@ Format specific information: lazy refcounts: false refcount bits: 16 corrupt: false + extended l2: false =20 =3D=3D=3D Successful image creation (v3 non-default options) =3D=3D=3D =20 @@ -65,6 +67,7 @@ Format specific information: lazy refcounts: true refcount bits: 1 corrupt: false + extended l2: false =20 =3D=3D=3D Successful image creation (v2 non-default options) =3D=3D=3D =20 @@ -141,6 +144,7 @@ Format specific information: payload offset: 528384 master key iters: XXX corrupt: false + extended l2: false =20 =3D=3D=3D Invalid BlockdevRef =3D=3D=3D =20 diff --git a/tests/qemu-iotests/242.out b/tests/qemu-iotests/242.out index 7ac8404d11..0d32dd9148 100644 --- a/tests/qemu-iotests/242.out +++ b/tests/qemu-iotests/242.out @@ -15,6 +15,7 @@ Format specific information: lazy refcounts: false refcount bits: 16 corrupt: false + extended l2: false =20 No bitmap in JSON format output =20 @@ -40,6 +41,7 @@ Format specific information: granularity: 32768 refcount bits: 16 corrupt: false + extended l2: false =20 The same bitmaps in JSON format: [ @@ -77,6 +79,7 @@ Format specific information: granularity: 65536 refcount bits: 16 corrupt: false + extended l2: false =20 The same bitmaps in JSON format: [ @@ -119,6 +122,7 @@ Format specific information: granularity: 65536 refcount bits: 16 corrupt: false + extended l2: false =20 The same bitmaps in JSON format: [ @@ -162,5 +166,6 @@ Format specific information: granularity: 16384 refcount bits: 16 corrupt: false + extended l2: false =20 Test complete diff --git a/tests/qemu-iotests/255.out b/tests/qemu-iotests/255.out index 348909fdef..4e1b917a0f 100644 --- a/tests/qemu-iotests/255.out +++ b/tests/qemu-iotests/255.out @@ -3,9 +3,9 @@ Finishing a commit job with background reads =20 =3D=3D=3D Create backing chain and start VM =3D=3D=3D =20 -Formatting 'TEST_DIR/PID-t.qcow2.mid', fmt=3Dqcow2 size=3D134217728 cluste= r_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/PID-t.qcow2.mid', fmt=3Dqcow2 size=3D134217728 cluste= r_size=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/PID-t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_si= ze=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 =3D=3D=3D Start background read requests =3D=3D=3D =20 @@ -23,9 +23,9 @@ Closing the VM while a job is being cancelled =20 =3D=3D=3D Create images and start VM =3D=3D=3D =20 -Formatting 'TEST_DIR/PID-src.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_= size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/PID-src.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_= size=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-dst.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_= size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/PID-dst.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_= size=3D65536 lazy_refcounts=3Doff extended_l2=3Doff refcount_bits=3D16 =20 wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.f= ilter index 9f418b4881..45c0fe746b 100644 --- a/tests/qemu-iotests/common.filter +++ b/tests/qemu-iotests/common.filter @@ -137,6 +137,7 @@ _filter_img_create() -e "s# adapter_type=3D[^ ]*##g" \ -e "s# hwversion=3D[^ ]*##g" \ -e "s# lazy_refcounts=3D\\(on\\|off\\)##g" \ + -e "s# extended_l2=3D\\(on\\|off\\)##g" \ -e "s# block_size=3D[0-9]\\+##g" \ -e "s# block_state_zero=3D\\(on\\|off\\)##g" \ -e "s# log_size=3D[0-9]\\+##g" \ --=20 2.20.1