From nobody Sun Dec 7 10:14:08 2025 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=1732819228; cv=none; d=zohomail.com; s=zohoarc; b=aYt1a7tmHE4xjg7OiFLEG7enR2yJX+viR3kmHtlWNgcJAsXGmTOL9PwxA1DoNAIjNi65PbwSFsTS65AtqCUGweet1Te4dRDwEEBNsd76m+o2ZrcVj/Gjfjd63/9BRcnBQz5feeM17YWIe+2JXBwMKFRGIFVv367LGZ22p6RWp20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732819228; 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=fk8PGJQHc/q4BIWFO0ftad01xvv3zgbb9jJTTEfmY/w=; b=cW9EtcA+T16uX0Mfm4pZzv2ujOETHv3i9TVjmkM8XKQC2wp4BKP686NyhnK194v1hk42ZcA2SlkhAQU5m+LgsCvEWnCTq4pPSjUIQhv7KtpTGEu943F6LznMNJPdqXbwip+tFwXBIWb2A4Mk3iZHamhthgWLy6xq3vUdSZG29Mc= 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 173281922828746.1011623356211; Thu, 28 Nov 2024 10:40:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGjQa-00074Z-FJ; Thu, 28 Nov 2024 13:39:48 -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-0006zV-MZ; 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-00060N-Jo; 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 1tGjPp-00E2DN-0c; 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=fk8PGJQHc/q4BIWFO0ftad01xvv3zgbb9jJTTEfmY/w=; b=Pw9ExQjRBGPv Kn1P/KK5HdgCpMk+Nwp3alqJL3iFBYXqfwv8B/qLQZR9GSBYI1aGLcas2aKtv5YGSXlmqnqt4xjv/ RAnXcZsN9dD8/dSl/s/T/Qg5cFZOmwEZwDRS22fmdDQywssVhpD/q7PUX0XEXxismcg+zfhIbUUpb KJI8oSaUDnAWkq+PsUe01jDozvkK8OieKLD6SDVO6OHspyjLRqwIH5iIjVjcXBO5sYHrvp6jVuCVP EK03ij9UO4VJoLc4np80e5OMkLph7XDzOgNzDCMG5BXRF4aCNi3h/ErtDO2g9ECohWzSrFV4FuN+A kauMtxXGAKlzRSxOITf08w==; To: qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: den@openvz.org, Vladimir Sementsov-Ogievskiy , Andrey Drobyshev , Kevin Wolf , Hanna Reitz Subject: [PATCH 5/6] preallocate: simplify preallocate_drop_resize Date: Thu, 28 Nov 2024 19:25:52 +0100 Message-ID: <20241128183911.837699-6-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: 1732819228730019100 Content-Type: text/plain; charset="utf-8" Once permission change process is normalized, there is no need to have permission update inside preallocate_drop_resize() and preallocate_truncate_to_real_size() could be merged into the caller. Signed-off-by: Denis V. Lunev CC: Vladimir Sementsov-Ogievskiy CC: Andrey Drobyshev CC: Kevin Wolf CC: Hanna Reitz --- block/preallocate.c | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/block/preallocate.c b/block/preallocate.c index c448258c42..886b1311f2 100644 --- a/block/preallocate.c +++ b/block/preallocate.c @@ -77,8 +77,6 @@ typedef struct BDRVPreallocateState { */ } BDRVPreallocateState; =20 -static int preallocate_drop_resize(BlockDriverState *bs, Error **errp); - #define PREALLOCATE_OPT_PREALLOC_ALIGN "prealloc-align" #define PREALLOCATE_OPT_PREALLOC_SIZE "prealloc-size" static QemuOptsList runtime_opts =3D { @@ -169,7 +167,7 @@ static int preallocate_open(BlockDriverState *bs, QDict= *options, int flags, } =20 static int GRAPH_RDLOCK -preallocate_truncate_to_real_size(BlockDriverState *bs, Error **errp) +preallocate_drop_resize(BlockDriverState *bs, Error **errp) { BDRVPreallocateState *s =3D bs->opaque; int ret; @@ -198,7 +196,7 @@ static void preallocate_close(BlockDriverState *bs) GLOBAL_STATE_CODE(); GRAPH_RDLOCK_GUARD_MAINLOOP(); =20 - preallocate_truncate_to_real_size(bs, NULL); + preallocate_drop_resize(bs, NULL); } =20 =20 @@ -488,36 +486,6 @@ preallocate_co_getlength(BlockDriverState *bs) return bdrv_co_getlength(bs->file->bs); } =20 -static int GRAPH_RDLOCK -preallocate_drop_resize(BlockDriverState *bs, Error **errp) -{ - BDRVPreallocateState *s =3D bs->opaque; - int ret; - - if (s->data_end < 0) { - return 0; - } - - /* - * Before switching children to be read-only, truncate them to remove - * the preallocation and let them have the real size. - */ - ret =3D preallocate_truncate_to_real_size(bs, errp); - if (ret < 0) { - return ret; - } - - /* - * We'll drop our permissions and will allow other users to take write= and - * resize permissions (see preallocate_child_perm). Anyone will be abl= e to - * change the child, so mark all states invalid. We'll regain control = if a - * parent requests write access again. - */ - bdrv_child_refresh_perms(bs, bs->file, NULL); - - return 0; -} - 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) --=20 2.45.2