From nobody Mon Feb 9 09:54:06 2026 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