From nobody Sun Feb 8 12:14:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644254784; cv=pass; d=zohomail.com; s=zohoarc; b=Tie8NkLztlrXSFDJ7dLgpqhtetfuNMhJzpbHUDsqDrHMLPL/j0/Tt6KHnRgv8OGVsTVqfyM4yt7aGwbzxh/Qt/C1ie+1+bL3z36YEhoYPUjkmbEh/aRcFa2WFNaStFQG1DKqUS/ozFlblkEmTX2ut2Zc8rJVgdZ+XCMnUhoYluc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644254784; h=Content-Type: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=tty7PQs0d6d2+Pp2OIMA28yZITQC7+ncWsCZ99J+230=; b=hhYPnv+16ua1n6ZsKQ+fXRxMvyS2P7gZ/IQ7WSqm7kaPRuNLa+Wdt2DKu7bedLrXcSrKUYbQ7ZwGMtbDAo4d91WxQk5UDjs6Hy1NE1HP/WzJbmjOEAJNHyXbR9KPJxj+Of/QFHw749PDA1WCqkB2umDizqFTVAIUq/tsXfr76+U= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644254783873898.8881788246151; Mon, 7 Feb 2022 09:26:23 -0800 (PST) Received: from localhost ([::1]:49992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH7mP-0004bw-IQ for importer@patchew.org; Mon, 07 Feb 2022 12:26:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71R-0001h9-LG; Mon, 07 Feb 2022 11:37:50 -0500 Received: from [2a01:111:f400:7e1b::708] (port=37729 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71O-0005HI-De; Mon, 07 Feb 2022 11:37:47 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VI1PR0802MB2288.eurprd08.prod.outlook.com (2603:10a6:800:a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Mon, 7 Feb 2022 16:37:38 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PttscNq2ksNsRd6ktHYXslpkog4B1QYbPSpYgc5SZ/5vR9Hc4m1j166ekmvHXHMUeqUnoR8RKt3D6CodWv2oKAzPh8e2WlO3SAnJ5yCXOXSE7jLA+122aMtp/pXH/yUzqIRk11aJZLaN6H0+hNcUSX+m7FfcHjtYkmWRRrHlVRLRrFPhEhdtsg5YCYZK5aD8vfEp8RZbPDKVZHILcQIE0cZOW3MenBwkF5g1iFIYOrsYkEk5XkeKXIewCUJXbNQixMK79CFR8aWDD8pOgEZxT71ksnAlQNmQUcVYre6XiqjwTzP5UB14bEg3mfEhbjwcF49HMk6dYt7azXiek0PoyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tty7PQs0d6d2+Pp2OIMA28yZITQC7+ncWsCZ99J+230=; b=nVgDticqcXo5qpC2JVzyByQCw4xP43k2SNgVD7LiQ/T54K/ph31Us1uFGwfy3gHAdEoKEDbBqq2cf/KTGnMYSxGY7GPNsd6/4GE3tiF/KINWrAo8QKQDioUKoZs+7ZmM1GT+U7v/2bwdaM4sagD1hnn/0J3dcvwenbt8ArLx2d6U1Wfcw6OgjvBhamAR8v6IryWfJ7UTsnAXNbj5xpZ+gqwiZU3/xKqQUH1rZESFkPAwHKY/UnFG2rK8Fuf4RgTRZCaRiciv//xBrWKgYBU821qmAv9Tfo36mRB0IwbcDnmFChiiKrm4YpU/9EJMciVfJ4vvHSfqNjqRYxchzXL+fQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tty7PQs0d6d2+Pp2OIMA28yZITQC7+ncWsCZ99J+230=; b=GVv8SreobHgNioF9F7yZmG+Ra3OsKe2y3Nw6LjswRu0IcgqbDRAjRcyvUAkeb7GZLruQE/erWJEINFWnpv7dT2bqXyln7yUKdXf5ZZWNk2QCtr9wt+4SRnnPeQngtJGAxKn8EFtFLkCjRyU8wEDXx8j4EoF13m0MoFFZyl4xVGI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 01/14] block: refactor bdrv_remove_file_or_backing_child to bdrv_remove_child Date: Mon, 7 Feb 2022 17:37:15 +0100 Message-Id: <20220207163728.30362-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b865726-760a-4d00-fc0e-08d9ea582719 X-MS-TrafficTypeDiagnostic: VI1PR0802MB2288:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lpglF3myqrPerKPInCO6oLXgurd8R2bvSwxPX3pSGVWZdAfDVszqgTnnKx79RIeOmk4cybGA/pNKcJ5biqwbQgtm43BSJc+kHLPuAyPZBka8r04iTgwmj5AT62inG62CHFDte/sLQ39Kaw5UKEkCYF1+srvSCvmFj3yHgj0syGR8mlD1qMIujmiy+DssxQGrKkIFA6EQj8P9Xy7NaTkBZL+ubHeNzE1o4ftFl6QjAEmOwH2Kz4e/C6TqIYyEYuuz9UhkwG/sJVTg6qXq6EiutbJrqZYamjjlj1W9RNdg9AZaqSdbckz18fy6WZOI94DYHq8XyoVaH99rAoB8VirL/e+dob5wiUwIMHOPCNlXaiTHxbRv/nu9/lAa1kBqgCRmiVlM/MDPVgsWJj95f8xrAwzN+WAyXcAuQAHM9MLDDKRblzYNe4raU9G31eUGx6mdRAohl9/1zA1/Br9fbz7ffgK0D1UCmifwLMcfwDkHODgmrN60zFD7AHPWBfJEjRNNwD/l8sIlHikUTPP85VD3d1rE59aPL1UsiSM0vNEu0jqakB3yjM9vDqAv1E1AEqqJ3ZUJQCmbq7eS+lYZfWy1JnKU3+uy6k06iGMQ8b9zEe0pFFVo44kH2a/dQIOmLK6TeNWIA7PxgG1F7lm1hALiVit7yNz/yw1aOMAW9jlJuFcQ61ZlafMstA6YjcjK2gfY4Ke2bKMF+oqKVCAvIQtzVA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(66946007)(66556008)(8936002)(8676002)(38100700002)(83380400001)(66476007)(5660300002)(6916009)(4326008)(2906002)(508600001)(26005)(1076003)(186003)(86362001)(6486002)(38350700002)(2616005)(107886003)(6512007)(6506007)(6666004)(316002)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?0fvZJXApnRH3+QIwIq96XS6wtPGV1EzyF2AbJAkmpfUno3p8JvMCEogh740e?= =?us-ascii?Q?jko9eJYrQfVZ6Vbx0ykOpJuFcPOY/h8/+8/9KVFEFdgzvvoInhbwkauNiRwi?= =?us-ascii?Q?tWyHkC5SeHadWVJyYgXAOu5ZmwlMMv2SUqMESJjqlsEIpNwpUisBb5OWH16Q?= =?us-ascii?Q?b+6pZLwuMoyuVEzCo1+Zfk11kw2+HSAPUGpI0D775niDsQqJZFoIIGt8ZWIE?= =?us-ascii?Q?x3tzdO51le8kAHkBtznl9D8sJEYFNJlUPX1pt9sI1Oqsaj1qgAlkyiLDqjoD?= =?us-ascii?Q?lI8xhXtmcYBCCmXZmbGLr+TU7mJqKu90uIak8j2wR4y66s0ML0jzA0OqAX2H?= =?us-ascii?Q?tmwyGd/fomdUV9wQaAVo87pW9ZTTEZaLEMXOj3jHFf5gil6RbV/ixN4wM0jt?= =?us-ascii?Q?FK2B07zl5ILRaA5brx3Fwj+Jk0acJXR7ngoJNZkKDRcb3mWXsuZJfcYPuQ5t?= =?us-ascii?Q?20sN4Miei/+owBxR7JVSmQunypszQtO2E9VFysnIBX6aUty+1DlZp0dGRa8m?= =?us-ascii?Q?SfndR4a7si02bAP0ugRo+RklkNvfbLeInOsC4CN2duUf1P7fTAK6vxvbzlqC?= =?us-ascii?Q?jcK4CVGUdTcmLhrfNKQTi9fYvryNSg75U6iXwabecrjDWqjS5uL67D7h7iba?= =?us-ascii?Q?YaPWHI19ncS6tri0a/Q14pcvC9tDuqbiA10TkzjA+REBc21F2f+AYPntgJfW?= =?us-ascii?Q?qMG2dVGOIAeiQLssifokdIfslSvN/2JjkNi3pM9iM0vkEgVOgZXBI2M3JJiV?= =?us-ascii?Q?NRdwTbFLUMAwLHLg4AgJpviKAyzhWEEUq4ZKAPmriiURGANCyGaGa0YZqNdX?= =?us-ascii?Q?YrytDSuhk3fGTtNha5hPXRXPqgC7rrn/hoYLhs3vj0fS5nyR502qLwEoo5k9?= =?us-ascii?Q?O7/NFl1N9GSR7SLxlWDOnjufbiPLDN4pCgMsMSGcxANurwGK9vY2KqNEd5Mb?= =?us-ascii?Q?KhREryr/BmBszQzMZqpiwZ+KObxa64erPGdmf30Y3tv9RBANsdeYN84i4GYO?= =?us-ascii?Q?rkgzze4x0iO+iwHFUFn6oGNDl523nV6dAezAwsPh4c9Zli9D+bXAZx1xK+Iw?= =?us-ascii?Q?11C/0bXQPM1w0QYKNY7ny36n/v+2mzrYtp6ZQ7iLVdfkdMSqof+0FlGP20jV?= =?us-ascii?Q?gzr7kPOuef9gdgJ7j3anpqC2Pzox9xxgWa0W28GoHZ7w6IrNIV4uyukp0AzR?= =?us-ascii?Q?cTWCqghz7uqtOK9MnCYVo+szOsS0mcNJXN78jA8Jsyj3jBccZhtOhvkvFnXA?= =?us-ascii?Q?8j1CWzIWS9GGFxcgI5yKSQDcs+8XvEnqtU7mzDHISex5JqpGt2YBvx7vA+sO?= =?us-ascii?Q?ifmEhzZ8wMKBy8PAveXMNlQkowwAyk8znZV4Na2sQo7mMUvF8l4AxGZ09c7v?= =?us-ascii?Q?FMsamYktonFrMJ8fNI1ao3iB4TmRMddkB+m+IRZKAwTkYLqxfV6oZIferrUK?= =?us-ascii?Q?ItDmEYBxGWMIeSxa7y+AHNw21g94iuxX01K/ZOfNKkJLvb+w710xOTLz+fOh?= =?us-ascii?Q?+qSRNX4/OzbFeRgK7D08CN/Y0q1Iw9l/JmoEBdSEizpHksFJtxc2+Ax3ZYPa?= =?us-ascii?Q?d1Ed9K8UN/4OffV1ERDkdPnXq/GmfwZyZ2Pa0/C7Id1Bm6fgoE8knWYQ338S?= =?us-ascii?Q?W1lK5Fyip8ORJS3+DwDI4x8pviI+yQDZmUVpnnhs23vrjWcJfuZiXO6hAbcR?= =?us-ascii?Q?4nG0mQ=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b865726-760a-4d00-fc0e-08d9ea582719 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:38.4934 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uzywADXqGDrskqoEasn6VeKZJYU6/7jnRUVhVuHXWc7S9EKINCCX5b5ffoXP10VuW2xqw9ixewtbks/kqaMmSd8afbdJGgY3TtmxmEXmXU0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2288 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::708 (failed) 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=2a01:111:f400:7e1b::708; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644254786273100001 Content-Type: text/plain; charset="utf-8" Now the function can remove any child, so give it more common name. Drop assertions and drop bs argument which becomes unused. Function would be reused in a further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/block.c b/block.c index 0fddb57e78..d852daf7c8 100644 --- a/block.c +++ b/block.c @@ -89,9 +89,7 @@ static bool bdrv_recurse_has_child(BlockDriverState *bs, =20 static void bdrv_replace_child_noperm(BdrvChild *child, BlockDriverState *new_bs); -static void bdrv_remove_file_or_backing_child(BlockDriverState *bs, - BdrvChild *child, - Transaction *tran); +static void bdrv_remove_child(BdrvChild *child, Transaction *tran); static void bdrv_remove_filter_or_cow_child(BlockDriverState *bs, Transaction *tran); =20 @@ -3236,7 +3234,7 @@ static int bdrv_set_file_or_backing_noperm(BlockDrive= rState *parent_bs, =20 if (child) { bdrv_unset_inherits_from(parent_bs, child, tran); - bdrv_remove_file_or_backing_child(parent_bs, child, tran); + bdrv_remove_child(child, tran); } =20 if (!child_bs) { @@ -4891,25 +4889,21 @@ static bool should_update_child(BdrvChild *c, Block= DriverState *to) return ret; } =20 -static void bdrv_remove_filter_or_cow_child_commit(void *opaque) +static void bdrv_remove_child_commit(void *opaque) { bdrv_child_free(opaque); } =20 -static TransactionActionDrv bdrv_remove_filter_or_cow_child_drv =3D { - .commit =3D bdrv_remove_filter_or_cow_child_commit, +static TransactionActionDrv bdrv_remove_child_drv =3D { + .commit =3D bdrv_remove_child_commit, }; =20 /* * A function to remove backing or file child of @bs. * Function doesn't update permissions, caller is responsible for this. */ -static void bdrv_remove_file_or_backing_child(BlockDriverState *bs, - BdrvChild *child, - Transaction *tran) +static void bdrv_remove_child(BdrvChild *child, Transaction *tran) { - assert(child =3D=3D bs->backing || child =3D=3D bs->file); - if (!child) { return; } @@ -4918,7 +4912,7 @@ static void bdrv_remove_file_or_backing_child(BlockDr= iverState *bs, bdrv_replace_child_tran(child, NULL, tran); } =20 - tran_add(tran, &bdrv_remove_filter_or_cow_child_drv, child); + tran_add(tran, &bdrv_remove_child_drv, child); } =20 /* @@ -4929,7 +4923,7 @@ static void bdrv_remove_file_or_backing_child(BlockDr= iverState *bs, static void bdrv_remove_filter_or_cow_child(BlockDriverState *bs, Transaction *tran) { - bdrv_remove_file_or_backing_child(bs, bdrv_filter_or_cow_child(bs), tr= an); + bdrv_remove_child(bdrv_filter_or_cow_child(bs), tran); } =20 static int bdrv_replace_node_noperm(BlockDriverState *from, --=20 2.31.1 From nobody Sun Feb 8 12:14:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644254407; cv=pass; d=zohomail.com; s=zohoarc; b=Hdb7MVf5LhoGYgyEgW5AtaFAKwYvQrY0nOjQ0sVZmmqd+5tFgAteQIT0os4XKPmI5zxLky6AJb7uIGZHCQog2nGKUhq9GgunQem/orXBOJwfx7h4D+STWmdOHPyHdGyKp6nNkKl0v+9/0N2l7VufFkETRyuEtwskIDJ+6gcNJbQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644254407; h=Content-Type: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=O6EErcn9fPaTCAN1xOePdKnlFzFGd9xI+8zfpXeWa7k=; b=HA6YpWOF9b4u8wb1SeAiycUEfBnlt4imKOtKlQj8ZeMfKzqzlQGpAvRdxT2lJU8V2j6YfwKtJVSJ6O6DYzXbm3xOPYsutzYeI8V5iD94umRAVx/gx8GJ1jf/5W10i0V3Ugvz7rThsCORP9/CJPSGsZOOt0f/uo97irVFh5/9HKc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644254407058332.2446859451999; Mon, 7 Feb 2022 09:20:07 -0800 (PST) Received: from localhost ([::1]:42744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH7gL-0007kh-5P for importer@patchew.org; Mon, 07 Feb 2022 12:20:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71Q-0001h7-J1; Mon, 07 Feb 2022 11:37:48 -0500 Received: from mail-am6eur05on2101.outbound.protection.outlook.com ([40.107.22.101]:1216 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71M-0005Gz-Fn; Mon, 07 Feb 2022 11:37:47 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VI1PR0802MB2288.eurprd08.prod.outlook.com (2603:10a6:800:a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Mon, 7 Feb 2022 16:37:39 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SKgILKGqp1PSJ9faRXHfKOA8taDgf/pshek8mmabOv6ZDJsQDu5hBWT1Wh76qcM10JneskmRcav9jRYR77IUSumQxIQ6fDJj9Ox89aY3rF1ZgLbr/+VKo3+XEVcWKWNsUXWyxMXG9mSHD0O9romH68Fr7DbrcRCa7uybA5MXgZITqFefM2wHN/1V54w0xk+cduebxWTfwBlmbfO1Pu03ztM/eDGau+F5AV8lrIR5NYiubCoKBfD2PRPWBNsk7un3GE0GT+Q0aEled74jjKh3krn5Lc/FofvnZXW/zQ31dIuryfJ5bUwQ1ne4PbFvTsYnpscZiZKyMU8sC7zxAseteQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=O6EErcn9fPaTCAN1xOePdKnlFzFGd9xI+8zfpXeWa7k=; b=eWBMFBmxNIEP/3F5rxpXODaxxoPNXX5ZJ+M7f8/2VdFzBKRviDp3FeFB1eo3nEqeph6vNHjcoEDGEy215V9SWOtimk/KkXy5B/ABDsN+se4wO8tT1mUV606J0lTrEYE2BwJ3pvvSyUZkj3Z4DD6fjZO6+wi24Cya2JjH1gh7+z7Yu1Cqgp+kqBLsoHgPgenzdO+ZY8e4Fb3Lj5yg16uROAUB8fbK+Y8pnQtyUKvBfRRrSvT86mdd6HUT5VTO59o5bNbYISIpmzB/hbun0w92aVlbsKkuL/Gf4lS4C3pL53Eb7nIgdFrhhkhiJhqsCkfrHRnHsPSrdMVOoF6KV9RYEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O6EErcn9fPaTCAN1xOePdKnlFzFGd9xI+8zfpXeWa7k=; b=jCT9ylAMut42B9xj19EzbJK5/EO3xg1CijdZp+6OnBOYIUX4tyzsTLEDaXLtlzSNgl+uc1uhmzIAGKvEKIkV40EwRaSIbccbOqZWZYfIf5cuyX5e5hNAIXGU/2twkMPYaIU3E0Dt0kq21jzfZEBHLFfZmWnng38HPwCE4AC3Bhc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 02/14] block: drop bdrv_detach_child() Date: Mon, 7 Feb 2022 17:37:16 +0100 Message-Id: <20220207163728.30362-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ebbee222-966f-4303-4fe2-08d9ea58275f X-MS-TrafficTypeDiagnostic: VI1PR0802MB2288:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kLYPg+nvqKnJS8MQ/LtFVoB9aUgcIrsfZAQaEVegzKHot1YnzAbF2qNRRuDxW1X1p84nbWn6VbPdA/rzhBASrxN/fCV5GTEqoZQkUr3OYP9hhRmFXHM0t5k2PxVoRqBkIYDY+ceBBeAmvqdeUYBNR2AuIvVDUI2ksW9Ga7iUZfK+u8lfiTP1GK32d+AW5XO5TIftG85E7N/4J0Z+QxqiLNTbvGmIY8Sw2P+NQtLwUqQ+J7iTn+3jAdqW0F6eHXnSiK8/5GB5a6IwudgKZNTmjllowy5xCwAMvwiF70LztgecEdOkt5b7yAxhIcv0bs/9j5b0CwQaBUEiBOtzVv3Br4WKevZwL5S9lWnRZZzE9/M1gi9zePaHrTnnbQ2vnjMVCbD+nfdzNIec6hbyRae05LgxUlspaSoiCKXU+UgA51yXMcQ21C3HJ4+64Ol+9mZcUyP+OcjW6ru78erEVYzd9i9on+A+gY+yGM5LnOZkKlo0Y9h3M8hQkEEAVzXaoIRbc7iu6d0/1EqLrvSXxBHxngxgHkUt242n6hyUDPrC+yoii2fs19BvjYZppupFW+H/9XF8pcS62aZi7Vm+KPPDVPY4OYbzmY4Bhe6ktc0Vo/+IZwa9aX3Ms7jEQhiB/jPHTX3y4HLK2BqxvS3wUiuPqOSSsAEMFPmd9iaGtOmhPRQ1J0zApPtcI5bcpc4bp7zvZde3qRzKbkH80BAhLBj//g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(66946007)(66556008)(8936002)(8676002)(38100700002)(83380400001)(66476007)(5660300002)(6916009)(4326008)(2906002)(508600001)(26005)(1076003)(186003)(86362001)(6486002)(38350700002)(2616005)(107886003)(6512007)(6506007)(6666004)(316002)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?CZODEPAB2xQO3f6/qOQhvPzTNpSiS6NF/MnxZZEKIFWG16nvKlsyMOtuwTgl?= =?us-ascii?Q?y/7BiqHyWYpSDV2cKZrl5NpXfSg9kVGSVr7CI8H6NOvSREmEWihMuNKGuvlp?= =?us-ascii?Q?AIYygW7q4+83lTptEPg6JoYLG4zIqfKJBFKMM610FrbmycNSof4HKFHMoocz?= =?us-ascii?Q?HcGLafJ9WwH/gSwYM1TV/cpW7NowDJ0X3zwpLisASq3rKMQT4mF4Wm+i7IeR?= =?us-ascii?Q?dnmQ5ogxVNEeO11382O/wCdieVY43En7Gg/lyo5HqkryKEFeHz2AimEmxGTr?= =?us-ascii?Q?8VTt+s9UOFjDnyQNUghEHhptZgHFUiIUNJ/aBB7du5fto23+XcYf75J1INpN?= =?us-ascii?Q?rLXC+GS/HV4NtW9N2x0nj7pqhn/CgViylX05NSQix5RRMTRZuxyJSESleW6d?= =?us-ascii?Q?PzO51aYoDwfHvXfzYS2a/V9C7GKT7uC6AAvSDB/TE1oMcKXZ7J6jHIpg3opl?= =?us-ascii?Q?m/1ZkeWkPTST7UzhCNpGBJuaRyvZuwNlhMxum2ZuBudyXDhE1SruiIyMoQXB?= =?us-ascii?Q?Vwola3kQzGLWs4X7N2J7MzWxENLsi7svAxBVSuuS4r6X6QZWE34KbSc4spAo?= =?us-ascii?Q?55IpPfbwbrE53JxD2b2/EUn61GOmc8ZQGbaTgc+XC/+BMtNLYiI3Z+01Z3LS?= =?us-ascii?Q?xWQlmN6CxG7VtKhmPT7XGQE21aHhZEAFKOkj17SGNBeIL6nQpMNFt73cOHis?= =?us-ascii?Q?Lm4ap+LeAwW2QftIOV02++P4S40MZiNbIuYpdSsm7muVlW1IU77yU4wckKFY?= =?us-ascii?Q?gK133gBhm1C+medsDpILmkA2AJRBQz99JGJlnKPVAX9tMIQLsnDMgOSagkT6?= =?us-ascii?Q?6slNqk2SDf378UzUefMbAJJAbzuVwLFeKgjf+QP7MDGtgbz49x8FbVVrQIDE?= =?us-ascii?Q?mEUT3RtjmAa/bVJPyjCgdlGTd6sBwwDNQmLFC1YXshYEyUoVSKaHFmtoNpZI?= =?us-ascii?Q?0E1pjlqaxt8T83GEe4/ZODmgBANs9jVCCv2akNUjMMgWt6AwLonljXdkS14y?= =?us-ascii?Q?n4Ar/MFCltSaic/3NiVRg+eYa8Oko4n4EbzLPIJjjyRuascbI54PMho4g7Bz?= =?us-ascii?Q?jBvHFPi9DEGDfqtUYn5xkvmI6VuIRFEC/X8xBeUYjfl0D70/NqdsV2uJlJkL?= =?us-ascii?Q?j3xhe+l5ohSihyaFBw+6EOsllmBqLmNHBYbK9exx9MLMyPdrSIPiggHIXefz?= =?us-ascii?Q?YfB2VGBYVZjOupxlozxmlJIJrPJIqCOQvLW5JlbRbacjc9MYbttxcWEVb8w8?= =?us-ascii?Q?la+JZMR1X024QDjdV8/aBJXQ0ZekjODzqDqLyAvnlFeG651qTNdEzV6VCQ/O?= =?us-ascii?Q?z6AWPylni9t2sKc/0Y6ydQBWJXIp1xae6GCGtryhRKrzoSHXRDHHL8X2moO4?= =?us-ascii?Q?LGHeRBh/jo7yCxnHlWIdGhSYRxvYyJ7SwT4usjh6cWvzuSkuocugn2FWPiVb?= =?us-ascii?Q?crCilDnsh/5ljWOsjbfs6GQEBsMhbxsALpKiIQn8k418o3+BQTMgfBUsE+90?= =?us-ascii?Q?SFGLzHcmgdoAVpdYjqcc+UmpeC9BAG0Clq3eYrQ5iw8V4Mk8ZhBJF9j+Lj0A?= =?us-ascii?Q?UQEMUXAgI9G8FGn+UBv1fa2VB0FFZqisInpqAx3JgZ1IefAqRIKt3yeoUMuv?= =?us-ascii?Q?9nJBVHoCrfItkQzQE9jk5RtZZMvvHpwo90Gd1JKRz8Pz+ALicez+PdZDLtYX?= =?us-ascii?Q?gkg/PQ=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebbee222-966f-4303-4fe2-08d9ea58275f X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:38.8996 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dKC6DCEDHynVbfQmGV383CZ3Cib6lwTUIsiqcGubdyx795ty0M5Ty5tSjnL2RtA4LE+wRNRZgGfVmBGlsuvynttWz3hkzGlN6SJ9lVQUpBk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2288 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=40.107.22.101; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644254409104100001 Content-Type: text/plain; charset="utf-8" The only caller is bdrv_root_unref_child(), let's just do the logic directly in it. It simplifies further convertion of bdrv_root_unref_child() to transaction action. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/block.c b/block.c index d852daf7c8..378841a546 100644 --- a/block.c +++ b/block.c @@ -2948,29 +2948,6 @@ static int bdrv_attach_child_noperm(BlockDriverState= *parent_bs, return 0; } =20 -static void bdrv_detach_child(BdrvChild *child) -{ - BlockDriverState *old_bs =3D child->bs; - - bdrv_replace_child_noperm(child, NULL); - bdrv_child_free(child); - - if (old_bs) { - /* - * Update permissions for old node. We're just taking a parent awa= y, so - * we're loosening restrictions. Errors of permission update are n= ot - * fatal in this case, ignore them. - */ - bdrv_refresh_perms(old_bs, NULL); - - /* - * When the parent requiring a non-default AioContext is removed, = the - * node moves back to the main AioContext - */ - bdrv_try_set_aio_context(old_bs, qemu_get_aio_context(), NULL); - } -} - /* * This function steals the reference to child_bs from the caller. * That reference is later dropped by bdrv_root_unref_child(). @@ -3053,10 +3030,26 @@ out: /* Callers must ensure that child->frozen is false. */ void bdrv_root_unref_child(BdrvChild *child) { - BlockDriverState *child_bs; + BlockDriverState *child_bs =3D child->bs; + + bdrv_replace_child_noperm(child, NULL); + bdrv_child_free(child); + + if (child_bs) { + /* + * Update permissions for old node. We're just taking a parent awa= y, so + * we're loosening restrictions. Errors of permission update are n= ot + * fatal in this case, ignore them. + */ + bdrv_refresh_perms(child_bs, NULL); + + /* + * When the parent requiring a non-default AioContext is removed, = the + * node moves back to the main AioContext + */ + bdrv_try_set_aio_context(child_bs, qemu_get_aio_context(), NULL); + } =20 - child_bs =3D child->bs; - bdrv_detach_child(child); bdrv_unref(child_bs); } =20 --=20 2.31.1 From nobody Sun Feb 8 12:14:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644252651; cv=pass; d=zohomail.com; s=zohoarc; b=H51YdRng9p3oyaSFGNhBrNrRssX4xYDx/+UJDaIco3Oaz3AvN3tYCoMPurPy+b2j1ILrmWI0TwYC+/mhuLMtpS3oGLwzCxJar/GFRmUsgT/HqvbOgJN9mRvGFT794U0qAOFYSSe1bvflzB/nOccOIvtGs63euWl5iyyHjTZcdho= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644252651; h=Content-Type: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=HieOdbkksE1iny0YXh1qWbUuWw+LwUAx3dDPEYDN6vo=; b=VA7iSpqZhPYxm2lfBKLLwAI/qjpzvxzhqr6T63N745r3MLRbuHR00ct2/ooppJiNjci3RdrIB9unsw/Wzl0P0aYomGzPG1pm0KtEI68vxODhyOHRu78ptMK2o3gjyBbZNBNobFWghrlk/Qvdf++l0FJlQCqdnlrUdARqROZfhlU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644252651881330.8117817190098; Mon, 7 Feb 2022 08:50:51 -0800 (PST) Received: from localhost ([::1]:59604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH7E2-0004EK-C2 for importer@patchew.org; Mon, 07 Feb 2022 11:50:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71W-0001uj-V6; Mon, 07 Feb 2022 11:37:55 -0500 Received: from mail-am6eur05on2101.outbound.protection.outlook.com ([40.107.22.101]:1216 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71R-0005Gz-1S; Mon, 07 Feb 2022 11:37:54 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VI1PR0802MB2288.eurprd08.prod.outlook.com (2603:10a6:800:a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Mon, 7 Feb 2022 16:37:39 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eLzMV2jWpX9n8Xt/xEIrlqQ0b/RKk4fbSwkSRMEcmoXl1WxG50WNj/PYql3rFO1xHSh8SaIlhCncibjPyTTB58/cNxeTygn2d4l3Juz97rTtu5i8CMwGNp+Q+lKFh9rn11o/MYJH3vmcjFAQmaX0LyuvQSak8lJDJWtr0KkL09kCNaQLbRSUrJxuJ7Qy3BI0mbOcAfUmVfSrTK5aYAaAdFvSuslshT1hCBt/Sqm+6V9mGvv/1DpEvwFQA27QbGGWLeuP+mSKqRXNq/F0jObRDTkgw5hWtP54R9Rnr1Vf4pyTB521wAS3zKFY0BIP0dekuFrwJ35j/tYfmIV1eClkXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HieOdbkksE1iny0YXh1qWbUuWw+LwUAx3dDPEYDN6vo=; b=eLKQwCSUT/z7fwG/4R+kQ81rc/vwQ9M/pyTelK5gKO9LxuZhAsps7BY0TP3+nRJAe0hM03dDgDKz6x1yAiWJcxA8gSOikvTMyDwn6SrfXU7OBodEOo0fVYSoRKuQKFFfqIUNfQYh7ke+uAnDn/6l213lw9gI8a/+7ue8TdtAkAh0sRcsUbW921RJaVVXY0VTMOJNOMFmMWoz0Ia6UODAH2pC2nQvLP0FYnHyC35ZYofCCIMXJZMRES67Qyg8zhqacQJ7d2KT1Dpdt9RRZ6ldhYj4bVZyJQ/HNhiRtXCBmNlAdosto9S20mS8NBC5ZHU2jDlwwWhp+Td2FsEl43pQVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HieOdbkksE1iny0YXh1qWbUuWw+LwUAx3dDPEYDN6vo=; b=V8n7y3sAbGRrYD6/WLsj2YBGXCVTCXLHCudqgKJ8vocjN1hjLosG/ZCNR1ljHrDNsJE3r0sZ3VcJSuMmRXp9Ef2+GBVZc5Wri+8S/KOQBuCW1HfayAaO6G4UNROqbndiplq3RNpzCxSIkcp8FGaK9pYslij+v3WQgk1e/vrNqQM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 03/14] block: bdrv_refresh_perms(): allow external tran Date: Mon, 7 Feb 2022 17:37:17 +0100 Message-Id: <20220207163728.30362-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fd1b0d81-fc74-44b1-fa40-08d9ea58279c X-MS-TrafficTypeDiagnostic: VI1PR0802MB2288:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yxdNlglfe8D1E7LMsX3LGlYAPfbplA5Ggd07jBYIgksrGpXUNEZGtf684CWgKv5ICGDzWUK6MsnjEN2XXAUmuXc4eXHC56fofxcMZULUuqjsOf6SeewK6jHf6tcpaNF1OH2tGfwO2ovU5wHqH8GCdKO9yUxBHZ8H3gNTaKrXv9VtO13lfr+juydgvYWWX8DebMNpLok8Qj0HR+O2wBnD9WGZmLKvUpqe7szux1Zkl/Sfl0FvPR4TJjlBbOL5UjAxIMuMe2xH7M5nrHKHdO4DdqDsMvdMgrcy36dVO/wv4Ykwx50h6huqDTAbPUaW6j54Jmu2yAHcAgVPybYHkS305f1mAjVJv/B303fhaaikJ34PSAxY5ev/XyjEDLx6dENMQSY2oJg5OVlARe3oy1zYAmKYskMJ/qdbqkgh4V85Ts3V4yymyQMu6j9q/+6IUXwMVF7qcOlUQm/TktvqF9LA7SpV3b4TrFHCJoVnYFnGSGVY/rOhJ1AQeSVIPVPpVUxcpYuT5SJ2HNQ5mrFhES0jUQ1jWA1NoHGrHQ8yzWGmDrkkMRMmYg8V9kksHp2bCk7fUIAVuotLd4q589Y+pbybcWvJB7bx/emCmWZON83nAbM3hPD8EBJ2Bp8pn//Vm17JbAkswl4oKgUVyEpbNrxKTvushyD5ED9LeBAUFIcsTE/6WQNSZnJWg+tI5q0RwgQWqu9dHDv6XEQfoGfsCaI9Ew== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(66946007)(66556008)(8936002)(8676002)(38100700002)(83380400001)(66476007)(5660300002)(6916009)(4326008)(2906002)(508600001)(26005)(1076003)(186003)(86362001)(6486002)(38350700002)(2616005)(107886003)(6512007)(6506007)(6666004)(316002)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?QefhUzMB5+my2LDaYXzMPal73xDWGZbpCYlIIWqbnl/LJplZvRnqXL29mzSj?= =?us-ascii?Q?55lax9DmHdtTsniCMNLhbT7HIQCV7AK9N2DfMB4azE15d0Ccy5FlWiU1qVsr?= =?us-ascii?Q?Jgu0upgU/R2HTuy9xt6oJkyaMgVH7sGisE3QDSFZqCjjog8D0bkPvO8+vQky?= =?us-ascii?Q?/pNesNyz/ccBpLOTxq+SMnfWfzh5rWHZcaxRcpXP2bN4TW21MYqqiOoWEXEu?= =?us-ascii?Q?AAo8TTeQRrTJT+4e65LL7zUvMfVEwSQjsTA08Q491fY4kTb9/MeO5ck9JqO0?= =?us-ascii?Q?B+bhOflwga4ZY/xW0cJukJUk6EN1d7YrxNKkbkWDhF8C+GMGMWz2bfaYYvZl?= =?us-ascii?Q?pSOXkvpJDFmCY8fLULDyJ94zEZWCFlEpLMkwi1MhUMdc0/bLfY8PMntvMKBx?= =?us-ascii?Q?wKAHUg6BAVcXe6ut07aSQeMkAP6mKR0MP7G9fhjk2UvJdoAhzEGQjyB73c8m?= =?us-ascii?Q?mFnJH4DO66It4JRv11ZMWgTsCfvVEa4wy189p6bq/FEfA4MFJs+ei9AZC7gs?= =?us-ascii?Q?k/GteUExreH1v6CsaKjDYrnz+MyY8guKVSxaloR+SgoVinb7+54G+XaGWmn0?= =?us-ascii?Q?cjU+3sOuAZtwOOKo9jU8PeAQphEJaNCBKEY0BPSlXtVKDDY0MDgG6DWY1MII?= =?us-ascii?Q?P4EBg1VrMUskvlmC+P7yC6n+1cA2VQNWJMroa9pGDLO18cvLjvkPFt3zTb2v?= =?us-ascii?Q?DQMP1kPKf0N3DFlpJAeaV3ALpDkXdGN5BfzINJfIOkFG4aE99kfNgBjC/e0n?= =?us-ascii?Q?AZ+Dz8aQO64E4jEowe0of+Oz9snKX9jn+FQY4SsFx0xTSJNR/t5Ap/rvA7cj?= =?us-ascii?Q?p31smt9t38z2NjO3+oogUHXsL2VaSkKeZD1RyKx+TtPUdvA4uPW4nYOPpMqb?= =?us-ascii?Q?y0Uz9hv/kTjdk5bKE7unNYYi0kUHQuNSVi6XoXhLUfV0lDBH8P67XEfmlN7W?= =?us-ascii?Q?GaTsAC/bYTF3ms4ArMprZZ18UxENj+bBXkOywIEBnV5+f/vxcWHuewQIlp3k?= =?us-ascii?Q?RoEWnUJ+sGPy0QdLYv/WIp6xzCWya/zTM1meTfrlZfujmYmxGDEADtCMNnSi?= =?us-ascii?Q?VzLH0hj/pZ36lvvuRjcYNzl76XCo4d/cXZVLB6aHxXuTdENb+5iwEOB0akd4?= =?us-ascii?Q?6j+S7rINkfzlcLdMUN/IgwoOaG5EQVDGR89MIO6JmcLxpQHfTJECrHo3ucPs?= =?us-ascii?Q?u+u533v88XI6qkq6Uu+rm9gDVLaKlUjwvrl55kUVnDeIN0TGsEIE4bLuDvCN?= =?us-ascii?Q?4+9p0zgg1JBmjWXAlst+AZlbsEEO2PPdNMMIX397EdWVV30/X3UZDGcUa8kK?= =?us-ascii?Q?2JixAGfflTqvmsDhTdTVa9/Wc7ZCi/kuntqUl+tsILGb6pRez0zL1fne8sxq?= =?us-ascii?Q?GmkmUI7i7nfCeDS5w+7qe/7D036l3+uZX7BIGclzpaKtu0KMBNuj/KjlwjUv?= =?us-ascii?Q?qdI2oDXfgvJngov9SFW7ZSjdfHkrC/cQXz2f8ctTq46ZSJPgNMoxe+VmIZz0?= =?us-ascii?Q?nn1o+Adu9rb9JtF5Hd5BGIoqOBp+KtJUquqGIwd42acZ9Cy17dM436+YaRUG?= =?us-ascii?Q?RbAt2d493s6FFAu7EC/Fe+jRnLbUmcQtRta/QEFk48/J6M8iq/Vj4evMhppt?= =?us-ascii?Q?6Cn/VbAZokXp68DVY+iOcBm79dAIlp6QIRUc6hjcFKU3lzGM+6KUrY83mmYM?= =?us-ascii?Q?EsMoew=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd1b0d81-fc74-44b1-fa40-08d9ea58279c X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:39.3037 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rGKHQLc72v4gZDXjCtnuq9DUAIkp1z7AoqIzTj1yVaAJGR2Q1wP+mrJy/QrevRpSZiOOE/vQr7IJ0EaMdkqCLjiKLFu3YTDGs7sPqdveygU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2288 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=40.107.22.101; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644252654442100001 Content-Type: text/plain; charset="utf-8" Allow passing external Transaction pointer, stop creating extra Transaction objects. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/block.c b/block.c index 378841a546..7b65c7c5c0 100644 --- a/block.c +++ b/block.c @@ -2475,14 +2475,23 @@ char *bdrv_perm_names(uint64_t perm) } =20 =20 -static int bdrv_refresh_perms(BlockDriverState *bs, Error **errp) +/* @tran is allowed to be NULL. In this case no rollback is possible */ +static int bdrv_refresh_perms(BlockDriverState *bs, Transaction *tran, + Error **errp) { int ret; - Transaction *tran =3D tran_new(); + Transaction *local_tran =3D NULL; g_autoptr(GSList) list =3D bdrv_topological_dfs(NULL, NULL, bs); =20 + if (!tran) { + tran =3D local_tran =3D tran_new(); + } + ret =3D bdrv_list_refresh_perms(list, NULL, tran, errp); - tran_finalize(tran, ret); + + if (local_tran) { + tran_finalize(local_tran, ret); + } =20 return ret; } @@ -2496,7 +2505,7 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t pe= rm, uint64_t shared, =20 bdrv_child_set_perm(c, perm, shared, tran); =20 - ret =3D bdrv_refresh_perms(c->bs, &local_err); + ret =3D bdrv_refresh_perms(c->bs, tran, &local_err); =20 tran_finalize(tran, ret); =20 @@ -2976,7 +2985,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *c= hild_bs, goto out; } =20 - ret =3D bdrv_refresh_perms(child_bs, errp); + ret =3D bdrv_refresh_perms(child_bs, tran, errp); =20 out: tran_finalize(tran, ret); @@ -3014,7 +3023,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent= _bs, goto out; } =20 - ret =3D bdrv_refresh_perms(parent_bs, errp); + ret =3D bdrv_refresh_perms(parent_bs, tran, errp); if (ret < 0) { goto out; } @@ -3041,7 +3050,7 @@ void bdrv_root_unref_child(BdrvChild *child) * we're loosening restrictions. Errors of permission update are n= ot * fatal in this case, ignore them. */ - bdrv_refresh_perms(child_bs, NULL); + bdrv_refresh_perms(child_bs, NULL, NULL); =20 /* * When the parent requiring a non-default AioContext is removed, = the @@ -3277,7 +3286,7 @@ int bdrv_set_backing_hd(BlockDriverState *bs, BlockDr= iverState *backing_hd, goto out; } =20 - ret =3D bdrv_refresh_perms(bs, errp); + ret =3D bdrv_refresh_perms(bs, tran, errp); out: tran_finalize(tran, ret); =20 @@ -5067,7 +5076,7 @@ int bdrv_append(BlockDriverState *bs_new, BlockDriver= State *bs_top, goto out; } =20 - ret =3D bdrv_refresh_perms(bs_new, errp); + ret =3D bdrv_refresh_perms(bs_new, tran, errp); out: tran_finalize(tran, ret); =20 @@ -6297,7 +6306,7 @@ int coroutine_fn bdrv_co_invalidate_cache(BlockDriver= State *bs, Error **errp) */ if (bs->open_flags & BDRV_O_INACTIVE) { bs->open_flags &=3D ~BDRV_O_INACTIVE; - ret =3D bdrv_refresh_perms(bs, errp); + ret =3D bdrv_refresh_perms(bs, NULL, errp); if (ret < 0) { bs->open_flags |=3D BDRV_O_INACTIVE; return ret; @@ -6422,7 +6431,7 @@ static int bdrv_inactivate_recurse(BlockDriverState *= bs) * We only tried to loosen restrictions, so errors are not fatal, igno= re * them. */ - bdrv_refresh_perms(bs, NULL); + bdrv_refresh_perms(bs, NULL, NULL); =20 /* Recursively inactivate children */ QLIST_FOREACH(child, &bs->children, next) { --=20 2.31.1 From nobody Sun Feb 8 12:14:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644255100; cv=pass; d=zohomail.com; s=zohoarc; b=cwFexY7lJOiqxNsnYww0UKdaPNhSz1gHX462ZEtx+J1z/Aekc5StIcNgHfVngc8SKU/Cf5C4ts8GnygifWabVR5YnupIHrkxA9Xb/nd5LNE64ZfQ8vQVtgWWU49w6kS2XAG1emifBkfdvW4+0szj/AGkGsXsGeY5bZZlkIAQNHs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644255100; h=Content-Type: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=s7GFdhK9WnFzKeTGkO6aPU0eFbuWIrLwLe2fmSJOgXY=; b=k9r3HUDZGr38bPqLaXUJ7MiqQZvPenD4pZU8cghLohAI4JnpwiEMNG+9jizfpPU9eIgy25lkop9YP6Iz4pGhGP7befNqD7mjS32VA/DsjxaQRY/PvbXe/TS3mj3IyO8DGeWGQxNymJ9uSjRZn4jYiOlbZKl+0EUc06yEnEl0RoY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644255100953134.59280457794034; Mon, 7 Feb 2022 09:31:40 -0800 (PST) Received: from localhost ([::1]:58258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH7rX-0001zE-C6 for importer@patchew.org; Mon, 07 Feb 2022 12:31:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71T-0001mA-76; Mon, 07 Feb 2022 11:37:51 -0500 Received: from [2a01:111:f400:7e1b::708] (port=37729 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71R-0005HI-01; Mon, 07 Feb 2022 11:37:50 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VI1PR0802MB2288.eurprd08.prod.outlook.com (2603:10a6:800:a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Mon, 7 Feb 2022 16:37:40 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AnzdDe8qoIC9Et1m4XnrnrQ56BZK8ZyGAItfQXJ2MNwgTJWzBDrT7Z17fdsVFZDYcudpF4idbtyVN2zzJRzGwEZZPh9iPze/EV1rJ6YG0Ugpvuht6Rg0We1lT/o4EAZNs2bO3WfvRRgJu/swBN/NB2mj4c8It1TRromBk55an/ueJaBl1CaMbj9XCtKllgLCXY+sGjyxtQ9aIfv7UlIEh2OWkKBA+dbjh0+nDl+Io3DnyheGXL1i7cOThQ1t7Lx+49k5O5BiWnmZ9eQqzk1GZryIQeayS4TfJgbdyr+67CnLTRQqxcvBjfJj4NAawgGSIVg4flpE6Po3pzcqe8ho8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s7GFdhK9WnFzKeTGkO6aPU0eFbuWIrLwLe2fmSJOgXY=; b=et9p7xv82GBpnfeaBOs+peKBnPBlg0IFgYMRsORq7z+eFNxO+nYtFlXcUiObFcLnWj8d7iCTG6asOzUxHNvNcDUKfmaC5MV0K50oDp7tTubqKT2i6L/h7Y6diucwHsybOGC8L+yGOEZ8QU54tDmRt8c36l5hJud35eORRWvpzVR65fNx9H4AaEvBKsHlgR56E4SzHJ6ceprb3zTBEx23ggI+Wly+TWXVPiKFyQJ9rJXD9JjtoIPUqdpsMVvTq9fG+j89bBaJlooCHn+qqhYAdE5HEoNfjhJAEeJDTZvelxocWAIb9vqk9zzLHj0mSg5B9OYSy7uglW6xcZzKkPropA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s7GFdhK9WnFzKeTGkO6aPU0eFbuWIrLwLe2fmSJOgXY=; b=P8FTCcfd+C+d6437sHuvWQcJvkWh56RkQRgoUo8SzLSRP3Q+VFYxUeI9PBUnamti6RsDEOhQchcdQWTP44SmFMDlhFTTUXCAHqgu280mIPm1GslGtaD1/m++5N1E85qCJrFYuxjm4AxwWH4jxaNC8h1+nHlMkb1J7dqD784KmF8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 04/14] block: add bdrv_try_set_aio_context_tran transaction action Date: Mon, 7 Feb 2022 17:37:18 +0100 Message-Id: <20220207163728.30362-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b1f7695-2840-4329-f471-08d9ea5827da X-MS-TrafficTypeDiagnostic: VI1PR0802MB2288:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:14; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B9mpEobuZjif9iXzTtc6Lh7ND8+8FIaMgJ9ljyZ0f42559Lcew8eZUC0btaMuoLYsnnt43yxlrtcFtfxG8RmaEVU0JcMt2+8IJGsEJotHRzj5iqwOzkhaOpPDdp3bbl3jHBKPxphRe+uP0RPhcGVRqtJ1CiihxYTJ1tm50Q/TRPX9cd2WXzB2PobP5mgyXc8h2DyhJVxeCeuAYyEQzNMUzPKDGEjrMNIH+MB8uPCza9cT+beAwK9DYXXErYTbQJebaBr0J3LzkgRAXuPKqg/xYnXXB1j2q/RJ6hye4JblSfKsycOwLb2W17ncwJMx2OJJKxTCiEMgNqC3lN6mgdH50aNAWr9EIhZZaDFIUcsUBu9yNDdhM3lsIwz+h+169yh1P3IWgyxnhC2/dgtmVnBt4G2NRJ0BXdUbeCOEEpy4YkkNxJ/SSTQZkGX/RF9TGWwTPCrTDdgwy06IpCbqo2Y619OP/lkCDj2Z6QgufkK/yD1eSsOWrsfFwRyFXSfsYb3CwJ4Qlzr1WicfiFYYXI2ve8N4z28tuTYTLLYblIcvPB9uQRFg1eB41x3OIMSYeUMh8zO1ECrKSsFl182kLNCvxJCBhpGR7jlmNOYHuohGHzHIp1dHpZjgy9zY3/JmKtzJjU0C1OGqROV6QPZLUxXS1Rai2ezTAyIQhLc5fHrV3n2Sqk26VgWoOmF/QTHDvyy7DvlQHPuahjU497h85xjWQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(66946007)(66556008)(8936002)(8676002)(38100700002)(83380400001)(66476007)(5660300002)(6916009)(4326008)(2906002)(508600001)(26005)(1076003)(186003)(86362001)(6486002)(38350700002)(2616005)(107886003)(6512007)(6506007)(6666004)(316002)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?kny8ZL1UyAsR7Y21+34fncLDnw4oE9Qg435xOnPZd1tX9NdLQp/qRVArVuHR?= =?us-ascii?Q?rDpRB6OWtysUChkF5Rmusgh0woH6+M/ddjDWPTBoIXt8vGljwBT30d/Bp6Id?= =?us-ascii?Q?cyGEUDE7Ia1iX8JtryoqjEqbWZehmamn4ebh2TztN7jrgj4AjouFrNRPzVZo?= =?us-ascii?Q?4GiKNTWmZpA/tfDq8VjvTY921/u/Ny2x2i8VUaa13FyhRRdNeB7AgTqa/6md?= =?us-ascii?Q?3ln5wo19MNVp7ksKlX/JjDOftLf6ekk7shTr/1nRgywYD5Ih5I8gsOVghPc+?= =?us-ascii?Q?QWQt+Ya4ZeU+vYgkKeri8K6qgSSE+nj4PVaBlHOO95qfaqt/eeswRZGUHC6f?= =?us-ascii?Q?JkzhPpWqLNZ66YQhUr6uiXVn/qvXEObU+ghWx9BoJahovJoZ/gDJf75CA0Zx?= =?us-ascii?Q?9oNUtwK/KJ00E9ErhV2cYI1dy8QrHk4zsIIyMqGPSCH/hsUQy9zneyzuvL00?= =?us-ascii?Q?tB2VhSs0k5d+W2/0vWeYeGhH63irGPsMUEVxaEikiwgr9r8jJiBYyJR7wqoY?= =?us-ascii?Q?fxEPwbAtBhJChUAV+PMu+6mpdMe3JCk+qB5RN4kUIWXGXgHKCMKCtzbRfY18?= =?us-ascii?Q?A05T0stdZGaI6TZvrpYg8tTU8z6PDho8v3VxDaV5RfTSi70EQ4r/gPDazVWJ?= =?us-ascii?Q?qOomRIpIyqDDD7LZZtpfa2Vq/bhnosWh6pZpDdvQDfD0z7S17QA28qQGeajK?= =?us-ascii?Q?hjvtLQ46bWLeXGoga76gCJkj3Jeim5ftGKyYckFrcj3A1BnMGtQxBfiyouc7?= =?us-ascii?Q?gjLoeR8VNfJKU6G0dBwyzFB7w/u2sCje11pocYtNu3OQR0TAfCea2GAQTqe4?= =?us-ascii?Q?Z/shtpE51zeam3NqPUi8QErRpKLRMI8ewmESD9/gI0hcatynoZ/VsQoDv51B?= =?us-ascii?Q?qyW21sNiEl7GfmVA6/69KJw2Da9sB8ScKQX9093SYhC9XbfCM027yYE1Pr/e?= =?us-ascii?Q?u5o4hhPJbzw3jI+U5NmHz4HYFFXLhygR3lERO22PANtngmlc5tS0KBviFeas?= =?us-ascii?Q?NfSBxx3fWnOZPpqoJs7YZwpWWs+Jn5dHJb6GQQJZVhVNsEZUlPneMtpfwGLx?= =?us-ascii?Q?ryvcHUZCACK/Ails1qSK7MIviN3KLsGKOSYOETKcNAK7UDTVRAxXVYshQVd8?= =?us-ascii?Q?XjgsuCtidWtzqu9mv2k07l6HDcHvx8WueYN97aod8duAS7I1iJ1sFnyANZCm?= =?us-ascii?Q?gT9LqxCInolqOifA28vpxjndv8loTJse+H7eilWaGNUrBPnqb6mqG5hyhpAv?= =?us-ascii?Q?r3CRR+Ai9/0UtY42zofJeLkjPCYMl/Dyvy0F5zDIegokctDOi7/ijHHJkOIO?= =?us-ascii?Q?hzPCQlMEuuP5SLbu07k/1oGPe/NUzX5q9xudf93Cb7E9RsWfTAuJWW5/OZ5x?= =?us-ascii?Q?Ju/KVvedrKo/LHs3nV+HeHj4uX30D2I6+la4SHqNrcE4fs3YMlHzVqIe2vKq?= =?us-ascii?Q?E6tPOFSstTrnnHfSB6BQx3hFMDHGe1FhekYkWiw6vyOTNjTtJiloq3AKUvei?= =?us-ascii?Q?COBX/jEY1J1QNutAyfgmuENhxYUacX6u3XZqsTZ9PVNu6/jjPmOPtOzczMpC?= =?us-ascii?Q?JJsjyYoM92wc6uB5C79Wj71kas1QyCz/cYJdv6OlBFJm3RXs42Sfv70qpFsT?= =?us-ascii?Q?g6fY6LqMRQhUYc0VzWmNpA4yCOmXt+ypOiU4LyF+7Y+TJFM+/A/PCrNYJexW?= =?us-ascii?Q?kuIp8A=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b1f7695-2840-4329-f471-08d9ea5827da X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:39.7880 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: A0gYkYvSFGd/qBG0yjOoS/qq96hpD6kN0/3fuZf5s7IvWn0vZ2Gjg7PLqwsEg77glpm+O+htXdf3EMcz75qhGzSCQ7OmsVKW/ThiYDoWBHE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2288 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::708 (failed) 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=2a01:111:f400:7e1b::708; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644255103678100001 Content-Type: text/plain; charset="utf-8" To be used in further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/block.c b/block.c index 7b65c7c5c0..82fbf81a3c 100644 --- a/block.c +++ b/block.c @@ -2791,6 +2791,54 @@ static void bdrv_child_free(BdrvChild *child) g_free(child); } =20 +typedef struct BdrvTrySetAioContextState { + BlockDriverState *bs; + AioContext *old_ctx; +} BdrvTrySetAioContextState; + +static void bdrv_try_set_aio_context_abort(void *opaque) +{ + BdrvTrySetAioContextState *s =3D opaque; + + if (bdrv_get_aio_context(s->bs) !=3D s->old_ctx) { + bdrv_try_set_aio_context(s->bs, s->old_ctx, &error_abort); + } +} + +static TransactionActionDrv bdrv_try_set_aio_context_drv =3D { + .abort =3D bdrv_try_set_aio_context_abort, + .clean =3D g_free, +}; + +__attribute__((unused)) +static int bdrv_try_set_aio_context_tran(BlockDriverState *bs, + AioContext *new_ctx, + Transaction *tran, + Error **errp) +{ + AioContext *old_ctx =3D bdrv_get_aio_context(bs); + BdrvTrySetAioContextState *s; + int ret; + + if (old_ctx =3D=3D new_ctx) { + return 0; + } + + ret =3D bdrv_try_set_aio_context(bs, new_ctx, errp); + if (ret < 0) { + return ret; + } + + s =3D g_new(BdrvTrySetAioContextState, 1); + *s =3D (BdrvTrySetAioContextState) { + .bs =3D bs, + .old_ctx =3D old_ctx, + }; + tran_add(tran, &bdrv_try_set_aio_context_drv, s); + + return 0; +} + typedef struct BdrvAttachChildCommonState { BdrvChild *child; AioContext *old_parent_ctx; --=20 2.31.1 From nobody Sun Feb 8 12:14:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644256133; cv=pass; d=zohomail.com; s=zohoarc; b=fYeG0AhhJJxefFlG68ticTKwHidJAxs02SchfTWjQ9LAQI454FSg9nlfsj7BuGpPPjCRMMGvmEotDJH6Idd/DEO+TaIYGOkOJ4s0e68DtXJyLdxKZM+s0Y1QHpGabiMVxo4z8MOTp9eeYD5xtIbvgTO5T4/foUMyN42B3EUgvr4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644256133; h=Content-Type: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=LBf9Wv2yMBcKq8er3VGGXeluEAn9O2+bmsEL+pVKm+4=; b=h3+MdTVa7RE6OeBHVf0Pdd7s/XsG/ZRQd7R9Yjrj8zaGmH5Sj1OKYhBmHT9NcZRBy97g0jaq/nLx4VE0lIXrNQm316WmYT1jqGES0kZm4yCXd+oXSp++0bSdeSe6x9wtyUwNgrBmbv4SqK92MBmEnZHjswJFHqBuui7Is4Lweok= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644256132940340.2468535801364; Mon, 7 Feb 2022 09:48:52 -0800 (PST) Received: from localhost ([::1]:58058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH88A-0005JE-K3 for importer@patchew.org; Mon, 07 Feb 2022 12:48:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71X-0001vj-PB; Mon, 07 Feb 2022 11:37:58 -0500 Received: from [2a01:111:f400:7e1b::708] (port=37729 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71T-0005HI-PS; Mon, 07 Feb 2022 11:37:55 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VI1PR0802MB2288.eurprd08.prod.outlook.com (2603:10a6:800:a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Mon, 7 Feb 2022 16:37:40 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=duumjSqhp1sHb2kGrm8wDbknwnrOqn8n37m4SZeq3fHgrdMMnC7yF3rgSExH+5xs3XvL7Kc5ajgt+yKBu/QB0i3G3VOIDt8XGiON77xC1IOgBB2XDp7GhMpaO/uMvF0WqJA6L9ub89xTULyvxFinmwJzk+n3hZ3bCd6v7RSoJamQspDrm5eRFTBw5aAwijZxHDdpy79CYJgfyJVWPweAwrz+sOODCkpLE0PhRACcG1IMsgnH0vvizUzBTp+2lG4kpcLTYaOV2mizSuXJgvPzVa2UcE/K6X1umqePnzbxs5JbQH0ho3IBIvwTii+4RbL5DF5NUvbZFqbRX36Gnf/ovQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LBf9Wv2yMBcKq8er3VGGXeluEAn9O2+bmsEL+pVKm+4=; b=ftdX8nqwBqGAU95rrCOX5p5nvVqso1c2jB6tWYc47cdXTf+sLLp2ln+IWUyNALjSkjqtTU1ylrU3zkRRvkxD79CB+oxf1/aeflev/wWe/7HZKr2ztWV5vd6ZJp0wIgd08i9i/uTHKL89LRhERlfNIBT9sbkV8PopGc84Yh1IaeqmGPJkS3S0fU6Wn+N9xapHCN8vJ2NiKkmM1+DfRvyaimut0NA0uCrLOF6lk73oUVt3XfmoeJx0nJO7II21BPSgRgcyakLS+0jLjaD+LacQGWkAUH4vt1a60j2S0vB/MtNGp7Dbg4G3yeI4wWh8vLlH+z6PKaH0pQgfYzUCfvaBcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LBf9Wv2yMBcKq8er3VGGXeluEAn9O2+bmsEL+pVKm+4=; b=tGdGtjz3cj/TBcLQGDkWauGcoNA4F3rcMukhn/ERPM2IU/P7U//wH0VMtLcrGRT/g43V+UX5AkhV778acpB+s1bsGgmXCeHaNcQdFkbdhpzBU8hwVu5hTwpBz254y1drRlaBTrFseKnOrjmXafi1i0ca6ZnIaK9+5GbPa0p3wDs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 05/14] block: merge bdrv_delete and bdrv_close Date: Mon, 7 Feb 2022 17:37:19 +0100 Message-Id: <20220207163728.30362-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: abfa54af-e0f1-48ce-00a3-08d9ea58282c X-MS-TrafficTypeDiagnostic: VI1PR0802MB2288:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:245; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jgpaCF7naCPGMogWEEXsdkeh5mIeY6weWSPQPFcymVQ+4AgwDytKjVzmXyH2XfYSncgU2K/CJnluDUsUvLA435Xt8IzHvi7Z/1og8J+rsZNG3/RQ7lKBzyKOrFYFve5X5k3e7mPrrEj/Wnss9KSLmnQuEb1JN3eUfqEYHYuoUvYNy0HFbm5zN/gOQ63Z/5UlkvwWfeGsMCblGNVzXDimK/tEhewzntXnNaj/U/cIqkwevW6ch1eMd4NIoHQ8dOPtroBUbJFjKNJiYYqlDvFTAx+Y2Oz3AEvfNx9ZLN/yM5q9oSHi1ig6OB0RkmVv9Dlrpwqh2vPCx7Q6ZZAKwoj/cQqQIbLNW468aX5KzFwCqB93nExwcD/M+QHpVBV8rWMjUtV79YTr/JTI3hsoq4HcPsLWaLGz569E9u3OEKH/yBhUNxPg2oZq/OVlelr2l9O7CslLQtJhGiFk9YlNiJdTOD+kFKLDfMTFoZLVjFk1fBxQBmkOPQC/AeSy3RoFQud0bLUmkjRgu8XvsUDTEJdRzzmEoj8XqYm2/a8B9DJgG1QLuLJEgf2tnVFoaaYebuSc5BJPVtZd5RuLd7MzQCy7liIc35FHzgek8yJluXA3CHMU4Y1APnPzTdeR7lrDrAEkO2IGv7hr00bhdNrsJ9BOPk8hrA8pV3q/06GSUmnBfpveKNSzbsbK/tvp/OXhalKk6gXgd2Gq5LCyuZS5iA1fZQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(66946007)(66556008)(8936002)(8676002)(38100700002)(83380400001)(66476007)(5660300002)(6916009)(4326008)(2906002)(508600001)(26005)(1076003)(186003)(86362001)(6486002)(38350700002)(2616005)(107886003)(6512007)(6506007)(6666004)(316002)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?t2BbtW4OqRu8MURJx0oQBWq8CcawPbtdgzK2FMI0wAbIAbOO4rcuxI/yhMDN?= =?us-ascii?Q?KzVgHrv8ddF/EcXPY7G34FoTCbUV5sd+NBUbo14ctNOGQfydWJxrSY+SqRLI?= =?us-ascii?Q?C7cZzFkT9Y2zl2Sh3Sk+vWB4v97UNrw7+YXkbIM2Vk+Al3XmSU/17Kr9sNP/?= =?us-ascii?Q?lIkq2v8RDVdh+iS2IRtdcVViwJiiisI43rhkAZzUyJV3+Hi+wklh6F8cQ7AL?= =?us-ascii?Q?0R5rCQTGcV9ef7r1YOzhju7P88pt6xOBlNM7jaFi+Xh88LihpUBmZjnDXTV9?= =?us-ascii?Q?P7DkWLwECC0VBbGuCnEx4anjqZLdDLD2ZnuSQ4ONqKySgj/U+Z8Zn2f2qaYe?= =?us-ascii?Q?STBOioMkNKshmEVk+8nYUDNqOTMgsnafLszC/knxYCjUkTHfmhthG9pv7iDk?= =?us-ascii?Q?bCPNboDJ0n4O3uaY3CAjWT6RrDipyeaqLOcrKi3WwswRISzhc7XDzRU6UgQL?= =?us-ascii?Q?4bRg5oeqyQRnzZ/77ua0e6530pkP3ZOD0pkZ0qRBLL+DhmUBzwZh97pAxHlP?= =?us-ascii?Q?mGXmUs9yt8IJYxN7Z73HXgIuSXkZqIOYkKyqAXP1S6PFT5JdMfP0AdAbQChL?= =?us-ascii?Q?aPPTLkTUAskbSTvpt81RNSQlNIF6ysAo3itmYXr8Bh2Bl+nRyPi1HZ9z4i+W?= =?us-ascii?Q?DsMDtzn/j4VZHNDHz8GgGoKcbstLzJ9nWLEr1GL1137T9UFrxn3BuEIbllai?= =?us-ascii?Q?CLvP8iL0lYo2YeJUGGihyvJAvDjBzkWqCvUJunbir7u+xwlZlqulxNrqpXVh?= =?us-ascii?Q?SAbutCLwYgS0t82jZKrCCSW4NKH5uICQwlGLo0jDigsPrpGRSdWsTFzmz1DE?= =?us-ascii?Q?T4pU2lIhIYsHOrIE4oVolgj5yU7HXQX7OF2tehe8MDDamVxG/xBB/eTDFOr9?= =?us-ascii?Q?hY6uY8c1qWDAvIh4bocV1PuGwri7aadl5lkxJBGhTKIgLb8mvk8amguZlXbH?= =?us-ascii?Q?690FsmyLTDE8RemYuUFQwZBz7kLx3ytho5PPUHklPFbn2pAuCsSeWKJ6OliZ?= =?us-ascii?Q?vg9FF3RxS8npBa4c43z923aUa8mS1KR/9Kp45Ufcl1/kF2hN94FCIRFL0x/J?= =?us-ascii?Q?W24x6dbPljqkjC2qnMr1ZXCTbpmdEyi7WFTLL6F0g8LAvqUAtQ3Div6hjuNp?= =?us-ascii?Q?/tVIZlh8TxlQaeCz/x4GCvCXcrl8EOhDecHb8kCNb7a9eJdLbD4CmC50Q9sx?= =?us-ascii?Q?dSIo7evdqUrD28cot4J7d43GllYziUqvyJyRdyCGP4w2pfmSPLveUHW1XLlI?= =?us-ascii?Q?ifXPdI/BWSKJy89m3HuGHqG6sRIp/EVrAp6CMJOqvksfP7R6bpxAJXXX38PY?= =?us-ascii?Q?WQuGlOp8GlOlb+FvfFwYb3uljJFbAvdX3jEsRYic6T7X6ymEjJmQjLfg1S+S?= =?us-ascii?Q?XrbZPWKUzhrgkIK6R31ZVYzZHyGZCR+FgOkztMTgLgYM9QQKA4hg5dgfPNLx?= =?us-ascii?Q?A5Mbo5v8nhIZV2dXlVApypoYYFnz6CHUrzpObDgx24wABdqOanG3S3xOmwSf?= =?us-ascii?Q?a7CAaBOGa3FwH/Mg+bpKr8zEwSfahi/eqG7PJtZTlsVQCaYz7imdDXaGVDD3?= =?us-ascii?Q?TIjsAsVlHMVmYtvakrwSHhtJPwSUTzi57MlOD2E8cI81jeVhotVB74jUW/Q6?= =?us-ascii?Q?wrPuJRl5b7mZDwYRWroXLZcJ3SwrKr3GKLgFBwA9ms+2ReOi7MZBta8r4NC9?= =?us-ascii?Q?1FHatw=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: abfa54af-e0f1-48ce-00a3-08d9ea58282c X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:40.2723 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9jjTs2BeCSZ/0/3+VK9xzZsGxlc2HEKftuhWGyOMAysZ4UIGXlrUHtiWtzSEyWrvgkf/LCQEkWktPN6UbkbhIgI7GZ78SG73dfPh+14cTAY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2288 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::708 (failed) 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=2a01:111:f400:7e1b::708; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644256134348100001 Content-Type: text/plain; charset="utf-8" bdrv_delete() is the only caller of bdrv_close(). Let's merge them to simplify further commits. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/block.c b/block.c index 82fbf81a3c..71a5aec24c 100644 --- a/block.c +++ b/block.c @@ -4785,12 +4785,19 @@ static void bdrv_reopen_abort(BDRVReopenState *reop= en_state) } =20 =20 -static void bdrv_close(BlockDriverState *bs) +static void bdrv_delete(BlockDriverState *bs) { BdrvAioNotifier *ban, *ban_next; BdrvChild *child, *next; =20 assert(!bs->refcnt); + assert(bdrv_op_blocker_is_empty(bs)); + + /* remove from list, if necessary */ + if (bs->node_name[0] !=3D '\0') { + QTAILQ_REMOVE(&graph_bdrv_states, bs, node_list); + } + QTAILQ_REMOVE(&all_bdrv_states, bs, bs_list); =20 bdrv_drained_begin(bs); /* complete I/O */ bdrv_flush(bs); @@ -4844,6 +4851,8 @@ static void bdrv_close(BlockDriverState *bs) if (bs->quiesce_counter) { bdrv_drain_all_end_quiesce(bs); } + + g_free(bs); } =20 void bdrv_close_all(void) @@ -5164,22 +5173,6 @@ int bdrv_replace_child_bs(BdrvChild *child, BlockDri= verState *new_bs, return ret; } =20 -static void bdrv_delete(BlockDriverState *bs) -{ - assert(bdrv_op_blocker_is_empty(bs)); - assert(!bs->refcnt); - - /* remove from list, if necessary */ - if (bs->node_name[0] !=3D '\0') { - QTAILQ_REMOVE(&graph_bdrv_states, bs, node_list); - } - QTAILQ_REMOVE(&all_bdrv_states, bs, bs_list); - - bdrv_close(bs); - - g_free(bs); -} - =20 /* * Replace @bs by newly created block node. --=20 2.31.1 From nobody Sun Feb 8 12:14:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644252428; cv=pass; d=zohomail.com; s=zohoarc; b=GkQ7p1dE9t5NVHNVE1VnXD4agF4x0bSUrEf8zn2oUHRytFYZ2thb8U6ZXRIn2KFipY1zudpvzV83FMY3t2sb8kQAfkrnLSpe9hNajrwif2AQKFOj1HaLKFCEcTejueUNh5nUCFeSd4or8WCTkWGMNCpmE3q9At+e5cx6iw13Zg0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644252428; h=Content-Type: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=7lnFpgIVdxs1RZImj/ndhVyBDbT/WqjtFKU9MRx1YOA=; b=mKHwXGQF19t959bVHIsdqCEGECKaelBBhqSe9gdgC9q70TT86WE2OKylvPDx9tLSP7dr+G3mGAAzMEiJQt0qovWpuKsSGusFT9kE0dkHFKRdtVQX2M0106QOaP6PfU2vDBEilAEi1UG+kFq64osXoGumcowjCdd7mrrlY1QE9ow= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644252428002497.866146410948; Mon, 7 Feb 2022 08:47:08 -0800 (PST) Received: from localhost ([::1]:53444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH7AN-0008Ao-FS for importer@patchew.org; Mon, 07 Feb 2022 11:47:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71Z-0001vx-9Q; Mon, 07 Feb 2022 11:38:00 -0500 Received: from [2a01:111:f400:7e1b::716] (port=32353 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71W-0005Iz-EX; Mon, 07 Feb 2022 11:37:56 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VI1PR0802MB2288.eurprd08.prod.outlook.com (2603:10a6:800:a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Mon, 7 Feb 2022 16:37:41 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RXZB2o1g7LOm1EJVZq9Sv/jz2WiztmgTrvX0+jbnR3knSEqFouNwFrjVVrxyHMmyfCUX40CCeNrG6YzX1noluQptFiYm7wwaC0S5NVIrwJp3D+d1sKoiuUw31JyFOf0vGpcW23H8h2IAs9i8TigYRE5ipFfJS7Ri746kCx77xmnVwVkYEghoMIvdV8/rZFmWJQvq8GDcHL2H/bpihlXgEP57vLf7U08o9KABoYDUDqkoiAbc8MS6WODsQjxkIwDBxYjucyODOyV7tMhO08PfEr4ckSjFaZKOLfwDhnIe5fgL/Md5F6T9Ij7WqlcFWYQlNlqdEgrQg/F5lCTRYHGPQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7lnFpgIVdxs1RZImj/ndhVyBDbT/WqjtFKU9MRx1YOA=; b=C3CZHvbyx5BMGzm8KQ+HuxHf1vX6T6XZS893+XF2W30VYUf1oqaDyyiumTs8GX3SfzwDwKAB5UYftp5boL0yOhdNWl97e/9EcY75fSOoYUcNF8ds+8odqJV3IIZBEuQPZ8vQT5pmTA2Pd4JWkb2S3ET/KG2FaSNu3FTXzphF/XDs2GA4/8PaeUuaImaTqqsNzQ6fPofsTYErGAWwxT8B0hn8+OAYuKOlfc0ekZ2v1YBonE8xpWr2NshHGta82s1DyQdjyloPI9+B1eai4bOmR97lSp47kp09QP2eL4ftkQnBPyrDJliEUMrQqO0hflRciw20ebN3D7EqSlUxUNlVOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7lnFpgIVdxs1RZImj/ndhVyBDbT/WqjtFKU9MRx1YOA=; b=dsT6rtRRFMb4Jk+wURCy9UtfTsbtdFN6rcEmgiQf50P8ctTrl3UHw5ZDS3VLwQzKuMLHt9w46QHkr0g/B2gDhmzS7foJEBI081/ayl8yLvOsfKPjHcZL3LzFjsfSahU4IQfcKisStDfric7G+RyMmcN2K2uaKns9ienEGgQ2J9s= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 06/14] block: bdrv_delete(): drop unnecessary zeroing Date: Mon, 7 Feb 2022 17:37:20 +0100 Message-Id: <20220207163728.30362-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d2432d3f-dc8c-465c-50dc-08d9ea582871 X-MS-TrafficTypeDiagnostic: VI1PR0802MB2288:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:130; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MiE1jCEH3forBYdKmuT/SpUAYbvZGLhgMJl7a+yPupNthj5dWwqcQAdb1NEW87948azTClFmkBoLOVgGVNLv5+bmXLqLZAzQfzFW8Fd0BQG8NkMSTUSKXN6XC8C2BeYDLPVxwEw8NbXq2LuWltS6ZS0/nT6spq9Il/tFK25ykdczU+DDYAPoJr5cNzQKUshCphjcYSUGtns71l+qGbCL2jXzgiQ0yRYeA2O3sdDhiIoszPWI/XNfj4Rb21wDE7kEkIXW8SZ7QfjlDIj8upV4xmExltRUd1+eW76GfhtzQ7UQnQdMftBedspyRvhPFwnnY6t5NhmhDHmPbtQjfLTY4HhniO+R61v0uOLdueS36cKZogdn9Hx+jYWP3uCiYNfm0TM/ty/Pg3zWQQvu9mmHxv8+GE9ZShua9Y/JFy3eMQqH/YpcsDpfyR0f6/O1aaCkdD5o/PCTozne0C5aXYqfawJIbYDEXCrLQgM8eEzI2J9KKUGfQrdLPx+ZZgUclUH4xNHiFX6Ik1SsitdhMjM7bL6b9gCWshfNPUAqt1ExbIaaYhjiPBV6u9Aud/5LCWVbwr9POi9ehIim3BXec+oBIPiLuBLAPscZd3gmdI2iGd94fNobFeFqGAzDmUaAwsm6q5wFfdHVJ/YW5DyKF8D1tqVIJtjQwfqCAjfToc8W9CGnjCDBTzR0qt6O3EbHXH822xWPfYpcrJUFCY6Jof8Fhw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(66946007)(66556008)(8936002)(8676002)(38100700002)(83380400001)(66476007)(5660300002)(6916009)(4326008)(2906002)(508600001)(26005)(1076003)(186003)(86362001)(6486002)(38350700002)(2616005)(107886003)(6512007)(6506007)(6666004)(316002)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?wQln8QkBIfUPx5Gk043bhlQnOZ3S0OZBd3nYyojlo5A/CQ/R6q7dqCVwRMa5?= =?us-ascii?Q?sJonpvUbrC5QdhvjhBIt+fq9OpvhtB8+TC4skmZ+6baEd5FvGIYMAFUGyCjZ?= =?us-ascii?Q?mBNz6rCZEA56knePX1SuQed3Wr31T8ozPsVgZkKzRzn/Q+OGi128jJ0G5HMb?= =?us-ascii?Q?wd8i2bMSOA375YjqxK77sSSVFuxiSIyLtTBQgvIt8PvRGVxKv7rzKLHtlaHA?= =?us-ascii?Q?/+ZYOBoalyr74yxii2zs9qvZczYXgbwARq7U2FA4uIl57lY5ps/OO/ha30NL?= =?us-ascii?Q?NoJRyUBRfqD5Ye412TVnZyzvNvwpYtRTxuAmF2bBwGGJMuqxWZB/EVIXOQyu?= =?us-ascii?Q?yt2Xahhsk0NCvbu2ZhQ4W/LbP1rcCnN6Yd7JZphBto9ZhUYtcivIwJuRJ9NS?= =?us-ascii?Q?iexnMgpL5RJtEZ9pKzQp2UKxo3iTlRo7QpDx2gTo3VbCrSFTvvD5jGmOr2dI?= =?us-ascii?Q?01x/j4br7uv4N07GOGtbbq+iJi0NR5vyrppn7IF4Sd9RQ/Q4snzn0FDSbZd9?= =?us-ascii?Q?rZY91p5apTBb0Hz8VsVeXFGgjj2Gd9HB5lnI5z3ZbVT3ZRU7MB40H+WNQ13k?= =?us-ascii?Q?YaTb1qqEbOyiexTUOKlm7233dlUyd8TubgjnCwVqK1QgKx+BIcsW6VN7dpB4?= =?us-ascii?Q?akbzwHMdPDgErwJfdhOHnNBKIT4YQFm4vRUYDiZXyeDfSnOZNuCp1yr2ohUa?= =?us-ascii?Q?8alPzOw5HOJCQSQmMzGFMCm7vZ6WkaqhEU4OIJ183HBI2+d/1rEjbxLjzlv/?= =?us-ascii?Q?qhr34m3PXOwBKFsdnXIzlXXnWUVjbkHMScsymhAGG5pOkYCtEPvvQvqOfxeJ?= =?us-ascii?Q?CeDnGRGUsde+z1/CxlOiom1sKcphg+cALVIwOQbh1vucZTXfjzCbzWp921AA?= =?us-ascii?Q?BQSXV6Ui61iFSvqL26gKFZLZ6l+vRr44bkz/QRy+SPVJbnNSgv33gZlTYCvx?= =?us-ascii?Q?Wk9bWldCMzGnGL917IuiMwzK1z9RDR6CjWyms/BCdx1aDT0U5+l5yzMvpske?= =?us-ascii?Q?dEcSUszF6aycz6aBuHbVr470ozPJ+mNQBIvtb4mgOIDH1oqaJNF9QRs3IODp?= =?us-ascii?Q?REx++novSUtvRGLp9APBOXosVpUENk+Kf1PQhgD5cnakYJfW87v64V/BatjX?= =?us-ascii?Q?okGKuZ12Puj/1Ntc0C0gjXMqtwCXTQ+BDSMnmn3la9LKSVakcrUsOWvYGUC/?= =?us-ascii?Q?Tcqh0l/KNAkzHs9dGsqKDmAk1n5rcD3hUSacUx3isIgop4VPyZswc3ZV6I8T?= =?us-ascii?Q?FokecrzrpyNTEFbYiqXs8WoCxWJpkiotM98Y8uMS3VlBLX3WykWyVCXM+13K?= =?us-ascii?Q?eTDdkrFg4FbHZ7mKYFvZDqV2H+MtsPRn7mVpgKP105b8C0ucWUunvi7Fmu5d?= =?us-ascii?Q?xw5hCPV3iQyJsEi/5+YtpKvlGOdknMjgNCILoAkW/FbWjcBihZ9OImDivISi?= =?us-ascii?Q?QX8fBZUkEIjd0pP6nBcnJ80Oof2c3UBiD6oSGksZEeR3oF1iGXgLDyAdglL6?= =?us-ascii?Q?g0p2BxV7r1AQhzoA30TpAtrMvviYt7/uw0GNJxEhwmcfpD6C6Srcra8ta/8d?= =?us-ascii?Q?CGJZsVWWS+sGO4np1MXYbaQ22Mtgm7q0hXadFa5MV5mHeFIBZ7nc+IEbLd6T?= =?us-ascii?Q?ybGkDJuPFXDv1efUtkhjzZTNHKywtEXNpa1FXVoqzTfjOdy3UVKdq6PvtzcO?= =?us-ascii?Q?bPBSjA=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2432d3f-dc8c-465c-50dc-08d9ea582871 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:40.7422 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: M7bskBH/JhSYg/xSG1mU6FoLP3nrCya4qS3ocmtHrUyeTrxOLYXPXcYVm3TLVaU8CplQxBo4kN2Fq8CdIZxqXJ9hYhy++DqOAq+/rQ4HxSM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2288 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::716 (failed) 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=2a01:111:f400:7e1b::716; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644252429074100001 Content-Type: text/plain; charset="utf-8" No need to zero all these things before g_free(bs). Move memory freeing to the end of the function to simplify further conversion to transaction action. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/block.c b/block.c index 71a5aec24c..231d1fc3ea 100644 --- a/block.c +++ b/block.c @@ -4815,32 +4815,6 @@ static void bdrv_delete(BlockDriverState *bs) bdrv_unref_child(bs, child); } =20 - assert(!bs->backing); - assert(!bs->file); - g_free(bs->opaque); - bs->opaque =3D NULL; - qatomic_set(&bs->copy_on_read, 0); - bs->backing_file[0] =3D '\0'; - bs->backing_format[0] =3D '\0'; - bs->total_sectors =3D 0; - bs->encrypted =3D false; - bs->sg =3D false; - qobject_unref(bs->options); - qobject_unref(bs->explicit_options); - bs->options =3D NULL; - bs->explicit_options =3D NULL; - qobject_unref(bs->full_open_options); - bs->full_open_options =3D NULL; - g_free(bs->block_status_cache); - bs->block_status_cache =3D NULL; - - bdrv_release_named_dirty_bitmaps(bs); - assert(QLIST_EMPTY(&bs->dirty_bitmaps)); - - QLIST_FOREACH_SAFE(ban, &bs->aio_notifiers, list, ban_next) { - g_free(ban); - } - QLIST_INIT(&bs->aio_notifiers); bdrv_drained_end(bs); =20 /* @@ -4852,6 +4826,20 @@ static void bdrv_delete(BlockDriverState *bs) bdrv_drain_all_end_quiesce(bs); } =20 + /* Free memory */ + g_free(bs->opaque); + qobject_unref(bs->options); + qobject_unref(bs->explicit_options); + qobject_unref(bs->full_open_options); + g_free(bs->block_status_cache); + + bdrv_release_named_dirty_bitmaps(bs); + assert(QLIST_EMPTY(&bs->dirty_bitmaps)); + + QLIST_FOREACH_SAFE(ban, &bs->aio_notifiers, list, ban_next) { + g_free(ban); + } + g_free(bs); } =20 --=20 2.31.1 From nobody Sun Feb 8 12:14:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644252749; cv=pass; d=zohomail.com; s=zohoarc; b=aLo+SmAKSqKx5M34NikflvxLwQ/HU25Jdqhk2ei1T9tOatpO80Faoz8f1+FwMoxGRClPFZhYKJegn4HnJWCxIxJNsrXe3cLb+eVPjhOJ8lP5qRP+B/IJPDwNYZIl9+VXJ8ZC4wEgu82xSFYXyCVObBAr5P69QYm98ugOJrGeA9Q= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644252749; h=Content-Type: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=QqxVebqERuPjgngu+3mg08lAPznmZ3tXdJj5+2tXJqM=; b=SnEoqEFxGVwzCu4kcR/bNfLMv6ECeQd2W2Q65kKzZQpyhuUUxYIChC+SBfyuZfomcnA4XyjtmlkJiNcm9TcPnuXIajGdW22MP/v5vmq2+4SGUrkBkmWrvJCh+5YkOKKHC9+6xQej85hLSefS+L7l4hsvL+xAfyqqy8wdRmalR0c= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644252749731276.02827406452855; Mon, 7 Feb 2022 08:52:29 -0800 (PST) Received: from localhost ([::1]:34880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH7Fd-0006oX-7k for importer@patchew.org; Mon, 07 Feb 2022 11:52:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71a-0001w6-Fc; Mon, 07 Feb 2022 11:38:01 -0500 Received: from mail-am6eur05on2101.outbound.protection.outlook.com ([40.107.22.101]:1216 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71X-0005Gz-MY; Mon, 07 Feb 2022 11:37:58 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VI1PR0802MB2288.eurprd08.prod.outlook.com (2603:10a6:800:a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Mon, 7 Feb 2022 16:37:41 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MOP9ZDK98txgaxSWM+CVEoI0KFCWzWiGF72zuk6dXE22zd4QX9/a1BeMQcLNO0dEfni3StqB8iPch8W2RSZykyBkMnTEUc0Fv6N73WD8zzlvWA4kDpN8W9JHyf9EZC3VSqSRT97qqxsN906AUV0lqhOKr+mrWfUks0pvt16FbTs03MNWyJBOjLsuGMKccN1wuoAog5eD9y/TouQOD2rihha5f9xyEO2WW6CpYNIEBIwx4Q54/oIwf3xKyKwF4TlzAZp3V7i20tRyIJb4Y6pPP+ygJrH3GtzEBmslzm6tsHl8xgD/cFI6wtZPI51fyvOqhEM/KLhBw6SXC53R39JvaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QqxVebqERuPjgngu+3mg08lAPznmZ3tXdJj5+2tXJqM=; b=VXb4iqfhsxToEaL16GaXzEztuEAvxJr7QRziLNk4ZlyXzVgo98uy0aRjnSCD0SEkJPnZ2dsBMrPtkbdBHt3wXVspYQau49TPHEUBJ5xcB34SsLudX91RNyV2DWXYkeIEkFMtQpbBshwH/xQXE4d1QM4rFuP+bXUJjh3eoIT2M+BLWR4ssnykaF+f/yS/ixoBfL3//iRoXApPpRCMX5FtHiqgKJQ4+xIKfRTBy/uRR7ss1L52n3Po+qGJj04jZfP2pnT8TzESM43dtPL1agWKzMu6YT8lym5jXERRm0Qqq7I3U85jMofY3hNLkEFLvTYL/rsUfiKi/a6X/5AyPt3DlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QqxVebqERuPjgngu+3mg08lAPznmZ3tXdJj5+2tXJqM=; b=g7FtQGpyT9ttZW59MskNNp2judKFB2+jr89fbjhnbV2U/23B+om2VMumaoBmrT0ykYQaiLT1MkC4tO+IVlBOUllS1wHgn9FGne+6FrMgoQBxXc1r7Q5o2vBnE5C7RcZ3rhyOUbz/0xMXxVE+xFGfwcfjTt73iN81IWh6oSuKR/U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 07/14] block: implemet bdrv_try_unref() Date: Mon, 7 Feb 2022 17:37:21 +0100 Message-Id: <20220207163728.30362-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b2d607b-1e7c-497e-0f86-08d9ea5828b4 X-MS-TrafficTypeDiagnostic: VI1PR0802MB2288:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:156; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SXEtA5qzRVORQj1iCl/DFeuDIl40ABZ+6RBO825kDh+phNahzJ7xkYUsCTi7aDc773+OyEtoBuu9lISkXp4uaDcomOUsTJ25m8dPCnT+1YvZ/gEEv9aLEPxVEtvD71MFsMbnR3MH2pQhTC8ECfrKtjQs6JEHDrThtBT5Ylvz06ErMe9LfHbXK0OXxWPWEEC0Fqs3Tbk571tD4HgWT/xRpl0qv8mmGFi+Lj1m5NDIgIzNnZlrdMOIjHStz6vH8ch7yBC6TTKy+yLJDJXM21zwB4F3TVNl1SdbfO9YXGnrCSZdn+dz/F2JIrA3IbpR4CwYaI8hmK6V7BIyYlFWdyNDBcolLuPZ715kUxQOHT7p9mXtYX0b7qWySEdBz/cOPqsSsAhEhgTud4FmL4WZAnTaXYM5+l3tuSmOWVRUXYT3gJ/fR8S/iFaPVBBb0tLJBqFJXz5E3Ex2VGUsWrN79FwLMo0Q2GRgqtUyJyctyHQ4FvtRNFzny+2R4SWWK0PztqHLq3YZLJREuYNy1R2a1K1pixbVlZX7T+xQjgOzQhrwIPn/7RRN2C4Rprew1fxj91X3oHvvpmIMy90EI/io21zP7GjnuFAcIzxzjRHJVz9Ool4bmXRHd3JYorjlI7lr+fyVqUDLVdn6IQ/U+WcnC4+Er1izpuVdLyj81jiqcj9bIrH3sUJ4JeDgpY3pPZu2eFOmsK+ya1AOMBDxaf+qoNWuBQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(66946007)(66556008)(8936002)(8676002)(38100700002)(83380400001)(66476007)(5660300002)(6916009)(4326008)(2906002)(508600001)(26005)(1076003)(186003)(86362001)(6486002)(38350700002)(2616005)(107886003)(6512007)(6506007)(6666004)(316002)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?TXVSckxz1orleZqwwDwFXIh3y9ot3xla/vthFMrj3XyMcl9ZDsPuPRY5/lOJ?= =?us-ascii?Q?rT45o3m/D2YuZxsxsbvQT/2MCg8ovm+qdawBt+Y0piJxiZ9DNH36xZ3Kz3Tb?= =?us-ascii?Q?LWVan5uFuY2SO8Y+SEiOOjeQf1dm0MbYPmhzHBJEMMlvKeoViwF73t/QmAtH?= =?us-ascii?Q?2oemHN+7luSCr0+WP0aZryLH2M8viuONZt4lQCraRSYRKhKGBGvvLsQU8ops?= =?us-ascii?Q?9qsm8zXhY5xY2oR424BallIIU0JHyBrO33ZlkqI5eLUOzC/JvcPSREWNhYb2?= =?us-ascii?Q?66L43sLpPYOLQ/fFNRmm1JF2e95E4u5e2qPWsdNHYM+PW3way2K/VmMVwCeh?= =?us-ascii?Q?AzlEvmH4P4so3FLG3cFCHd+qrj1Ca+GSc1cZRMZW3G9amtFT3TZ8ZHp1dnNf?= =?us-ascii?Q?tuv9Ti1MQbL8LlKxwHs9VxItD5n/w14adwAtD+Qv9vN27A96YjYdpzMXgAHo?= =?us-ascii?Q?8lb5Py1OMKSazS+xnb0kkT17mg83TAE4tbqbITrQdz7rOgWV+9VxmLJ6/IG0?= =?us-ascii?Q?RrvWscshYOfBz5khXLyJpgTSEmnQd4/5p+KlpcUOSQtGe5p0E0qFuedDlkEi?= =?us-ascii?Q?fD49GK9/8N3TCEseOOIadbizBNnFjQxGMFp9b8mMBDS+XERrGeMdR3+vBybL?= =?us-ascii?Q?xDw2DYxztTPKznfzBrQZO/jRWDD893estMWO0J+5RCMcSoSgL0gVouxcAjfG?= =?us-ascii?Q?W8C2ryulYsJDuSeraEW4x1GT8pP6w7q4BVpU764n5GGHBQu1uQxW1vX5lqtj?= =?us-ascii?Q?5lh1jFctDHQIXcGhwphW87Vuv48cHnr0kwyeeHPwQNFctEJmqhJDfXew5gIF?= =?us-ascii?Q?bFUTBjy39jd+XQNi1NKBCDxT1aZEcmlFB9PEc+DEpQHJjU+qKTEt9dKCib59?= =?us-ascii?Q?5wpw3/4wKbEh1+o+jVuUcmYK8PNdf/jG/MOmWKo/YPKGepvDsAdYmPzqP2UQ?= =?us-ascii?Q?VNB/uKRYr/N1xyfZn3bp8S0hsHLErRojZXClVmgHLLZmlGuJWJ8ubmtTW5fq?= =?us-ascii?Q?ZOZT0hAExq8A/fvrQgVPKUCgdS/4+RCED5Vj1zVsA88XmR2kl5c5Hx28IzJh?= =?us-ascii?Q?eVMl/e5HcZ5U6fwy1JEYLwTYsB/jh0UF5sXUokSF7BPwKGhXdNuXtAVLsusg?= =?us-ascii?Q?ptW59wDnIxMT90qsS1D2SZo5lWTZ1o8x6SA1jlaecUTnO86ixRCyYrLPSAm2?= =?us-ascii?Q?7TYaFuzfu0tgdnJNGJ9DlCWXF2TBb3aVjD6km+/KtxoZTVKF7hS+COI/jvNa?= =?us-ascii?Q?vfE1Ypn7ZPtsDTDsl3cn0ebK6jtQ1bLBHmwvnrQvv+0bZqiccNVgDUU7NiRU?= =?us-ascii?Q?G1SqONbTayaRNv3Lpt9aD3ht9tZAwzYWeaLbqQ67loh4rK96zRAF4A5qsp8+?= =?us-ascii?Q?0oIUpC35692STRHmhI7LwGK5Ku2xPHOPO5/ORX/+H2ujpTxUboOuYb41a7z8?= =?us-ascii?Q?ctvhfzkQZ17XQH8BZFZ2XemV38hokiNuxtodW2/AHM9W0/MxteQS6k6LqDwE?= =?us-ascii?Q?E9taFQlMdZiJd3hQMMBA2xLci1heHR14zDjLW37QH5Yy61/iOHBij27b3o91?= =?us-ascii?Q?OwOTw2r5M9y/v/wzU5YpaHZMeTPJJylnNKjeZbnAnuL8bWBdiNYBP0t7fFWu?= =?us-ascii?Q?T+L6pA0/wIwnxFAeZciS/9fIcx9Fssu0V3HltEFFNjwEj3YmHEKktUg6s8/Y?= =?us-ascii?Q?oHS3EA=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b2d607b-1e7c-497e-0f86-08d9ea5828b4 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:41.1952 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Zp9qvz7m+KtQsoO/g5gNfCmi8AxErKAtXVGIp8Kanhr9saj0NGvuwULljD+da11XZx4n/12MsK7S3EIsIAZ6TZDbQdGJBD7S769Jf5Jy5Iw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2288 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=40.107.22.101; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644252751768100001 Content-Type: text/plain; charset="utf-8" Make a version of bdrv_unref() that honestly report any failure. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block.h | 1 + include/block/block_int.h | 2 + block.c | 247 +++++++++++++++++++++++++++++++------- 3 files changed, 208 insertions(+), 42 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 768273b2db..42d78a7a31 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -672,6 +672,7 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs); void bdrv_ref(BlockDriverState *bs); void bdrv_unref(BlockDriverState *bs); void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child); +int bdrv_try_unref(BlockDriverState *bs, Error **errp); BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, const char *child_name, diff --git a/include/block/block_int.h b/include/block/block_int.h index 767825aec4..3126868633 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -188,6 +188,8 @@ struct BlockDriver { int (*bdrv_file_open)(BlockDriverState *bs, QDict *options, int flags, Error **errp); void (*bdrv_close)(BlockDriverState *bs); + int (*bdrv_close_safe)(BlockDriverState *bs, Transaction *tran, + Error **errp); =20 =20 int coroutine_fn (*bdrv_co_create)(BlockdevCreateOptions *opts, diff --git a/block.c b/block.c index 231d1fc3ea..187732c6f8 100644 --- a/block.c +++ b/block.c @@ -101,6 +101,9 @@ static void bdrv_reopen_abort(BDRVReopenState *reopen_s= tate); =20 static bool bdrv_backing_overridden(BlockDriverState *bs); =20 +static int bdrv_unref_safe(BlockDriverState *bs, Transaction *tran, + Error **errp); + /* If non-zero, use only whitelisted block drivers */ static int use_bdrv_whitelist; =20 @@ -3084,30 +3087,60 @@ out: return ret < 0 ? NULL : child; } =20 -/* Callers must ensure that child->frozen is false. */ -void bdrv_root_unref_child(BdrvChild *child) +/* + * When @tran is NULL, function never fail and returns 0. Still, some stat= es + * may not be saved correctly. + * + * When @tran is not NULL, first failure is returned and the action may be + * rolled back. + */ +static int bdrv_root_unref_child_safe(BdrvChild *child, Transaction *tran, + Error **errp) { + int ret; BlockDriverState *child_bs =3D child->bs; =20 - bdrv_replace_child_noperm(child, NULL); - bdrv_child_free(child); + if (tran) { + bdrv_remove_child(child, tran); + } else { + bdrv_replace_child_noperm(child, NULL); + bdrv_child_free(child); + } =20 if (child_bs) { /* * Update permissions for old node. We're just taking a parent awa= y, so * we're loosening restrictions. Errors of permission update are n= ot - * fatal in this case, ignore them. + * fatal in this case, ignore them when tran is NULL. */ - bdrv_refresh_perms(child_bs, NULL, NULL); + ret =3D bdrv_refresh_perms(child_bs, tran, tran ? errp : NULL); + if (tran && ret < 0) { + return ret; + } =20 /* * When the parent requiring a non-default AioContext is removed, = the * node moves back to the main AioContext */ - bdrv_try_set_aio_context(child_bs, qemu_get_aio_context(), NULL); + if (tran) { + ret =3D bdrv_try_set_aio_context_tran(child_bs, + qemu_get_aio_context(), + tran, errp); + if (ret < 0) { + return ret; + } + } else { + bdrv_try_set_aio_context(child_bs, qemu_get_aio_context(), NUL= L); + } } =20 - bdrv_unref(child_bs); + return bdrv_unref_safe(child_bs, tran, errp); +} + +/* Callers must ensure that child->frozen is false. */ +void bdrv_root_unref_child(BdrvChild *child) +{ + bdrv_root_unref_child_safe(child, NULL, &error_abort); } =20 typedef struct BdrvSetInheritsFrom { @@ -3176,15 +3209,28 @@ static void bdrv_unset_inherits_from(BlockDriverSta= te *root, BdrvChild *child, } } =20 +/* + * When @tran is NULL, function never fail and returns 0. Still, some stat= es + * may not be saved correctly. + * + * When @tran is not NULL, first failure is returned and the action may be + * rolled back. + */ +static int bdrv_unref_child_safe(BlockDriverState *parent, BdrvChild *chil= d, + Transaction *tran, Error **errp) +{ + if (child =3D=3D NULL) { + return 0; + } + + bdrv_unset_inherits_from(parent, child, tran); + return bdrv_root_unref_child_safe(child, tran, errp); +} + /* Callers must ensure that child->frozen is false. */ void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child) { - if (child =3D=3D NULL) { - return; - } - - bdrv_unset_inherits_from(parent, child, NULL); - bdrv_root_unref_child(child); + bdrv_unref_child_safe(parent, child, NULL, &error_abort); } =20 =20 @@ -4784,14 +4830,17 @@ static void bdrv_reopen_abort(BDRVReopenState *reop= en_state) } } =20 +static void bdrv_delete_abort(void *opaque) +{ + BlockDriverState *bs =3D opaque; =20 -static void bdrv_delete(BlockDriverState *bs) + bdrv_drained_end(bs); +} + +static void bdrv_delete_commit(void *opaque) { BdrvAioNotifier *ban, *ban_next; - BdrvChild *child, *next; - - assert(!bs->refcnt); - assert(bdrv_op_blocker_is_empty(bs)); + BlockDriverState *bs =3D opaque; =20 /* remove from list, if necessary */ if (bs->node_name[0] !=3D '\0') { @@ -4799,22 +4848,6 @@ static void bdrv_delete(BlockDriverState *bs) } QTAILQ_REMOVE(&all_bdrv_states, bs, bs_list); =20 - bdrv_drained_begin(bs); /* complete I/O */ - bdrv_flush(bs); - bdrv_drain(bs); /* in case flush left pending I/O */ - - if (bs->drv) { - if (bs->drv->bdrv_close) { - /* Must unfreeze all children, so bdrv_unref_child() works */ - bs->drv->bdrv_close(bs); - } - bs->drv =3D NULL; - } - - QLIST_FOREACH_SAFE(child, &bs->children, next, next) { - bdrv_unref_child(bs, child); - } - bdrv_drained_end(bs); =20 /* @@ -4843,6 +4876,88 @@ static void bdrv_delete(BlockDriverState *bs) g_free(bs); } =20 +static TransactionActionDrv bdrv_delete_drv =3D { + .commit =3D bdrv_delete_commit, + .abort =3D bdrv_delete_abort, +}; + +/* + * When @tran is NULL, function never fail and returns 0. Still, some stat= es + * may not be saved correctly. + * + * When @tran is not NULL, first failure is returned and the action may be + * rolled back. + */ +static int bdrv_delete(BlockDriverState *bs, Transaction *tran, Error **er= rp) +{ + int ret; + BdrvChild *child, *next; + + assert(!bs->refcnt); + assert(bdrv_op_blocker_is_empty(bs)); + + assert(!(bs->drv && bs->drv->bdrv_close_safe && bs->drv->bdrv_close)); + + if (tran && bs->drv && bs->drv->bdrv_close) { + /* .bdrv_close() is unsafe handler */ + error_setg(errp, "Node '%s'(%s) doesn't support safe removing", + bdrv_get_node_name(bs), bdrv_get_format_name(bs)); + return -EINVAL; + } + + if (tran && !bs->drv) { + /* Node without driver is a sign of something wrong */ + error_setg(errp, "Node '%s' is broken", bdrv_get_node_name(bs)); + return -EINVAL; + } + + /* complete I/O */ + bdrv_drained_begin(bs); + if (tran) { + /* Add it now, as we want bdrv_drained_end() on abort */ + tran_add(tran, &bdrv_delete_drv, bs); + } + + ret =3D bdrv_flush(bs); + if (ret < 0 && tran) { + error_setg(errp, "Failed to flush node '%s'", bdrv_get_node_name(b= s)); + return ret; + } + + bdrv_drain(bs); /* in case flush left pending I/O */ + + /* + * .bdrv_close[_safe] Must unfreeze all children, so bdrv_unref_child() + * works. + */ + if (bs->drv) { + if (bs->drv->bdrv_close) { + assert(!tran); + bs->drv->bdrv_close(bs); + } else if (bs->drv->bdrv_close_safe) { + ret =3D bs->drv->bdrv_close_safe(bs, tran, errp); + if (ret < 0) { + assert(tran); + return ret; + } + } + } + + QLIST_FOREACH_SAFE(child, &bs->children, next, next) { + ret =3D bdrv_unref_child_safe(bs, child, tran, errp); + if (ret < 0) { + assert(tran); + return ret; + } + } + + if (!tran) { + bdrv_delete_commit(bs); + } + + return 0; +} + void bdrv_close_all(void) { assert(job_next(NULL) =3D=3D NULL); @@ -6571,18 +6686,66 @@ void bdrv_ref(BlockDriverState *bs) bs->refcnt++; } =20 +static void bdrv_unref_safe_abort(void *opaque) +{ + bdrv_ref(opaque); +} + +static TransactionActionDrv bdrv_unref_safe_drv =3D { + .abort =3D bdrv_unref_safe_abort, +}; + +/* + * When @tran is NULL, function never fail and returns 0. Still, some stat= es + * may not be saved correctly. + * + * When @tran is not NULL, first failure is returned and the action may be + * rolled back. + */ +static int bdrv_unref_safe(BlockDriverState *bs, Transaction *tran, + Error **errp) +{ + if (!bs) { + return 0; + } + + assert(bs->refcnt > 0); + + if (tran) { + tran_add(tran, &bdrv_unref_safe_drv, bs); + } + + if (--bs->refcnt =3D=3D 0) { + return bdrv_delete(bs, tran, errp); + } + + return 0; +} + /* Release a previously grabbed reference to bs. * If after releasing, reference count is zero, the BlockDriverState is * deleted. */ void bdrv_unref(BlockDriverState *bs) { - if (!bs) { - return; - } - assert(bs->refcnt > 0); - if (--bs->refcnt =3D=3D 0) { - bdrv_delete(bs); - } + bdrv_unref_safe(bs, NULL, &error_abort); +} + +/* + * Like bdrv_unref(), but don't ignore errors: + * On success, if node (nodes) were removed, it's guaranteed that all stat= es + * are stored correctly (for example, metadata caches, persistent dirty + * bitmaps). + * On failure every change is rolled back, node is not unref'ed. + */ +int bdrv_try_unref(BlockDriverState *bs, Error **errp) +{ + int ret; + Transaction *tran =3D tran_new(); + + ret =3D bdrv_unref_safe(bs, tran, errp); + tran_finalize(tran, ret); + + return ret; } =20 struct BdrvOpBlocker { --=20 2.31.1 From nobody Sun Feb 8 12:14:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644252973; cv=pass; d=zohomail.com; s=zohoarc; b=ediNbnzFCGt/2+XzZF1lPXa4kP6vBc4b4ELudv29JTbwi7AGVLE0TfDstMaR5KXU5TSsaXBWX20BP2AaCRU73NES8vsQvavnamx21TvZzcbbgdA7rhTonskdczkqJE8h2lAFeYrZD2mHmbVx++++4iy+sCmbIGuWvgl13WZ8QBY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644252973; h=Content-Type: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=f/qrTksJY1xRlLtzEuVEraV2yLKM3ZHATY/b1TP3yJo=; b=H3/yuKUl21/BrI5xtma+8oDlSn103aTsIcmhp5ipF5GKQMzsJoh5C01McUhWuF6Wj8bLZXzXXK7y/HPTkz1UAIZUfF2cF/hdSpd07kQWKhdUIGbcuJnkTeG4bubqW2NI0i5zOLnsHCzT70WRpx5WqNtjsfLAgyECt+/ZajTzZ50= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644252973131708.2965537710847; Mon, 7 Feb 2022 08:56:13 -0800 (PST) Received: from localhost ([::1]:40708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH7JD-0002Nw-Hn for importer@patchew.org; Mon, 07 Feb 2022 11:56:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71c-0001wP-Ea; Mon, 07 Feb 2022 11:38:01 -0500 Received: from [2a01:111:f400:7e1b::708] (port=37729 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71Z-0005HI-2X; Mon, 07 Feb 2022 11:38:00 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VI1PR0802MB2288.eurprd08.prod.outlook.com (2603:10a6:800:a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Mon, 7 Feb 2022 16:37:42 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kZJD8vqfJHxTx6IQYGExJ+RhEbAvqTMcm7VKO79GrICFIlRU2/eeZ5MGO/mICCm8Hms3ftiui1FoO+KGoH3sU8muMX4RgU23sFgAoylJA1CSxfgteDb+Hq96QcBWIovUjVEn45073nQ533msh4C/b+zfa4M5gYgloiA5d6Q3zK8xQy6/WEfGVvJtr0odA9jeueBj+6cBh4Rj3eF5uQA7QC4M18XSb3LVenI4OvQkNcYukWdzTa256UVkxU3+UeluFzrrxAolc5LUNxjYHTvrIiCTnVaxxcm2LibrDjWcIAeX/+tqaWX/c3B2iPwmUvv3unvdddUzDgo98gQXU5b9RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f/qrTksJY1xRlLtzEuVEraV2yLKM3ZHATY/b1TP3yJo=; b=JYCjgbZkrGby2oXrpWIrRVcB/LgkT6fLbGMI/e2aQhj2WQJRaJuhEZq1+uVAAWDsZcnH+P2VK6fVECHwx1JCQaj4v/lGXIGdC1gYzrcGlBrkBBku+L+UoRruEt8+T2pAzWyDUpTRyh886Vok3itCe04XyVgBaVqL7zo424UkQO1vSK6fz77JVYKpFNvDJbVvRw6D2hUHtTmjIC7LnLNq8XJKOT1+v7dofAYfb442eLHSfIkIvIVS7ICc96r71WvsUNX61bDVNbPBQR3c6FPzMCxORX8vZl5W697lOGC7YalMLV6pi36sonPm2MISKyCk8tpK7c95R0O62fyW/4hr3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f/qrTksJY1xRlLtzEuVEraV2yLKM3ZHATY/b1TP3yJo=; b=Ai2drIpo4uk646tCNXtzwVBCYkKOmSScMFeLccLiFMJ6VYkgVK4y4Jnhj7zKUTpF1eZDixYkDtMNNwrct4+JTjA1kf54dlvCeYRxd9e+nco5XjmEoVqP2NsXIhL86AQQUS+2JzLwXXIEVZYtJIqeqZ5Hw8dDR8Xxz4ntnmByqlw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 08/14] qapi/block-core: add 'force' argument to blockdev-del Date: Mon, 7 Feb 2022 17:37:22 +0100 Message-Id: <20220207163728.30362-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 34ed3fd8-3e46-479d-f500-08d9ea5828fd X-MS-TrafficTypeDiagnostic: VI1PR0802MB2288:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1332; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Adgm7Ecb52sKHyKvloS5hOKb2Tb9NS4LkhRPej4qeWipZzvuFJwrCqiyZY7LPC/e+XM5PwGKL0PBGrNCL8Mkxn1dTInoWtgljZhtZn2uhuM2DA2eWql12ktjsMgDCLYAsHAIwLfHIu+HUilGLsNUtpLEza5gm56gy+ChzXmb0rU+WYN9Q68fOJ5iQ+b3mZmdsPv8BcK6eIUd5qc8mGvIwW+EkJLdgbCqXxcrMScgykxllJPJ5xGbH7egj2S6xiwZ7sQXg8sfnjgwbkIcsUNk3Bv+5wyVDjeweuCyXoOEjQOsz9jrPYWYDMEHjBJvCwhRwrw/CbabTL+iwTxwowxU1t81nLBTbrSZzSl/aV/Ps+QeZhbPbgh55TiVaGuAk1Ugkn7zJpTs2PM+Utq8wCR8cGpR+hMCB4cu5qev8AbCinyOmbfaUgXs4aem+1FyUaAX5oEQZlhIHbEhoihCdVfREOoYfWr8wBgSK6IDnElwGobnjq7iNNFyv16+KqP0GVdJNP1F5ZfaKUZU50aG1SFktmg3WJBGQDgsYWXT/OMINw0j+Xbwp9LX5AODXFDXOrsH5NeIHEXTYYnVUnzN3MiSM8QA+si3UiP2ovK0swmov8xLb1p8HvBVuog1+sa8jNHc6IGlPrZJWxKRCFbpXy8Adq8i4x7arZHcAYcNxahX5zbXAZHTYa8g70IaYfgHwQpxUOwbAuH1G2YzIp1N0Kl8GA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(66946007)(66556008)(8936002)(8676002)(38100700002)(83380400001)(66476007)(5660300002)(6916009)(4326008)(2906002)(508600001)(26005)(1076003)(186003)(86362001)(6486002)(38350700002)(2616005)(107886003)(6512007)(6506007)(6666004)(316002)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Kt4f1kMd+KOtnWHM20zWITE+UxL9w2jmBDUA3TGB5lSyeLVjul9LG3jh/jD5?= =?us-ascii?Q?1nvFk5C19bE/i9YcDpSLCb6rZVMubDiTCGtK7NFMOgWKDj+BWjUc2EzacO7p?= =?us-ascii?Q?/hFZP3yJRgnRHOQA2Mqi+pYgrCCSErcptCtmd8au6QNVIPccKj1UsJ88EDwF?= =?us-ascii?Q?kaAKqXrLQrBXF/efzOYvhY1IgQXzb/CANmcYmT4QW7ISHZrXPl6uhnsvfod1?= =?us-ascii?Q?sIMU5msgbBJofUIk5B7vz5mREuvJGspAYVEatWbNYUNnq/Ejd5mUHEXDlNX5?= =?us-ascii?Q?DD69h+BZMBG1xUSacw2F3AgN+raSNxOhqakTNssg1KxI7xOdr9zxt05x39E0?= =?us-ascii?Q?bHjTa0KOhjKmqa/fEdxEwsH3QSbfyHsbZMlaXrZxiZdscsNC6RX5uHHgtVKE?= =?us-ascii?Q?MnqKfPYKcMUv13Jq8ev+PL0gmJttbagWw+edCKBQXqBPLLrEvFNeUdt4s4+R?= =?us-ascii?Q?Y/XKov9wjDbQBXWDszN1NcM+L8Hg6nCnV01RkU+C/g39UsO0c/1dUh+qBrap?= =?us-ascii?Q?J6hLDe1sHk1WhpTWG3uP5/m97GyaV1Xm7Ok6NvD5j/AhWN/pqOnPFliA81Cu?= =?us-ascii?Q?Kayv5YSh1erKX+ChaAD/YbjEY0SwhMu1iD69bIGLNxXReQ0b2okRKYvF86ti?= =?us-ascii?Q?kb/LwHbQ0f8dbugNVzyW5nIdS/Vtyd6sfORtZw4v1OQoXc7NtVtg44qSyOTQ?= =?us-ascii?Q?6dJD1YEIu10Ick4Le96ApNo0bGsqqyJR8E05Ssuy5+/CWSXQYwbSXjVVDaoU?= =?us-ascii?Q?P1DZO3f+PxUO68+JM+1Tf+m4lzVGvZzcgW67bLOfDjPRHpGTo+tvjd5BmMfQ?= =?us-ascii?Q?C8e8jsexU39wwz+J9gR0FMkUt0O/qsx7aGZYQEjUyM8ckKOkayRW2+ww11Lq?= =?us-ascii?Q?VPK2ua2NWFCbsk1SmiTJYqUHazKYg1ddSRUx9vJjHQhtreUZ6hr5EtiDoJAa?= =?us-ascii?Q?8A/9FjtbyCqDJk7kPGJRPbcqnBrgVOfaLr6U6EK3lU555kyBA6Re0Paa+WYy?= =?us-ascii?Q?yLCJsO56lD4ZLbxGzWulHwi6h4y/6RCgc+15XFlpuklcR2/PgTpi5ZQpfB/c?= =?us-ascii?Q?vXlVEN9K6m68xVb8bxJQ3yXAjcEteHQrFMHoJWxH1p5fzH4baP9DY3vxzVzp?= =?us-ascii?Q?seRu4TnJDsUo7OPN1cnUA900pmKBbvVLpl8susyiACiujLhULWQAUngbffy7?= =?us-ascii?Q?bAqEuz8VtUjcmsoSRitgm25u5QpykwyUbDEP2kilRWl5F0X9qTG3Tosxyspp?= =?us-ascii?Q?7rruVShLLssEPCMEEHUvw++rJ3oDEB7iTHkji3PkqQxXDgfp+XsodO1xWfp/?= =?us-ascii?Q?j6fkQZ493v5qnqBzZeygO1U9QS0KaGUfr0+Blbk47JWeLEZZftWaVK5IPbIU?= =?us-ascii?Q?bM05CbN6+jqY+vpy7sUXmfPVg9gxryNaXT0WZoVVj81iByALkTA//FIlk2ZC?= =?us-ascii?Q?Wn3mWwxYQPYlmAqYVlCbf3nMUY7nJovqmKP78ZjC+PKCQ7kVSFXSMqjXNioQ?= =?us-ascii?Q?FvKDUozvmNYt5PLYdlOAJZGA0JjrN5KeCDkAYQNHIhu3oSIeMNcs7VlTiKp/?= =?us-ascii?Q?OZeUmJ31sRQvLtQ3WLHHJeuRsJ5Lcj7NBv8wG/p0lWB5eovxz9unCfapMszg?= =?us-ascii?Q?mrXvwl+E/ovRN6Iugk8/1QtUfdI2D7BYEXt5R9KBYLkINQP4e0IDvW245pBr?= =?us-ascii?Q?vGqYzw=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 34ed3fd8-3e46-479d-f500-08d9ea5828fd X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:41.6482 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nlU5HDiD2+G3SrQIEFlaViC+xk6xNn6T23NKYfL75GekZJL+xRtBYjhSpelMSd1gsaR1tcc9unbM+rKC5GkM9lrjgcuewyhU7p214lUeAfM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2288 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::708 (failed) 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=2a01:111:f400:7e1b::708; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644252976367100001 Content-Type: text/plain; charset="utf-8" Default behavior is force=3Dtrue and it's unchanged. New behavior is force=3Dfalse, which makes it possible to be sure that node removal is done successfully with no error and all metadata is stored and flushed successfully. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 6 +++++- block/monitor/block-hmp-cmds.c | 2 +- blockdev.c | 17 +++++++++++++++-- hw/block/xen-block.c | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 9a5a3641d0..b37d195772 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4403,6 +4403,9 @@ # # @node-name: Name of the graph node to delete. # +# @force: Ignore failures when closing block-nodes, like failed IO +# when try to store metadata. Default true. (Since 7.0) +# # Since: 2.9 # # Example: @@ -4425,7 +4428,8 @@ # <- { "return": {} } # ## -{ 'command': 'blockdev-del', 'data': { 'node-name': 'str' } } +{ 'command': 'blockdev-del', + 'data': { 'node-name': 'str', '*force': 'bool' } } =20 ## # @BlockdevCreateOptionsFile: diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index bfb3c043a0..1c35aa2d6f 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -145,7 +145,7 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict) =20 bs =3D bdrv_find_node(id); if (bs) { - qmp_blockdev_del(id, &local_err); + qmp_blockdev_del(id, true, true, &local_err); if (local_err) { error_report_err(local_err); } diff --git a/blockdev.c b/blockdev.c index 8197165bb5..34a195b592 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3582,11 +3582,17 @@ fail: g_slist_free_full(drained, (GDestroyNotify) bdrv_subtree_drained_end); } =20 -void qmp_blockdev_del(const char *node_name, Error **errp) +void qmp_blockdev_del(const char *node_name, bool has_force, + bool force, Error **errp) { AioContext *aio_context; BlockDriverState *bs; =20 + if (!has_force) { + /* Historical default is force remove */ + force =3D true; + } + bs =3D bdrv_find_node(node_name); if (!bs) { error_setg(errp, "Failed to find node with node-name=3D'%s'", node= _name); @@ -3616,7 +3622,14 @@ void qmp_blockdev_del(const char *node_name, Error *= *errp) } =20 QTAILQ_REMOVE(&monitor_bdrv_states, bs, monitor_list); - bdrv_unref(bs); + if (force) { + bdrv_unref(bs); + } else { + int ret =3D bdrv_try_unref(bs, errp); + if (ret < 0) { + bdrv_set_monitor_owned(bs); + } + } =20 out: aio_context_release(aio_context); diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index 674953f1ad..0ac9b599c0 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -649,7 +649,7 @@ static void xen_block_blockdev_del(const char *node_nam= e, Error **errp) { trace_xen_block_blockdev_del(node_name); =20 - qmp_blockdev_del(node_name, errp); + qmp_blockdev_del(node_name, true, true, errp); } =20 static char *xen_block_blockdev_add(const char *id, QDict *qdict, --=20 2.31.1 From nobody Sun Feb 8 12:14:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644253579; cv=pass; d=zohomail.com; s=zohoarc; b=WoC9OjnIhr40QWtatXlNsX1Imo1eTN0p3qNM2YuzUO2+GrZTgZe86hzBxikXllDx7pTagYZCFuXH0U/rlriSlFDfCGFxcSm8J19sSzY7m864o7XH1bLRpC1KcTAR4MH1P95bxXdN64l3d2a2Q/gCTZOpppsilLnbfcrvb7cP3vI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644253579; h=Content-Type: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=QzqYMs72nxr/rvULzlYntudxsUVjUT8tEEdz91HA9NE=; b=Ak+3mJMOOx6LNykSu3i3azwxYVNT8Q3OqhEsOvS1RKJNqM0w0PEZpnskdRJYYN2BekKSj913GmxHhjV4SoUmle1/7Gc/4VjrAFOtlr/ETQucKgjiGduuMGSdGjHSqAhpZCMhWqkTj/BVn1h9vxk0rFEq3Q7ARKE4sdqXkDCYhZM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644253579535179.61828682410453; Mon, 7 Feb 2022 09:06:19 -0800 (PST) Received: from localhost ([::1]:51686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH7T0-0002CB-FK for importer@patchew.org; Mon, 07 Feb 2022 12:06:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71g-0001zf-Qr; Mon, 07 Feb 2022 11:38:06 -0500 Received: from [2a01:111:f400:7e1b::708] (port=37729 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71d-0005HI-2l; Mon, 07 Feb 2022 11:38:04 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VI1PR0802MB2288.eurprd08.prod.outlook.com (2603:10a6:800:a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Mon, 7 Feb 2022 16:37:42 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aVqlVtQ5OF42sdmHE/XVWBeGXS74cBHjN/+gIH3l+ht/i4EmJL4Z7SOEzHWjrZFWHypw856/dvgZg95Cp8hy429wtt2d0MHPXeXbh1ticvSpelc7wKHdqlHz80wP39ygAtD+DNiKYg00DZOVcZfHmkRWFl3ywtHsW6na1U95HYu065lpq+iv/8Gr1458vCtUf+if5W/dpdwOJjL3lSiWBscVHdviK1z2oSGvikb+LtFNy/NtERuI+Uj+jzINrM8JMJ8PgKxNK2JhvWM9ktTmSzzPONlO7jEICc8e/j+yvyVpeuodLNTx13wFiWhoiBvc6eDW13yyYA4yaouV63OGCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QzqYMs72nxr/rvULzlYntudxsUVjUT8tEEdz91HA9NE=; b=NUEJcQJNHwzG9YLk4tOYM454l3RfQBajNNtgNb05yVIXx0WJ8rvaj26dGUjtgTJL4e64pNRNPw0PbnhLaPyART81gJNpvPz76VE43nyTp/RqwtPOvWTgMB87cTlwKK4unfjFjCocUQMqJxQHduTkeFAsSf+I968Z1Psg1+kTMGwJ0y1YA9w59QMx0o4L8EtI9kQLEcWBNyviUDfKFknU06yeOlagOcOF/LQ4q/U19euEYm/zMeKmAmSblGwVmSI9k3aQMiTb3EmHhfuCSQU+kGAtaOA9wui9oB4gWRkUxkta5rrxKH3N9699ZPH8wK4l2EWVOnXuNyVz5K37tlmHPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QzqYMs72nxr/rvULzlYntudxsUVjUT8tEEdz91HA9NE=; b=KTeQ5M1fD2f2YYtIfCnJ/z6vGHxdH6XMwC/DXRW1ybdVp7vApH0yb06qTFPqntHloEGYIBk29zUPvHcq4QqFDuyFkjzSSqBMinnpmhxc7zu3aPwdEPl4Syl8nAKZxGTSDhF7xrGx2z0B0qPB0RNfRABy9/fqBfAEXTJItm1Z4aw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 09/14] qcow2: qcow2_inactivate(): use qcow2_flush_caches() Date: Mon, 7 Feb 2022 17:37:23 +0100 Message-Id: <20220207163728.30362-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78ec8d04-27b4-4b9a-15f1-08d9ea582943 X-MS-TrafficTypeDiagnostic: VI1PR0802MB2288:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:45; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YiHE7Q7MrJtgCldW6dg/1Bg0J36iHLV7oUFnGT4zuz8/URS9H3BtH8WPz6g9XwFicux8SsbC6UIoJJq3wPECvpVZhTvQmeUNdAg72hKhbeBUOPAOYFoEtvRFy8Z1q8Z3Siwr2h3i048/po81TgdB6ZAQxlXcyI5JqMTrSYjUKfQGJVLm3JshaL4pemmrWYT/OpqvNSBl8WPr6X1rEsMfopTrnqGe3CazqCUOZcw3s3sv/Km/Bz4jVAOjf0eyRBa5oH4vFADQSVQcb+XIVgfyrMK3oewNpNXlpOLhsQ2Pz1jcLmcY2AP6AwKlAb6+VuzEwYV7CI1nwdpSpDcbZ95pxK6I3FbEhVGLS8KihRfY6sKDZ4pRGd0dXOEy5dNzIsMT9JKpghehMmhnWxi6mzps0uiQr8F94vZ0YyJil1eYZwWCcIDytTKU47LR7GSP0W7TSj7tIkhy3sc2TKdxdTmqsZtK7I179z27LJ1UCSzTudghspStf+eetikYAgii7duklSNtaIqG7A398AgQADQZ07ZBgeFeIqU2Hj1+nkz7KaS6QGWIbMitq3VgOpnk1aSYIbvUUC8XKdLj6brUM2MYuQQlzMIZfIGUIA+daM6sh//oqVxIoF+rD+/N1B8UVQxgnNsNGlvKnWBQVOzNYsjsgpOzljmsVKCRHZDs7m12HQTBeNVAtrtgs034j2Fwkj6vBdc2yN4RPeeDAQJqFaGkQQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(30864003)(66946007)(66556008)(8936002)(8676002)(38100700002)(83380400001)(66476007)(5660300002)(6916009)(4326008)(2906002)(508600001)(26005)(1076003)(186003)(86362001)(6486002)(38350700002)(2616005)(107886003)(6512007)(6506007)(6666004)(316002)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?50sCjicGNYAlENjCjaKDEk0z8cEPI5dDMAdJ2i2wk65z0rqDxLy8VGKFeo6n?= =?us-ascii?Q?TgUNohdpaX/ecnzMg/3MPTgNpYdsdRY8MNphibbhEvNPClx/SA5EgXXAo/OT?= =?us-ascii?Q?RHQEoz02TseNup7Hk8mj7A2gg84LylvBxQ2aTtg98rGooRXIXlCDrFiqcoaD?= =?us-ascii?Q?ChRhqMqiQ6QFVU13YZgmNJK64X2Of/ndpSgBmkuqbIjig8PYs+z/ofd3icqK?= =?us-ascii?Q?o6mm6uULZDWqnQGFq+0w4vj21XOEHuTp+MVOa4TAnVZfEqYUzjo7lUX2XThQ?= =?us-ascii?Q?1WyDrI/pjuV8JvvbSuCawbTyTANiTSlZAUymlSp5+/B3nY+dbspCWykFVp9D?= =?us-ascii?Q?s45PjDpaoQw6NCEQsFE6QL8D83dPQ/bUoOPLS/y4Zahjh8kvmvXRgLL5KjJE?= =?us-ascii?Q?Bgm+q3GV2WAW9+s0Qg/Co0A7/VUOrjTmLxrdik4X48a9YaqH0zAHRyVbgvXZ?= =?us-ascii?Q?vIdKglCUdS5qZiPPIkZQv7fn/g4V2AAxQN2i/XSdsbFiqLz4JAfsBHoF2GDy?= =?us-ascii?Q?RAcMWsiTlUHE8pKVgG9NetUYYyD3asyjS6s8utIgHARc1DEAM61q+n+569ww?= =?us-ascii?Q?Ih36esrkMjBNUyqeHfC2kixyT++d0TVH+rAEtchJjS3OMmb+jp4bIXE54UoG?= =?us-ascii?Q?zbbo53TqHTaHCH5YeZTeIu+64zmv2hKx+ohtOlKYGfk/NzWlKkFWK+IAW+VI?= =?us-ascii?Q?8Ylh7S/2HyhhFvrEfFB44cd/9O3UcJJQ5jw7Gl5TTASuoWDvdYbIYQzkxicS?= =?us-ascii?Q?PkNJGd8KCuty2S9VKj0YUqbRLzor/Od3Sx1J6i0couK3n0RSyqzpFzOD7/8T?= =?us-ascii?Q?VgVosNzdTN4vxlEPQoihNgvHI1YECDDEK+/xZqLxkkiY4of6AT/vzfYFEU50?= =?us-ascii?Q?Ffcsgg+YwTOjFTSJ3K78k3W4y/eMY5uwCgExroaYW2c4gXt1GIERp6+NPkCO?= =?us-ascii?Q?xPLp/Em4xS8l5xarRibj/JNxszL7utPIjVl7HsjrO9jMEQnqiLPQDfJUID1y?= =?us-ascii?Q?wBR+iRz/hrnxW2J4Q0rZ0xdFXFlPmK0lTrxcs+0kWd1xGzyGyrUUfxjqflZc?= =?us-ascii?Q?dJI6QlImwcmhAur7bMZ8iCQAr5BRRR3TsHfPgWlfB2Nta6w9/JdTASr4SC7/?= =?us-ascii?Q?Np9UJO4BHgxwkX7BNR+S65f/Mxwinz44dViwXV0WRzqKdrcEhbXtYqeYLh6I?= =?us-ascii?Q?9A/uv3UUYk+Z2ByMK5r2Ng4e7tboPjRg+2ym5AkJu724j0z1LDDHj8Svo0Qn?= =?us-ascii?Q?2oEgU3H15NRHRfxNL9VpwZWBUdVXb5vdb5qwwT8HF7z4GFWv8jefVBXKL5Jq?= =?us-ascii?Q?NIkKLnQYHz+bPGQnRHjRbUCqITncNmzUS9SN+EaDTY+r4JWucjzqnB/cioXG?= =?us-ascii?Q?fPQv+Yd0NJJYBx6Miu3vE6MFgOXxjiBZ8bdzHAr5JhKYoHXVGxNRvs6kqz7c?= =?us-ascii?Q?FGv2W+Xcq5bb8opeewldYCld3KphI4RUbKQ+SWDblrtA0OvotmVlDS/8tLFZ?= =?us-ascii?Q?9GAxBnllGUxJXvpOooS3P5vFwVA9kWTw/iXg1qStgNqlMzzfgMUji+P3eXl7?= =?us-ascii?Q?5MY4ibI6sQAtj1mYmr19UdwgbWnKJnwy+mmjZ23vYpROrQPVtQWRO25Dz3Zs?= =?us-ascii?Q?aqPXp3RpInqOj6RBD9o4tZTMt+MR0pacqsKGf2eUGxzfRsOe2PN0y1wx4dOT?= =?us-ascii?Q?ljUlwg=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78ec8d04-27b4-4b9a-15f1-08d9ea582943 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:42.1482 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: W6gaeMQYVWOQpEwyWIRNwM47rZwkJ/XziGlXDysCzpknqeq0WVcisRXmEfAnXa+1oqWbV892vLBDnP2QTplWsB6uSQN7PvPAUOVtMx7KmVM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2288 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::708 (failed) 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=2a01:111:f400:7e1b::708; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644253580938100001 Content-Type: text/plain; charset="utf-8" Maintaining similar logic of flushing caches in both qcow2_inactivate() and in qcow2_flush_caches() is not good. Let's refactor things to use qcow2_flush_caches() directly from qcow2_inactivate(). For this we need two things: textual error messages (add Error **) and possibility to unconditionally flush refcounts (add force_refcounts argument). Iotests output updated correspondingly. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.h | 6 +- block/qcow2-bitmap.c | 2 +- block/qcow2-refcount.c | 22 +++++-- block/qcow2.c | 25 +++----- tests/qemu-iotests/026.out | 126 +++++++++++++------------------------ tests/qemu-iotests/071.out | 3 +- tests/qemu-iotests/080.out | 4 +- 7 files changed, 76 insertions(+), 112 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index fd48a89d45..a83183d533 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -874,8 +874,10 @@ void qcow2_free_any_cluster(BlockDriverState *bs, uint= 64_t l2_entry, int qcow2_update_snapshot_refcount(BlockDriverState *bs, int64_t l1_table_offset, int l1_size, int addend); =20 -int coroutine_fn qcow2_flush_caches(BlockDriverState *bs); -int coroutine_fn qcow2_write_caches(BlockDriverState *bs); +int coroutine_fn qcow2_flush_caches(BlockDriverState *bs, bool force_refco= unts, + Error **errp); +int coroutine_fn qcow2_write_caches(BlockDriverState *bs, bool force_refco= unts, + Error **errp); int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix); =20 diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 8fb4731551..0f463ced4e 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -899,7 +899,7 @@ static int update_ext_header_and_dir(BlockDriverState *= bs, return ret; } =20 - ret =3D qcow2_flush_caches(bs); + ret =3D qcow2_flush_caches(bs, false, NULL); if (ret < 0) { goto fail; } diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 4614572252..c8251412ce 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1203,19 +1203,23 @@ void qcow2_free_any_cluster(BlockDriverState *bs, u= int64_t l2_entry, } } =20 -int coroutine_fn qcow2_write_caches(BlockDriverState *bs) +int coroutine_fn qcow2_write_caches(BlockDriverState *bs, bool force_refco= unts, + Error **errp) { BDRVQcow2State *s =3D bs->opaque; int ret; =20 ret =3D qcow2_cache_write(bs, s->l2_table_cache); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to write the L2 table cache"); return ret; } =20 - if (qcow2_need_accurate_refcounts(s)) { + if (force_refcounts || qcow2_need_accurate_refcounts(s)) { ret =3D qcow2_cache_write(bs, s->refcount_block_cache); if (ret < 0) { + error_setg_errno(errp, -ret, + "Failed to write the refcount block cache"); return ret; } } @@ -1223,14 +1227,22 @@ int coroutine_fn qcow2_write_caches(BlockDriverStat= e *bs) return 0; } =20 -int coroutine_fn qcow2_flush_caches(BlockDriverState *bs) +int coroutine_fn qcow2_flush_caches(BlockDriverState *bs, bool force_refco= unts, + Error **errp) { - int ret =3D qcow2_write_caches(bs); + int ret =3D qcow2_write_caches(bs, force_refcounts, errp); if (ret < 0) { return ret; } =20 - return bdrv_flush(bs->file->bs); + ret =3D bdrv_flush(bs->file->bs); + if (ret < 0) { + error_setg_errno(errp, -ret, + "Failed to flush after writing caches"); + return ret; + } + + return 0; } =20 /*********************************************************/ diff --git a/block/qcow2.c b/block/qcow2.c index 614df0307f..04994df240 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -544,7 +544,7 @@ static int qcow2_mark_clean(BlockDriverState *bs) =20 s->incompatible_features &=3D ~QCOW2_INCOMPAT_DIRTY; =20 - ret =3D qcow2_flush_caches(bs); + ret =3D qcow2_flush_caches(bs, false, NULL); if (ret < 0) { return ret; } @@ -574,7 +574,7 @@ int qcow2_mark_consistent(BlockDriverState *bs) BDRVQcow2State *s =3D bs->opaque; =20 if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) { - int ret =3D qcow2_flush_caches(bs); + int ret =3D qcow2_flush_caches(bs, false, NULL); if (ret < 0) { return ret; } @@ -2680,7 +2680,6 @@ fail_nometa: =20 static int qcow2_inactivate(BlockDriverState *bs) { - BDRVQcow2State *s =3D bs->opaque; int ret, result =3D 0; Error *local_err =3D NULL; =20 @@ -2690,20 +2689,14 @@ static int qcow2_inactivate(BlockDriverState *bs) error_reportf_err(local_err, "Lost persistent bitmaps during " "inactivation of node '%s': ", bdrv_get_device_or_node_name(bs)); + local_err =3D NULL; } =20 - ret =3D qcow2_cache_flush(bs, s->l2_table_cache); - if (ret) { + ret =3D qcow2_flush_caches(bs, true, &local_err); + if (ret < 0) { result =3D ret; - error_report("Failed to flush the L2 table cache: %s", - strerror(-ret)); - } - - ret =3D qcow2_cache_flush(bs, s->refcount_block_cache); - if (ret) { - result =3D ret; - error_report("Failed to flush the refcount block cache: %s", - strerror(-ret)); + error_report_err(local_err); + local_err =3D NULL; } =20 if (result =3D=3D 0) { @@ -4517,7 +4510,7 @@ static int coroutine_fn qcow2_co_truncate(BlockDriver= State *bs, int64_t offset, =20 if (prealloc !=3D PREALLOC_MODE_OFF) { /* Flush metadata before actually changing the image size */ - ret =3D qcow2_write_caches(bs); + ret =3D qcow2_write_caches(bs, false, NULL); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to flush the preallocated area to dis= k"); @@ -4936,7 +4929,7 @@ static coroutine_fn int qcow2_co_flush_to_os(BlockDri= verState *bs) int ret; =20 qemu_co_mutex_lock(&s->lock); - ret =3D qcow2_write_caches(bs); + ret =3D qcow2_write_caches(bs, false, NULL); qemu_co_mutex_unlock(&s->lock); =20 return ret; diff --git a/tests/qemu-iotests/026.out b/tests/qemu-iotests/026.out index 83989996ff..cdc1ed2748 100644 --- a/tests/qemu-iotests/026.out +++ b/tests/qemu-iotests/026.out @@ -14,15 +14,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l1_update; errno: 5; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l1_update; errno: 5; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -38,15 +36,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l1_update; errno: 28; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l1_update; errno: 28; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -126,15 +122,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l2_update; errno: 5; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the L2 table cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l2_update; errno: 5; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the L2 table cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -150,15 +144,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l2_update; errno: 28; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the L2 table cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l2_update; errno: 28; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the L2 table cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -174,15 +166,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l2_alloc_write; errno: 5; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l2_alloc_write; errno: 5; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -198,15 +188,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l2_alloc_write; errno: 28; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l2_alloc_write; errno: 28; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -222,15 +210,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: write_aio; errno: 5; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: write_aio; errno: 5; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -246,15 +232,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: write_aio; errno: 28; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: write_aio; errno: 28; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -270,15 +254,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_load; errno: 5; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_load; errno: 5; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -294,15 +276,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_load; errno: 28; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_load; errno: 28; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -318,15 +298,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_update_part; errno: 5; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_update_part; errno: 5; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -342,15 +320,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_update_part; errno: 28; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_update_part; errno: 28; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -366,15 +342,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc; errno: 5; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc; errno: 5; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -390,15 +364,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc; errno: 28; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc; errno: 28; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -457,15 +429,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc_hookup; errno: 28; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the L2 table cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc_hookup; errno: 28; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -481,15 +451,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc_write; errno: 28; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the L2 table cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc_write; errno: 28; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -505,15 +473,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc_write_blocks; errno: 28; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the L2 table cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc_write_blocks; errno: 28; imm: off; once: off; write = -b -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the L2 table cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -529,15 +495,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc_write_table; errno: 28; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the L2 table cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc_write_table; errno: 28; imm: off; once: off; write -b -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the L2 table cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -553,15 +517,13 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc_switch_table; errno: 28; imm: off; once: off; write -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the L2 table cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: refblock_alloc_switch_table; errno: 28; imm: off; once: off; write = -b -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the L2 table cache: No space left on device write failed: No space left on device No errors were found on the image. =20 @@ -595,8 +557,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l1_grow_write_table; errno: 5; imm: off; once: off -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -607,8 +568,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l1_grow_write_table; errno: 28; imm: off; once: off -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -619,8 +579,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l1_grow_activate_table; errno: 5; imm: off; once: off -qemu-io: Failed to flush the L2 table cache: Input/output error -qemu-io: Failed to flush the refcount block cache: Input/output error +qemu-io: Failed to write the refcount block cache: Input/output error write failed: Input/output error No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 @@ -631,8 +590,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 =20 Event: l1_grow_activate_table; errno: 28; imm: off; once: off -qemu-io: Failed to flush the L2 table cache: No space left on device -qemu-io: Failed to flush the refcount block cache: No space left on device +qemu-io: Failed to write the refcount block cache: No space left on device write failed: No space left on device No errors were found on the image. =20 diff --git a/tests/qemu-iotests/071.out b/tests/qemu-iotests/071.out index bca0c02f5c..de1c59154d 100644 --- a/tests/qemu-iotests/071.out +++ b/tests/qemu-iotests/071.out @@ -86,7 +86,6 @@ read failed: Input/output error {"return": ""} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} -QEMU_PROG: Failed to flush the L2 table cache: Input/output error -QEMU_PROG: Failed to flush the refcount block cache: Input/output error +QEMU_PROG: Failed to flush after writing caches: Input/output error =20 *** done diff --git a/tests/qemu-iotests/080.out b/tests/qemu-iotests/080.out index 45ab01db8e..860228f93b 100644 --- a/tests/qemu-iotests/080.out +++ b/tests/qemu-iotests/080.out @@ -66,7 +66,7 @@ wrote 512/512 bytes at offset 0 qemu-img: Failed to load snapshot: Snapshot L1 table offset invalid qemu-img: Snapshot L1 table offset invalid qemu-img: Failed to turn zero into data clusters: Invalid argument -qemu-io: Failed to flush the refcount block cache: Invalid argument +qemu-io: Failed to write the refcount block cache: Invalid argument write failed: Invalid argument qemu-img: Snapshot L1 table offset invalid qemu-img: Could not apply snapshot 'test': Failed to load snapshot: Invali= d argument @@ -89,7 +89,7 @@ wrote 512/512 bytes at offset 0 qemu-img: Failed to load snapshot: Snapshot L1 table too large qemu-img: Snapshot L1 table too large qemu-img: Failed to turn zero into data clusters: File too large -qemu-io: Failed to flush the refcount block cache: File too large +qemu-io: Failed to write the refcount block cache: File too large write failed: File too large qemu-img: Snapshot L1 table too large qemu-img: Could not apply snapshot 'test': Failed to load snapshot: File t= oo large --=20 2.31.1 From nobody Sun Feb 8 12:14:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644255816; cv=pass; d=zohomail.com; s=zohoarc; b=EQLEf8AL+vP1Ys1bM3EDqOJ4lD+++a/Hq8QxuwTWqR9VGJY/8RMmtoUq9Gr2GFGL47Fga3XbnYVgdR6AauVNMj2/vZrWOkSRen0a/Xb0HodL6Ubt7aSOCR+DI0kAqCVZWcrpPtkWFZjL/upZZ/Gjw9eVsdeeO5wRcRDVJVMCgTI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644255816; h=Content-Type: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=/qgBjLGqaRpQxkoNuZY6HzxzJBR8Z9gINVDxuoPbiF8=; b=Pjwr2w070DNNysZOvUaaBKMW1NyayMRvffADs1CoiQWfeRkfkHYQ1mihEaGfgUGfpXQB4JZn/XLoJdBAjQUlIvkxU0C6ejH218kR0iUBW1ysKgDny+D96iJ3QUiYfGFbt92Hz/V+okH4xqPGYLFkXzm/q7t7cNWnhQIRxe9fbhU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644255816307477.17144246408657; Mon, 7 Feb 2022 09:43:36 -0800 (PST) Received: from localhost ([::1]:50580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH834-0008J9-OC for importer@patchew.org; Mon, 07 Feb 2022 12:43:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71c-0001wQ-II; Mon, 07 Feb 2022 11:38:01 -0500 Received: from [2a01:111:f400:7e1b::716] (port=32353 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71Z-0005Iz-Rm; Mon, 07 Feb 2022 11:38:00 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VI1PR0802MB2288.eurprd08.prod.outlook.com (2603:10a6:800:a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Mon, 7 Feb 2022 16:37:43 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RYVUqFAE4RROaJdbOnrU1zaHP3j3ZWu63NXCUmP9Bzz83CHv05kfVtjAgfivQmZg7cRr/FSjxnGX9I9QfpT5CuNLhXYPWN1gVzqp5pLcgI6gh0wTP2G0ihMyrFU0gbutAU7Dc3soHVxptG7IcCOmel1A/3jA+VC+Cxd3Y363s9OERtx/fQ+nbe1lXOkkqWNo4eWjsKlC0XkqkpCgEohTI9udKCY/0VqSPjER3Or0PCfWc9J0XQQmf+rUQQVXZ7EMho1/v2ym8udGtU7LqcLyg3HBIjZbl1KcloAMQPIoYG4naDM1pz4PRRFrKkZv/GO03L3EdC3iFIXmDwALfd3Ceg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/qgBjLGqaRpQxkoNuZY6HzxzJBR8Z9gINVDxuoPbiF8=; b=DfmlI+Hki5ebmUQWDHI4ANLUgSyNsmBhUv7kNIqXoTg6PWqocNnSEdtJCpFeonT+Dy74XX2OD9OulPgHCp6NW7l5ODErqu3qAWo4LMjPOQ4D8piNTpXklR81TZ9GIrOWhS3QTn0/ylmG+cFYgW3Ag6ZUvKKoPZ3U9gAcvVvJXJ3RqmUAAukQdemWsBirq6ACy3ilMTbT2UpdpUGwjYon40dyY7ThlbOrfn+Sg0G+H5IaIlKqYzWcRUDHDiH/wmO4E7waOGihMTqEY0RMpdFAv13Jo54Vf6cXYdFWle/vf9LjSaFFzg3Fv8Gjn3JSU0yMjJ6/kfMQitxUA98GvKc7yg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/qgBjLGqaRpQxkoNuZY6HzxzJBR8Z9gINVDxuoPbiF8=; b=MLuqLF+XBQlKGASTCxtlsLalCfI1uTVs/knf4JJ4tXOCUXYSePQQ7N60F6RmEaV7LmEt/+/7el98YUW9dfbxA1XgEaLPJM+XKQxCvsmWdog7M2QEBpyQq6vnTrxyFS9GBig0VRCh+NpHr1A5g3CreSvzY6wtZv2aO1zxSm1I4DA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 10/14] qcow2: qcow2_inactivate(): don't call qcow2_mark_clean() when RO Date: Mon, 7 Feb 2022 17:37:24 +0100 Message-Id: <20220207163728.30362-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ea0ea432-c4a2-46c8-991f-08d9ea58298a X-MS-TrafficTypeDiagnostic: VI1PR0802MB2288:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:220; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eU7G27XAXA/KdSOqzX1lw/7BTFW1w+i8EwZnQz7rCaO69KDtnpSj1erM2u+cWx9iJGzIj57eWjy5LOqvlWzhIFrnebcVAdRQWq9Tt8PRXtVe67ZG6E/d4sF+V0bYb6eE/NHQKH3OvKZ13Xv/CIhDaaA6Md+44KkxgKHk2A2BegoHppIHtXNRWw9DxUjeNtkKE6YAgG909hYu+erp16NpbpGQkcsACI/Tx/691O3CeXSpM6zO9SFQL4XP97vgZhtXeg4yfowmWyjXqSKu8+miQDKQgg7tkcl/07pn9fmOFpkJZ470V+ESARxXF7q7x4CBWT77+P2Hn57SSzz+WjgitnpgxNYwVWGLDxGLrlN5u04IZtwmrxX9zTbUw0TiwZotu+UeG6r44gClgYjRM5Q7z1xx4mcKDHsgbtirOxtwBPLplbqUY7PRONzuhxfj5P0lYtoXQTxJGR/ovHy4zMG32IUbtvP/AsIJuf7pPRbzjCHlHofXjln1HaG32RvzfGhaHa7LN3NhCanK+GHc3YZc8V48IklUaZlHVpNgEU5JnuuQ0cos16Rh1tXzxmc8s2o+zCssDMLQTXU7JFJkOdkAZ9SjWbA9t6uqgSPPebPXL34TEWTdJlO8Re5xuB09sUCiqBiiRysklU6mSR3cmxWWD9fPQpyMCrfcDMfXfkU83mOjFXVA4e8U10uuxJzCTqeGPkkaakKcAlkJmQ24qkwmyw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(66946007)(4744005)(66556008)(8936002)(8676002)(38100700002)(83380400001)(66476007)(5660300002)(6916009)(4326008)(2906002)(508600001)(26005)(1076003)(186003)(86362001)(6486002)(38350700002)(2616005)(107886003)(6512007)(6506007)(6666004)(316002)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?K37W0busVPuxsp/snNQSVv7O/JWCa9MrfrBI1FjV45awX9q6peypWOSjMLQx?= =?us-ascii?Q?wUAksi9KFYqsJeh8ey/Km2Y7X+RhiEZ2R8JhJG30YMdVBwqUABAm6KqyuJ+o?= =?us-ascii?Q?bRD//beXF18tJXkNcRcARgtVtBu6t6OQiBcEUd4qit1q3enQbZ8lv8dS9BnT?= =?us-ascii?Q?ZFj68WmgZ200I/qQvR2KvWJ1/Ii1vBjOCAcclXxAlHm+YPX4d3vzJSZDJd/H?= =?us-ascii?Q?dnWy9kIxALA9Il9pUwQMjGNMuXXqHNeq893gW8PipHzlCBVEtdSgvpeqE1Wa?= =?us-ascii?Q?Uv2wdS/phOAP3nr6mC+E3aV+0YBx4jENt9QDYuC2ifmAxKcROGYpjTrpwE8d?= =?us-ascii?Q?Lt0FzVBJlloWprAPXNuinDu765U+qEBpwq2c0nALQBbPf6ehvEmT992Tx23V?= =?us-ascii?Q?92HCc3mVf9z0pkKk6R9nlbqNCHv45QT9SWqfHCqY3izp7gWeKQspW6G9pWop?= =?us-ascii?Q?1sHeayCGPvkjDJoWI6P3C4K2hfgtJDywfw3epd+AGyTIdfrZtFkvwuyGaKwj?= =?us-ascii?Q?acMG/1IiqK6GD0BBH5f1dMMtFytGXPYeWDew/HAKjtdt+uGqnU3DAZZFDMNX?= =?us-ascii?Q?2mgReQew1MBaD41srQsrAizgzeLeTK4Dn6y+Q3RZ3afpnEODkDqILLcN2y5y?= =?us-ascii?Q?dFji4RGufTi2Nrz5jTTIZueXqMfDXBOb3ckOsLDSwvrO4bhU/fZizIemPpQD?= =?us-ascii?Q?nGjJS/Zi7BW18biOzkNejpXpQr0T2awbB40UXJ2Wi6XqigaXTtwEMhnE0YSQ?= =?us-ascii?Q?HQwo1hXxeJ1ItknIVMcBySh4oPhUlRsEZSsUj8E8DGsorzo4x1/P5gLCbxf9?= =?us-ascii?Q?ayTJjqOzAr4atIr91mNKfWgCflW4shrQ/tjFoQwvRjbfIszCn9Ote34YjDiO?= =?us-ascii?Q?AAjPx5m7ijE8Ovm0aRCAkt1vf34Gno8LUUHdLaeTBBh+qzrEyQVfyL0KqCkk?= =?us-ascii?Q?z+1WUDgAe91bb3btgEqOy3VyqbiNby0DFuwb/SU2MCcDYcuGn/5dZG2umbRd?= =?us-ascii?Q?MuTv46CiIg342YvEZfUm0m9EvXHsDjRFonZAQFsSZwbK1a2NRs+VFft9Nd8S?= =?us-ascii?Q?50Bi+MWs+IP6LAUN95RBCYnhdhLpAqGnNjfdUAeZ8QMhLHYWIm9thT/kfYpA?= =?us-ascii?Q?96QaPj0nRdaTKQIz88piotRYDqNvSuRjqyfAbiRV1UzsS7IoDHziIjBUvb+w?= =?us-ascii?Q?f6tk6WpZ7/tZsRNmocZsoibnUzyyGqgsyUSrf0ThxjM8KalhYLhVD6Yvgy1D?= =?us-ascii?Q?yAllGrDAUpHsgMb7l2BlGeX6QC7zc830btZxt8wEoGObg8P1ybM/RRrXnlsw?= =?us-ascii?Q?/PR9E9SpXT1HRdaKbXZjF73QNukIoiRo/9pDgSZ5zwQ8MkdYFOiJJmgH6Pgx?= =?us-ascii?Q?eXUU//cThBjXhg6VD6BDqeqxzOtsC8dAJJeS/bjOk3n2GNzbGDuhdvV36b6W?= =?us-ascii?Q?YoZbmqcoI72pIdCdBukkPiljpnEaQMmnUeq9Ybb20SwrgWU+3WHWhgDHqG6R?= =?us-ascii?Q?KTb5PwRnrVIS7IEcuVsH0J6dQb8c9qfDERQufMr9EmrZWghIpDnjfr/2+XaY?= =?us-ascii?Q?JG1aYGFIG8PvSQNMQIn/flY9koh8VE2/fch5F1om+Kj6qvVwCahB7H6Zm28e?= =?us-ascii?Q?jEUSEGVyLP3Jpnuq490eRWGxhX3BxlcJN8S6V8aply7TtZkOm4P+dsnRbWmY?= =?us-ascii?Q?9oNsgA=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea0ea432-c4a2-46c8-991f-08d9ea58298a X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:42.5869 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: a2m9EzHYqnq3zKoZNE/UnGMBbBlWwCVcGcNxRwO0nyzclFh28M69C1AOpvyJ1j6w3jQT/OCvEIS0g3jweGCI+I1gROIbMJA2HE9/t228tIM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2288 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::716 (failed) 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=2a01:111:f400:7e1b::716; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644255817680100001 Content-Type: text/plain; charset="utf-8" qcow2_inactivate() prints errors on different failures, let's not exclude qcow2_mark_clean() call. Still, if image is read-only, no reason to report failed write and no reason even to try write. Write failure is possible when we open dirty image for check in read-only mode. Let's not do it. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 04994df240..ccfcd0db05 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2699,8 +2699,12 @@ static int qcow2_inactivate(BlockDriverState *bs) local_err =3D NULL; } =20 - if (result =3D=3D 0) { - qcow2_mark_clean(bs); + if (result =3D=3D 0 && bdrv_is_writable(bs)) { + ret =3D qcow2_mark_clean(bs); + if (ret < 0) { + error_report("Failed to mark qcow2 node '%s' clean", + bdrv_get_device_or_node_name(bs)); + } } =20 return result; --=20 2.31.1 From nobody Sun Feb 8 12:14:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644253363; cv=pass; d=zohomail.com; s=zohoarc; b=N8AN/MILMWxi+V47C4GjhpxsjYY+8l0ChuQIVLrR+znK72DBI2pKob38e0bMgbFAJcGZDQPEx5tTul2Rs+B00CUDdS6k8JiHqm3MRM4YGcMEZYsGVahr71zXwxvK/nSPC4HigAeKwfotaa7Dne5UvpATLNTKJk4scCuVV349Nto= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644253363; h=Content-Type: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=teNNot30Je7QmN/Gb8CSjZ1foW65qEOEJ6yy/d50Eho=; b=LO5hF8QpyLgfdG4QT3Nsnpsb4rdOjf8Re8oPDmJpENGi30UsX9JBq7YYYIz05+IaSHg8VufW1+vB71ydAgH+uQfVeGikxreE++/5WZyFwcrUT5hYPJEckYPvl2SsE2mccBsBlb09DkTSIG0Ut1PgjNbW/lOZdu9wPTEr9NFkW0E= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164425336335180.87630438106544; Mon, 7 Feb 2022 09:02:43 -0800 (PST) Received: from localhost ([::1]:48476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH7PV-0008CE-JK for importer@patchew.org; Mon, 07 Feb 2022 12:02:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71d-0001y0-TP; Mon, 07 Feb 2022 11:38:03 -0500 Received: from mail-am6eur05on2101.outbound.protection.outlook.com ([40.107.22.101]:1216 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71b-0005Gz-3B; Mon, 07 Feb 2022 11:38:01 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VI1PR0802MB2288.eurprd08.prod.outlook.com (2603:10a6:800:a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Mon, 7 Feb 2022 16:37:44 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gcIn10nWh7WwWH7NQeKIWMA3FjjF+yCZcqp43jtiSap2vVA5IKheZq/vOBBtTaP4YXSDp/R8nNC0CURuqWMPVrSJ9H1X/1+0izpLWS8Csoy/CmwQWx5EnrfxKlFt7+Mf97h2lNF2Jqfz51j7+IYTYLULmW5ncfGnXB1XO2Kq5GO5U13gnjXemY0p450CRZuDVrcW5Sk7U5Ymm6mpbhRhHjJqp7pOv+/G/JMAW67V1JSXtmRTvVVXRvrw9DAm3+UyJ3+0n0fo/46ismRq/bcnU/KekDfCWcNfJp9cYlCTLZLI8QVIDCicUEcsFf1YBB5ooO9sETmtGvkGB0qH6vvsSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=teNNot30Je7QmN/Gb8CSjZ1foW65qEOEJ6yy/d50Eho=; b=d9y407Qe8LV1hLYg0eDmXkZqUf16/y8kTkTCDXYkq55wGdJla1i+mEEvHROVAaFMzchTz4dM0NLxfhD91YjZb63MqImh7bDuwTNZXIYl4bwCCWT5kOLzqVfwNwBSCYvoVuvpLer1Md5uOmHA60wvMTOddJ5U4v6SvIzHi/Ta0hJDe4w52tC/odTKN8c2cLsiUAgdzddMU8+sBIfYZkpxEcdlQwjc3JQJDmg6uJIQRRVaaRJUoKXShSKJ5g5XqehIakwCqizoC3TDCNOiAPRx1hfJKID3hNVLr6lmnVvwAbKf0ELNfb5l9Km4GtO6+i0CGyu1mGIHToANGI55hHW3LQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=teNNot30Je7QmN/Gb8CSjZ1foW65qEOEJ6yy/d50Eho=; b=ZlPvjwpKo+bD4YPzJ4gbj9uIPUqSLuqKUpbIVx+Ck3P/ExHxcLYol4h18Uja/mIRbA8azdTQniyKt9mrT3z+hFodEE4ouGPpXiXTltEvUhKZXIbW57fmmBDgkd5KuQ65q5ZMQdG/jyqjQjZHS5C8942ybuDvXXb8w9Wn7DqnSp4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 11/14] qcow2: refactor qcow2_inactivate Date: Mon, 7 Feb 2022 17:37:25 +0100 Message-Id: <20220207163728.30362-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6084d552-2fb9-4cfe-84bd-08d9ea5829d2 X-MS-TrafficTypeDiagnostic: VI1PR0802MB2288:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:26; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YtxZ3gBOjQDrJS8dl6zKNAQkq6o6Nzr2bvfs7nNuv9hiiqiHx2njWpJDbG2Gk4jhhT16E6oz/oannwncMtbAfFNi2S7GSz6BL/Ri5DjElJiPzJLcrlwkr8QawlIpIcxvWjz6C76P0EPxOGUzl2IR1NU0MEkjFGQ60RCdwKFs6jYmI2tTxzVSzpEPBbH7+GNn1+BuyIytmPGzFRlpM/YSdh4BGBwCxt2DbK0IRa6Qqhh/bTE2RNO8Op2Ivjs3dwx+xlYYy817Gli15n7I6+XWj+91C5SSeT6GAYGGmvQfyNnHsI2WjJvrOBlG3anBHumCmsRRGpVxbxdDks0L9dtssK29hy2yzwnypu85/yHWu0FTBZYE6BN2M1ATrSLrV49jRFWX0WKv5R9aIgOydusvBDWDnVYpFRoh88+k//gPOrj4XKnomv0sUMBVJK9Zhyh4NnArLpfEiSIHVXh+yv1gORPptOOSQhgwdmUhgEJKkvbhO80lHV+6idd5Kqx5Yb8xFRG9OqT1rty6U3A/QBz9d8xUtVzGiqMoXTQFKpJ3OpbzNUG3tm0IT+DkPrnkrwe0jaa2PcWthu4EwR57OYn1CcJn69wTsAvqQJv2/qVqaW+zm0whA0QBRudlKnDvcXx6rt0h8+Kio61qT6mm2cPEoMMbOmBoRuBVFns1qgZxDuUO1AOBzjvGVAxZCoqwLg8YihgvK7GxXtj9OUKZ752WWA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(66946007)(66556008)(8936002)(8676002)(38100700002)(83380400001)(66476007)(5660300002)(6916009)(4326008)(2906002)(508600001)(26005)(1076003)(186003)(86362001)(6486002)(38350700002)(2616005)(107886003)(6512007)(6506007)(6666004)(316002)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?kRtsmRdMhzgCbQQuFVyHJDZqZ26HT5cai30+aACnddCt3cHXDbtggNY1dx/4?= =?us-ascii?Q?7fssGPYkqhOPO/j/90+Z3aFgCg5okIg7nhSJ8opug9S2oAb6l6CvcMGDYXfc?= =?us-ascii?Q?WcqknVjGXcIlGF+Hfblb5LtBpuMUmXWPU8Rn6/rpfY6WFei6K24gAhPvFGdf?= =?us-ascii?Q?wIybDD+W7rwd0U5h1808z4zoNznStF2IbIW+lBkxY0SKCri1rCFKBowRgXTO?= =?us-ascii?Q?q27ZzzZ/JVfsAKyI7jTGvTOI74UIftHRLoDKeNMjiOjhDzVEZ13lluML/S34?= =?us-ascii?Q?kQYR+Ohett4/LnY1i2A1s6sSIwPUT6o9m8ZNPbgT+UMPKEE6PtdeJoQI+wFO?= =?us-ascii?Q?G2CZWG37oQdVocGoG0J+LUtSclpi72vKB10kMVPQAviv10qd4kTg21yUB9D8?= =?us-ascii?Q?mBWxRtBcDROZaCHgc96BLGElrUTGxDyL1n4ICx/gYxx0Ak5SaMppSTu/k7Ep?= =?us-ascii?Q?bPVgC1Gi7ztNW7DKGvEHsMxVn/X2PayQPc/eF7+HRZaCQy4tlMssY2aF9qvy?= =?us-ascii?Q?f0j4h6D1wsv123W7CrGKW1+KJqvXdTHBJwGMLpLg2x4QtyjUIlgzEL8cucxX?= =?us-ascii?Q?XlF14yR00ciAh1zOUeBoQske4foSfftg3A1RR5Jyw5zzfIuKkbjQEklXs2Wt?= =?us-ascii?Q?7WxgqHPWth95xLmpzJidP7J9GT6ihlnNVB7OgTWTxO1mXzLvrijztNjhGU+Q?= =?us-ascii?Q?MUT9n6HwD11PTD2J4vleLJ9Il0Ogu0KYRtocEU4tdwdPM6gaTq4Gs8dbbnE8?= =?us-ascii?Q?fopvRRh0Cr5ll4RFWRgNE1Z21UUoy2V220djYz3+Yjgbo/XEAEhI57CYQbRk?= =?us-ascii?Q?C3Xd6quOwJeUhGU5vLp72W+uao35ZM+jpECvhfZU87R72iC+CSbjNcPn088d?= =?us-ascii?Q?i/uH90fENdXQ0sGPucBkVgrB4Oe0nVS9WRW+NTvTjUUrR7f57ZrYbNCZONr8?= =?us-ascii?Q?7fYAJqGbTmkeNkzLpXTag8+UbwwJBEGsONDXuRMDRKsndZV6ABwWmP/lKeQS?= =?us-ascii?Q?sLUasFEiInahP4jfyyUO3io54vtnJKrPi9Y8+NGzA0W4AOHfLsI7C/oBpPj6?= =?us-ascii?Q?8T8kSPJf069SQIAUfbMa9PDcM4BfKBxBrhwnrIKBAOaZBHswDsqPMhO8QrSI?= =?us-ascii?Q?hk0VLnT12DIryI3+r0utYmFiR6IJNAsYBeaXwxr8F/aZBo55qR8fFI2JAC4l?= =?us-ascii?Q?luCpAxevlwlBwLCOq0roKpL+TlUgVzmt4a6D+9EmiKXITusHjXzzBQsAQLYu?= =?us-ascii?Q?kk0qO2AtbK+bPk04p5/5obEBPU2oJqs71HnIj9VENwyj7J9mq+pAFRIZDX9V?= =?us-ascii?Q?g3UpiZ7JdTyl0/D3HntVPu1G1GM4jSlNHcTrHZr7ljQMLKfqloPXYM199xBa?= =?us-ascii?Q?DO9ZdxqfyYZYMt4b5FfKcYYLhRcnhWRvN8MBJduiz9tnMnYeMMFAuAdas01y?= =?us-ascii?Q?Q3rbu3yg/MHonf1SvlmNn3VbjWDW9nCEGpVZfR4P6rnC+uO8ZEbocU8Qd7Ar?= =?us-ascii?Q?JxLMOXI9QEh+NGzGl+Ez1pWKJlVn7wJ2I41ZG/jEVhDcF8lgy4+6IZVP+Mox?= =?us-ascii?Q?o3/rGH12zBHnYGx3Nn3t71ygndYYd+bIioGj18PM+tMYf8cOoH63FIaxcOIs?= =?us-ascii?Q?98ADhHBRkWajbGAklw7eGG9HalECbznKR8DZe25MipPmgovPXLFXwB+VvtCr?= =?us-ascii?Q?maUHUw=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6084d552-2fb9-4cfe-84bd-08d9ea5829d2 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:43.0413 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: f6RxjeoywL4P8T5KBo2iYOM9DhUq4Th6EQO3z41nUFuwyeYdAkJob2QPMwnG28h6YCvOc+X+7RSgbLZjLRsWKq20DjmQQ03Yunp5yKpF03U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2288 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=40.107.22.101; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644253365701100001 Content-Type: text/plain; charset="utf-8" Add a possibility for safe behavior: stop on first error end report in in errp. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index ccfcd0db05..8ad555feb7 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2678,13 +2678,29 @@ fail_nometa: return ret; } =20 -static int qcow2_inactivate(BlockDriverState *bs) +/* + * With force=3Dtrue, ignore failures and just print them. Don't set errp,= but + * still return a value < 0 in case when something failed. + * + * With force=3Dfalse, return error < 0 and set errp on first failure. Not= hing is + * printed. + */ +static int qcow2_do_inactivate(BlockDriverState *bs, bool force, Error **e= rrp) { int ret, result =3D 0; + bool ok; Error *local_err =3D NULL; =20 - qcow2_store_persistent_dirty_bitmaps(bs, true, &local_err); - if (local_err !=3D NULL) { + if (force) { + errp =3D &local_err; + } + + ok =3D qcow2_store_persistent_dirty_bitmaps(bs, true, errp); + if (!ok) { + if (!force) { + return -EINVAL; + } + assert(local_err); result =3D -EINVAL; error_reportf_err(local_err, "Lost persistent bitmaps during " "inactivation of node '%s': ", @@ -2692,8 +2708,11 @@ static int qcow2_inactivate(BlockDriverState *bs) local_err =3D NULL; } =20 - ret =3D qcow2_flush_caches(bs, true, &local_err); + ret =3D qcow2_flush_caches(bs, true, errp); if (ret < 0) { + if (!force) { + return ret; + } result =3D ret; error_report_err(local_err); local_err =3D NULL; @@ -2702,14 +2721,25 @@ static int qcow2_inactivate(BlockDriverState *bs) if (result =3D=3D 0 && bdrv_is_writable(bs)) { ret =3D qcow2_mark_clean(bs); if (ret < 0) { - error_report("Failed to mark qcow2 node '%s' clean", - bdrv_get_device_or_node_name(bs)); + error_setg(errp, "Failed to mark qcow2 node '%s' clean", + bdrv_get_device_or_node_name(bs)); + if (!force) { + return ret; + } + result =3D ret; + error_report_err(local_err); + local_err =3D NULL; } } =20 return result; } =20 +static int qcow2_inactivate(BlockDriverState *bs) +{ + return qcow2_do_inactivate(bs, true, &error_abort); +} + static void qcow2_close(BlockDriverState *bs) { BDRVQcow2State *s =3D bs->opaque; --=20 2.31.1 From nobody Sun Feb 8 12:14:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644253086; cv=pass; d=zohomail.com; s=zohoarc; b=NgeuW/LSWa+cXmwQrlKbJp4xx5dUGZAaRx8TM+F8Tjf0728uQm/eymTqvkmunaUK4xj8l3lTVO/CWkzEh/LSkdToyo8UE6YdVt/EnzPNMTnFvmZyFM64KhoLl/Wk+i5P2Cq2612rJztd8FmGLMbtHXG+9dBULe2RJjYYJY78knk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644253086; h=Content-Type: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=H1OlxZzs7F0wEu/bdT7/ECBbghpOwnIpR9VbwgCczCQ=; b=FZp3JXTTC/FjIza2j5u+Ql2Kw7ELo+mehThkWrtIpnWqq4h+mkVMrVcEFIaZlVXpkzvAJHu2d/pH4d5Fn7qYkNHvG3FIVj4hhEx28OhxFzxVwWhlFcyqdRuxDZF9I1MjDPwajrxxXVRJ3ZRjo9cZ+gDKaS3CIeBHtqQTF4qS9Ms= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644253086385850.9459880468655; Mon, 7 Feb 2022 08:58:06 -0800 (PST) Received: from localhost ([::1]:43646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH7L2-0004nz-Um for importer@patchew.org; Mon, 07 Feb 2022 11:58:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71f-0001yF-Bs; Mon, 07 Feb 2022 11:38:03 -0500 Received: from [2a01:111:f400:7e1b::716] (port=32353 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71d-0005Iz-6j; Mon, 07 Feb 2022 11:38:03 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VI1PR0802MB2288.eurprd08.prod.outlook.com (2603:10a6:800:a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Mon, 7 Feb 2022 16:37:44 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gs44eXXSp9S8imgjU8cSJioaQW3GQ58czbg+RZ2ge+hvNje6cHrjWfjJyAnOLookbtqwZ5KnLCdBp7zg96Tl2CuGPEvLJzuCM5SlT1vGHI520u+vQVq4a2u5RJw9tL2wN612+lQmzthzm4MO3fD7XgsXmhiwUT7THWSHJK+tLQvy89zS7spnqQW5LSis756yzDYz7Yz1IASLAAiQr9DawwFQTr9/6EIlUBYS0QbfhLdNctIJmCiVPi36Eu8TG0FhPAX/ylUGBdhYQzidt+cAa46/pJujM2V/GxaeXMKrFdNy/z++Oc5DW49PHa2iweLDX8kcKgHftZ+vamBkjuwEEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H1OlxZzs7F0wEu/bdT7/ECBbghpOwnIpR9VbwgCczCQ=; b=nUyJWUh7K/H7P217eu7sWkzpqK50hnPb9e3+mM6UCHJaKXhT7DvbCiskcEkuuT3AXdKnmeD7tfOs0lM4Ki9dtcI7CPVSykyaP6xibOHRwCuKBFUtDiJOm06zTaAmTrmjUDzQ3yrnf3NyvxzLDfSOqzlVuyOBolMrp6mwDOj+3aIHA32R1VjJ4VKX9Yr/PJs+sk5LNMGUWkFccDYtXcj1derg88vjU4at6Zgw0T/ck6bKQQBZLDDpMHRv2V7ImjZfP2YPtuf1ay3AHTkMbShslWGjIdGJNcG1W2c7Gjz/BaehCDf9d/aIvSTBSwlhUxmQRX69WcvBZfxByzWuB2dw2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H1OlxZzs7F0wEu/bdT7/ECBbghpOwnIpR9VbwgCczCQ=; b=ibhR/3ogQmjeYGckIVuG1UplcvK9wOOgWLazG58eXGPYnKHhKxjxAVqNqy1N2EUkTQcKTWXB5rcNcJKuWxKme+nL08qoC/JgPPvj+jjxtO+tpN2ABJ4S5vyHkJ+BWM3VMQS30fYkWrN0BYFVMHlEEv26wla+gDtnvNvub92M1Eo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 12/14] qcow2: implement .bdrv_close_safe Date: Mon, 7 Feb 2022 17:37:26 +0100 Message-Id: <20220207163728.30362-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c0c082e7-cde5-41fe-4375-08d9ea582a15 X-MS-TrafficTypeDiagnostic: VI1PR0802MB2288:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:117; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e+/v9d7A04cY4zRG6VZ/dNO2hhoZfl5wpG5UrqUqlsJGA5giiqNTz7sN+50oCWOPPLikESH2DmvfLyBs/8UpDfGClswqWUw7jSXJ8WWEqKvztafiEQDxCmVunRGoJk+8By4Q++pHqK2sMbFMnJitdvBO8BukRfZjkYdUwsUHnppJIwSaiTmIZHtO4agmjE9+0z29j69gJSNfzzMMFzuVxKSf2Y3pk/cFqruP3mSNYJ2fGaivdc9koIJ3hLQnrzmqXb8zWXGiAsn60fTsUHdE3UakASxbg/GKIoe5jPxgX+46FH8tJo0ciOJYdhCe5s3lfAIF5UI+KvyOtgou0b8mT+UTMy53tgWfeCdUnDAB1S8h7E0vETHfnb60iROlQRekkJGcrQDYSl86Pa98sjP5q3wcVw134SKM1aBNH/qdUgzq23WyeEhn37feotqxUVWyEtxhPhC/Qij2a+uGOs1/gwp67WZXVEnQjQKeFrncAmVmMrMHn1fQfaWWK4B/UaJtxxVp30xlOYmDyJ9Q683HYbRMg+3t9OFxuobqo8W2DXNB1zuxvFH1H+d/6SbVKfytXnZ6bJBF0shtK2NrJqCeFWUaal+P7nythfctUeod/HXvD1fCKV1TPivYFYjUHe/OTa6SEu2p8KBZnAK+WG42BRphxgZsgrcsvDxQmgDOJozT/3ePG6i4Adi5C+58Nm23iid2EtRdadPcT6AVI5MH9+eTyrUbzvzkutSilsmS/3U= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(66946007)(66556008)(8936002)(8676002)(38100700002)(83380400001)(66476007)(5660300002)(6916009)(4326008)(2906002)(508600001)(26005)(1076003)(186003)(86362001)(6486002)(38350700002)(2616005)(107886003)(6512007)(6506007)(6666004)(316002)(52116002)(142923001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?31FlC5QHCmg2MFsj4H0pZab3ChbaMSlo3G/C6x8aoO90xYvj06AmqvqdShBp?= =?us-ascii?Q?d7EjF8fLkSoDhnmDcgJ8Q6zJmaVBzRqncvthNRQvk0sXK5mQ914oF0ZolGDP?= =?us-ascii?Q?03EHn2ePMG7nJ10R57EZZDcUAyb+bmBEnYUUX66YBBn53nKTtIq0AZha+p92?= =?us-ascii?Q?4uBWw3pXkGmU1dGA5XoZ/axQYAX9uI6Sge3GMVVCffGRNEzxoJxlIj7fWtD9?= =?us-ascii?Q?4N6DvQDcJ7SlL4XgfzmTdrjVIHYz5jRnBMsb8JZTenJPYL6x1wVx8H+3c9fJ?= =?us-ascii?Q?mucI9qQNt7XMSrqoO5NJCtcbdW1wnIKwmdkbpZ8We2IWbjrVIEDg+FJCmbIE?= =?us-ascii?Q?5UtPaeYd+Sjb4q3CyHsNt9KxJBH6OSKGnjRpfkAxhzUquIj6UR8d3LX0+xjS?= =?us-ascii?Q?kKNpiVIVFWOgEqheSP0jI3+pJiB63S/odBlz+u7IM0RhUDhAhGaq3l9aRZN6?= =?us-ascii?Q?6nf6kZMKvZQejSyWvaafEyI2kmY8a/sSxhuM5ycblLydPaUamu9SgmoSfFMD?= =?us-ascii?Q?SkJZblgHz6Yh0w6JMJPa3VQ3IovezKs3rSHGq9N4nmEB/5p58vtbm4KmdXxD?= =?us-ascii?Q?MwgFTOYMXMVeRJXp6DpRTNPZqF5/sY5EK7vvNON/uwjbGfQRvy04UJ2gMvhq?= =?us-ascii?Q?iBYx148hYI6/u8cHHe7cKCyYOdfdkIOGNzNg3E8nGe5G+EGY2Ge4hSdMrva1?= =?us-ascii?Q?dGxQFL+AkHQxvxzOo9UyRpZiIhwaA1F27V8vRvc2Jgr8PmU2jM7PsV3o2XXx?= =?us-ascii?Q?dP/aNuAeIQIcA6ONCCXj3XgUGXpAZJAHOCooceuUihVbp0ndegyhmlH/F3IA?= =?us-ascii?Q?g5zIwSfZ++dsKdp/H1jPBTUnwIMkda1CdGCuqznfekjQ7YUJ1qs0lVXaVLsW?= =?us-ascii?Q?mwvjRy7N+4BGQ1/UeNz7sNfM3Gj5oHhxlzhqRSW2gdoBd+MSaaeAYHcECUCg?= =?us-ascii?Q?Zy0By296TazwdpYSIoyJTiG85rneDKUJ82smsTXay41+79GBl9dz1heXi9g5?= =?us-ascii?Q?cYknsfLNt5BphfOGk2OPP65N/DfN79Nl4nX3Dh+WLQ4bWa3fCTxn7/Pr26ED?= =?us-ascii?Q?n0ev8PLX5TwO852SjjpXPCwUOdErpmxcV9n4HqwNURvN1YHWcccguIwqDRbz?= =?us-ascii?Q?jLccJr0LYMl2VANgfx7WJVFfWIYfvdl2Z2J64RYcVDIAA5q6iBg91dmei901?= =?us-ascii?Q?lWswkq2XleOjD0kg4P+eqK5xWa4mVe3ySTi+80GNQxA6Qqm3P7FwRHHguzlL?= =?us-ascii?Q?zAOMPKdvXzwv9HCEeaNOn5h8GII06fL/9eEwvqC5fwbxkgtcKA0WV/AO+kwJ?= =?us-ascii?Q?LHOlPWmJITfVG3pWBkKaCCjWDRny+BXgeR7zNazCiUBUGgTRTkIrTSqgoZE9?= =?us-ascii?Q?f8SXXM4AXJ3lgSsJTz5mB0iwvRwizy9y3i9BTCqmNWfX2oIRiuqgCSoAXLtR?= =?us-ascii?Q?madYhvlV5EiAQm1ig6fOUorwo4dC91vTEMxMS5MdEpC0FITosAW1n2nBfFW/?= =?us-ascii?Q?hY6jZGNQc68CRWbe8pFN78Bl2UE9EQPk3+6RbsbLjHo2GcYNT33vEcZWYxQg?= =?us-ascii?Q?JdynOOZuxUv8FOLA8PJ7TETgM99qQsEUDkl0d/AceZI17ak1JtQLYov3R3KO?= =?us-ascii?Q?ok2SQRd0rcmtOcC+o/q1bucJXXZVVUfY+wG2rXeiitHdzntfnj4/qoddWEdf?= =?us-ascii?Q?a62ksA=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0c082e7-cde5-41fe-4375-08d9ea582a15 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:43.4318 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2wpt49Lp9pGhe2SnRzAWczdKmkcInfO0+FGd3utki7E3xHkpc8ARNBSuUIwOx9C0akl+zR+Hnf3xn4Jsj0d9vZ7lBIjpVHWeo2PwkRxBtB0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2288 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7e1b::716 (failed) 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=2a01:111:f400:7e1b::716; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644253089237100001 Content-Type: text/plain; charset="utf-8" Implement new API, so that qcow2 supports blockdev-del with force=3Dfalse. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block.h | 2 + block.c | 4 +- block/qcow2.c | 85 ++++++++++++++++++++++++++++++++++--------- 3 files changed, 72 insertions(+), 19 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 42d78a7a31..fbb5f3ff6d 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -672,6 +672,8 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs); void bdrv_ref(BlockDriverState *bs); void bdrv_unref(BlockDriverState *bs); void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child); +int bdrv_unref_child_safe(BlockDriverState *parent, BdrvChild *child, + Transaction *tran, Error **errp); int bdrv_try_unref(BlockDriverState *bs, Error **errp); BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, diff --git a/block.c b/block.c index 187732c6f8..dd2ddedc86 100644 --- a/block.c +++ b/block.c @@ -3216,8 +3216,8 @@ static void bdrv_unset_inherits_from(BlockDriverState= *root, BdrvChild *child, * When @tran is not NULL, first failure is returned and the action may be * rolled back. */ -static int bdrv_unref_child_safe(BlockDriverState *parent, BdrvChild *chil= d, - Transaction *tran, Error **errp) +int bdrv_unref_child_safe(BlockDriverState *parent, BdrvChild *child, + Transaction *tran, Error **errp) { if (child =3D=3D NULL) { return 0; diff --git a/block/qcow2.c b/block/qcow2.c index 8ad555feb7..a8f891ee34 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2740,23 +2740,24 @@ static int qcow2_inactivate(BlockDriverState *bs) return qcow2_do_inactivate(bs, true, &error_abort); } =20 -static void qcow2_close(BlockDriverState *bs) -{ - BDRVQcow2State *s =3D bs->opaque; - qemu_vfree(s->l1_table); - /* else pre-write overlap checks in cache_destroy may crash */ - s->l1_table =3D NULL; +typedef struct Qcow2CloseState { + BlockDriverState *bs; + void *old_l1_table; +} Qcow2CloseState; =20 - if (!(s->flags & BDRV_O_INACTIVE)) { - qcow2_inactivate(bs); - } +static void qcow2_close_commit(void *opaque) +{ + Qcow2CloseState *cs =3D opaque; + BlockDriverState *bs =3D cs->bs; + BDRVQcow2State *s =3D bs->opaque; + + qemu_vfree(cs->old_l1_table); =20 cache_clean_timer_del(bs); qcow2_cache_destroy(s->l2_table_cache); qcow2_cache_destroy(s->refcount_block_cache); =20 qcrypto_block_free(s->crypto); - s->crypto =3D NULL; qapi_free_QCryptoBlockOpenOptions(s->crypto_opts); =20 g_free(s->unknown_header_fields); @@ -2766,15 +2767,65 @@ static void qcow2_close(BlockDriverState *bs) g_free(s->image_backing_file); g_free(s->image_backing_format); =20 - if (has_data_file(bs)) { - bdrv_unref_child(bs, s->data_file); - s->data_file =3D NULL; - } - qcow2_refcount_close(bs); qcow2_free_snapshots(bs); } =20 +static void qcow2_close_abort(void *opaque) +{ + Qcow2CloseState *cs =3D opaque; + BlockDriverState *bs =3D cs->bs; + BDRVQcow2State *s =3D bs->opaque; + + s->l1_table =3D cs->old_l1_table; +} + +static TransactionActionDrv qcow2_close_drv =3D { + .commit =3D qcow2_close_commit, + .abort =3D qcow2_close_abort, + .clean =3D g_free, +}; + +static int qcow2_close_safe(BlockDriverState *bs, Transaction *tran, + Error **errp) +{ + BDRVQcow2State *s =3D bs->opaque; + int ret; + Qcow2CloseState *cs =3D g_new(Qcow2CloseState, 1); + + *cs =3D (Qcow2CloseState) { + .bs =3D bs, + .old_l1_table =3D s->l1_table, + }; + + /* else pre-write overlap checks in cache_destroy may crash */ + s->l1_table =3D NULL; + if (tran) { + tran_add(tran, &qcow2_close_drv, cs); + } + + if (!(s->flags & BDRV_O_INACTIVE)) { + ret =3D qcow2_do_inactivate(bs, !tran, errp); + if (ret < 0 && tran) { + return ret; + } + } + + if (has_data_file(bs)) { + ret =3D bdrv_unref_child_safe(bs, s->data_file, tran, errp); + if (ret < 0 && tran) { + return ret; + } + } + + if (!tran) { + qcow2_close_commit(cs); + g_free(cs); + } + + return 0; +} + static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs, Error **errp) { @@ -2793,7 +2844,7 @@ static void coroutine_fn qcow2_co_invalidate_cache(Bl= ockDriverState *bs, crypto =3D s->crypto; s->crypto =3D NULL; =20 - qcow2_close(bs); + qcow2_close_safe(bs, NULL, &error_abort); =20 memset(s, 0, sizeof(BDRVQcow2State)); options =3D qdict_clone_shallow(bs->options); @@ -6043,7 +6094,7 @@ BlockDriver bdrv_qcow2 =3D { .instance_size =3D sizeof(BDRVQcow2State), .bdrv_probe =3D qcow2_probe, .bdrv_open =3D qcow2_open, - .bdrv_close =3D qcow2_close, + .bdrv_close_safe =3D qcow2_close_safe, .bdrv_reopen_prepare =3D qcow2_reopen_prepare, .bdrv_reopen_commit =3D qcow2_reopen_commit, .bdrv_reopen_commit_post =3D qcow2_reopen_commit_post, --=20 2.31.1 From nobody Sun Feb 8 12:14:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644252740; cv=pass; d=zohomail.com; s=zohoarc; b=WmIcWypv1TPO0MeBzYS76bCl41TobbZWjS+2qxvqVN2EcOcriy1E60UIvDboijMiIHavuITinMVjhQeOpnpEuQJXmfSWCVRhVz4k5DxZJCsusTxDCBs29tesPxKpCjDMd0eSKUj0+DI/NTAs1aTZWxVdLksq/kR9eDQOkK3cOVw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644252740; h=Content-Type: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=e2lcUxEp6by0XL8MDp2pEofILUfI9zC3aZyHKMkrhHM=; b=RH+7yRF7r4MRNT1O4BRn4MrjIzKjSIg1lQRIu3kvwIsCO+TigeAb3I+ZszH0OYlut39udaZA7joYed0Qhb8DmXONwQObnMd+Lz4zUO9SBmWv5GO2vsWCKzV0tuRMocX0EkZjaUpE18n6cvEkK8gFfbyBsq/Gchhse009TcsNDJE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644252740549130.1579251974822; Mon, 7 Feb 2022 08:52:20 -0800 (PST) Received: from localhost ([::1]:34080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH7FT-0006FS-77 for importer@patchew.org; Mon, 07 Feb 2022 11:52:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71X-0001vV-Gw; Mon, 07 Feb 2022 11:37:55 -0500 Received: from mail-db8eur05on2129.outbound.protection.outlook.com ([40.107.20.129]:2208 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71S-0005Ix-F4; Mon, 07 Feb 2022 11:37:55 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VE1PR08MB5085.eurprd08.prod.outlook.com (2603:10a6:803:106::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.16; Mon, 7 Feb 2022 16:37:45 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wi+xvJy7VR36YukFCkevHEehmhYKEp0Avn0ziBotL0KY1DMg06O6WMuGT4U6rH/MQd/fGn8vKFMPEj0Ck2GSZeKdEA9zOP4YSjUdpl+9vXQtrD4fmrBO61JDtxaGCtW60yI7eH7LSTmf12zF1n7BuUPZbWKevzL6vO3p1K7LdiFh4AtTj5aHuuJQ/QTZHVdxQobq8SimN2aJ6d9OEFXcBaa+8W1bd2z1HvEdRpL+6i5lAS9ku0zP9KCXGnVRHoann+fniCIUv0EAMIDVSwgaRImH0QHqrapc0SN1yrfkGKrvLrWc5yTIerB1HvdnIyEB2N9oBVT0WE5ySVUnL97a2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e2lcUxEp6by0XL8MDp2pEofILUfI9zC3aZyHKMkrhHM=; b=ALa3okq9vF0J1w0bcEzPNVA/zqYEmXrdvdRMdCaH4Dt9kJQ2iabypgGcr0fDtSW1ZioSRPHkfEqAI9R6YIuRcreh18ckhWfpsF/SX090Ilfmo5m1Uvu72nNd5vqGA1Do2k87PK+q4hZRBVjcUKVoPcIfRpp71nQlzw6geldVSWyL3Rj1LJ6ye1T3SRp7riDtsZEJBuC/o25T4c5RdjB8Hi9D/WhCcGAsW2PDPRaOc8k31C5IzJ0yPefumRAuYqb7eWosw77O2PzvFt6Vz9uApsC83XykT8WNqRAyGtTNd6crpLeEvy/LFxEfp7vZOPKBGBeFx+odg6h3vLRheRR3Nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e2lcUxEp6by0XL8MDp2pEofILUfI9zC3aZyHKMkrhHM=; b=lj7UfGFvonIbdXXH1Z7l65/qblXQm1VVZT1QS3KxfmK5nEbKXsPGOZD3Ef54hpp/X1PIoL/qE01HYtRwaE7z5OjzqrcpgEuAyJrZwmabmOCdVhimg7r96J2Q8jIildNl81WjLubLt3n9DpbZuNFeTjWd/GXixsf9dtt+h7dHN5E= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 13/14] block/file-posix: implement .bdrv_close_safe Date: Mon, 7 Feb 2022 17:37:27 +0100 Message-Id: <20220207163728.30362-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: df1fb12b-0b45-4e11-023f-08d9ea582a58 X-MS-TrafficTypeDiagnostic: VE1PR08MB5085:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:103; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /fzcsa4mokcZHCLO5oKi9gDh5DZlrLTqK/pstvxIHgRNoeMMZFQgQXzpWCMAuqe8JvpuzJKMv6inaxZnBwvm7EoGrOSU+HtH2MAuaBtuIFxrMTGhn4OH0hY+MF6sJi3/y1i1dkYB96WMawelRKgh8soGTbObxJWv1DkwOrVfuiafR5uT/F/5bQDVFFPFJAktU8I6LM3EyfW7MU4Q1vVftpvj6dTBiPdAzzjQfEbjD9vcuTLkF2Tziu6Yaa26SknBA13XYK6Wl0MvIoU4s0sXeWN0f1v7iH8IdgHPTsm58IXifv6V25nVMq1QSMjw++J7Hy8uO93XOoj0BCVv7bX8jTzlQp8ILxgOakhQqQLImPw5WoCofUGoWhO4n3h92DRPZO7a4bZnL2oEw1N0Ju+Jdrjka3VrGbC6OaSc+bWN/YiIPu/XkboVEHNde8oCpBQkZjp3NxQvuS7CItyxiV6ca/Nx93w5xT7TW7cN1QiLHdxbx1VEd9+cEgj6TXi55eh4y3NiIepG1QPfExpoALVor6oHMwM0fe0vuHPGoSxllvXumsie2k6nOyX1Q3no5zmY8pGwnxdsB2BgmxBdK5Ee474vkLKouS6T++iV88/OidNBkyaKvSdSVl6lqT3WpFDgbC87l9p6blF40l+BZUWjNFQt4wZqMqo5IiMqIkjqi3w7rVwpphzdBX1HeeWs8hB/MP8REQkEPz2BxD6Wn7ajpwpW840wUdO0T3SRvUyfXNzdxW2+t70Gy5Qa1ht6cPCM4xjPDmr1Eizvzl1ZTgQ0Ug== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6916009)(38100700002)(316002)(8676002)(5660300002)(38350700002)(86362001)(2906002)(4326008)(1076003)(66476007)(66946007)(66556008)(107886003)(6486002)(52116002)(508600001)(2616005)(83380400001)(36756003)(8936002)(186003)(26005)(6512007)(6506007)(6666004)(142923001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ixcOhuqtezyXRB96vHWYH6r7v/C788s833ilR7Y7qqFqsCS+oPgnNN20kpz+?= =?us-ascii?Q?Es3YIFiVa7SrpPH9hWDyICfrpvyRHu+sPMz+8ST9u+WGd9EANB3M/z5KpelC?= =?us-ascii?Q?srQ2lNulRhFLxwze+VanDlRJP3Xra+XiNinJDGasInf+AN/5iVfAgD2n4oSP?= =?us-ascii?Q?Pi0AklBKfgDphSA640+dn3nlJvvdpi0YfFvwROZwMCpiJo7+1s24T8uOZIGV?= =?us-ascii?Q?9K9xXGTX/Z3YapxlOWMYYBR7TVj/W9+FkvG09EbfIwWdKmVczPjU93Cwa+Ho?= =?us-ascii?Q?9xGl7fdfKNCWcRFqzzmgy8EXP5AiP2WSMuD+5LagMcPV94+XRWZ0nFgJ+/8n?= =?us-ascii?Q?zOMbJT1zIzYUm9/iuMQptfOGP8nhCRCChWpZClIQHYvKMPfWCjDIi7hmWKcG?= =?us-ascii?Q?8B7Q6o0o/wLKgdYUhUcAynImcMfz0VBE9r6ZV9TgNVBghp2QkPw2YVDBqQHb?= =?us-ascii?Q?4sdmhWdc8gvO9H0MFDIR50iHwUtS0V19ts1pfytHq20/PVsb7cruUQI9r4D0?= =?us-ascii?Q?IU9MfuMXKz5/w6z+hUJNsJLLRzm8b0e4DD0vmLvWyf6TUs2wijTZflxlfpgI?= =?us-ascii?Q?8spSoY6P/LAVtKGD3uDRqjMBFuLwcshOELjFGBg5sxA8wUybSEseFziyu48M?= =?us-ascii?Q?o8yuERgykLHXjVHmtmBjYDU77fIqJqiw5b4i6QDAWsirkIyvAF0ZtqEuF0JB?= =?us-ascii?Q?bwydthbjVPDje2cb/yMj5UAsDyzxEwmp3CX5HQqBxypQxZmM7TtUvipyFmIL?= =?us-ascii?Q?e6l7cTKKn7QzhRaY4CR9gSyNcuazs1odwnWRp4Q57efX1/znsQmYMyWqRB8A?= =?us-ascii?Q?CZ2Jf4cK10vAgDx9cqCARuYSDMaYNrfxqvo7oMrVkB6nlFJGmq5mAz9VAKEc?= =?us-ascii?Q?OPM7vrHduJsic99plbTTQryE58Fi8ToV+9IOVLpi/CLfBDSbSr4AnTzx8WTQ?= =?us-ascii?Q?hWs4gpjedB+HNZewUC382g3RKPuzpOMBBxZAKKK8YvptArO4komATcTOI6z1?= =?us-ascii?Q?H/VdbCrbsEDAtR2/QS9EEJVUbTM6I2FNLLhRhFtzKNIgYvIOkKovW8F7ALmo?= =?us-ascii?Q?vas20IrLoKu5DEsDaycluoS0AbV8pSMA3k4COehEZ+p27uEQWfLsCSAaGaut?= =?us-ascii?Q?COe6H58QWNLuH/Am7K45/dBJzlwwyUmpPieVvDqaCumRNigJB7wxlBdOFuTo?= =?us-ascii?Q?Ti0JwWvARqC1j8cnTyZUgQQ+e61JYDwjC7/ha+n3bMlvdw76REaH7CTUoO53?= =?us-ascii?Q?JzBiBZRg5yxf968ns7L90zcRdIVe3D7K5QUPOezzL2wM9XFGuqoa3AWgM9UO?= =?us-ascii?Q?AQSaOqe5N33QZtZx4rX+Yp4LIz1FIGmxYHH0Gb2KjsekjY2FKIUoNXVycMVz?= =?us-ascii?Q?yw9Kuo9xk8kTLvSTRefb3qUtHf2hZTvniiR0VMpMoMPwDfFP3Y2XCbs3q87s?= =?us-ascii?Q?Ra8zx9NggS55GMw9OkwptyReo2cZEfHxbt6eFl7bYvGapV5cH7njdgj94Tmv?= =?us-ascii?Q?qf6kp8ymWN+jo4UsBbTOH057yhYPRKBiyVnPuLYXReTLlADppf5Fxu287yXT?= =?us-ascii?Q?U11DnFafg1Gr2rNp3/FRowG3Po9URnYG6UhHknRx5bWHVmvUWJ0tEsh/y7HS?= =?us-ascii?Q?MkkIu7XLQV3qOsEkYDzmiJUWddjBkMxiAGnfSKaWlsrMh0NjCrym2ROawvMm?= =?us-ascii?Q?wKGxTg=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: df1fb12b-0b45-4e11-023f-08d9ea582a58 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:43.8849 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PnbA7TsucSjXTTryUkRDonwjuOqXpZT+Cyu2lQ2cP9dowYq2kGSWBAlcLeApZgc+MnPVsvr/UafKep/WusIsqj6nQKxzxtNQKaEQgnQ7qlo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5085 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=40.107.20.129; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644252742271100001 Content-Type: text/plain; charset="utf-8" Implement new close API for 'file' driver, so that we now have the minimal set working: qcow2 + file. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/file-posix.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 1f1756e192..90642d8185 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2195,14 +2195,38 @@ static void raw_aio_attach_aio_context(BlockDriverS= tate *bs, #endif } =20 -static void raw_close(BlockDriverState *bs) +static void raw_close_commit(void *opaque) +{ + BDRVRawState *s =3D opaque; + + if (s->fd >=3D 0) { + /* + * Closing fd is unrecoverable action, that's why it is in .commit. + * So, yes, it may fail, but we ignore the failure. + */ + qemu_close(s->fd); + s->fd =3D -1; + } +} + +TransactionActionDrv raw_close_drv =3D { + .commit =3D raw_close_commit, +}; + +static int raw_close_safe(BlockDriverState *bs, Transaction *tran, + Error **errp) { BDRVRawState *s =3D bs->opaque; =20 if (s->fd >=3D 0) { - qemu_close(s->fd); - s->fd =3D -1; + if (tran) { + tran_add(tran, &raw_close_drv, s); + } else { + raw_close_commit(s); + } } + + return 0; } =20 /** @@ -3278,7 +3302,7 @@ BlockDriver bdrv_file =3D { .bdrv_reopen_prepare =3D raw_reopen_prepare, .bdrv_reopen_commit =3D raw_reopen_commit, .bdrv_reopen_abort =3D raw_reopen_abort, - .bdrv_close =3D raw_close, + .bdrv_close_safe =3D raw_close_safe, .bdrv_co_create =3D raw_co_create, .bdrv_co_create_opts =3D raw_co_create_opts, .bdrv_has_zero_init =3D bdrv_has_zero_init_1, @@ -3643,7 +3667,7 @@ static BlockDriver bdrv_host_device =3D { .bdrv_probe_device =3D hdev_probe_device, .bdrv_parse_filename =3D hdev_parse_filename, .bdrv_file_open =3D hdev_open, - .bdrv_close =3D raw_close, + .bdrv_close_safe =3D raw_close_safe, .bdrv_reopen_prepare =3D raw_reopen_prepare, .bdrv_reopen_commit =3D raw_reopen_commit, .bdrv_reopen_abort =3D raw_reopen_abort, @@ -3771,7 +3795,7 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_probe_device =3D cdrom_probe_device, .bdrv_parse_filename =3D cdrom_parse_filename, .bdrv_file_open =3D cdrom_open, - .bdrv_close =3D raw_close, + .bdrv_close_safe =3D raw_close_safe, .bdrv_reopen_prepare =3D raw_reopen_prepare, .bdrv_reopen_commit =3D raw_reopen_commit, .bdrv_reopen_abort =3D raw_reopen_abort, @@ -3902,7 +3926,7 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_probe_device =3D cdrom_probe_device, .bdrv_parse_filename =3D cdrom_parse_filename, .bdrv_file_open =3D cdrom_open, - .bdrv_close =3D raw_close, + .bdrv_close_safe =3D raw_close_safe, .bdrv_reopen_prepare =3D raw_reopen_prepare, .bdrv_reopen_commit =3D raw_reopen_commit, .bdrv_reopen_abort =3D raw_reopen_abort, --=20 2.31.1 From nobody Sun Feb 8 12:14:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1644255426; cv=pass; d=zohomail.com; s=zohoarc; b=Tye7yUg6uSV5a+N3y/nNszTQA44tGPMY7416mFf5h4FkJNaZTEmde6Ib37L/AcBZjzErhfzppb2Cwot5JRH1ygUabvGhlzDTEcZCUSylf4hjkRM8legaLW3JnykMtYR3VuYOQQG9v4Av6BaqtrNihooRGep+IQIXZOrq4/pZBq0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644255426; h=Content-Type: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=p6N2areXa5/PvBykciQCdMGLPxqi17k9S4yCirRbb3A=; b=ThXYBM3NSS/a+w8N+w8vr/JhpGuDhgUQVGh7+a6peLJYgHnTy6AAuqYit7lYddvHnRgaT1zP8QxyO2iW+oDRL7zbnFiGc+fl5dklRnxSPhTZnlsr4B2ruFJcghf5WG/grkw0aLS1p3M01JvtxuTERlkEFpoqaklyc7izPJooZwo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164425542643366.74876358055587; Mon, 7 Feb 2022 09:37:06 -0800 (PST) Received: from localhost ([::1]:41808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nH7wn-0001gG-3T for importer@patchew.org; Mon, 07 Feb 2022 12:37:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71a-0001wC-Nq; Mon, 07 Feb 2022 11:38:01 -0500 Received: from mail-db8eur05on2129.outbound.protection.outlook.com ([40.107.20.129]:2208 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nH71Z-0005Ix-2I; Mon, 07 Feb 2022 11:37:58 -0500 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by VE1PR08MB5085.eurprd08.prod.outlook.com (2603:10a6:803:106::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.16; Mon, 7 Feb 2022 16:37:45 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 16:37:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j/zNg4+g6TCZx0qhQh/u7wj9YxjUVmRs/e0KCKA9IYQJP0VJkVLEFRtGhIxyx2NRHvZtzZj5yimoOIohYAdW5f6UkO1bm4jHf3+02Ef3C79gY8jhv1BQH7j9TIIDz0BNOUWvSA0DbGOz4nvQub7ZC1O3Qrw742QMUpxE7BdEjli6adUrHfRHdc7mAR1Y36wb2L9qd/XZU+fKIbtEYgGM6GOYbO2Hi6RE+LlggmDsk/HdBlKTI+p7Jq7Bph6E8R5ApDxPjdrapwmtqIEK+vxAzhSTh+gDG38yPqkNM9isrzsdsyNhQBdBzPeoMWo2fOYa/xym1OnwLqooeN60CIUDzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=p6N2areXa5/PvBykciQCdMGLPxqi17k9S4yCirRbb3A=; b=OgiAkCAkA6otDuHZWz9KxLWOaI7diYkaeGmVbvzMS344B8G/J6CGYWEmGtI/IDl1GAJiKfax2cq7M3XYugjduakBPTylek8VnDrIcfpAzma/Kpcct7Yx6GTvW8pv0bO9J40zPoNZWe2102XuCH3kpSMg15UOWIMGEYAkzniDas1yuN4+9+GuAY6MTaxmgyATtFbS2VeBFSjv/JA48fxgsQ5SZ4NKlCEGU4W4Pb2gs3EII1Nc/+OM6W5fQwhbkkvO9nvSG5uNSDMqht4JwdmWmpzJKG53VxccWgtuyfd3c+wdKGUddtpxWV77q+PCDjIvOXatQp+tKQZu2flcAh/S6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p6N2areXa5/PvBykciQCdMGLPxqi17k9S4yCirRbb3A=; b=EG7aMV5HB3uBGTvk0D1LyIkrAsVwBr4wCZWyGmQ5COId+Om1/15gYhAy6LMrlq9NZ/WcYBRtZew9PJyqPp6Ea/iLRJyVhLjuC9RfInC8bxz7bfD+z20Nr6Kd5ycxznYd5rOUS0WAmYYVwqMZedkR1tpaQhbt1leB+Hk6dmdxTUo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, ktkhai@virtuozzo.com, igor@virtuozzo.com Subject: [PATCH 14/14] iotests: add test for blockdev-del(force=false) Date: Mon, 7 Feb 2022 17:37:28 +0100 Message-Id: <20220207163728.30362-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220207163728.30362-1-vsementsov@virtuozzo.com> References: <20220207163728.30362-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ab80776c-0f18-4ce5-9b5e-08d9ea582a9a X-MS-TrafficTypeDiagnostic: VE1PR08MB5085:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WpEl7amz3XF23hIofcy14Wngh+e7fOhGvJK/zWDc8q8d7hC0VxN/AoypYFFIqW90pZOlYWEgwkE0k7+MOWLx4KfMl6RP4Dmt4JO5cG20bZHNjGiUUHocJMxPJl2qEEhG9bz4kq8vLWn8kHIm3rqdAhGvN8ySot67IVEG+/LjTSp+7bANHLNN1fzAgzuloHNxesllyTMDOy4u6P1+WKPsa8ohjQdkEpuptzjluQkhubqLwj1GT/ZACMnZWgL1VLaMFufZMer2krF1Md1VgKM2b92aFAQe5V6kYzeo3P/rXA9G0LxUUsVjytIDUX3qAbBUURCB38RcqyGxq15n8FherQbn/YvOm5YGXrAX1i1UsU6SXH2dgVZhginHrBFhbSutzJ+qEdZhIe8ARsvM0s9aFpkMqT7PQ0P9U3K106AnQdhTeGLWohnYYTH6BnWGyZjfylIKmi77e/2qM18onOkvmJV5I2rPoTf3ifJhtWk7n0ldCX9komaNQClUJkr53lBDeMGu4KbGrWd68L5dvXrkl1JJg2Z5WwRJc1S8t92Y1DyWbLpRUoaxAy8Wz633jlTO5ZJb6sCf/rQEeRl05jzEhAM9216p3k41jr8LpdjHMgNKVaFwox3YSSoktalyJqBvkdii08UtWWVz/7HmUXPQwE2SekcGqyXQKfctZ+F7m9Bc9899Ul0qCwSBdqbir20+8c79t84F4fpPxqv6UT8IIzwZ8kwzZo06vCYQCVP/gQUII7orqxS5k0UJvpj9Ku1+hcLaDXYMq3lLLVSgXmCeULD/w++VqobFq9hfHXQltDV1nQnp2PAqVC1nxcv/dhQKV/4Na1uyEYfZ6xmJgeiHpIVq7fEQOSbSeXeDJE12kQM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6916009)(38100700002)(316002)(8676002)(5660300002)(38350700002)(86362001)(2906002)(4326008)(1076003)(66476007)(66946007)(66556008)(107886003)(6486002)(52116002)(508600001)(2616005)(83380400001)(36756003)(8936002)(186003)(26005)(6512007)(6506007)(6666004)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?UOLRvQ7DIrnXS8oC9opsA6WyG+uUETcVfPQFwqNHEtJj5JJV4VpFcddpFwWj?= =?us-ascii?Q?uKfE2SjowgmNY5EFQ1Z1CNvMHiggm8quDKQLW0zy/ihd8AHOqMZJY//SyGzp?= =?us-ascii?Q?4Eiro85oVJDXqVadZ1M/b8DoDGbq/6itdT7z2vybaM5T4IFrYNAc/SysIP9f?= =?us-ascii?Q?AKkcXgKYxuwffABZQbWGJ5iAdtEbYhpwit77+vP26bVvZ8RjoCbeysd9PTAe?= =?us-ascii?Q?J5FuOgnBRmgiBPvfT8bboyKPiCNjxDlbgFeCT4JF4fwdxa7WAL1rM2ZPA4vi?= =?us-ascii?Q?cssP2djOvqYpIjjgt0hVmUhWvEDVG2nmr09GgSzcF380p43whk/X9R6p5Qqs?= =?us-ascii?Q?XSqrYJ5mQf87sKBgLB72MhoDLbTdAUustv5jVMVtGVVm3f6+nRuwOC3dvsIK?= =?us-ascii?Q?JEdiLGMn7lyjCedwnmeAsSwLjpsLYYRHox09f2uv5nhz4cEGmBwbG1gaqU83?= =?us-ascii?Q?nQC2r3XNNSgvzOr+TX4DaV4obQJxatl8HTu+V5gT5sEcHfPsIiiTzl5r1QWi?= =?us-ascii?Q?WH9TwfOC0/MUZeXVfd3pKTtve6cAj4KrQ6VI7swTg/1E1nVMNWyOyjfE+7C0?= =?us-ascii?Q?PCsCKLZ08jJK+aqY1+WAwAvIVftd+qT+jeOC3sK8vGs7JIdZ4V4kRtwg/VBr?= =?us-ascii?Q?zHru6+RKlGEdOL/CcOd8XIM40qvUYTl06NWJaFFv32lyenZR+GXuNlqB4Ohn?= =?us-ascii?Q?+TKDvOmYoX+iUhogvU7ZU1h9lpeUm93BcR4L23l/L5ov17xzyQjR4P7TCf6g?= =?us-ascii?Q?cenod2S2lpupwo3+kQbmJI+Lq+4k4VFD2BDsUEdZSv+1415iboLyR4QAdjzW?= =?us-ascii?Q?NQVO7ZerGDiTs/qjXtrNEKLUWFkD7H+3V+U2z1bougJvDyyuq9zneIBIEjxc?= =?us-ascii?Q?5siFkR/mJvCQK0OZZDwKc94nVsFqVZoLB1X0wJUlrjXvCILSeMjdBqE2ARS9?= =?us-ascii?Q?uszDDe9iaCtcbnlXZDgrfrXlortf4+v062XnemjGBjATWtn6OpDe3pi3REb/?= =?us-ascii?Q?wO3vX5hy8vb20Ml2Ez8ps8t6ytuRigB0uJepPm/kqJ+/5Koi4QtIuC0MCRrf?= =?us-ascii?Q?5Ji5y2W+CZfZa0sQK5gplWBYFkuXA9j+YF0FXXPOTlQKOaziA+BczejU3u2+?= =?us-ascii?Q?KJV+ERqxdlmxC0FD/wq06yk6ateoN6s/JumPtAomAUyVL7A2eepaUM6ReKHK?= =?us-ascii?Q?lbZQqV2R7VtdwRCLdQbjqQILR9+2J8QBVyN2/ZUWwfelj7f0dY5m/uILuiWQ?= =?us-ascii?Q?mGm9FoszCJV+1XV60qNTV5ou7EGS+JpjcRNftux5MJYy2iogcAu0BWXMstrW?= =?us-ascii?Q?C5jDOZzaT5xueL80mK1mptx2Y61hZ5qkCDJBVOaE8JK7PUMpJAuwDEsxvj31?= =?us-ascii?Q?ocJC68bmiAAiVvNK7B7ZDkqFxWUA2kWtdKsNZ67Uz6z8Kew7046B0npikUi7?= =?us-ascii?Q?NpSjWnsfkFbCqyjHyiGI2IYmggFha4Bpn4SQi3V4zAxYMCE9i6jnMV/ApsaO?= =?us-ascii?Q?ZlkbfTJJc5VuqwjYd3Teg9Ru+Urc+zpBu0OYMoChCiTgU11QtHhpwPukkMBa?= =?us-ascii?Q?1HOiP0eEIJYR4vsAbb98oPpjCLwk5nOvesu/sQUm4lBze+UuyMuIfB2qdsvR?= =?us-ascii?Q?yEGPIgDep7mczwYp2sy0xNTsNfxEEoqxi7oT1Q5eJ67ywO5dwgEfKnGo43dj?= =?us-ascii?Q?5MmSag=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab80776c-0f18-4ce5-9b5e-08d9ea582a9a X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 16:37:44.3682 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SQYCI0EJV/CkahowXjxTukK0zCJG3UJhNApy90dewX5dMebb5kOAOWqouzvY66ovps6HaY+rS+BtF/9XejhfO8g3f2LJAHgK2MUhrz/tFAY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5085 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=40.107.20.129; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1644255426874100001 Content-Type: text/plain; charset="utf-8" Test for new option: use NBD server killing to simulate failure on file close. Signed-off-by: Vladimir Sementsov-Ogievskiy --- .../tests/blockdev-del-close-failure | 54 +++++++++++++++++++ .../tests/blockdev-del-close-failure.out | 4 ++ 2 files changed, 58 insertions(+) create mode 100755 tests/qemu-iotests/tests/blockdev-del-close-failure create mode 100644 tests/qemu-iotests/tests/blockdev-del-close-failure.out diff --git a/tests/qemu-iotests/tests/blockdev-del-close-failure b/tests/qe= mu-iotests/tests/blockdev-del-close-failure new file mode 100755 index 0000000000..12b442f43f --- /dev/null +++ b/tests/qemu-iotests/tests/blockdev-del-close-failure @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +# +# Test blockdev-add force=3Dfalse +# +# Copyright (c) 2022 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import iotests +from iotests import qemu_img_create, qemu_img, qemu_nbd_popen, qemu_img_pi= pe + +iotests.script_initialize(supported_fmts=3D['qcow2'], + unsupported_imgopts=3D['compat']) + +disk, nbd_sock =3D iotests.file_path('disk', 'nbd-sock') +size =3D '1M' + +assert qemu_img_create('-f', iotests.imgfmt, disk, size) =3D=3D 0 +assert qemu_img('bitmap', '--add', disk, 'bitmap0') =3D=3D 0 +assert 'bitmaps' in qemu_img_pipe('info', disk) + +vm =3D iotests.VM() +vm.launch() + +with qemu_nbd_popen('-k', nbd_sock, '-f', 'raw', disk): + result =3D vm.qmp('blockdev-add', { + 'node-name': 'disk0', + 'driver': 'qcow2', + 'file': { + 'driver': 'nbd', + 'server': { + 'type': 'unix', + 'path': nbd_sock + } + } + }) + assert result =3D=3D {'return': {}} + +# Now bitmap is loaded and marked IN_USE in the image, but connection is l= ost +# Bitmap can't be saved and blockdev-del(force=3Dfalse) should fail +vm.qmp_log('blockdev-del', node_name=3D'disk0', force=3DFalse) +vm.shutdown() diff --git a/tests/qemu-iotests/tests/blockdev-del-close-failure.out b/test= s/qemu-iotests/tests/blockdev-del-close-failure.out new file mode 100644 index 0000000000..4a4776cc98 --- /dev/null +++ b/tests/qemu-iotests/tests/blockdev-del-close-failure.out @@ -0,0 +1,4 @@ +Start NBD server +Kill NBD server +{"execute": "blockdev-del", "arguments": {"force": false, "node-name": "di= sk0"}} +{"error": {"class": "GenericError", "desc": "Failed to flush node 'disk0'"= }} --=20 2.31.1