From nobody Mon Feb 9 01:12:12 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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 ARC-Seal: i=1; a=rsa-sha256; t=1577014975; cv=none; d=zohomail.com; s=zohoarc; b=d9s3fIOd6ozSWzknfet0+Z3rGl+5Nq6qKnTNAkGkQP3Kp2oBwjp8f3MYG+Znrra2n7qt+UZ7qTm2Ev5e7aDNYSnKs8Z057mPmtrHbb64/tSSTxu+xsOo3mK4O2WNUaHbsHMkypZeT9c2DFxqvqz6AWZeotmkzqmq1U+MEJaMeAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577014975; 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=7yEjOZlUVJ7jHicAcELr1+Yiz+TxR8WDeHeO6wbNjdo=; b=biz1YGLvluf/RLOYFyG+6kmUJmDQWS28935Lb2i73xe8I5ZXsECD9Rx8nxB1BjwyuGkbXe4pvcamoI9qaCZ7ETujwIAJGQIiQ1zgI7zWwPJ5xFe+CGfP6/O6teM52woM8Z3AUw9JMVXjsMPWfcvTFDizIYl8p62aw97SIJniH90= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1577014975728387.424811042775; Sun, 22 Dec 2019 03:42:55 -0800 (PST) Received: from localhost ([::1]:46672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iizdO-00004w-NU for importer@patchew.org; Sun, 22 Dec 2019 06:42:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43676) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iizZ8-0003La-SU for qemu-devel@nongnu.org; Sun, 22 Dec 2019 06:38:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iizZ7-0006nn-K8 for qemu-devel@nongnu.org; Sun, 22 Dec 2019 06:38:30 -0500 Received: from fanzine.igalia.com ([178.60.130.6]:34965) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iizZ7-0004Uk-6K; Sun, 22 Dec 2019 06:38:29 -0500 Received: from [80.30.182.172] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1iizYU-0005dN-W8; Sun, 22 Dec 2019 12:37:51 +0100 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1iizXu-0001W9-S6; Sun, 22 Dec 2019 12:37:14 +0100 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=7yEjOZlUVJ7jHicAcELr1+Yiz+TxR8WDeHeO6wbNjdo=; b=RqYFzZt3wyGDyp0iwR5FojAIGOn7SVGmqCQMuTEA8nJqMMLJSn2vNOhi/BRGumWeW0+zej3axuYRQYSdUu70V5ubGCUuQ7m4KRB9eWayLZNpdHyDwwwotWvfNgcb32yeHNRFKAAvx3Jc+O0iG28FylgcOUvfOy3JDHUgrGNybAgbGpiStOSnRhxaJciB1UDe5E4JRcATx3ikZP9i/+Ziay18NWvzgQhL28eLgKFaRksp1HjmWO2m2+5e3KJnsgqYZRjZb8gAjbZIGEY00boZ5LdGhpjXZEI012paytWWllu+Q4eEGNsixpZTOwXPV/WSZk247/Ia3x/XxK+ZPlI5nA==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [RFC PATCH v3 21/27] qcow2: Update L2 bitmap in qcow2_alloc_cluster_link_l2() Date: Sun, 22 Dec 2019 12:37:02 +0100 Message-Id: <4e1c4c2994470119889e8f602b9c98f4d3457e8b.1577014346.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 , Vladimir Sementsov-Ogievskiy , "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 Reviewed-by: Max Reitz --- block/qcow2-cluster.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 0a40944667..ed291a4042 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -986,6 +986,23 @@ 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)) { + unsigned written_from =3D m->cow_start.offset; + unsigned written_to =3D m->cow_end.offset + m->cow_end.nb_byte= s ?: + m->nb_clusters << s->cluster_bits; + 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++) { + int sc_off =3D i * s->cluster_size + sc * s->subcluster_si= ze; + 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