From nobody Fri Dec 27 15:18:55 2024 Delivered-To: importer@patchew.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; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1732819257; cv=none; d=zohomail.com; s=zohoarc; b=CW4KX0yeqjWbU9P38+z7YnnFzvQEr/j04ox0tcFf2x7VK6/65YBRHUtqw3dGlihQLnCCZB33kC0JulwpWTsv4eZDLnr9utSVhf3e74wAzNtMMD0hQZmi93ivVm/OnkCzHiEjetlcbwTaWIAhuZvAM3wjQWY3Lgd27f3cSFyinLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732819257; 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:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=xrg7ndqG9+Oki7uB+Q6dALsj7L6NNtOivee5Srln6YM=; b=eE4YwwloXyepFFc0YjlGOo5t/QaJmMXwGmJrA9f16uyOhzv5bGUof9XfppZZVVf2Oi4MVPlIek3UN0gkfbRCv6aWAXxOAEzGN5lUnrbzHWn+vn7XNUE/4M7kmlwgDHoujs+vU05kxcRBwQUXUIAsmTU0OjvzQWLOMzphEHXg9Ww= 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; 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 173281925707563.98105761734939; Thu, 28 Nov 2024 10:40:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGjQU-00072l-KK; Thu, 28 Nov 2024 13:39:42 -0500 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 1tGjQN-0006zY-Na; Thu, 28 Nov 2024 13:39:35 -0500 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 1tGjQI-00060I-G1; Thu, 28 Nov 2024 13:39:33 -0500 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 1tGjPo-00E2DN-2s; Thu, 28 Nov 2024 19:39:10 +0100 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=xrg7ndqG9+Oki7uB+Q6dALsj7L6NNtOivee5Srln6YM=; b=Mn4PwxBUan3S WSefy3p3bE6Iu2r3m3V3McF0ol02uqTk6FyiO/T/YTwj50vWtxHMfcgaju/18Xqm7SzZ7YMsU/ks2 V1VfF9nUQXhx4BLu6dBg4d9ht/22rdq6PVwd/73MLoIJx/YxoZknOZcsEHhC3BCixWFDRqIEsLhrR eUa8ByeS+Ab2zG5qGX0V9PEDnzaOZ1v9LqTek6ETAdXlOgECoB5aFK0vgVt0kQ6xYOvvj/MGeG1wK /FdYZNpf5pNs89a9pTm5n5SYBpkxeXzrLqkcEbix78jK46/IQa+7vn4O+7ipiYkzMx0tIZBhzg3Io +qTtMiihwcA00x89wWWWeA==; To: qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: den@openvz.org, Vladimir Sementsov-Ogievskiy , Andrey Drobyshev , Kevin Wolf , Hanna Reitz Subject: [PATCH 4/6] preallocate: remove bottom half from preallocate filter Date: Thu, 28 Nov 2024 19:25:51 +0100 Message-ID: <20241128183911.837699-5-den@openvz.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241128183911.837699-1-den@openvz.org> References: <20241128183911.837699-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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732819258962019100 Content-Type: text/plain; charset="utf-8" IO operations like truncate inside preallocate_set_perm() looks like insane complexity which should not seen in the reality. Preallocate filter lifecycle is very close to the lifecycle of CBT. This is well handled inside QCOW2 driver. The approach should be the same inside preallocation filter. It should be enough to be handled inside preallocate_reopen_prepare() and preallocate_inactivate(). There is no more need to have preallocate_set_perm() and preallocate_child_perm() perms. Signed-off-by: Denis V. Lunev CC: Vladimir Sementsov-Ogievskiy CC: Andrey Drobyshev CC: Kevin Wolf CC: Hanna Reitz --- block/preallocate.c | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/block/preallocate.c b/block/preallocate.c index 65c1ff5d78..c448258c42 100644 --- a/block/preallocate.c +++ b/block/preallocate.c @@ -75,13 +75,9 @@ typedef struct BDRVPreallocateState { * be invalid (< 0) when we don't have both exclusive BLK_PERM_RESIZE = and * BLK_PERM_WRITE permissions on file child. */ - - /* Gives up the resize permission on children when parents don't need = it */ - QEMUBH *drop_resize_bh; } BDRVPreallocateState; =20 static int preallocate_drop_resize(BlockDriverState *bs, Error **errp); -static void preallocate_drop_resize_bh(void *opaque); =20 #define PREALLOCATE_OPT_PREALLOC_ALIGN "prealloc-align" #define PREALLOCATE_OPT_PREALLOC_SIZE "prealloc-size" @@ -150,7 +146,6 @@ static int preallocate_open(BlockDriverState *bs, QDict= *options, int flags, * For this to work, mark them invalid. */ s->file_end =3D s->zero_start =3D s->data_end =3D -EINVAL; - s->drop_resize_bh =3D qemu_bh_new(preallocate_drop_resize_bh, bs); =20 ret =3D bdrv_open_file_child(NULL, options, "file", bs, errp); if (ret < 0) { @@ -200,14 +195,9 @@ preallocate_truncate_to_real_size(BlockDriverState *bs= , Error **errp) =20 static void preallocate_close(BlockDriverState *bs) { - BDRVPreallocateState *s =3D bs->opaque; - GLOBAL_STATE_CODE(); GRAPH_RDLOCK_GUARD_MAINLOOP(); =20 - qemu_bh_cancel(s->drop_resize_bh); - qemu_bh_delete(s->drop_resize_bh); - preallocate_truncate_to_real_size(bs, NULL); } =20 @@ -528,34 +518,6 @@ preallocate_drop_resize(BlockDriverState *bs, Error **= errp) return 0; } =20 -static void preallocate_drop_resize_bh(void *opaque) -{ - GLOBAL_STATE_CODE(); - GRAPH_RDLOCK_GUARD_MAINLOOP(); - - /* - * In case of errors, we'll simply keep the exclusive lock on the image - * indefinitely. - */ - preallocate_drop_resize(opaque, NULL); -} - -static void GRAPH_RDLOCK -preallocate_set_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared) -{ - BDRVPreallocateState *s =3D bs->opaque; - - if (can_write_resize(perm)) { - qemu_bh_cancel(s->drop_resize_bh); - if (s->data_end < 0) { - s->data_end =3D s->file_end =3D s->zero_start =3D - bs->file->bs->total_sectors * BDRV_SECTOR_SIZE; - } - } else { - qemu_bh_schedule(s->drop_resize_bh); - } -} - static void preallocate_child_perm(BlockDriverState *bs, BdrvChild *c, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) @@ -604,7 +566,6 @@ static BlockDriver bdrv_preallocate_filter =3D { .bdrv_co_flush =3D preallocate_co_flush, .bdrv_co_truncate =3D preallocate_co_truncate, =20 - .bdrv_set_perm =3D preallocate_set_perm, .bdrv_child_perm =3D preallocate_child_perm, =20 .bdrv_inactivate =3D preallocate_inactivate, --=20 2.45.2