From nobody Fri Oct 18 08:32:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1695283222; cv=none; d=zohomail.com; s=zohoarc; b=akuFD4pvArC8wwWSPgSsVlNw4xkDP8CXUGpz+Hin7I1fM7WD3frO3ufmkO9WpMjptvjf4/YCJcgpUhd4zokuiAuK2OS0i7oYHAA7gH5RkCN0SiC+TEYqhZVZPFLDMy8ldN0jXYWMOzV2cQQbeeYr8YQyHC6fCRyzW6t4/vck4k0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695283222; 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:Reply-To:References:Sender:Subject:To; bh=H49wF1VCgVFB4Vtc9xrAoCloZ/DnCtQvhL8zTX7ZFKA=; b=MhsZx4NmWvK2djcHZctcBjelcAX2wWfRHb+takJuf/lLbDHMnXVKvAFcIBbhIkzdG7jsdLrPxnDH+r9SRIGBv1SruQgqYt//39WQJmJcICe1SwOpNmb13/MdVIDVKyb4nbPk0iD2We8oaemqBpUOqq7JsJCuhK1/0trgsAKfmVw= ARC-Authentication-Results: i=1; mx.zohomail.com; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695283222757894.8504015703586; Thu, 21 Sep 2023 01:00:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjEY3-0000K5-9U; Thu, 21 Sep 2023 03:56:31 -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 1qjEXz-0008Ar-0H; Thu, 21 Sep 2023 03:56:27 -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 1qjEXx-0002Fg-Fk; Thu, 21 Sep 2023 03:56:26 -0400 Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=iris.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1qjEWU-00BsUn-04; Thu, 21 Sep 2023 09:55:06 +0200 To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Alexander Ivanov Subject: [PULL v2 16/22] parallels: update used bitmap in allocate_cluster Date: Thu, 21 Sep 2023 09:54:54 +0200 Message-Id: <20230921075500.694585-17-den@openvz.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230921075500.694585-1-den@openvz.org> References: <20230921075500.694585-1-den@openvz.org> 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=den@openvz.org; helo=relay.virtuozzo.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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: , Reply-to: "Denis V. Lunev" From: "Denis V. Lunev" via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1695283223711100001 Content-Type: text/plain; charset="utf-8" We should extend the bitmap if the file is extended and set the bit in the image used bitmap once the cluster is allocated. Sanity check at that moment also looks like a good idea. Signed-off-by: Denis V. Lunev Reviewed-by: Alexander Ivanov --- block/parallels.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index 3df73aa8a0..ec35237119 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -282,6 +282,8 @@ allocate_clusters(BlockDriverState *bs, int64_t sector_= num, return len; } if (s->data_end + space > (len >> BDRV_SECTOR_BITS)) { + uint32_t new_usedsize; + space +=3D s->prealloc_size; /* * We require the expanded size to read back as zero. If the @@ -305,6 +307,12 @@ allocate_clusters(BlockDriverState *bs, int64_t sector= _num, if (ret < 0) { return ret; } + + new_usedsize =3D s->used_bmap_size + + (space << BDRV_SECTOR_BITS) / s->cluster_size; + s->used_bmap =3D bitmap_zero_extend(s->used_bmap, s->used_bmap_siz= e, + new_usedsize); + s->used_bmap_size =3D new_usedsize; } =20 /* @@ -336,6 +344,12 @@ allocate_clusters(BlockDriverState *bs, int64_t sector= _num, } } =20 + ret =3D mark_used(bs, s->used_bmap, s->used_bmap_size, + s->data_end << BDRV_SECTOR_BITS, to_allocate); + if (ret < 0) { + /* Image consistency is broken. Alarm! */ + return ret; + } for (i =3D 0; i < to_allocate; i++) { parallels_set_bat_entry(s, idx + i, s->data_end / s->off_multiplie= r); s->data_end +=3D s->tracks; --=20 2.34.1