From nobody Wed May 22 03:10:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1697839061; cv=none; d=zohomail.com; s=zohoarc; b=dLok+MWfPZ0M8+2x5yRmPRlNOz9FxS/lb82sbZz8znbe/l/vIA5Z/WoeUZWFVmfwawspf+6H9+0E4/V7OTYf+1rdlmc2zh9N3vHz4aKeNaMHvFmc8STs+rG7kCSuY2oaFEZpGudskg6ED6txzAdW83hS00achJTRBkWm0WVPJyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697839061; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iHfVvyVjq4g5YNZ0DhXc240zSGDlc6cdMexUlDF6B1U=; b=MUwUUpHPNYr/x4cBBf0Uv9/J0P8AtoyYiC8lA0Nn+L+CIAeqpWKL6kcvw/gcsp8uQ6abkxL2fgxyWHJsj4URdOLz2jtHYcZo1Fd09pyOVYKDyV0u8OcsJX9QmygnNqZKtXPIl2zmjj7DSX8XSjCcmUhpen4UxOQ2ZOpbu3IijQs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697839061735705.9520215100456; Fri, 20 Oct 2023 14:57:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtxTy-0003rO-1i; Fri, 20 Oct 2023 17:56:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTu-0003pO-AW; Fri, 20 Oct 2023 17:56:35 -0400 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTq-0008G5-Mz; Fri, 20 Oct 2023 17:56:33 -0400 Received: from [130.117.225.1] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1qtxTT-00A9pF-1k; Fri, 20 Oct 2023 23:56:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=iHfVvyVjq4g5YNZ0DhXc240zSGDlc6cdMexUlDF6B1U=; b=inFcDJSPdY6O yEuiW+4CnlCEsWiwFYN31xijQPeJ9saVyjqYdoIPW1F940fSNmRGoDBt8bb9CANQK6dh0x7N685KY fwc36Q5AId6jcjqiMh5irTzH9GebcUutkjNC3XhXjKm9QvPeGZQ3I/Fadf6Ik80Korslllhzte0jG pSDC0+iJjFx4lOQqVuqhH0hww1/N4xLoTD0F8yT1mgiUKCo61uK6aC3JE2yInANHVvKOgThCUgw2+ P4EFoio/P5riIunsvANW3Ut8n6aTOwz59cCUqVliro28I760cQFnWKlPL6gT+7SX9zMHmwWaNJ5nX vVWPbQl7zcfowYpBaI1tgg==; From: Andrey Drobyshev To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, berto@igalia.com, andrey.drobyshev@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 1/7] qcow2: make function update_refcount_discard() global Date: Sat, 21 Oct 2023 00:56:16 +0300 Message-Id: <20231020215622.789260-2-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> References: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1697839062309100002 Content-Type: text/plain; charset="utf-8" We are going to need it for discarding separate subclusters. The function itself doesn't do anything with the refcount tables, it simply adds a discard request to the queue, so rename it to qcow2_queue_discard(). Signed-off-by: Andrey Drobyshev Reviewed-by: Hanna Czenczek --- block/qcow2-refcount.c | 8 ++++---- block/qcow2.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 0266542cee..2026f5fa21 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -754,8 +754,8 @@ void qcow2_process_discards(BlockDriverState *bs, int r= et) } } =20 -static void update_refcount_discard(BlockDriverState *bs, - uint64_t offset, uint64_t length) +void qcow2_queue_discard(BlockDriverState *bs, uint64_t offset, + uint64_t length) { BDRVQcow2State *s =3D bs->opaque; Qcow2DiscardRegion *d, *p, *next; @@ -902,7 +902,7 @@ update_refcount(BlockDriverState *bs, int64_t offset, i= nt64_t length, } =20 if (s->discard_passthrough[type]) { - update_refcount_discard(bs, cluster_offset, s->cluster_siz= e); + qcow2_queue_discard(bs, cluster_offset, s->cluster_size); } } } @@ -3619,7 +3619,7 @@ qcow2_discard_refcount_block(BlockDriverState *bs, ui= nt64_t discard_block_offs) /* discard refblock from the cache if refblock is cached */ qcow2_cache_discard(s->refcount_block_cache, refblock); } - update_refcount_discard(bs, discard_block_offs, s->cluster_size); + qcow2_queue_discard(bs, discard_block_offs, s->cluster_size); =20 return 0; } diff --git a/block/qcow2.h b/block/qcow2.h index 29958c512b..75d6a1b61b 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -891,6 +891,8 @@ int coroutine_fn qcow2_check_refcounts(BlockDriverState= *bs, BdrvCheckResult *re BdrvCheckMode fix); =20 void qcow2_process_discards(BlockDriverState *bs, int ret); +void qcow2_queue_discard(BlockDriverState *bs, uint64_t offset, + uint64_t length); =20 int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t of= fset, int64_t size); --=20 2.39.3 From nobody Wed May 22 03:10:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1697839091; cv=none; d=zohomail.com; s=zohoarc; b=BskH+r3lFKHuEaPx8/suOwMPHBQETtJGDz3Li1xDoFJ01P6Qq1WvDTLTFMIvrdmll/jkb8OYNRdMqFjENDT5LsD0i1/O3bJbX9OKIlJ2Hp6sOj3y1Cwpwym5QElIER0d9Iab7XNhmcW7g6hdh5u4SMMq85QUppNHXCoD9cq1HMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697839091; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5EW9dBv700hG96A7F9K7bifxv268XKy4vOdbQChMeHA=; b=S0jLzpkvKpceZTM3NHYxuvLwmCyMQIpyAb9mcOBqTN6vR5Glk/dp2qAD5DP2f9pPUfqn/acwwzcxbWLit3z0kQqk5b8SR44hXBhTOpeQlf65dQF+jr54oH9HjxRsaT1brfLhrzzxQBpgxmdg6EyTyA0TwxGhvG/CBUnjYP15NBE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16978390910196.959504090984751; Fri, 20 Oct 2023 14:58:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtxTz-0003sc-BE; Fri, 20 Oct 2023 17:56:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTu-0003pM-A6; Fri, 20 Oct 2023 17:56:35 -0400 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTq-0008Fz-NS; Fri, 20 Oct 2023 17:56:33 -0400 Received: from [130.117.225.1] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1qtxTT-00A9pF-1v; Fri, 20 Oct 2023 23:56:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=5EW9dBv700hG96A7F9K7bifxv268XKy4vOdbQChMeHA=; b=dHxm6Tcexdsh KUVCDk/2TURH/Z+724Ngp6cA7fP6RjGELjEYv5jb9Nn8jFK0xsuXQ8JkiZOVOHmKFIw26BrQrcE1E sr+e+C58RAIi6/hq1vb3nSgedHstWXE6gTLFPc4TBwOy2xHxkq4NHf/Tmh+IFMksoRu/XZ9n53X1W juMWNLq3DZWzHtWJOs9cG5R2s+xJXlQR728nvqbJht8Opb3pCVsqXFQQ28LE7bKFYhh3Nze/Zc09r qTdNagMd/K28u/Z4XO1+BHQY/wEoczX8HHs96K+LIskKJRlfP7+ANxReOJSgUUhyEKJtwLbeYxVHT Yb3aTYCJTqAd/DAaSHa9sw==; From: Andrey Drobyshev To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, berto@igalia.com, andrey.drobyshev@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 2/7] qcow2: add get_sc_range_info() helper for working with subcluster ranges Date: Sat, 21 Oct 2023 00:56:17 +0300 Message-Id: <20231020215622.789260-3-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> References: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1697839092352100001 Content-Type: text/plain; charset="utf-8" This helper simply obtains the l2 table parameters of the cluster which contains the given subclusters range. Right now this info is being obtained and used by zero_l2_subclusters(). As we're about to introduce the subclusters discard operation, this helper would let us avoid code duplication. Also introduce struct SubClusterRangeInfo, which would contain all the needed params. Signed-off-by: Andrey Drobyshev --- block/qcow2-cluster.c | 90 +++++++++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 28 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 904f00d1b3..8801856b93 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -32,6 +32,13 @@ #include "qemu/memalign.h" #include "trace.h" =20 +typedef struct SubClusterRangeInfo { + uint64_t *l2_slice; + int l2_index; + uint64_t l2_entry; + uint64_t l2_bitmap; +} SubClusterRangeInfo; + int coroutine_fn qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t exact_size) { @@ -1892,6 +1899,50 @@ again: return 0; } =20 +static int get_sc_range_info(BlockDriverState *bs, uint64_t offset, + unsigned nb_subclusters, + SubClusterRangeInfo *scri) +{ + BDRVQcow2State *s =3D bs->opaque; + int ret, sc_cleared =3D 0, sc_index =3D offset_to_sc_index(s, offset); + QCow2SubclusterType sctype; + + /* Here we only work with the subclusters within single cluster. */ + assert(nb_subclusters > 0 && nb_subclusters < s->subclusters_per_clust= er); + assert(sc_index + nb_subclusters <=3D s->subclusters_per_cluster); + assert(offset_into_subcluster(s, offset) =3D=3D 0); + + ret =3D get_cluster_table(bs, offset, &scri->l2_slice, &scri->l2_index= ); + if (ret < 0) { + return ret; + } + + scri->l2_entry =3D get_l2_entry(s, scri->l2_slice, scri->l2_index); + scri->l2_bitmap =3D get_l2_bitmap(s, scri->l2_slice, scri->l2_index); + + do { + qcow2_get_subcluster_range_type(bs, scri->l2_entry, scri->l2_bitma= p, + sc_index, &sctype); + if (ret < 0) { + return ret; + } + + switch (sctype) { + case QCOW2_SUBCLUSTER_COMPRESSED: + /* We cannot partially zeroize/discard compressed clusters. */ + return -ENOTSUP; + case QCOW2_SUBCLUSTER_INVALID: + return -EINVAL; + default: + break; + } + + sc_cleared +=3D ret; + } while (sc_cleared < nb_subclusters); + + return 0; +} + /* * This discards as many clusters of nb_clusters as possible at once (i.e. * all clusters in the same L2 slice) and returns the number of discarded @@ -2097,44 +2148,27 @@ zero_l2_subclusters(BlockDriverState *bs, uint64_t = offset, unsigned nb_subclusters) { BDRVQcow2State *s =3D bs->opaque; - uint64_t *l2_slice; - uint64_t old_l2_bitmap, l2_bitmap; - int l2_index, ret, sc =3D offset_to_sc_index(s, offset); + uint64_t new_l2_bitmap; + int ret, sc =3D offset_to_sc_index(s, offset); + SubClusterRangeInfo scri =3D { 0 }; =20 - /* For full clusters use zero_in_l2_slice() instead */ - assert(nb_subclusters > 0 && nb_subclusters < s->subclusters_per_clust= er); - assert(sc + nb_subclusters <=3D s->subclusters_per_cluster); - assert(offset_into_subcluster(s, offset) =3D=3D 0); - - ret =3D get_cluster_table(bs, offset, &l2_slice, &l2_index); + ret =3D get_sc_range_info(bs, offset, nb_subclusters, &scri); if (ret < 0) { - return ret; - } - - switch (qcow2_get_cluster_type(bs, get_l2_entry(s, l2_slice, l2_index)= )) { - case QCOW2_CLUSTER_COMPRESSED: - ret =3D -ENOTSUP; /* We cannot partially zeroize compressed cluste= rs */ goto out; - case QCOW2_CLUSTER_NORMAL: - case QCOW2_CLUSTER_UNALLOCATED: - break; - default: - g_assert_not_reached(); } =20 - old_l2_bitmap =3D l2_bitmap =3D get_l2_bitmap(s, l2_slice, l2_index); - - l2_bitmap |=3D QCOW_OFLAG_SUB_ZERO_RANGE(sc, sc + nb_subclusters); - l2_bitmap &=3D ~QCOW_OFLAG_SUB_ALLOC_RANGE(sc, sc + nb_subclusters); + new_l2_bitmap =3D scri.l2_bitmap; + new_l2_bitmap |=3D QCOW_OFLAG_SUB_ZERO_RANGE(sc, sc + nb_subclusters); + new_l2_bitmap &=3D ~QCOW_OFLAG_SUB_ALLOC_RANGE(sc, sc + nb_subclusters= ); =20 - if (old_l2_bitmap !=3D l2_bitmap) { - set_l2_bitmap(s, l2_slice, l2_index, l2_bitmap); - qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); + if (new_l2_bitmap !=3D scri.l2_bitmap) { + set_l2_bitmap(s, scri.l2_slice, scri.l2_index, new_l2_bitmap); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, scri.l2_slice); } =20 ret =3D 0; out: - qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); + qcow2_cache_put(s->l2_table_cache, (void **) &scri.l2_slice); =20 return ret; } --=20 2.39.3 From nobody Wed May 22 03:10:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1697839097; cv=none; d=zohomail.com; s=zohoarc; b=DUltkJwSTdUoYz6debPYxBXpuvWsLGTvRcLwtAtImq0zvKhKmjGcttfbRR5Z4q4vLwCtWbr+uhpsbkVn94r5fEP07XkF468TxUJ0qN9dzoGssDEJmcmpWHaHb/tsSBxJA/kqOhdDo1RDq6Cu6mFeHA7mNAaPH/P94wN0NmKwMw0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697839097; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AAm3BCi7oLK+rMtTaRnf4YstYpBZyRvRpC4m7z5RCrM=; b=noMTc7uG1pAW27Om/dbu2etdT/y0oF6s6qdp7+PAS0I9y0GD1P0Bd2hj8E5EyTc8krZI601u5UWqhPk3Yk9sVkoV2lyQBL3MVFd8sEZkNBhYKayt7Uz+GcgOvjZUkWe7dsNi5fz3Lj5/rQow/f2uiEEHoLkuQc5dXJvwws+AJ38= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697839097581677.4017994560712; Fri, 20 Oct 2023 14:58:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtxTv-0003pR-9m; Fri, 20 Oct 2023 17:56:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTs-0003nm-RZ; Fri, 20 Oct 2023 17:56:32 -0400 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTq-0008G0-Iw; Fri, 20 Oct 2023 17:56:32 -0400 Received: from [130.117.225.1] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1qtxTT-00A9pF-26; Fri, 20 Oct 2023 23:56:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=AAm3BCi7oLK+rMtTaRnf4YstYpBZyRvRpC4m7z5RCrM=; b=Spc48BusaTgy M2MveG7EpevasYorRVBbYmuwedD8zP1/iGbmEnZwwZcXVtgSJp/o70vPjv4fZ/mtojLoy1xWvdZiw fpTBjmscgIIu9mW+inf9EbmSc0GUNXHycQl31xCMQuTIWGowuzsY1g+IKPooWrxPRpr/mHsXne2xo h5pUJOLhfey1IOW0zFErn4feXRZbEZRre63H9sG7c+q1kUL4J7/x6hX5VVZCipmi3ulbraD8g5gFp PHi6KGc/pA6DgsYFCTxWq7TLpgQ2kXtBZrJoYea4V594TePJUTlCl0blRd/hRd+c28wa8jlIVrJiR W/J280PSxSPN4dwO7HCopw==; From: Andrey Drobyshev To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, berto@igalia.com, andrey.drobyshev@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 3/7] qcow2: zeroize the entire cluster when there're no non-zero subclusters Date: Sat, 21 Oct 2023 00:56:18 +0300 Message-Id: <20231020215622.789260-4-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> References: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1697839098334100001 Content-Type: text/plain; charset="utf-8" When zeroizing the last non-zero subclusters within single cluster, it makes sense to go zeroize the entire cluster and go down zero_in_l2_slice() path right away. That way we'd also update the corresponding refcount table. Signed-off-by: Andrey Drobyshev Reviewed-by: Hanna Czenczek --- block/qcow2-cluster.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 8801856b93..7c6fa5524c 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -2145,7 +2145,7 @@ zero_in_l2_slice(BlockDriverState *bs, uint64_t offse= t, =20 static int coroutine_fn GRAPH_RDLOCK zero_l2_subclusters(BlockDriverState *bs, uint64_t offset, - unsigned nb_subclusters) + unsigned nb_subclusters, int flags) { BDRVQcow2State *s =3D bs->opaque; uint64_t new_l2_bitmap; @@ -2161,6 +2161,17 @@ zero_l2_subclusters(BlockDriverState *bs, uint64_t o= ffset, new_l2_bitmap |=3D QCOW_OFLAG_SUB_ZERO_RANGE(sc, sc + nb_subclusters); new_l2_bitmap &=3D ~QCOW_OFLAG_SUB_ALLOC_RANGE(sc, sc + nb_subclusters= ); =20 + /* + * If there're no non-zero subclusters left, we might as well zeroize + * the entire cluster. That way we'd also update the refcount table. + */ + if ((new_l2_bitmap & QCOW_L2_BITMAP_ALL_ZEROES) =3D=3D + QCOW_L2_BITMAP_ALL_ZEROES) { + qcow2_cache_put(s->l2_table_cache, (void **) &scri.l2_slice); + return zero_in_l2_slice(bs, QEMU_ALIGN_DOWN(offset, s->cluster_siz= e), + 1, flags); + } + if (new_l2_bitmap !=3D scri.l2_bitmap) { set_l2_bitmap(s, scri.l2_slice, scri.l2_index, new_l2_bitmap); qcow2_cache_entry_mark_dirty(s->l2_table_cache, scri.l2_slice); @@ -2221,7 +2232,7 @@ int coroutine_fn qcow2_subcluster_zeroize(BlockDriver= State *bs, uint64_t offset, =20 if (head) { ret =3D zero_l2_subclusters(bs, offset - head, - size_to_subclusters(s, head)); + size_to_subclusters(s, head), flags); if (ret < 0) { goto fail; } @@ -2242,7 +2253,8 @@ int coroutine_fn qcow2_subcluster_zeroize(BlockDriver= State *bs, uint64_t offset, } =20 if (tail) { - ret =3D zero_l2_subclusters(bs, end_offset, size_to_subclusters(s,= tail)); + ret =3D zero_l2_subclusters(bs, end_offset, + size_to_subclusters(s, tail), flags); if (ret < 0) { goto fail; } --=20 2.39.3 From nobody Wed May 22 03:10:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1697839061; cv=none; d=zohomail.com; s=zohoarc; b=ejFtPB3JFOFICaXSadmSDkBX4euP0TpuYfe3Nlz02E6jkGCj2gmSm60/dAGNTjv+vrV8t54lW0EVckKydfyBpHZie/doBGCMKV7NEWIF+xyBcMV82vnn+ZJb6JiLjrdXglpHzzA35CEJD32/g5ddsSGCxfS2AMg1MnEJhEPsF5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697839061; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AOdVB5L+10G1WQ+8o75fKXSttdivBvesl0iH9zSiDRA=; b=dmCWiDEOCmz5qWJDogRbaTCObxnnAE5+SY1pX5Py9kF4tG2+GKNlifDZYGhwK9TG7XieIuUU2rRSmXodW4FEX3C0/3RXQYzKsYpJoyXTndVHbmpdi6lXALOrwokUD3rSrXq5DLXBeaXROEyaCVOwNcWLEW/7MWRT3L10RUD9gmM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697839061352296.06900082232517; Fri, 20 Oct 2023 14:57:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtxU8-0003xp-E7; Fri, 20 Oct 2023 17:56:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTy-0003s4-E5; Fri, 20 Oct 2023 17:56:39 -0400 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTq-0008Fy-M4; Fri, 20 Oct 2023 17:56:38 -0400 Received: from [130.117.225.1] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1qtxTT-00A9pF-2H; Fri, 20 Oct 2023 23:56:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=AOdVB5L+10G1WQ+8o75fKXSttdivBvesl0iH9zSiDRA=; b=RWsp3xhUFTQ3 kVAhfThRyMtF2JWs4amcOI/U/r68AliLrhp+eNS2WWZ+WGI7xIzAUyFy96Tn4SwyDSa0XcnZjD3we 97oaB/FcUDRkBaxM8eFJOPrUFB5yWH1rUsdJ/BlrqmXQytOWeES2uQFyqemCUw+sALC/sYl0BY4p8 LDVMXnQyGh1fnkCNx6RZ50sM+tWkQNrZsyXBxkbCC3G8yjG+prPy5ox9V+Aei2H8vlgw3mjrDkuBa QSQWXiLwQSjut9d5lUkKPlb3078rKKK2hSloGhc8d9yg2xvA4fP+ZKEDt0DBeae1QMCvj2EaQ+8Dp OR3qf2KJ9skjJ/npaXAetQ==; From: Andrey Drobyshev To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, berto@igalia.com, andrey.drobyshev@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 4/7] qcow2: make subclusters discardable Date: Sat, 21 Oct 2023 00:56:19 +0300 Message-Id: <20231020215622.789260-5-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> References: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1697839062330100003 Content-Type: text/plain; charset="utf-8" This commit makes the discard operation work on the subcluster level rather than cluster level. It introduces discard_l2_subclusters() function and makes use of it in qcow2 discard implementation, much like it's done with zero_in_l2_slice() / zero_l2_subclusters(). It also changes the qcow2 driver pdiscard_alignment to subcluster_size. That way subcluster-aligned discards lead to actual fallocate(PUNCH_HOLE) operation and free host disk space. This feature will let us gain additional disk space on guest TRIM/discard requests, especially when using large enough clusters (1M, 2M) with subclusters enabled. Signed-off-by: Andrey Drobyshev --- block/qcow2-cluster.c | 100 ++++++++++++++++++++++++++++++++++++++++-- block/qcow2.c | 8 ++-- 2 files changed, 101 insertions(+), 7 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 7c6fa5524c..cf40f2dc12 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -2042,6 +2042,74 @@ discard_in_l2_slice(BlockDriverState *bs, uint64_t o= ffset, uint64_t nb_clusters, return nb_clusters; } =20 +static int coroutine_fn GRAPH_RDLOCK +discard_l2_subclusters(BlockDriverState *bs, uint64_t offset, + uint64_t nb_subclusters, + enum qcow2_discard_type type, + bool full_discard, + SubClusterRangeInfo *pscri) +{ + BDRVQcow2State *s =3D bs->opaque; + uint64_t new_l2_bitmap, l2_bitmap_mask; + int ret, sc =3D offset_to_sc_index(s, offset); + SubClusterRangeInfo scri =3D { 0 }; + + if (!pscri) { + ret =3D get_sc_range_info(bs, offset, nb_subclusters, &scri); + if (ret < 0) { + goto out; + } + } else { + scri =3D *pscri; + } + + l2_bitmap_mask =3D QCOW_OFLAG_SUB_ALLOC_RANGE(sc, sc + nb_subclusters); + new_l2_bitmap =3D scri.l2_bitmap; + new_l2_bitmap &=3D ~l2_bitmap_mask; + + /* + * If there're no allocated subclusters left, we might as well discard + * the entire cluster. That way we'd also update the refcount table. + */ + if (!(new_l2_bitmap & QCOW_L2_BITMAP_ALL_ALLOC)) { + return discard_in_l2_slice(bs, + QEMU_ALIGN_DOWN(offset, s->cluster_size= ), + 1, type, full_discard); + } + + /* + * Full discard means we fall through to the backing file, thus we only + * need to mark the subclusters as deallocated. + * + * Non-full discard means subclusters should be explicitly marked as + * zeroes. In this case QCOW2 specification requires the corresponding + * allocation status bits to be unset as well. If the subclusters are + * deallocated in the first place and there's no backing, the operation + * can be skipped. + */ + if (!full_discard && + (bs->backing || scri.l2_bitmap & l2_bitmap_mask)) { + new_l2_bitmap |=3D QCOW_OFLAG_SUB_ZERO_RANGE(sc, sc + nb_subcluste= rs); + } + + if (scri.l2_bitmap !=3D new_l2_bitmap) { + set_l2_bitmap(s, scri.l2_slice, scri.l2_index, new_l2_bitmap); + qcow2_cache_entry_mark_dirty(s->l2_table_cache, scri.l2_slice); + } + + if (s->discard_passthrough[type]) { + qcow2_queue_discard(bs, (scri.l2_entry & L2E_OFFSET_MASK) + + offset_into_cluster(s, offset), + nb_subclusters * s->subcluster_size); + } + + ret =3D 0; +out: + qcow2_cache_put(s->l2_table_cache, (void **) &scri.l2_slice); + + return ret; +} + int qcow2_cluster_discard(BlockDriverState *bs, uint64_t offset, uint64_t bytes, enum qcow2_discard_type type, bool full_discard) @@ -2049,19 +2117,36 @@ int qcow2_cluster_discard(BlockDriverState *bs, uin= t64_t offset, BDRVQcow2State *s =3D bs->opaque; uint64_t end_offset =3D offset + bytes; uint64_t nb_clusters; + unsigned head, tail; int64_t cleared; int ret; =20 /* Caller must pass aligned values, except at image end */ - assert(QEMU_IS_ALIGNED(offset, s->cluster_size)); - assert(QEMU_IS_ALIGNED(end_offset, s->cluster_size) || + assert(QEMU_IS_ALIGNED(offset, s->subcluster_size)); + assert(QEMU_IS_ALIGNED(end_offset, s->subcluster_size) || end_offset =3D=3D bs->total_sectors << BDRV_SECTOR_BITS); =20 - nb_clusters =3D size_to_clusters(s, bytes); + head =3D MIN(end_offset, ROUND_UP(offset, s->cluster_size)) - offset; + offset +=3D head; + + tail =3D (end_offset >=3D bs->total_sectors << BDRV_SECTOR_BITS) ? 0 : + end_offset - MAX(offset, start_of_cluster(s, end_offset)); + end_offset -=3D tail; =20 s->cache_discards =3D true; =20 + if (head) { + ret =3D discard_l2_subclusters(bs, offset - head, + size_to_subclusters(s, head), type, + full_discard, NULL); + if (ret < 0) { + goto fail; + } + } + /* Each L2 slice is handled by its own loop iteration */ + nb_clusters =3D size_to_clusters(s, end_offset - offset); + while (nb_clusters > 0) { cleared =3D discard_in_l2_slice(bs, offset, nb_clusters, type, full_discard); @@ -2074,6 +2159,15 @@ int qcow2_cluster_discard(BlockDriverState *bs, uint= 64_t offset, offset +=3D (cleared * s->cluster_size); } =20 + if (tail) { + ret =3D discard_l2_subclusters(bs, end_offset, + size_to_subclusters(s, tail), type, + full_discard, NULL); + if (ret < 0) { + goto fail; + } + } + ret =3D 0; fail: s->cache_discards =3D false; diff --git a/block/qcow2.c b/block/qcow2.c index aa01d9e7b5..66961fa59e 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1966,7 +1966,7 @@ static void qcow2_refresh_limits(BlockDriverState *bs= , Error **errp) bs->bl.request_alignment =3D qcrypto_block_get_sector_size(s->cryp= to); } bs->bl.pwrite_zeroes_alignment =3D s->subcluster_size; - bs->bl.pdiscard_alignment =3D s->cluster_size; + bs->bl.pdiscard_alignment =3D s->subcluster_size; } =20 static int GRAPH_UNLOCKED @@ -4102,11 +4102,11 @@ qcow2_co_pdiscard(BlockDriverState *bs, int64_t off= set, int64_t bytes) return -ENOTSUP; } =20 - if (!QEMU_IS_ALIGNED(offset | bytes, s->cluster_size)) { - assert(bytes < s->cluster_size); + if (!QEMU_IS_ALIGNED(offset | bytes, bs->bl.pdiscard_alignment)) { + assert(bytes < bs->bl.pdiscard_alignment); /* Ignore partial clusters, except for the special case of the * complete partial cluster at the end of an unaligned file */ - if (!QEMU_IS_ALIGNED(offset, s->cluster_size) || + if (!QEMU_IS_ALIGNED(offset, bs->bl.pdiscard_alignment) || offset + bytes !=3D bs->total_sectors * BDRV_SECTOR_SIZE) { return -ENOTSUP; } --=20 2.39.3 From nobody Wed May 22 03:10:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1697839061; cv=none; d=zohomail.com; s=zohoarc; b=b8gWPjaKfdcsc0SQE9XSswinJYM5QXdr2r45bjphMEI4e/OJ3oJygwHmMTSOMlo1D/gEsw7AAsX2KgPc+NpHbgfuBeKv7LeqFxlem8ARXzpY0D4HRbnWhHyd195jf3g+5lFEpDJr9AUftY6Ckexcx8PHu/pOSg5n1B6HWnCdtLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697839061; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mEK1pV36MoJx+qzm6bIJ01vudQTCQDmFPR0gocEfWEI=; b=Pn2jAzkBZIVg7T2TQIDSKcEW1xF1Iy6c6ThYj2cVXQtLrKQT4xDSTJy8ByMUSozV4ydGNgQLFc1QVpi8lHrswd54gM+r/1jIaovESQyWy4sOH6VernB5Z0mMvtTMBBEMuJhTyct73KxNAxr1i4HEWJ3Ar3ymGfdgn+HThnXAvDM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697839061226508.6589560494916; Fri, 20 Oct 2023 14:57:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtxTz-0003sd-EP; Fri, 20 Oct 2023 17:56:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTu-0003pL-9Y; Fri, 20 Oct 2023 17:56:34 -0400 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTq-0008G1-PA; Fri, 20 Oct 2023 17:56:33 -0400 Received: from [130.117.225.1] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1qtxTT-00A9pF-2S; Fri, 20 Oct 2023 23:56:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=mEK1pV36MoJx+qzm6bIJ01vudQTCQDmFPR0gocEfWEI=; b=bjCGOG30fRcL jcRsgs+LdCPJ2Hf2WfPFw3sroGjwJykanMKSAc1/y7c/hOYELZ6Uy/OD75SgUNKfeM74NHAaMxNmS 4IYCPq/K+r40JpZ+6JwHVXl13vEZYB7pVv7qhxCJefePEAVU7OfvYPmcFfJsBLR4hLSLJimDm2J7d HoNjTOGFL2lQH487iCfYliS+NOQsUtLKJYRLEiSTcWx0omf6XTO3RSwGv+QF4pw/RNCui7BPZgWpF 2q1l5MAX8pl1dAsg6rsR2fQ5k/UtUkbhFHCVtyrh2Brx47YJPoQyaGQPViinQqueFWCT6O9jG4pRK lDZN0UCLDjo9d5DW29t/8w==; From: Andrey Drobyshev To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, berto@igalia.com, andrey.drobyshev@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 5/7] qcow2: zero_l2_subclusters: fall through to discard operation when requested Date: Sat, 21 Oct 2023 00:56:20 +0300 Message-Id: <20231020215622.789260-6-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> References: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1697839062308100001 Content-Type: text/plain; charset="utf-8" When zeroizing subclusters within single cluster, detect usage of the BDRV_REQ_MAY_UNMAP flag and fall through to the subcluster-based discard operation, much like it's done with the cluster-based discards. That way subcluster-aligned operations "qemu-io -c 'write -z -u ...'" will lead to actual unmap. Signed-off-by: Andrey Drobyshev --- block/qcow2-cluster.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index cf40f2dc12..040251f2c3 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -2242,7 +2242,7 @@ zero_l2_subclusters(BlockDriverState *bs, uint64_t of= fset, unsigned nb_subclusters, int flags) { BDRVQcow2State *s =3D bs->opaque; - uint64_t new_l2_bitmap; + uint64_t new_l2_bitmap, l2_bitmap_mask; int ret, sc =3D offset_to_sc_index(s, offset); SubClusterRangeInfo scri =3D { 0 }; =20 @@ -2251,9 +2251,10 @@ zero_l2_subclusters(BlockDriverState *bs, uint64_t o= ffset, goto out; } =20 + l2_bitmap_mask =3D QCOW_OFLAG_SUB_ALLOC_RANGE(sc, sc + nb_subclusters); new_l2_bitmap =3D scri.l2_bitmap; - new_l2_bitmap |=3D QCOW_OFLAG_SUB_ZERO_RANGE(sc, sc + nb_subclusters); - new_l2_bitmap &=3D ~QCOW_OFLAG_SUB_ALLOC_RANGE(sc, sc + nb_subclusters= ); + new_l2_bitmap |=3D QCOW_OFLAG_SUB_ZERO_RANGE(sc, sc + nb_subclusters); + new_l2_bitmap &=3D ~l2_bitmap_mask; =20 /* * If there're no non-zero subclusters left, we might as well zeroize @@ -2266,6 +2267,16 @@ zero_l2_subclusters(BlockDriverState *bs, uint64_t o= ffset, 1, flags); } =20 + /* + * If the request allows discarding subclusters and they're actually + * allocated, we go down the discard path since after the discard + * operation the subclusters are going to be read as zeroes anyway. + */ + if ((flags & BDRV_REQ_MAY_UNMAP) && (scri.l2_bitmap & l2_bitmap_mask))= { + return discard_l2_subclusters(bs, offset, nb_subclusters, + QCOW2_DISCARD_REQUEST, false, &scri); + } + if (new_l2_bitmap !=3D scri.l2_bitmap) { set_l2_bitmap(s, scri.l2_slice, scri.l2_index, new_l2_bitmap); qcow2_cache_entry_mark_dirty(s->l2_table_cache, scri.l2_slice); --=20 2.39.3 From nobody Wed May 22 03:10:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1697839114; cv=none; d=zohomail.com; s=zohoarc; b=nJTgiIFAp9BwIb9ivHSl+ys61vU7RIxTGk0OLgHXZvHBZYGQC1mQbyVib1jCor6ln/WLphqGXYhN3jkbiHaE0c1Wrr48xKE9xw6cCIpBuRgfJFPcJnIMqN/dxQW6uOiJ1gXfMMudeZf2JUycmZ1WAlHmUSr8IGmmAZzsG/CCDE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697839114; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Xc0s5rzni+x47c5YoKWzgM1EXDpgmhujUFkXgIBX2Ec=; b=EOQi/8ThULYiSuL0jlrAhqtWuHRG15wcAdkdKAMAMmybXHr76Mzf2AUyN9hfSaohX1Q2pnnodabDxIjxVnFC0Lp18mEV1hiwcxg49+muGV1xcbLXQjYmePZccISJx0zL+B5xtOGJCZoqJ1d/7FRM2DhsTS/AVam4Y7iz6D3Nx8I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169783911413455.49657583718101; Fri, 20 Oct 2023 14:58:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtxTv-0003qQ-LX; Fri, 20 Oct 2023 17:56:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTs-0003mU-EM; Fri, 20 Oct 2023 17:56:32 -0400 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTq-0008G3-NA; Fri, 20 Oct 2023 17:56:32 -0400 Received: from [130.117.225.1] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1qtxTT-00A9pF-2d; Fri, 20 Oct 2023 23:56:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=Xc0s5rzni+x47c5YoKWzgM1EXDpgmhujUFkXgIBX2Ec=; b=Ys4kzVyyw8Ap cHO1/oos/k/dlUAxWrB8wpwE5gT2fbCiawE1Upl9KOr2hW+MTJ5M3B/ilCOP40UfUhr2E9lok61+4 cXhi/1ReNLVfDS6ysR+HqKUgG3KSy2Tt9IGSPXKjnT1uV+9SRgyRU5yvQyQbleGIYUYAmYj1gYZi6 myocjmAJWTzATKJXBNJc+sMcw7Yr4bzR7nz+bt4tU7G2JR5CSBhwJn1YORKviMDyZdOGAnV/UEIb6 WzAcnP0QJC5Z4bK0Hfl/UStde/4DH5+ynEtfvznLt92XoTReD2GOslURBQFeKJSJ+uO4C6AyOpRFu 4yT35uXrG8HQ8kzr1OPW7Q==; From: Andrey Drobyshev To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, berto@igalia.com, andrey.drobyshev@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 6/7] iotests/common.rc: add disk_usage function Date: Sat, 21 Oct 2023 00:56:21 +0300 Message-Id: <20231020215622.789260-7-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> References: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1697839114385100005 Content-Type: text/plain; charset="utf-8" Move the definition from iotests/250 to common.rc. This is used to detect real disk usage of sparse files. In particular, we want to use it for checking subclusters-based discards. Signed-off-by: Andrey Drobyshev --- tests/qemu-iotests/250 | 5 ----- tests/qemu-iotests/common.rc | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/250 b/tests/qemu-iotests/250 index af48f83aba..c0a0dbc0ff 100755 --- a/tests/qemu-iotests/250 +++ b/tests/qemu-iotests/250 @@ -52,11 +52,6 @@ _unsupported_imgopts data_file # bdrv_co_truncate(bs->file) call in qcow2_co_truncate(), which might succ= eed # anyway. =20 -disk_usage() -{ - du --block-size=3D1 $1 | awk '{print $1}' -} - size=3D2100M =20 _make_test_img -o "cluster_size=3D1M,preallocation=3Dmetadata" $size diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index 95c12577dd..5d2ea26c7f 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -140,6 +140,12 @@ _optstr_add() fi } =20 +# report real disk usage for sparse files +disk_usage() +{ + du --block-size=3D1 $1 | awk '{print $1}' +} + # Set the variables to the empty string to turn Valgrind off # for specific processes, e.g. # $ VALGRIND_QEMU_IO=3D ./check -qcow2 -valgrind 015 --=20 2.39.3 From nobody Wed May 22 03:10:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1697839110; cv=none; d=zohomail.com; s=zohoarc; b=T2sD10zinkuzVdtNUTThjPCG1s67xwxhADUhV4M4UpyTsewHfuIiFHLugKKUqAtpm0aw+YYFvehbAme8Jpi80IF6mYZVzCrI7CBISaAIRfQaKQBOsARbJmouz+Swc5EIdFcPhSSMRmbmscKxmNwsarS6yY0e0QZWvnIYTVaWBoE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697839110; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xoAP6FRspQjKbgVizSw7Z47QzqhgL7NJIPq3ksUKjlQ=; b=A9NzPg6pjzztLimPOe5Z6T4Sw1+V1P5KODft5XNmXfAOg76ppa3C+ICpKq4xpFgbuDQNK4dx4pr8/D/B1zvQqtifEJ9RtFrW6OFd/Y7UmKpDCWBPhqNTxP/y6MpMUrZ7kDNmA1+NcHgILYY9pEWIml/OXD63oKye8S7VpjYUirg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697839110933597.8083436009184; Fri, 20 Oct 2023 14:58:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtxTx-0003r7-87; Fri, 20 Oct 2023 17:56:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTu-0003pN-AB; Fri, 20 Oct 2023 17:56:35 -0400 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtxTq-0008G2-OS; Fri, 20 Oct 2023 17:56:33 -0400 Received: from [130.117.225.1] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1qtxTT-00A9pF-2n; Fri, 20 Oct 2023 23:56:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-Id:Date:Subject:From: Content-Type; bh=xoAP6FRspQjKbgVizSw7Z47QzqhgL7NJIPq3ksUKjlQ=; b=CLcr3tGDzQpd 4+NuWJAQd0mk3B2QF8YmZZhYCYO8AjI4AyqJbSAYXY/Qzfvj4gpmHsQnN1dV0XBQMmsmH2FaIkP6y QJF27wyG729GUXK6sxiERxKB/sNrytvWVDpA/ZI2OuUda73bZil9kDZ3MOi6DNFgnsluX7zWZe/Lx TTQ8p5MQh3I/mmZLPn5uZ9YyWSsGskQAKyH2xspoP9ok5EhcWagJIbE59HIGCzpwiwGH61idMoSYv 5+5xv1kvxe0iey525ZoL2vZ06/G2daZd92vFvmgmm+NjhPSgpm8bKCyd7kWQq7iGW/TXBg5232wlU m5jFPanI66HdTSQUzOxkDQ==; From: Andrey Drobyshev To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, berto@igalia.com, andrey.drobyshev@virtuozzo.com, den@virtuozzo.com Subject: [PATCH 7/7] iotests/271: check disk usage on subcluster-based discard/unmap Date: Sat, 21 Oct 2023 00:56:22 +0300 Message-Id: <20231020215622.789260-8-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> References: <20231020215622.789260-1-andrey.drobyshev@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1697839112397100001 Content-Type: text/plain; charset="utf-8" Add _verify_du_delta() checker which is used to check that real disk usage delta meets the expectations. For now we use it for checking that subcluster-based discard/unmap operations lead to actual disk usage decrease (i.e. PUNCH_HOLE operation is performed). Also add separate test case for discarding particular subcluster within one cluster. Signed-off-by: Andrey Drobyshev --- tests/qemu-iotests/271 | 25 ++++++++++++++++++++++++- tests/qemu-iotests/271.out | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/271 b/tests/qemu-iotests/271 index c7c2cadda0..5fcb209f5f 100755 --- a/tests/qemu-iotests/271 +++ b/tests/qemu-iotests/271 @@ -81,6 +81,15 @@ _verify_l2_bitmap() fi } =20 +# Check disk usage delta after a discard/unmap operation +# _verify_du_delta $before $after $expected_delta +_verify_du_delta() +{ + if [ $(($1 - $2)) -ne $3 ]; then + printf "ERROR: unexpected delta: $1 - $2 =3D $(($1 - $2)) !=3D $3\= n" + fi +} + # This should be called as _run_test c=3DXXX sc=3DXXX off=3DXXX len=3DXXX = cmd=3DXXX # c: cluster number (0 if unset) # sc: subcluster number inside cluster @c (0 if unset) @@ -198,9 +207,12 @@ for use_backing_file in yes no; do alloc=3D"$(seq 0 31)"; zero=3D"" _run_test sc=3D0 len=3D64k =20 - ### Zero and unmap half of cluster #0 (this won't unmap it) + ### Zero and unmap half of cluster #0 (this will unmap it) alloc=3D"$(seq 16 31)"; zero=3D"$(seq 0 15)" + before=3D$(disk_usage "$TEST_IMG") _run_test sc=3D0 len=3D32k cmd=3Dunmap + after=3D$(disk_usage "$TEST_IMG") + _verify_du_delta $before $after 32768 =20 ### Zero and unmap cluster #0 alloc=3D""; zero=3D"$(seq 0 31)" @@ -447,7 +459,10 @@ for use_backing_file in yes no; do =20 # Subcluster-aligned request from clusters #12 to #14 alloc=3D"$(seq 0 15)"; zero=3D"$(seq 16 31)" + before=3D$(disk_usage "$TEST_IMG") _run_test c=3D12 sc=3D16 len=3D128k cmd=3Dunmap + after=3D$(disk_usage "$TEST_IMG") + _verify_du_delta $before $after $((128 * 1024)) alloc=3D""; zero=3D"$(seq 0 31)" _verify_l2_bitmap 13 alloc=3D"$(seq 16 31)"; zero=3D"$(seq 0 15)" @@ -528,6 +543,14 @@ for use_backing_file in yes no; do else _make_test_img -o extended_l2=3Don 1M fi + # Write cluster #0 and discard its subclusters #0-#3 + $QEMU_IO -c 'write -q 0 64k' "$TEST_IMG" + before=3D$(disk_usage "$TEST_IMG") + $QEMU_IO -c 'discard -q 0 8k' "$TEST_IMG" + after=3D$(disk_usage "$TEST_IMG") + _verify_du_delta $before $after 8192 + alloc=3D"$(seq 4 31)"; zero=3D"$(seq 0 3)" + _verify_l2_bitmap 0 # Write clusters #0-#2 and then discard them $QEMU_IO -c 'write -q 0 128k' "$TEST_IMG" $QEMU_IO -c 'discard -q 0 128k' "$TEST_IMG" diff --git a/tests/qemu-iotests/271.out b/tests/qemu-iotests/271.out index 5be780de76..0da8d72cde 100644 --- a/tests/qemu-iotests/271.out +++ b/tests/qemu-iotests/271.out @@ -426,6 +426,7 @@ L2 entry #29: 0x0000000000000000 0000ffff00000000 ### Discarding clusters with non-zero bitmaps (backing file: yes) ### =20 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 backing_file= =3DTEST_DIR/t.IMGFMT.base backing_fmt=3Draw +L2 entry #0: 0x8000000000050000 0000000ffffffff0 L2 entry #0: 0x0000000000000000 ffffffff00000000 L2 entry #1: 0x0000000000000000 ffffffff00000000 Image resized. @@ -436,6 +437,7 @@ L2 entry #1: 0x0000000000000000 ffffffff00000000 ### Discarding clusters with non-zero bitmaps (backing file: no) ### =20 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 +L2 entry #0: 0x8000000000050000 0000000ffffffff0 L2 entry #0: 0x0000000000000000 ffffffff00000000 L2 entry #1: 0x0000000000000000 ffffffff00000000 Image resized. --=20 2.39.3