From patchwork Fri Dec 3 20:25:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11096C433F5 for ; Fri, 3 Dec 2021 20:28:57 +0000 (UTC) Received: from localhost ([::1]:58346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFAu-0003sv-Gu for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:28:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8j-0000mO-0d; Fri, 03 Dec 2021 15:26:42 -0500 Received: from mail-eopbgr150139.outbound.protection.outlook.com ([40.107.15.139]:14661 helo=EUR01-DB5-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 1mtF8V-0001cv-2m; Fri, 03 Dec 2021 15:26:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CLxBFoyV1HVSDnho8fAMai/2hhjAZS8BJFBg8wHCGS9qRNlV8jz9HAZiCaVGm4D9e5vhNWJLXmeG9Kdqd3k2OXaRsq5hQQTXKWvJJcMdw6QuBCtWLlxbXXVSFkgB3fIkaoGj9jPNpUvlOXhrvD4nzNwGE6nBJ5QwJ0F9t0re6odGpNd2EYKvz4z3Y7o4bSMwpKI9QfDCV8nrkzP/I1ZtpMRXAGXZbLHraRHM9cOkFA91qedgd/+fs7kPl0aa13fUjPIm3hvsyHnhZKrTfYHFD4Y3MgUWnHknKHspQZeDraaC/ydFwxj8Pf4KaTMCGyNfAPJVJfh3Ia8P//nLtQqbJg== 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=8Y9LPTxEfEll8hr7ZfNbGMzDqY1ke2XkpUh154uh+aE=; b=cKcMabTEvhX+w0UEr0kE9fwZJZtnDIRG/gMFz7dLd85cWrakiv/nokubIjWv8o8mLQQJhJCX8CGsuq5m35djRXOa9URzNJrjUW0OeoUJyTzb4kdUnapddVhd5Du8I9JrsAn9iovCHw7OQV05pP3jJ1F53pn/pqI/FpeAKjLihOGZ8MW4zDCPORZCt7/uBI8aH6Fpz/InAIWzpRrTlVqkYCsK7kzowZeud55ktSnkW0FWtgf6K3mqix4ogyrri2AYc1FlxcDu8YjpjDoGKESx0XROOD25xA5oc6Gqq/OCugttOueC1l9EfyMPBUYKc311gcty0lEHfr3NSpYwXm+UeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=8Y9LPTxEfEll8hr7ZfNbGMzDqY1ke2XkpUh154uh+aE=; b=WlvN+8N6dL+ozIJGdFPEyKCnqJUAl5ulMSsYw/UM+0BHKTzdEgFwxnpoPtXdcpM9Wsu0jMVdbgzDjzLE1kcOgkFzgpx7rsfKjzyYRm+2PX2R+1WDgqE/T8/ECm5MeWYKpAcO5Mxx2qzPEQo8AftCjdIBxSQgo8dCPpEHgrk3V3k= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB3841.eurprd08.prod.outlook.com (2603:10a6:208:106::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Fri, 3 Dec 2021 20:26:17 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:17 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com, John Snow Subject: [PATCH 01/14] block: BlockDriver: add .filtered_child_is_backing field Date: Fri, 3 Dec 2021 21:25:40 +0100 Message-Id: <20211203202553.3231580-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a94453e4-788a-4d52-16cb-08d9b69b2889 X-MS-TrafficTypeDiagnostic: AM0PR08MB3841: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KhlXKqJDc8yYES/XTQ8YHeXM77U4M6F5xuhgN243mXcNyDeSK/hkCFfaBDfPiVdHkHrbNzyW/l6wBbv8/gD2B3nxthuVc6eDmyxVQRZV+z0DtAoNK8NMH66wLAZrSahneUlUBSasmDYbVRauI01YPbbMyjnxp2HIOqwRUtBQjQDnSXq5kFPoj5A5EPpau87Nf0eJDKqvOf/uQiPAxHJg+c2vSvi96CQ2P74+j8JPttjfLymLhp2pxMvvB8ZBnOmXQDFa263il8h7nVnORjnDBYjPJb/OWE/vmTFeYOIah0n0oPZ1qmKO23GP+l/47YFKYVc6B6RSl6N/u+Uu1H3luBkQZ+vxRidwhtsNT6XvHRy5F5Y15vNkqiG2T+TMVtnwgfsvngL3kEj/URlVPfN2Ca2Ylo1w7nAdQY79m7DZAOy/Wd/RYP4b3knxjK+nlpzjnxxRPWvxefmK41kLtFpxmuCPFvYvuUtoLcA/Ty8fEU1zd5VRuKOuKYzT81RIeCo6NqIRlZHm4p8RjnxijkXGh8wSYeivj4/g+nRZJCDa/LRQC4xtNhLmNE3wNM8dHQJgHapCEWZ2HAlVopgm9TIRf5PXLwRJJZ74CXvEhS90uYc1QIRUtMbuItCqFRpXbjYeyuEJO1O8ItU+XCQqJla+LXHR2bUKLcD8jDvVCUnOsUNrP9DT3pNPOr4sspSKhm2iMYlUJPigkuX2VbLB2tlTFbfZCTcwC8y2WVSr8oQpwkM= 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:(4636009)(366004)(186003)(86362001)(2906002)(2616005)(6506007)(6916009)(1076003)(66946007)(26005)(36756003)(6666004)(66556008)(6512007)(52116002)(38100700002)(83380400001)(38350700002)(8936002)(8676002)(5660300002)(508600001)(4326008)(6486002)(316002)(956004)(66476007)(142923001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Msmb5Vaht9DYDc1D8wF/Ur0Qqx5SjOHMnu1dupCOQGUAyzge7F3E11jhAJDwmvEMcIa91eYaghENWsmNPnwZOQ0YYhC8b08JQ0uPEMvs/ZEcGGt4IV2EddIdNacky4xSinzOyxYauP6xdxOfR1OnF7ZcfbfytH7iPciYvnvy4LJ+EDtmCqYSibNTncjeuyOOLzb7chEPFffAImncakIvoB2zYpt4EwLbluaT6knfd6dPf18132uh1Yfl48qjbkPNtOnuZP2bDOqCxCfT5ym2fTNbV9LjJNKMxB6kOTQjJq7Y8JDT70T2GiaGef1N1IApbhIGDc7TrC+oIrDeNTufsmU/t7wb+ILRBovg/wk352v9PcAQNWAgRF3wHTpLJhg0GnhWysdIdfma3D1MCjih2SuTftDJ8Ijr6DcL168p8/tZKmw6mCZMEOxVL3CK9r0ycwi6AFh1ahSIDFiOMhvgmIz1bwl64jBzp+O8bZjRDNZE/kD6DwHJKD3ZmKzQXBJ+ePLoRmIFRu18O0iiIQtLp3JM57JZspgDTewEuO3IH0DMBgLHRreeIq9VnswORSWAy7tXBsNBCa35mDpLYJ75sXkD3mDef+cUCM3zGQyb9DCLvMxwPZ+8XYDjRkxts6tRdGdQh/BeVwYufEiVg7CiGLsJfOsTRwE7nMW2TWJS0MBHtn9XuVIk6W7VUaM8hNF3BFEwVPWjaXfUg6HNPkNwZNfWFxlxSNkh6VwywoW2V3H/DrDdjxP0u+I4pklvVLf/jUeA5bRRLecwr0lff4lXEMM4BlAVTP8xQkGiYwtCUGv00/M5Vq9e9J+L4AyZSsE5/WdwCcVsFfNfw9/WTQOy4xQWgpyQIL/GznuNXQw0QU5hfDu5ZivxtUbKKhc56bfpnYYLVeWeDENL8mgXG4jEWPabRIp7du2TYrlQ6GB93LliE+kh63UCUyPI0fKbtKM2DVx/aTqXUQ0bqFLm7VfVP6Qxyfb8kYkLMSo6gi1mvBl3/tpW9TvGCl8pMy/OrCHf9VqRxNj7KPmbj986l4oaFskSnsm0993VT+ZPViO9WmqHkk7KND4mKgYA8ypduYBblAQUyyapp8kxKT+yuYbAm4JS/8dK/E9cZAy7CfiPjolBmMjvUZ0Vs6jbCDB1JpeMxhFKtQDRTBgByOKN0SIYIiEWdsZvhPiepF6YYJ5k8nNGNIyTLZTDlVWOyPe6MzCwXi4q0BP6ugcn+1uGPV9xLGfXBcCBYSvF9zltunSD5jWBs4p82Ubd35+8EQYvIKaf/NHyAwn1DNIWVzEb6wTZqrkp3Lm2wx2468hmYNjeuFsln9+xXB65wh4wtelqY1T2BqvRMPJSv3ch464a7x7bVYSAKzvlWO2njI+/hr8XFvKTrn7pyg6vsHzFo6jGScVY+7VJJm7Xv+MlnzCReOZLLbtvlTbN/BSHw9UYSINsmXv0uyyQXsa4YSqCtQQJ65RFaWR+jTgiMomBNdoo/ozqQLUQ56CtuwyULW/tgnyhB620+h+n+ahQmuHfH8qO0mBH7kWGs5ck8hUwaNY3Thio9otEV10M/WIf4y98Z88wnjJa24r9UnCghCFRgtNAPyjBc6QI1IKKFHY4kbWHYM2nK+9oD7Hzj2yFLSs54q3eJSNIjsAlbHp2LMIKkFT50SOBofr1vcB4+EbdJgYW2kxkWYEhkJ1Jrpmjx5L5G3G8Two= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a94453e4-788a-4d52-16cb-08d9b69b2889 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:17.2356 (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: ax04YpyCKa8/J5c6bMC8pauNiJPBOwaqLRZBqMjUCvCkZiyg9hIpj+tikPxVbfjNs8VgNdndwoMFWkli6ZjeM26IoKifa8UFXOHr8sAbRTg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3841 Received-SPF: pass client-ip=40.107.15.139; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Unfortunately not all filters use .file child as filtered child. Two exclusions are mirror_top and commit_top. Happily they both are private filters. Bad thing is that this inconsistency is observable through qmp commands query-block / query-named-block-nodes. So, could we just change mirror_top and commit_top to use file child as all other filter driver is an open question. Probably, we could do that with some kind of deprecation period, but how to warn users during it? For now, let's just add a field so we can distinguish them in generic code, it will be used in further commits. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 14 ++++++++++++++ block/commit.c | 1 + block/mirror.c | 1 + 3 files changed, 16 insertions(+) diff --git a/include/block/block_int.h b/include/block/block_int.h index f4c75e8ba9..9c06f8816e 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -117,6 +117,20 @@ struct BlockDriver { * (And this filtered child must then be bs->file or bs->backing.) */ bool is_filter; + + /* + * Only make sense for filter drivers, for others must be false. + * If true, filtered child is bs->backing. Otherwise it's bs->file. + * Only two internal filters use bs->backing as filtered child and has this + * field set to true: mirror_top and commit_top. + * + * Never create any more such filters! + * + * TODO: imagine how to deprecate this behavior and make all filters work + * similarly using bs->file as filtered child. + */ + bool filtered_child_is_backing; + /* * Set to true if the BlockDriver is a format driver. Format nodes * generally do not expect their children to be other format nodes diff --git a/block/commit.c b/block/commit.c index 10cc5ff451..23d60aebf4 100644 --- a/block/commit.c +++ b/block/commit.c @@ -237,6 +237,7 @@ static BlockDriver bdrv_commit_top = { .bdrv_child_perm = bdrv_commit_top_child_perm, .is_filter = true, + .filtered_child_is_backing = true, }; void commit_start(const char *job_id, BlockDriverState *bs, diff --git a/block/mirror.c b/block/mirror.c index efec2c7674..22e2b7b110 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1587,6 +1587,7 @@ static BlockDriver bdrv_mirror_top = { .bdrv_child_perm = bdrv_mirror_top_child_perm, .is_filter = true, + .filtered_child_is_backing = true, }; static BlockJob *mirror_start_job( From patchwork Fri Dec 3 20:25:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA29EC433F5 for ; Fri, 3 Dec 2021 20:33:51 +0000 (UTC) Received: from localhost ([::1]:48390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFFd-0007nM-1C for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:33:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8o-0000pC-PO; Fri, 03 Dec 2021 15:26:46 -0500 Received: from mail-eopbgr150139.outbound.protection.outlook.com ([40.107.15.139]:14661 helo=EUR01-DB5-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 1mtF8j-0001cv-L6; Fri, 03 Dec 2021 15:26:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M+oqbECkkfhD5HGhzwvMn48SU8tM/anaUSEzCmymXOnhNSJ9Jf1yHKC5Y8LnN0JuMWtbgZjgX5m/gUcADfyrhlapIqwmD3J2mshf6m3n1F2mG125lzHHY8nkr9EwflrTrowT+cQl341OqAkOiAM5Gp3CWuLrxdnF/TvC7LaApIsRSMNb2fV51VWiIiCqOiTI0bqxYhas3lNWqrDAPOa/bzsvcJMBpQbNoDUFZLoM/P1SJN4xm5kDZ/iphw+TF4L6LcSI/zp5tXXhbH94rh4Bpa72euBl04eceAkozbdFCpMaC2lRqfhWGI0qSb0TjclZWqfxr7+/a8H2jRs4nleArw== 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=LZPWIGAerzxn5KHBLmT+bIVXzg7sxl6k7Hk+9IS1jo8=; b=WXQxWj7gypxA54ZBqtZxT8yIXQgpCQmgt81wXMtRPx1xuRGWqYWrlOVI2CGwPcZ6U8z01ig+R0UuTN2uDsEHUzmW3kxSbsOlj11mmdEHs1TZiGTsXosxN9HZ8SF8VQtFVges5oZsR4P3sqgJBmsxSIFGClPPJ1PW6gE+rUfqemm/2OzOFvb2BFdY49DGFiharQLDEnSjKaMYnzlUyKkQiFuPdiWgSfgMktOxRv47wG24nNjYSmwbZe2lkqJKg0mCCqu1fAdi2jyVrnTCKLGfBeFAm4LYqm4jmd9AE2hKk582hLvlszY6W0wVZIetkdBm6XTrAS5Qzc13D2eAOmHlSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=LZPWIGAerzxn5KHBLmT+bIVXzg7sxl6k7Hk+9IS1jo8=; b=NfzhPlA4BVkcaHDELG+8AKGek1+XLeX6RO6nN+X/BRmSlBIIyg66etVUSTRBY4PxVbBAv0rPnTDBoXSy8k6wamPsfRPPuHpGKcw1AEK+ebNkNJBtoe9EvYHw09BUxuFokSzZC4r1TPNQ0lVEiva26RV3P2BNcwF0txRLNCRISdc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB3841.eurprd08.prod.outlook.com (2603:10a6:208:106::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Fri, 3 Dec 2021 20:26:18 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:18 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com, Ari Sundholm , Pavel Dovgalyuk , Paolo Bonzini , Stefan Hajnoczi , John Snow , "Denis V. Lunev" , Wen Congyang , Xie Changlong , Stefan Weil , Jeff Cody , Fam Zheng Subject: [PATCH 02/14] block: introduce bdrv_open_file_child() helper Date: Fri, 3 Dec 2021 21:25:41 +0100 Message-Id: <20211203202553.3231580-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d8722c69-829a-45a8-85d7-08d9b69b294d X-MS-TrafficTypeDiagnostic: AM0PR08MB3841: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:431; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kmdXILhK/TK+mMU7NOx//SNONXzdQzqSqLLgBp+m3VfbpHUOMU4o4ynQHH3Ja+q7rEKwLmp/aMPwnNoYW6wtrmaJvi3af0T6k/68m62G8TvaG8k05RKIUAm/e5sZmsuxTTTBDmimvHRElus/swcuiJQ6xwGFY4ah0HI5yhwOIfx9yiVTzAPLKjnb/C+fGrFECcEGSpRVXQ6UPDqknZzPbzZ3zJlCVz/dxH5itB1g7tvk5sZWK5xtsuPXkVEyjImeVarLICSCbxkN2oB9bDFu80+FYvimM63LmMgQctia+5VFtbAtcv5ZeAvjE2KCOCM5ejQjsCzHzh7ekRHT7VD8awDwG81+iU8pjM31I0bqomGRU5en6XEXbAdHNxSfxekUn0YEBlItFd+32tH8UbRGJ1ZPc02lpiyrByza65ZP5RN3GB1hTzhvohmrU04XIAL2nxw2bxe0gr+5yrWTSBbGglnx1qE0ON0KqBASD7iEEUZ/sz4NPNO8GsMHNZUxu/wI8jz4jYs5StJeTQG37aZLF3CpOZtCjTjZHn/7Arkk8FIcDm2N5h+FEdjttiuGVxtw8RPFl/Wt+Ra4VLMrxtIe6cP9sbZXXxf7uNU3JzXXgV6mQOLIBrT+odTjPX4sm28fE0uOJFI/FBS9cJTGUd1Tnp1oT2wmJNSh78ugao7kKB89R3R6J/4i1eJSbnXfapTOyVaNU7EgubwNNYxRDntxvA== 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:(4636009)(366004)(186003)(86362001)(2906002)(2616005)(7416002)(54906003)(6506007)(6916009)(1076003)(66946007)(26005)(30864003)(36756003)(6666004)(66556008)(6512007)(52116002)(38100700002)(83380400001)(38350700002)(8936002)(8676002)(5660300002)(508600001)(4326008)(6486002)(316002)(956004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tgurNpzvOgZ+O4hl5u9TfaPcfusaOidpvKpc8JbTzN+iN6Z+q94d9GR7nyOJEpmwV2hhN4ikE19N/zvDjk8LyNG825GiYnltEOxEYc3fDBCW1EZNYUGC7C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4iXw3zAMYAehcqBkFyLzqn+wpwe9uEVuuD87MU3TohubkumDJI2m/02QriosclmhGwMgaCuPAkR/FrTxtajoyHnB5v+Eh3DJD+f7S5jZ5IyVQNB0fahVocNv2GFeQqvr5XcI6xVAso48Gf72cc+ybMxEkD87QNPTsCFB89iWpgMpr4zA4niJDR2z4yfUkT8uOnB0YFFaJfOoEy8hjmejWF2g8vR4zPMghQHOqO7Bs1ZR5acpj8MgG3kGJedA6AGzvE8tFtRhkI3N4UynXNvT9eQU1rNBLIAub98R/UX3YOYcTc1Hlr460ct6ZSTP5hqFkCXE3GAdjjtgJbKk4zN2nW3D/ZE/3FVSZw+Yk9qUESy2WYVYje0bHA4MSd/WrjDlpvo/I6eyodQ36Fa7X7LLczSbvFxbFgGD+2vQIquIPCsm5+CkWseLMvri9mE7pGWTehlugaW8dsh9dEqP3ZNN1erIJNJ/aMYvC1bJbmCa6NEbiA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8722c69-829a-45a8-85d7-08d9b69b294d X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:18.0490 (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: jEqcsms+5C6GSikMPE+kCfCOnoVibulYwdgb8oj6H0IBFCdeRfT23jqYCtZnOYk3deOHFpr9Xxa/uEm3ep8ywGnGvsGLQYtLxhOIX9V5H1w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3841 Received-SPF: pass client-ip=40.107.15.139; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Almost all drivers call bdrv_open_child() similarly. Let's create a helper for this. The only not updated driver that call bdrv_open_child() to set bs->file is raw-format, as it sometimes want to have filtered child but don't set drv->is_filter to true. Possibly we should implement drv->is_filter_func() handler, to consider raw-format as filter when it works as filter.. But it's another story. Note also, that we decrease assignments to bs->file in code: it helps us restrict modifying this field in further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block.h | 3 +++ block.c | 21 +++++++++++++++++++++ block/blkdebug.c | 9 +++------ block/blklogwrites.c | 7 ++----- block/blkreplay.c | 7 ++----- block/blkverify.c | 9 +++------ block/bochs.c | 7 +++---- block/cloop.c | 7 +++---- block/copy-before-write.c | 9 ++++----- block/copy-on-read.c | 9 ++++----- block/crypto.c | 11 ++++++----- block/dmg.c | 7 +++---- block/filter-compress.c | 6 ++---- block/parallels.c | 7 +++---- block/preallocate.c | 9 ++++----- block/qcow.c | 6 ++---- block/qcow2.c | 8 ++++---- block/qed.c | 8 ++++---- block/replication.c | 8 +++----- block/throttle.c | 8 +++----- block/vdi.c | 7 +++---- block/vhdx.c | 7 +++---- block/vmdk.c | 7 +++---- block/vpc.c | 7 +++---- 24 files changed, 94 insertions(+), 100 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index e5dd22b034..f885f113ef 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -376,6 +376,9 @@ BdrvChild *bdrv_open_child(const char *filename, const BdrvChildClass *child_class, BdrvChildRole child_role, bool allow_none, Error **errp); +int bdrv_open_file_child(const char *filename, + QDict *options, const char *bdref_key, + BlockDriverState *parent, Error **errp); BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp); int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, Error **errp); diff --git a/block.c b/block.c index 0ac5b163d2..a97720c5eb 100644 --- a/block.c +++ b/block.c @@ -3546,6 +3546,27 @@ BdrvChild *bdrv_open_child(const char *filename, errp); } +/* + * Wrapper on bdrv_open_child() for most popular case: open primary child of bs. + */ +int bdrv_open_file_child(const char *filename, + QDict *options, const char *bdref_key, + BlockDriverState *parent, Error **errp) +{ + BdrvChildRole role; + + /* commit_top and mirror_top don't use this function */ + assert(!parent->drv->filtered_child_is_backing); + + role = parent->drv->is_filter ? + (BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY) : BDRV_CHILD_IMAGE; + + parent->file = bdrv_open_child(filename, options, bdref_key, parent, + &child_of_bds, role, false, errp); + + return parent->file ? 0 : -EINVAL; +} + /* * TODO Future callers may need to specify parent/child_class in order for * option inheritance to work. Existing callers use it for the root node. diff --git a/block/blkdebug.c b/block/blkdebug.c index bbf2948703..5fcfc8ac6f 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -503,12 +503,9 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, } /* Open the image file */ - bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image", - bs, &child_of_bds, - BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, errp); - if (!bs->file) { - ret = -EINVAL; + ret = bdrv_open_file_child(qemu_opt_get(opts, "x-image"), options, "image", + bs, errp); + if (ret < 0) { goto out; } diff --git a/block/blklogwrites.c b/block/blklogwrites.c index f7a251e91f..f66a617eb3 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -155,11 +155,8 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags, } /* Open the file */ - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, false, - errp); - if (!bs->file) { - ret = -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { goto fail; } diff --git a/block/blkreplay.c b/block/blkreplay.c index dcbe780ddb..76a0b8d12a 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -26,11 +26,8 @@ static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags, int ret; /* Open the image file */ - bs->file = bdrv_open_child(NULL, options, "image", bs, &child_of_bds, - BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, errp); - if (!bs->file) { - ret = -EINVAL; + ret = bdrv_open_file_child(NULL, options, "image", bs, errp); + if (ret < 0) { goto fail; } diff --git a/block/blkverify.c b/block/blkverify.c index d1facf5ba9..920e891684 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -121,12 +121,9 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, } /* Open the raw file */ - bs->file = bdrv_open_child(qemu_opt_get(opts, "x-raw"), options, "raw", - bs, &child_of_bds, - BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, errp); - if (!bs->file) { - ret = -EINVAL; + ret = bdrv_open_file_child(qemu_opt_get(opts, "x-raw"), options, "raw", + bs, errp); + if (ret < 0) { goto fail; } diff --git a/block/bochs.c b/block/bochs.c index 4d68658087..b2dc06bbfd 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -110,10 +110,9 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags, return ret; } - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_IMAGE, false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)); diff --git a/block/cloop.c b/block/cloop.c index b8c6d0eccd..bee87da173 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -71,10 +71,9 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags, return ret; } - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_IMAGE, false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } /* read header */ diff --git a/block/copy-before-write.c b/block/copy-before-write.c index c30a5ff8de..8aa2cb6a85 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -150,12 +150,11 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags, { BDRVCopyBeforeWriteState *s = bs->opaque; BdrvDirtyBitmap *copy_bitmap; + int ret; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } s->target = bdrv_open_child(NULL, options, "target", bs, &child_of_bds, diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 1fc7fb3333..815ac1d835 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -41,12 +41,11 @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags, BDRVStateCOR *state = bs->opaque; /* Find a bottom node name, if any */ const char *bottom_node = qdict_get_try_str(options, "bottom"); + int ret; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } bs->supported_read_flags = BDRV_REQ_PREFETCH; diff --git a/block/crypto.c b/block/crypto.c index c8ba4681e2..abfce39230 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -260,15 +260,14 @@ static int block_crypto_open_generic(QCryptoBlockFormat format, { BlockCrypto *crypto = bs->opaque; QemuOpts *opts = NULL; - int ret = -EINVAL; + int ret; QCryptoBlockOpenOptions *open_opts = NULL; unsigned int cflags = 0; QDict *cryptoopts = NULL; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_IMAGE, false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } bs->supported_write_flags = BDRV_REQ_FUA & @@ -276,6 +275,7 @@ static int block_crypto_open_generic(QCryptoBlockFormat format, opts = qemu_opts_create(opts_spec, NULL, 0, &error_abort); if (!qemu_opts_absorb_qdict(opts, options, errp)) { + ret = -EINVAL; goto cleanup; } @@ -284,6 +284,7 @@ static int block_crypto_open_generic(QCryptoBlockFormat format, open_opts = block_crypto_open_opts_init(cryptoopts, errp); if (!open_opts) { + ret = -EINVAL; goto cleanup; } diff --git a/block/dmg.c b/block/dmg.c index 447901fbb8..38c363dd39 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -439,10 +439,9 @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags, return ret; } - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_IMAGE, false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } block_module_load_one("dmg-bz2"); diff --git a/block/filter-compress.c b/block/filter-compress.c index d5be538619..b2cfa9a9a5 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -30,10 +30,8 @@ static int compress_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, errp); - if (!bs->file) { + int ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { return -EINVAL; } diff --git a/block/parallels.c b/block/parallels.c index 6ebad2a2bb..ed4debd899 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -735,10 +735,9 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, Error *local_err = NULL; char *buf; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_IMAGE, false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } ret = bdrv_pread(bs->file, 0, &ph, sizeof(ph)); diff --git a/block/preallocate.c b/block/preallocate.c index 1d4233f730..332408bdc9 100644 --- a/block/preallocate.c +++ b/block/preallocate.c @@ -134,6 +134,7 @@ static int preallocate_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVPreallocateState *s = bs->opaque; + int ret; /* * s->data_end and friends should be initialized on permission update. @@ -141,11 +142,9 @@ static int preallocate_open(BlockDriverState *bs, QDict *options, int flags, */ s->file_end = s->zero_start = s->data_end = -EINVAL; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } if (!preallocate_absorb_opts(&s->opts, options, bs->file->bs, errp)) { diff --git a/block/qcow.c b/block/qcow.c index c39940f33e..544a17261f 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -120,10 +120,8 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, qdict_extract_subqdict(options, &encryptopts, "encrypt."); encryptfmt = qdict_get_try_str(encryptopts, "format"); - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_IMAGE, false, errp); - if (!bs->file) { - ret = -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { goto fail; } diff --git a/block/qcow2.c b/block/qcow2.c index d509016756..99715c498a 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1890,11 +1890,11 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, .errp = errp, .ret = -EINPROGRESS }; + int ret; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_IMAGE, false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } /* Initialise locks */ diff --git a/block/qed.c b/block/qed.c index 558d3646c4..e3b06a3d00 100644 --- a/block/qed.c +++ b/block/qed.c @@ -558,11 +558,11 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, .errp = errp, .ret = -EINPROGRESS }; + int ret; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_IMAGE, false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } bdrv_qed_init_state(bs); diff --git a/block/replication.c b/block/replication.c index 55c8f894aa..2f17397764 100644 --- a/block/replication.c +++ b/block/replication.c @@ -88,11 +88,9 @@ static int replication_open(BlockDriverState *bs, QDict *options, const char *mode; const char *top_id; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } ret = -EINVAL; diff --git a/block/throttle.c b/block/throttle.c index 6e8d52fa24..4fb5798c27 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -78,11 +78,9 @@ static int throttle_open(BlockDriverState *bs, QDict *options, char *group; int ret; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, - false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } bs->supported_write_flags = bs->file->bs->supported_write_flags | BDRV_REQ_WRITE_UNCHANGED; diff --git a/block/vdi.c b/block/vdi.c index bdc58d726e..c50c0ed61f 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -376,10 +376,9 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags, int ret; QemuUUID uuid_link, uuid_parent; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_IMAGE, false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } logout("\n"); diff --git a/block/vhdx.c b/block/vhdx.c index 356ec4c455..e7d6d7509a 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -996,10 +996,9 @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags, uint64_t signature; Error *local_err = NULL; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_IMAGE, false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } s->bat = NULL; diff --git a/block/vmdk.c b/block/vmdk.c index 0dfab6e941..7d7e56b36c 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1262,10 +1262,9 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, BDRVVmdkState *s = bs->opaque; uint32_t magic; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_IMAGE, false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } buf = vmdk_read_desc(bs->file, 0, errp); diff --git a/block/vpc.c b/block/vpc.c index 297a26262a..430cab1cbb 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -232,10 +232,9 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, int ret; int64_t bs_size; - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - BDRV_CHILD_IMAGE, false, errp); - if (!bs->file) { - return -EINVAL; + ret = bdrv_open_file_child(NULL, options, "file", bs, errp); + if (ret < 0) { + return ret; } opts = qemu_opts_create(&vpc_runtime_opts, NULL, 0, &error_abort); From patchwork Fri Dec 3 20:25:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7B093C433EF for ; Fri, 3 Dec 2021 20:33:39 +0000 (UTC) Received: from localhost ([::1]:48252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFFS-0007hR-H2 for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:33:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8p-0000qb-Dt; Fri, 03 Dec 2021 15:26:48 -0500 Received: from mail-eopbgr150132.outbound.protection.outlook.com ([40.107.15.132]:11453 helo=EUR01-DB5-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 1mtF8k-0001bp-Rc; Fri, 03 Dec 2021 15:26:47 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GuI1lZbjICSiu0nJutufwAz61UlwbTGO9n7QhFSp6SeKuPCUWex5TS8wZUW++fcjJCWCEIuuHTLapVG0E8rewiYcOHRwDIb5M5qqsP67nKP6aunpLbpAbnWdYnF0hf9MNYnJoKZ/0VJqvIOhZfbmyraPNV1wL3sCnnTS4HDWDspaaU+KSMOH39nvNPdhbUJuxeAK4FVL3P0pyQx9cyx9+b8/Z/EjnrY51h0yowWIPITiNFGh9LZ6wMvuxi//bBjTybmtT7U2j0lnVcvb1yRJzL7KwJptDx+r1M3P3Uv3oaFBTaNGXvyvnJLVHJWXuyXeqy6/pzxUgBt+EZeAI0binw== 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=dOr0HWuR3O0+5qlixqfI+5w2UMg5tnLevoDOA0CQUOg=; b=mQnNnCakZSx7J/QagspPMdVVo8UVa3EPP9js8oJ/7S8DT59xe+qZjXx/TukPs2c9zPWkRF+XEMj12kJ0mDXhNJdSaljSDHXdv+NsIYJMRWQ4u7KXHVuyxDDfEQvsCf5aEWGPicB3ZMjXeJKEn3hAm8MwZf7N/NUqtwkfDWt/MIpM45IRv23UnjhKgKQnlZzJgcSeMpkbCRlnukhkViu/uGTI92cVUp+M0FKf9zhrtnjgAU4He9JzSRk0y2b0iXOpvkvu29Bi/cOtzneiM+hO8yXoov6p0yP1Vuwn8y0T6ubMM/nZ0ihM1ezojk0Oo6nxBHDP8SFeKclueoaCp0P3qw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=dOr0HWuR3O0+5qlixqfI+5w2UMg5tnLevoDOA0CQUOg=; b=YwBJJiSjnnrBQ86i/fJZ0MQCv21ZP54GSDo9HC+hjT9dommKZPbYrl1sNZbi1Hat+FbKEqPu2NxSSB7cazCz5u761+SHUvDPZLTOY1+PiiLIeUIaQF2FEEQOtLVdXot1o8V5b3cf7n4vBTA+Zu5yDQ/9MwRnJBmHR176h+KCgl0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB3841.eurprd08.prod.outlook.com (2603:10a6:208:106::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Fri, 3 Dec 2021 20:26:19 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:18 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com, Ari Sundholm Subject: [PATCH 03/14] block/blklogwrites: don't care to remove bs->file child on failure Date: Fri, 3 Dec 2021 21:25:42 +0100 Message-Id: <20211203202553.3231580-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bc1e384f-b78d-4d8f-78c3-08d9b69b29a0 X-MS-TrafficTypeDiagnostic: AM0PR08MB3841: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:288; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TAA19pqxRrR0ZNBliqhsj/3uOp6GSkLcS/geW7OLY92jvVgegPmZR3TFZmD5gXkbptODVfOZOhCaCB4i7e9RunSIz+rS+c/AlXhQcxlShO9mZNggXK2DGcD9zBD+BI0ZVrJF3CGDsc7GXPsSjypFAcSV65pJVjnDnouzIR1RmkHqv8zESzUCukVorGoZ82dV27fjygYQQL0QHZsh0HgCuUhmwEjsmG7vxdKDgZtsMg3wkwsUd6M+jcqC7+8xXUOdsqdx19u5sEesEae80/8Jby1LlGVm0b91tR59KQqrCC71jNDjmkAH7EpU5eNjN0vHinnQJERUA7bTtUQ3wfDglSxZlCGlwwgsF3zEma5hqu+yqzpTIoxPMFAZDKmcPTCOE7jxMxRy2/13D9LO6LuIK6QN5GXd9To90/FA7t1Y++R9GjxaOOhWm4/sw6ht1/pMrU6QbYUWnuF6OUO1IVd3LqLkfF3lf4gsvuyGEPTI+C9G8gjzHzPESSS9he0uUAll4bk7EVS4NGB/tW3vwRvGhYSZFMgzHqoINGP79WQ7NtbfJ2QN1qoJXT+hE47BM/HhcezjqU2OUDl47NiNpnqbBxMxvKWYAjYqegpWQcwEnfsQ6pdStvDjuHFS5wbsSXL50bOU2RtouPKA6rL35jQ2nxvnvIqa+8EonnvwaeOfI9CKlFzf9DheK4MT4QpJ0xm78qQCB4jNH/Zrc8xUIv0WZA== 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:(4636009)(366004)(186003)(86362001)(2906002)(2616005)(6506007)(6916009)(1076003)(66946007)(26005)(36756003)(6666004)(66556008)(6512007)(52116002)(38100700002)(4744005)(83380400001)(38350700002)(8936002)(8676002)(5660300002)(508600001)(4326008)(6486002)(316002)(956004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pIwfIA2Ysg/xBN4quk7juRwgmS1/k1m/5kotxFJlqJkPSZsRSZl8grVWrLECasg1reNwfupX1OQexv3YcFeWqWV/drQEdj8NAW+HutjlgSfgYGade7grUlqZNrk6LeGwD+BoWTRXMjOhdPcBzVYjNw+vagNGP4VwnTkh8jxWX7pwjrxuzJ+h/i0iRDn187wwTHxyfa+KVR5Tr2qvTtBD/S1WtqVBy/r2ZxKn6sFCTAwEUcG/CsbrApcfJ+YtYpF3Jn0n6m7yYaGiUmIn5J9ojAfMm33bx3C9D4cf3bRD4j+dVShRgeEqAizpcdP/T+Zy3x2bq7p8pvzuN2xc8uvvl/8S/TAy++sZDgx2f1gj0c8aFEy5UGo9fYeVdrlY5OFGKOWN0ViktThialceJiYnHoDA90TSEbxtEeut2yUlnnwsJdL3OYqMg011YdQ0EepTXh6faKwNp9ydfIK7NDutBm8Y36HhSVqPu6Bo1tsFXShgd+l4bDsDbBBvPoB+OI79nUB8jcnyJpS10zYI+B+sZ+kQ4rE2znf+nXfNaMUj5CDZ3m08rmReKrMduSYAXG3sAHj+pSlKtcxST1QnDYGxRKHSmelFp1Dp+L7hDJTZ79QYyZ4PV7yw6atlnA7UN6LbU0ko+YFbHAjNBNhG0NVfX1W4K8GX7S5sod7Ef2sDMf658BA0NNaikY2w+0tVyrw8e5KxN31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uthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:18.6076 (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: nL7+MOE6GNS/buib8GBN7obtC4c214IUcP3MUtChkO+77CKhvvRIFlG/zQLOS6b4opRbK2G4fvP8tF2Pf1+mycpzt2VuUj7ILd0BQEyUc34= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3841 Received-SPF: pass client-ip=40.107.15.132; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We don't need to remove bs->file, generic layer takes care of it. No other driver cares to remove bs->file on failure by hand. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/blklogwrites.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/block/blklogwrites.c b/block/blklogwrites.c index f66a617eb3..7d25df97cc 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -254,10 +254,6 @@ fail_log: s->log_file = NULL; } fail: - if (ret < 0) { - bdrv_unref_child(bs, bs->file); - bs->file = NULL; - } qemu_opts_del(opts); return ret; } From patchwork Fri Dec 3 20:25:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA08FC433EF for ; Fri, 3 Dec 2021 20:35:23 +0000 (UTC) Received: from localhost ([::1]:51362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFH8-0001LB-Re for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:35:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8s-0000uj-5C; Fri, 03 Dec 2021 15:26:50 -0500 Received: from mail-eopbgr150139.outbound.protection.outlook.com ([40.107.15.139]:14661 helo=EUR01-DB5-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 1mtF8p-0001cv-Bw; Fri, 03 Dec 2021 15:26:49 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A1tuwxQ0mTDEu5jvvoSA8wvLsSbKKqOsgGPqxl42vogGcc41X5+eDLRFqsWxDyjrsdKGQKkgrOTZQxUJfPkWhWWeyjiTafGUiMaRcS03UM/1PPxvl5Kpx4dgMJdCVcGMBydeEapHPSvY+8eVHdZfKLCB2tbSStra2V4TEaftoNGjyVno7ncHWAVADNO2nVnX9IrhRHbBGlop7iksJP2dvX+ECqwiOb3Svgs45LDDZSJEtC14dPk365D5L7bvQDbSK84Bk70V3yPsQ/FPXr/oiwpISiEql0fvZ3zx29266HDWRA3N8b4fnb89M9ja5YaI8LTldx6wD2KmFNR7YEf0jw== 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=ru2Qyekc23yNTSSZ7f+D4q9vcp3smdZW3BCxktVLiMU=; b=FFCeMP2cM1dIHkkmHXvVwtvHP3VnHVMhJ3oSv7KhtlLzEUB6QK0bngQJG8eV7tzOPtXjqUpfwQJQ+Bz6YSIRhvttrEV64jCvghIeAhMsVKPQSgzWSF7KZ6MDj9WrLYkA9AphDbvENEA5qROkcqiAEg7AtwDDILKVebuIxdqpJ/lnOPzREGAFMpB1Qx2UvVWVzyM4M5wjOZae0D/YaWuQVEDqyd8USq9+aJQMrC0F2rfkd000V7UMZNTv10BYo9mwZAi5D6Tnto1bMkewWcXDE0NjzewRbZ48geb1Ik6zwuT+YiZo3nmMy/HNHiy/a2e6+ecdjYgVmBbMwNZeSq5ZsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=ru2Qyekc23yNTSSZ7f+D4q9vcp3smdZW3BCxktVLiMU=; b=C6SsBQD/oZr1loYorjEMDpBvv6926RIxz1fz1/Js4CztGtBSMeSAYcbpN8HdC2afIE9q2dorRZSy2mC7DsVO5jwxwWLOfaZhjT37quZUFM6d1EiLrab39/jfqSL5BEvdX/DLWm6EKgpGvr1OzUJJMONs5Vr2zUV2Jt4jXygTDK8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB3841.eurprd08.prod.outlook.com (2603:10a6:208:106::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Fri, 3 Dec 2021 20:26:20 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:19 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com, Alberto Garcia , Eric Blake , Paolo Bonzini Subject: [PATCH 04/14] test-bdrv-graph-mod: update test_parallel_perm_update test case Date: Fri, 3 Dec 2021 21:25:43 +0100 Message-Id: <20211203202553.3231580-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 05cef809-91fa-452c-6a87-08d9b69b2a2a X-MS-TrafficTypeDiagnostic: AM0PR08MB3841: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U6NvLSbLUE2HEv11V8w3lAUTg70aLbCX8rTXNnmsMCI1RMdesTr+F5H/tv8yTq0UY5RN2cXA3zwwBMIz/jWIHZffcY2yqjr+RyFTKd8OtTxq/8pdVOabNbMq6GGZbMgMzOipj8pyLE0IEIzdHKHwLaTnzV8OAjyWpRmwJvpkeHLpXPs2WxTOvork89NhWFczlyF3TgVHpSCzGkDFlTB3LUiWstgZGEdECR2yR1vcWhclSvbBNtOji8TwCix6GXJPyJuAoh/ks/r/+BWIvHx3bzGwJlGYKK8xSJ8yznpaXzeDGTaocEEqdCgrO63nawPISklln/xvPoFiLLOtg4K84+0k9LGP6EdRuVAwpFlUXaSE5linaKlIJFymGqScmivhmG0ZxIQMJDlBYI+beYK1U9AXG09j372+bM4SqGIsUFIOeRKXFslMbDhOerSakBgUYWR6dn6y/CFMaUhPZkgXRos+b4t7qZNVlkzdcS2fsXZSR++iQAoaA/RFID35f7vKYzJTFayixUBde25NEjhkxNRORYlBOeT61E4JUwVCEFSmexdm3aNmkN91x+pD+faeJRpLJRp7i/SwtAVtatzRSXyK/GJmNKukZnbukgA2ooDfXAY8NqXRzm6ot1NguuQ14no7Ut5dsODmgKnI3QDikz206rG2F9+JqxNGnbAhoj2CK0nEPr9s8bIaja4UQRwKZFolCRgvC/TY2onxFRXxnQ== 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:(4636009)(366004)(186003)(86362001)(2906002)(15650500001)(2616005)(54906003)(6506007)(6916009)(1076003)(66946007)(26005)(36756003)(6666004)(66556008)(6512007)(52116002)(38100700002)(83380400001)(38350700002)(8936002)(8676002)(5660300002)(508600001)(4326008)(6486002)(316002)(956004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?GS3uV/LMtJ14rw4F4SUDQeSBtlMT?= =?utf-8?q?hMVkd2U3yAA0CviFWcQ4qv4qQVcIhMoOuDUEQ/MZix752dns+a//pmdM06jC0B57u?= =?utf-8?q?z8HR+dhdNCasLb3ROZVS5rS4uOFN8uiIrk2r4NjBKyVpPMveoupH6ZCX3QR3Hxc9x?= =?utf-8?q?p4k5ZNfx7oAy11xMYlUKvwmLbw+2/aRRBNA0Mnk5/4bKSIzr76qWgD60duzelYugz?= =?utf-8?q?Am/xgBVDs5hjGkBJRHhRWFATrZ/iQ0twjPjcHEv/qtn1CQVzEoEu5mClwVyKhcHx+?= =?utf-8?q?u4n/GBjKT2O6uJS/3sUvYkWo0tt8tpNFqZ7eS1RJPYy2l1EfuZxVHtdoRtKS+DaHJ?= =?utf-8?q?PLc883isAh5gDk2RrZgluoP2+c309srPgF4uNAojv7etk+fRpyg0/EY8ogzLUu7LT?= =?utf-8?q?D6PzwyDIsFsTx6+LJdoa0mP9awbpE11AKdEZLvfTTxIE0wPPKr4bmJlk9SOqb+pNv?= =?utf-8?q?3zTdYppfkXV0vk/4xSvD1Oat2bLCfJAneHrte1/cB2tgAdN/sXNKFlGKilflL3621?= =?utf-8?q?3NycObQd47UfBmEDB/e0NksjeiGWmZ/Cc6i3YKnk01Tcaw4lmUULgKZWx2gQR8l0/?= =?utf-8?q?tYaWYSZN0vLSwsXLrCs00gLHfzyG56obS+R8AnQ9PdmFhOWdWCo1ri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EJqdxN?= =?utf-8?q?2oxECLqNH5K6LUmNN7UgQ+a7pZJbeST5NSDkomuPoFMHWCGy9plhZXOn8clzVnQj0?= =?utf-8?q?rjjnM7mmzT86ZgoyZPWCoWFHC8h4QqXRQ=3D=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05cef809-91fa-452c-6a87-08d9b69b2a2a X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:19.4887 (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: 39tT7ypFl1RiobYKKd4vI9ZnmG1tYDDaIRI75ZyWGUP7+FmE+HCRziug54CMrd/8ixSZVACC8BDWj64JinpuTYbjomF7qnIkrzotyvkjSg0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3841 Received-SPF: pass client-ip=40.107.15.139; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" test_parallel_perm_update() does two things that we are going to restrict in the near future: 1. It updates bs->file field by hand. bs->file will be managed automatically by generic code (together with bs->children list). Let's better refactor our "tricky" bds to have own state where one of children is linked as "selected". This also looks less "tricky", so avoid using this word. 2. It create FILTERED children that are not PRIMARY. Except for tests all FILTERED children in the Qemu block layer are always PRIMARY as well. We are going to formalize this rule, so let's better use DATA children here. While being here, update the picture to better correspond to the test code. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/unit/test-bdrv-graph-mod.c | 70 ++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/tests/unit/test-bdrv-graph-mod.c b/tests/unit/test-bdrv-graph-mod.c index a6e3bb79be..40795d3c04 100644 --- a/tests/unit/test-bdrv-graph-mod.c +++ b/tests/unit/test-bdrv-graph-mod.c @@ -241,13 +241,26 @@ static void test_parallel_exclusive_write(void) bdrv_unref(top); } -static void write_to_file_perms(BlockDriverState *bs, BdrvChild *c, - BdrvChildRole role, - BlockReopenQueue *reopen_queue, - uint64_t perm, uint64_t shared, - uint64_t *nperm, uint64_t *nshared) +/* + * write-to-selected node may have several DATA children, one of them may be + * "selected". Exclusive write permission is taken on selected child. + * + * We don't realize write handler itself, as we need only to test how permission + * update works. + */ +typedef struct BDRVWriteToSelectedState { + BdrvChild *selected; +} BDRVWriteToSelectedState; + +static void write_to_selected_perms(BlockDriverState *bs, BdrvChild *c, + BdrvChildRole role, + BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared) { - if (bs->file && c == bs->file) { + BDRVWriteToSelectedState *s = bs->opaque; + + if (s->selected && c == s->selected) { *nperm = BLK_PERM_WRITE; *nshared = BLK_PERM_ALL & ~BLK_PERM_WRITE; } else { @@ -256,9 +269,10 @@ static void write_to_file_perms(BlockDriverState *bs, BdrvChild *c, } } -static BlockDriver bdrv_write_to_file = { - .format_name = "tricky-perm", - .bdrv_child_perm = write_to_file_perms, +static BlockDriver bdrv_write_to_selected = { + .format_name = "write-to-selected", + .instance_size = sizeof(BDRVWriteToSelectedState), + .bdrv_child_perm = write_to_selected_perms, }; @@ -266,15 +280,18 @@ static BlockDriver bdrv_write_to_file = { * The following test shows that topological-sort order is required for * permission update, simple DFS is not enough. * - * Consider the block driver which has two filter children: one active - * with exclusive write access and one inactive with no specific - * permissions. + * Consider the block driver (write-to-selected) which has two children: one is + * selected so we have exclusive write access to it and for the other one we + * don't need any specific permissions. * * And, these two children has a common base child, like this: + * (additional "top" on top is used in test just because the only public + * function to update permission should get a specific child to update. + * Making bdrv_refresh_perms() public just for this test doesn't worth it) * - * ┌─────┐ ┌──────┐ - * │ fl2 │ ◀── │ top │ - * └─────┘ └──────┘ + * ┌─────┐ ┌───────────────────┐ ┌─────┐ + * │ fl2 │ ◀── │ write-to-selected │ ◀── │ top │ + * └─────┘ └───────────────────┘ └─────┘ * │ │ * │ │ w * │ ▼ @@ -290,7 +307,7 @@ static BlockDriver bdrv_write_to_file = { * * So, exclusive write is propagated. * - * Assume, we want to make fl2 active instead of fl1. + * Assume, we want to select fl2 instead of fl1. * So, we set some option for top driver and do permission update. * * With simple DFS, if permission update goes first through @@ -306,9 +323,10 @@ static BlockDriver bdrv_write_to_file = { static void test_parallel_perm_update(void) { BlockDriverState *top = no_perm_node("top"); - BlockDriverState *tricky = - bdrv_new_open_driver(&bdrv_write_to_file, "tricky", BDRV_O_RDWR, + BlockDriverState *ws = + bdrv_new_open_driver(&bdrv_write_to_selected, "ws", BDRV_O_RDWR, &error_abort); + BDRVWriteToSelectedState *s = ws->opaque; BlockDriverState *base = no_perm_node("base"); BlockDriverState *fl1 = pass_through_node("fl1"); BlockDriverState *fl2 = pass_through_node("fl2"); @@ -320,33 +338,33 @@ static void test_parallel_perm_update(void) */ bdrv_ref(base); - bdrv_attach_child(top, tricky, "file", &child_of_bds, BDRV_CHILD_DATA, + bdrv_attach_child(top, ws, "file", &child_of_bds, BDRV_CHILD_DATA, &error_abort); - c_fl1 = bdrv_attach_child(tricky, fl1, "first", &child_of_bds, - BDRV_CHILD_FILTERED, &error_abort); - c_fl2 = bdrv_attach_child(tricky, fl2, "second", &child_of_bds, - BDRV_CHILD_FILTERED, &error_abort); + c_fl1 = bdrv_attach_child(ws, fl1, "first", &child_of_bds, + BDRV_CHILD_DATA, &error_abort); + c_fl2 = bdrv_attach_child(ws, fl2, "second", &child_of_bds, + BDRV_CHILD_DATA, &error_abort); bdrv_attach_child(fl1, base, "backing", &child_of_bds, BDRV_CHILD_FILTERED, &error_abort); bdrv_attach_child(fl2, base, "backing", &child_of_bds, BDRV_CHILD_FILTERED, &error_abort); /* Select fl1 as first child to be active */ - tricky->file = c_fl1; + s->selected = c_fl1; bdrv_child_refresh_perms(top, top->children.lh_first, &error_abort); assert(c_fl1->perm & BLK_PERM_WRITE); assert(!(c_fl2->perm & BLK_PERM_WRITE)); /* Now, try to switch active child and update permissions */ - tricky->file = c_fl2; + s->selected = c_fl2; bdrv_child_refresh_perms(top, top->children.lh_first, &error_abort); assert(c_fl2->perm & BLK_PERM_WRITE); assert(!(c_fl1->perm & BLK_PERM_WRITE)); /* Switch once more, to not care about real child order in the list */ - tricky->file = c_fl1; + s->selected = c_fl1; bdrv_child_refresh_perms(top, top->children.lh_first, &error_abort); assert(c_fl1->perm & BLK_PERM_WRITE); From patchwork Fri Dec 3 20:25:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 77A5DC433EF for ; Fri, 3 Dec 2021 20:29:23 +0000 (UTC) Received: from localhost ([::1]:60620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFBK-0005Ra-H8 for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:29:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8s-0000w8-GQ; Fri, 03 Dec 2021 15:26:50 -0500 Received: from mail-eopbgr150132.outbound.protection.outlook.com ([40.107.15.132]:11453 helo=EUR01-DB5-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 1mtF8q-0001bp-0R; Fri, 03 Dec 2021 15:26:50 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pi8UyQpbnsPOG1hEVcT82H8CsrQ9wrBCL3UtlLut470t0P8KZ7OCms2VUvzrfMQ2HmNEIlrWhV2poHljJ3R7zL3eM0kCJqneHPd3129iRmWKuwWO+PtFhE3qiS5xoE5YTZRdk46AHDKZGoq2UuWjrVo/wen4/hDr9D7KhGObsfNrN5dtvAb89lM9/95DOQGjqT6tiKJDToL92pbMTA27aU/0xm2fGFLjusqZtdkY4XRHX+wbBacS643eUbBGsegFie4emxwv5uP2856NuysI9ZqwddIWkp8xluaKAz7n9h7M16dz+gUfUsxeUyyX7Ei1ymmAN1G7kNsfLFRfRTQKxg== 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=hVEciihopY4LWBv8udTvqAdszKG8R0KJlDSLT6UCO3U=; b=MpYkwFy7vrjTyIETg7fPUG2eaZOvxokTuo7aPbnVpcSX7FeB9RnTmoXcDpdTvRtYXjDu86ogtaqhhQlwXEWNiwMJfy7ToYUW6HUPogTH4OareCbzHoPAdq+oe9VCC78KxLcgZamKGH20SmSLhkFYeUh+OQ42s80SRP5EIlwufzsvg7veKdHd1TOPrsEgYhDSP9VX+PNFTJIQGWv2bEETzl9ChYYTI1Q5mjeFCXIlDnQSUGhucLTDNsdYOX6dgOW7YBI3bdcxouYRH1Za6y+AV1LkOSKcXJxiemkaVLXYPsOYVT72KkISS1Nu23pDJlFFHteLY7VaLnCh3RDxR7EG8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=hVEciihopY4LWBv8udTvqAdszKG8R0KJlDSLT6UCO3U=; b=HHFa2AaVQg5xsevieBOEPR/RblemTbhZ2ItT4z25ooa/1xdMQNMNg1jZYwgHfa+/IEoJcDElVWpB2o1W0iCMAAaDn8R6BfTmPIl6UUDsKl6vQC/9M3w6HQ9TPGt3Lyi0e7lvBWLDvzPWTQVAmh8et93JswNdx1VBXZXlrcHxDpg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB3841.eurprd08.prod.outlook.com (2603:10a6:208:106::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Fri, 3 Dec 2021 20:26:21 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:20 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com, Eric Blake , Thomas Huth , Paolo Bonzini Subject: [PATCH 05/14] tests-bdrv-drain: bdrv_replace_test driver: declare supports_backing Date: Fri, 3 Dec 2021 21:25:44 +0100 Message-Id: <20211203202553.3231580-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b32a485b-b890-4691-f298-08d9b69b2a7f X-MS-TrafficTypeDiagnostic: AM0PR08MB3841: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:133; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E8ipvKoaHfMYQsVU3QXimu9tMCqHUKPZMXgF3rSfOwuOMzEByvZNISbfGnLeicOt0neVlcqoVVBimLRvZNW2ClallTW59FimE5xUP1aPi6U1sJqExINS37oJAXb0ngK0ay/UToP/daouq8gtc3quZ5Soi7CWTcKU78kQVsiXhP7lLHO3dujLM1ADSx4qywV5mSzT9R58YxPHk27UsJqzZ2p8sw16MP70/sWnauKz5eYhgjr1kan69MtAf1YHlxRfaq7i3HljdqtsP6U7lGRoeI4lzhBnZ6BUcse8TTjroIOpX33/uBTugt/Dw2tlKbrrlh1eJOObWRh4/vnuh2xT5fJGB/DCWI6K+1E1i8psr6btJ0klEIra2skvkVVlyBksbcsJ3tVBu5Etvp4cirvBu9NnLWgwzkeQkfmUaYgWWlnJj9wHfPQBBrLsATGBDvW9eWhVTya7MWt1XePrjklxaV21dDAXuNW5Ih0WYha9NdOgWwDdYwBVAGKKg2WBoqsTa3Gl0nzlNpKLgjKPaeHTmkSAPRPNqqlYJ3r/27Wm15Adct5W8KYndOabEeav96Ihwsf8wXEd7c/fIglsG2a2YJdZAuaM1FXo7idBzwq7mPYpCtxjgtjnF1zPicmJ/zn5krQuEJln9RTRNlltxmJwz/m1KdyRJWdZSeWNOXeor3ZzpYomDGduzqv38XCZA2r4deZJEhXLftk+CxPWqTpS+w== 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:(4636009)(366004)(186003)(86362001)(2906002)(2616005)(54906003)(6506007)(6916009)(1076003)(66946007)(26005)(36756003)(6666004)(66556008)(6512007)(52116002)(38100700002)(4744005)(83380400001)(38350700002)(8936002)(8676002)(5660300002)(508600001)(4326008)(6486002)(316002)(956004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: T+ilbDWhnttXG0gHjR85Lkiu9/BjDDYeF6SBfP0hq0G3fBAfxujn+hc2tgKWi7TZyo/tWV9ksw7sljKChuKy8rMoW3dBkrXT3c0ti6iFGKv2qrqBTRftMqy3I4c/s9u/xLbhLUhrDGwIW7ROfYkmg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F2HhzC/H8MhPDybwYmw4l0WkrlEtAbiIA3rnB4FoBOcLujUEZLvyEYPY1MYjHMSjtyFlQwpxZl2/iurGjzUo0hXLUjQz/KGxHcntXSfWQcL+Fdndrz3QllxspaGFISq4QgQC7SWVYYp51TLo+vxNIqPWK/r7uMIaanvJVvMH+8PSPuOR5r5V0XhFPM4s7wAVnF0NoAi0LCIcJUOXsLX//DqprjH8iYJusN7I5d6jYa5varPJvDQiQbWXp30DvxgOTcqObvygpXhOONA2eGEy3aEz2xHCFllaetsxWroIJMwLNYx3tQSx6v1DPXNXWh0lmThqiekePg/dB53MvALwkHbfPbnzD9BM+TxyN0q/rVMX9uM/IjzkyD94OOXEBu5O6MNyeCaOpSiQWlujk/uxNoHVEiHFp/5RoiZmYhphhPR0LUNaKvb3UhjSPfaPD+zsbs/f9u7vA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b32a485b-b890-4691-f298-08d9b69b2a7f X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:20.3599 (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: RimJuYDp4JIy+dW+loG6EW/q+1ibDgRT58a/LEQFhPyo4yEk9e5eGE3OR1mb9a34J2JA7MErYUW6mTCYBC5ByWkKdJD9cxbG/ChxX5NPxW8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3841 Received-SPF: pass client-ip=40.107.15.132; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We do add COW child to the node. In future we are going to forbid adding COW child to the node that doesn't support backing. So, fix it here now. Don't worry about setting bs->backing itself: it further commit we'll update the block-layer to automatically set/unset this field in generic code. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/unit/test-bdrv-drain.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c index 2d3c17e566..45edbd867f 100644 --- a/tests/unit/test-bdrv-drain.c +++ b/tests/unit/test-bdrv-drain.c @@ -1944,6 +1944,7 @@ static void coroutine_fn bdrv_replace_test_co_drain_end(BlockDriverState *bs) static BlockDriver bdrv_replace_test = { .format_name = "replace_test", .instance_size = sizeof(BDRVReplaceTestState), + .supports_backing = true, .bdrv_close = bdrv_replace_test_close, .bdrv_co_preadv = bdrv_replace_test_co_preadv, From patchwork Fri Dec 3 20:25:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655781 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CBE10C433EF for ; Fri, 3 Dec 2021 20:38:55 +0000 (UTC) Received: from localhost ([::1]:35732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFKY-0001FP-Kz for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:38:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8u-00015W-Rf; Fri, 03 Dec 2021 15:26:53 -0500 Received: from mail-eopbgr150139.outbound.protection.outlook.com ([40.107.15.139]:14661 helo=EUR01-DB5-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 1mtF8s-0001cv-Qa; Fri, 03 Dec 2021 15:26:52 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BuzUXjTFZCy3Qt9OesAYQojxCLbZXv+FO4duUEkvMBCLT3IfHAZdrW6wanZyYLluPXRTJicTim0LBav2+k344WD6iI0sW9uEGT4rM6CzFrbSu5DRVG4hrYPtyDM5KLd5zmFURzmYreomPGW+YBquuBbFPeFbBHSRtEPNIxcCwfagnSksNV3zfX7kZeaxM0Cu0E+4DuunvL2spWozTxc5+QQs8tkcWLOpqWT8l+Tc9a+sMZwe7mH4uTWPXsZUPnzkb7cZVWw6X3VUbKaTsYOURdv9u0zkW8BzWjcE9f4RwV4ZWnHNen2A4ZIFDzuY7mT9zgSdhFJsxfxotaDuIXPtBw== 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=+9Nc4I/1HmU7AlQC1CAHYouh9KxjNx1KeO5ILNaq/nM=; b=fmppWEKs8rNVwEQm7cHIF0h+VMd5xnIiYYJxYJHiAMbSOj11kWLfreA7gQ42UO9hISMJ6zRGR78WcVogyhVhnPDlXVQPeJ2iZdfhIkJ+f0oQmCIucGfg9MSzKPpB4IC6S2rqE6YNZA4xfp86SCyLEwi5txVg+Ym5LgizRKTYua8yXVDewwmOC0tPwNICDFv60CDsV9F2bkwbmc/KRBzF0L9mjGkbzm+whM/b0XFwwDEmn31pqDeeDBgLg0hA9m7c/q2xKymBCEnOSLA5EEHgNHJ2ePz2ZQ0NYquNkfHOB4JuEL+NebwLIopPLLuaFYFIdVydxGklJ+3fl70Z9eb10g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=+9Nc4I/1HmU7AlQC1CAHYouh9KxjNx1KeO5ILNaq/nM=; b=Ap/HC7KvJsAKr+NeqoiaBQZ2BOidciHw9S+f+TssrW//62a/wFzPyGzaA+T7kKHpJvClbADWUrPf6dvnFvek4ZbbEPBzE0VctP4QSCI/+4l8yTdG+WRYPFc0VQ/xm8gmzQwmxQ8z9LKwonc7r1aVcSne51Lhj1cvdRlNWmcbN3Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB3841.eurprd08.prod.outlook.com (2603:10a6:208:106::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Fri, 3 Dec 2021 20:26:21 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:20 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com Subject: [PATCH 06/14] test-bdrv-graph-mod: fix filters to be filters Date: Fri, 3 Dec 2021 21:25:45 +0100 Message-Id: <20211203202553.3231580-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 29675257-08b5-4cbe-c6db-08d9b69b2b00 X-MS-TrafficTypeDiagnostic: AM0PR08MB3841: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:400; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dof1M5ep2mF7ANUSDn1ZRytmhcCYEyJdw4cGVFs7OzlqjQTRQU0jazxkLmkdR7heORTCcW36c1q136cIZ3o9GXPjSaE8JBF8JdjIxUc0GTv0eVvqsHaO/0pWuNdiRuAg5WlbzwsG+ULmPZJcZUy0eFdG9g5pQ6u/HNJARGkBPHxhntdBEBN6fYCAMXK2sJFJiARvJIvY8hkWftMeMqGxgZB1yiip8bLjmv/uNXiXMTFKcy1WeqJW+l+BftoEiBj0KGQH01bcygrkzwh4zFr3l+NtyJMQvV3hd2R6DXOfAoJQIv1qfAYWPgcEHGmprAOSL3w9KqLgshepMrZmldUYRdJWE9EQrNPfjRqkNbrL6rrEvmoWjoLi795B6PhamCxssbjTjl+RNNeu+vVJJ7lurMo7HZ8YnutnkkTg4VCl/42jLjE9z8ABuDun7ByctWIlgbu9HGrmzYFxjP2iuXyFK6H7B2z74axxQDzcDNdTkcJVu6fjRNyfqzNXt7VXyt1O5wRxFbHkj8BplDFOG1uFuTtZcMz7H2QZydaXw3AHcoZUVY19fV0eB4wemFRRVc4uM/L2oRpD/D7pwvwqy5aeCLzqiBZzdpQcODZs6ImcyAzb33w/ScnhMJS5HTmqbTIOQ663PsF8hT04eIKVOchEmgy8uEdSY00k/8eLIckpCoq5LDVfl+8uZDonZVIitVDWWI91MwZ/iOkVNahUaKOTJQ== 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:(4636009)(366004)(186003)(86362001)(2906002)(2616005)(6506007)(6916009)(1076003)(66946007)(26005)(36756003)(6666004)(66556008)(6512007)(52116002)(38100700002)(107886003)(83380400001)(38350700002)(8936002)(8676002)(5660300002)(508600001)(4326008)(6486002)(316002)(956004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X7kC+HdzBx9atKBrEJDdPpOD7vaAQ+9F4fPuZj2otW7axs2CQJ2BZCRllGA0NXLLGLGmngUGCwbFY+FJIT7mm32IkiwmOP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F2wPhgqcEQJv7iO9HrQacDpYCybPw/DAjOu/fjXz/Yp6O/geBXxuws/OFlgTXjqQkRLD+R1j0YSL7W1C2osIy2XhdyABHDewVn9HuY46cFO3CkHe7ncin8XSn4hUZLmSW9twvlFQKrAWFH48Zat2B/sFtigTbp8ktwF62LxOVYLvKFRrlC9RClI7JhnLdZ4WSbCgyJ67AtR9v3YTVw/T3ShowDPG5Zl0LmMI28OgzBA4JWupQZ7SfwDIYMv7EqWO2w8GHt2twuak6YJjZlCHEvRNGRKu5zoEJGmolp3hccIY0FxCAGibzzvJrY7IjEJjszEvsmfz2FSMPp7hYafJrNS2nS0eeqSONLY+y/zHmKutEMPG0gYWI2ffJza4Ppuyj+zkP+jaB9tP6OF2UvRfuaZg0YO42Eojya6TylPZLf8SyJvEcC7IDKdYOcUtRrKHFTOoMxiUnG12YZJmTcNaninuu2/Una5ltj/+3tVc4oICXw+fwL96s4ducmrfLlOmcoFXbuw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29675257-08b5-4cbe-c6db-08d9b69b2b00 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:20.8189 (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: RY9FoYKHCSJ3aIoX/iqdeDlllLVKvWF7g0g7RIG8bCvRRi9K1s1IPC5/IZ6/Spam7Cdrnd3SAOBywfEEgZRpUXuqtMwgWPxDiYQhZ6Zs4qc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3841 Received-SPF: pass client-ip=40.107.15.139; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" bdrv_pass_through is used as filter, even all node variables has corresponding names. We want to append it, so it should be backing-child-based filter like mirror_top. So, in test_update_perm_tree, first child should be DATA, as we don't want filters with two filtered children. bdrv_exclusive_writer is used as a filter once. So it should be filter anyway. We want to append it, so it should be backing-child-based fitler too. Make all FILTERED children to be PRIMARY as well. We are going to force this rule by assertion soon. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 5 +++-- tests/unit/test-bdrv-graph-mod.c | 24 +++++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 9c06f8816e..919e33de5f 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -121,8 +121,9 @@ struct BlockDriver { /* * Only make sense for filter drivers, for others must be false. * If true, filtered child is bs->backing. Otherwise it's bs->file. - * Only two internal filters use bs->backing as filtered child and has this - * field set to true: mirror_top and commit_top. + * Two internal filters use bs->backing as filtered child and has this + * field set to true: mirror_top and commit_top. There also two such test + * filters in tests/unit/test-bdrv-graph-mod.c. * * Never create any more such filters! * diff --git a/tests/unit/test-bdrv-graph-mod.c b/tests/unit/test-bdrv-graph-mod.c index 40795d3c04..7265971013 100644 --- a/tests/unit/test-bdrv-graph-mod.c +++ b/tests/unit/test-bdrv-graph-mod.c @@ -26,6 +26,8 @@ static BlockDriver bdrv_pass_through = { .format_name = "pass-through", + .is_filter = true, + .filtered_child_is_backing = true, .bdrv_child_perm = bdrv_default_perms, }; @@ -57,6 +59,8 @@ static void exclusive_write_perms(BlockDriverState *bs, BdrvChild *c, static BlockDriver bdrv_exclusive_writer = { .format_name = "exclusive-writer", + .is_filter = true, + .filtered_child_is_backing = true, .bdrv_child_perm = exclusive_write_perms, }; @@ -134,7 +138,7 @@ static void test_update_perm_tree(void) blk_insert_bs(root, bs, &error_abort); bdrv_attach_child(filter, bs, "child", &child_of_bds, - BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, &error_abort); + BDRV_CHILD_DATA, &error_abort); ret = bdrv_append(filter, bs, NULL); g_assert_cmpint(ret, <, 0); @@ -228,11 +232,14 @@ static void test_parallel_exclusive_write(void) */ bdrv_ref(base); - bdrv_attach_child(top, fl1, "backing", &child_of_bds, BDRV_CHILD_DATA, + bdrv_attach_child(top, fl1, "backing", &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, &error_abort); - bdrv_attach_child(fl1, base, "backing", &child_of_bds, BDRV_CHILD_FILTERED, + bdrv_attach_child(fl1, base, "backing", &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, &error_abort); - bdrv_attach_child(fl2, base, "backing", &child_of_bds, BDRV_CHILD_FILTERED, + bdrv_attach_child(fl2, base, "backing", &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, &error_abort); bdrv_replace_node(fl1, fl2, &error_abort); @@ -344,9 +351,11 @@ static void test_parallel_perm_update(void) BDRV_CHILD_DATA, &error_abort); c_fl2 = bdrv_attach_child(ws, fl2, "second", &child_of_bds, BDRV_CHILD_DATA, &error_abort); - bdrv_attach_child(fl1, base, "backing", &child_of_bds, BDRV_CHILD_FILTERED, + bdrv_attach_child(fl1, base, "backing", &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, &error_abort); - bdrv_attach_child(fl2, base, "backing", &child_of_bds, BDRV_CHILD_FILTERED, + bdrv_attach_child(fl2, base, "backing", &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, &error_abort); /* Select fl1 as first child to be active */ @@ -397,7 +406,8 @@ static void test_append_greedy_filter(void) BlockDriverState *base = no_perm_node("base"); BlockDriverState *fl = exclusive_writer_node("fl1"); - bdrv_attach_child(top, base, "backing", &child_of_bds, BDRV_CHILD_COW, + bdrv_attach_child(top, base, "backing", &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, &error_abort); bdrv_append(fl, base, &error_abort); From patchwork Fri Dec 3 20:25:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02130C433EF for ; Fri, 3 Dec 2021 20:35:05 +0000 (UTC) Received: from localhost ([::1]:50204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFGq-0000Ys-UC for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:35:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8v-00016h-Ct; Fri, 03 Dec 2021 15:26:53 -0500 Received: from mail-eopbgr150132.outbound.protection.outlook.com ([40.107.15.132]:11453 helo=EUR01-DB5-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 1mtF8t-0001bp-2G; Fri, 03 Dec 2021 15:26:53 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TIHYYHz3876aPcqjfmxh6rW8aj995FuEAlh2z4uOxDDykHtef8hExctHCzba8qfpp9YNT+N4lMqOjuWcoO7dq3dnZe04ScvRWg6dfWXMX0xuqOSfllTPzQhjNmsCOBm82qIlbBCq3HJrHFoVSNHGB/7PKNrPZdTSzSw4KCJK0q2smnBF+ga9C+JM2GHeIEslQTKVYXcACy3OJbrStDlQgtTjE6/uYkuHi+rQQQW/SwQDPmRj3/GwjU5WBbe4gBgEYfXtXVj7BO9XS8ITzue1Yk4U3FAG/nVrxj5rxW3dmA6rnsg1VNbK1J8oP12codTczZlnVoYpfRzUyGM+3lB0OQ== 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=YhoxgGe3Ea0Tt6RFHkgMQQ5XGu0P2U3WzRhaJRV7OeI=; b=gJZYRS6JuqbVQ+0HRRNnxJ3Fp6bGfywGDsj+h7zhn30y3N8gw6mEosgXZWrLPWinC9KMKQa5Mh6cninlnyMKCQhmTiZAuoCNsXz6RcwNzQx2AFFVoBfi3PDU+G7oePRoUKH0Q5dbF1Mq+gYggulaNSezJ41P1wi1vEfZ8Sdx1fLl4FB+DMYtQI5HnGW4GjdoE+QuN2c4Mqase+IfqsFDmP2h0Hkjvgt66C0JmRhg2IH+J4purIkcDQ+2Gd/QyC1TeSv2OHrAoA5JUsFVM7PO/6iQE71qWzbxg0RAeZMgn7FmAUG9KWXm7oaQ8W+DOCgVa9HbkSClyZuAdS1L5eYfdg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=YhoxgGe3Ea0Tt6RFHkgMQQ5XGu0P2U3WzRhaJRV7OeI=; b=X5EPESk3lVSQ9N7MHMm3cJPDquZWbYz9vdlAeEdHrp77td1KSDewvCB4Jxy2VeixjRlLQ5Zc5jiibOK5QLTGReagBwIkCCnArvCevc8apKPNs9OkgyjgBPhx70NHPDRy70m0fWBebh7Lez7pWJ8BRhWeFVnJXUoJ6oyIM5/w6WQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB3841.eurprd08.prod.outlook.com (2603:10a6:208:106::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Fri, 3 Dec 2021 20:26:21 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:21 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com Subject: [PATCH 07/14] block: document connection between child roles and bs->backing/bs->file Date: Fri, 3 Dec 2021 21:25:46 +0100 Message-Id: <20211203202553.3231580-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e5f6ab20-8082-4344-13e1-08d9b69b2b44 X-MS-TrafficTypeDiagnostic: AM0PR08MB3841: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1107; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2+d+Uwh6viZ/9yOQLrXtUjYJBGJ5oPUJjCq1eCV8K3tzZy07DObjNx9Ang1pN/J6rfb2HLORza/2dZ/ZskZoBb0noQfrOwvPAiL61FSVpdlHIIO2HCV20Vcc0eKNmcu8OQUmxaNIviymroUO+6FMzcmpeUQgmOluEb9HpiR23wHahCqpc/RFwyNIQGFyAYN5I4AVAePAkl7x5A+WyuREEcRoPB3nf+Jq8u4VsALXv1gbEfWAo9FFL3Zg6bPHAU4D1xvVeNbsi8U7dqsAXhj0IkF/+n7imDG/TiLYX+wQTMUZSNU7sn3cJUk07oF4Wyq9frCS8zjUzwZnkuNaKIPLcqibQDnx24fHZousaDzGiRDsxCHvePYTT1635dgiPhszBGCJR+OI1oDaai9xXebOQqXTCLea2B+6tM5JGFYBT7CAALbwPZnaqe5UDL1LctzjlUEmRnWwZtTNRcr4gVxzrwN5K4cdYrJ2o5eLS2kyEdeK2/xqSV1mZBiXONO0hjGcMT59BhCm8t+0fWM+gT62fLWw0Fn1C9DEE7nRqW/BIx+v9yJh3++9yyNeTfDhDRrI2PmgGY1fBrzaFeCTrC4uVn8P4uU0WCRkNYItmfT2XjsR4ju1x9HhETFEBL9UX466PIWbt/8HDLFRkHgSsLaYHGfwd8G+LSumbsiPDfbvENPhnqbfU8mmfcVYOx1yJYqnofEXXMbjX/F1CXUmGJ5Oow== 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:(4636009)(366004)(186003)(86362001)(2906002)(2616005)(6506007)(6916009)(1076003)(66946007)(26005)(36756003)(6666004)(66556008)(6512007)(52116002)(38100700002)(107886003)(83380400001)(38350700002)(8936002)(8676002)(5660300002)(508600001)(4326008)(6486002)(45080400002)(316002)(956004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SbN7VIVw6j7TcxkE01wZ2gYGs/U32M5+cMT5o5eHUhLJcQYsVrZjCGnulwtF3keDSbhibxUHcXdzZULupWVoOYTAJg00ra7JLkZsbDK4IMsgVCK+MkC363sJyBo6Lr78Hqh/EDV+4PjDVpO9a8sBG5IDUPgqONY5bk+wjE1B0yOMERl2HF+pQfxJUEI4HJCVGMMcQ8/F39l3BB2LYqy9Yhrq8KO5Y7IFzsMvItVB1aFx6tnc4o07kHcvzM+r4hLrXY/hT/E2pqyRWGBXqc2XXWtO73AuG9PthAfnvSa0CGZKTkwdPeeknf+gVufZvlQlFh7wK6lMI1f7y7I4vC+oJrZJvS74SduG2WYhaQ9IAElbHdvK0WJ/65TO74fVn4guqpTP9v87Mi+XQzIfIowpl//5DhDujAhliEetLlyPTmmd0oBuUmx3jnQm2/KZ8Qi5r12VJXbd+v8bpJOUxSTQVTg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9vx44Qki7NTRnWdV90it4DmZgUNWTB8knG305n+8lKBO8XyS49cRWixDccaE23Rd8WjeNpdXHGnjEYtM0smH341OASzHmFEK6T+2dpxrUa8UIQzrTxjB/qSxvl+It0Q== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5f6ab20-8082-4344-13e1-08d9b69b2b44 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:21.3167 (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: z8IUMcWSQ46CzzEKAWU9avPgINPWC0sMVVigqVvsetdSg3kYmjHv17Gk6XNVpvVVacHlI1CBY1iW7CuG5WEFmSLHiCQb1ImqX3zaNZ6VXks= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3841 Received-SPF: pass client-ip=40.107.15.132; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Make the informal rules formal. In further commit we'll add corresponding assertions. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/include/block/block.h b/include/block/block.h index f885f113ef..8a3278d4b6 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -290,6 +290,48 @@ enum { * * At least one of DATA, METADATA, FILTERED, or COW must be set for * every child. + * + * + * = Connection with bs->children, bs->file and bs->backing fields = + * + * 1. Filters + * + * Filter drivers has drv->is_filter = true. + * + * Filter driver has exactly one FILTERED|PRIMARY child, any may have other + * children which must not have these bits (the example is copy-before-write + * filter that also has target DATA child). + * + * Filter driver never has COW children. + * + * For all filters except for mirror_top and commit_top, the filtered child is + * linked in bs->file, bs->backing is NULL. + * + * For mirror_top and commit_top filtered child is linked in bs->backing and + * their bs->file is NULL. These two filters has drv->filtered_child_is_backing + * = true. + * + * 2. "raw" driver (block/raw-format.c) + * + * Formally it's not a filter (drv->is_filter = false) + * + * bs->backing is always NULL + * + * Only has one child, linked in bs->file. It's role is either FILTERED|PRIMARY + * (like filter) either DATA|PRIMARY depending on options. + * + * 3. Other drivers + * + * Doesn't have any FILTERED children. + * + * May have at most one COW child. In this case it's linked in bs->backing. + * Otherwise bs->backing is NULL. COW child is never PRIMARY. + * + * May have at most one PRIMARY child. In this case it's linked in bs->file. + * Otherwise bs->file is NULL. + * + * May also have some other children that don't have neither PRIMARY nor COW + * bits set. */ enum BdrvChildRoleBits { /* From patchwork Fri Dec 3 20:25:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9559CC433F5 for ; Fri, 3 Dec 2021 20:37:29 +0000 (UTC) Received: from localhost ([::1]:58048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFJA-0005v8-KL for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:37:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8x-0001Fa-C6; Fri, 03 Dec 2021 15:26:55 -0500 Received: from mail-eopbgr150139.outbound.protection.outlook.com ([40.107.15.139]:14661 helo=EUR01-DB5-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 1mtF8v-0001cv-Db; Fri, 03 Dec 2021 15:26:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WHIDL22ykN2Hn9f7DN+ELunGr9bArU21SXvvbiODPw1fftuNxoKP9ma64XNdH/S/je3icbAUnq1oh4Zdt5muDgtNYoxL7q7AMQSCyxbj8noYOwww8ziI9m9Lbl5IXn23Y4GroFBCjIyodOfyr2VyDhMGD8t8HS6WSRZtf24nk8uOgaYMz+sXCntwEdekkvfyldtnTD9XAIkevYFRW+lmPM6p0SWb76huaAgo44rBlgWXmrO75bm9GZN287tpcNbieZnMycWxQAdKj+If8gW0sH+ODG4LgYceoJYpaNvSV3Fn/4IJSzB06O4Ba5nRLmXFZWvpcWz0l5lO1UFqnlZfng== 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=VcS5iw+7biQUKidhckmjzMK5OKupplkEZZwW4G9n3oE=; b=dpPgye+MPwLcUaGRb46USErG5AP/tAdybqvmU9JagG/WUtBGa2GA7UDnfWQSMmzDUp0hLCB2FQp4UTSemLbpfPEh1JP3aVnCSL43dZjq8UwAnIJCHm9biFpna+8SdeCu3PHW+4wHzYSv68Py0BLLO3jih6/Jqpa4+IB62VFQdrFoxYW9OpmIAo/BwwHQd48UTf09nWZT56icuq5LV+krXKS7f9MIodY7+6YmY3vvMAqXkQRGkTEWf4ccWgNhn/3EqSFzEtjNrGDneaXE4+ev4KlXv4986IxrxF2xiE+3JhWTz3XSEHTGXEAvEOnCPLCSAyE05A2JeZLu97LqPN9kDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=VcS5iw+7biQUKidhckmjzMK5OKupplkEZZwW4G9n3oE=; b=HRZXrCZoGa37XfF4tg4/UZY7qRafdhVoqF18I/iqJCw8TB3VqyEu4OqJxQEq+1dj8nMYryQHGuGhAnS5+zkEZb0e7bsZerwKemCVe1puY+xlkbiEKjnmorDPhGYgtlasbCDdEdNW4E3QmkFQHo5ui6fY2+gkN/Ia+MY45bZrnuw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB3841.eurprd08.prod.outlook.com (2603:10a6:208:106::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Fri, 3 Dec 2021 20:26:22 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:22 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com Subject: [PATCH 08/14] block/snapshot: stress that we fallback to primary child Date: Fri, 3 Dec 2021 21:25:47 +0100 Message-Id: <20211203202553.3231580-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c89d31eb-cfee-4daf-80fd-08d9b69b2b7d X-MS-TrafficTypeDiagnostic: AM0PR08MB3841: 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: rKxMwgbIz+OwlJIDpFY18PXBuCg4xxiDNQEx0KcHNylBwzxUyF6m/9JihbaUxNMsCfb+/mPq7Llws09Nyl2wATvMCh13Krtf55eD9saYTvvlOH9NTiKaVlyacPciT9A88RGigqKog19k4zar5DEBMOwjI/3AFmLaDQ4aYEmudhQ/zW+WCYNvhZhGSDFammJSDhZpVz3yBy4isxTzJpbZ2cGCaKvH1EexNkyZxKeHqjXg1TieRVKJlK+nXVNgUhNmAtDPO9MrkOkXxxHoJAyzeHRB5n0Ns1M0cI+2vRT7B6z2z8CkagNHcQYrVzoiNgy11iYYyJCzMvyKiog1K0Ej/axBp94I1LrqhvcE6SLWoWgSFTA93vBsPv1NDxzHNdCPsvWWTQpXB+T0yi2vBa4jXIj6j7+rpF1lOqkUSEInivduZurcNA7TC1LvldKqSbD1wCeJP3w4Q27dQ5kHz2pEnRvm2c/O4vYwdY+7J5FBVp1+05uQpRLj0+kmr1oqSXpiFAr8cnoffMVfetLNoFUe1wdXaUIWdsxEKWcrzMYta2PQszEJUuepTKcAuFpDwNWWz24D1uzwPr/ZE9OkkOgAE7z6oMvimylhkqYTBcTBDw8ugEmtNr5cFxKFjSYPFggVccB09cMCRbLGXDATxDVhEnQEQ8AkHilLZ/Phx7pwieQZq8g9UTtt63550/Myy/AiNzggeLoJOgwZ+sCjkvOu5w== 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:(4636009)(366004)(186003)(86362001)(2906002)(2616005)(6506007)(6916009)(1076003)(66946007)(26005)(36756003)(6666004)(66556008)(6512007)(52116002)(38100700002)(107886003)(83380400001)(38350700002)(8936002)(8676002)(5660300002)(508600001)(4326008)(6486002)(316002)(956004)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hg/w8n2a2DtgbbO0g1IP9zpDI5unrm3AuUDpHvww4X39JrbPIyHbJikFkM7vPPwe8N52UrtUQ4i2/CNAiuCc2b639zK9e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/rI0n4GiLqkBexW7ENGiBgj9LVR2OI2W7TY/JCHSLoTe540cnJ09XRgdz2h1pAwdl/9OIXrb5Sw1wUyoIrX8nR9MW45E07fH5G2zQRmdSuKRZbbm5bdOudmRtpc3mufzk4cw1Iui4pklFtK2rD2XfcTRR6xn6kXmZoDJmLsnRnsu2+kS4/bepQ4FY6YEyoaU/tvAaN/3PbrwPggGnCdlEfFsKhIpaSflvSWK5gHY8hNdMrUdxv1mLpqrovAVjCc2swDJ7gaBQq/8g+gNYEbtEfI7JF+dXgQsgX94e5QzBpWxiJSUJCgyyVGixNV3obfu1+Pl5d/wLBHmEzotlyo/Jm6Mkusm4EBem1+ZfKGnX37HJhvYQuK8r4swkwByn5zPvFJeJnX+gtJ6vEEUHuT10NkvdJedcgO7Sag4uRiMMTqIGhG9DYjdiBa2i9CG2J/uES7Q5tWLM90OV1vQBInbeEhuQogFRYE/n7oDsBXVtsVniO4HO+SGbd8blquN3Cg77c2sg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c89d31eb-cfee-4daf-80fd-08d9b69b2b7d X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:22.0963 (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: d/N1vQ0hws/UKyFqp5esL/Lt+meijwItE0Idnc5zDrkVEk/CGJ5sIdJgIL8TVolb8x3qnpQd0D9UfdBGXP1eAeCQ+dY4NpgL+UO6hMPAEOA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3841 Received-SPF: pass client-ip=40.107.15.139; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-DB5-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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Actually what we chose is a primary child. Let's stress it in the code. We are going to drop indirect pointer logic here in future. Actually this commit simplifies the future work: we drop use of indirection in the assertion now. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/snapshot.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/block/snapshot.c b/block/snapshot.c index ccacda8bd5..12fa0e3904 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -158,21 +158,14 @@ bool bdrv_snapshot_find_by_id_and_name(BlockDriverState *bs, static BdrvChild **bdrv_snapshot_fallback_ptr(BlockDriverState *bs) { BdrvChild **fallback; - BdrvChild *child; + BdrvChild *child = bdrv_primary_child(bs); - /* - * The only BdrvChild pointers that are safe to modify (and which - * we can thus return a reference to) are bs->file and - * bs->backing. - */ - fallback = &bs->file; - if (!*fallback && bs->drv && bs->drv->is_filter) { - fallback = &bs->backing; - } - - if (!*fallback) { + /* We allow fallback only to primary child */ + if (!child) { return NULL; } + fallback = (child == bs->file ? &bs->file : &bs->backing); + assert(*fallback == child); /* * Check that there are no other children that would need to be @@ -300,15 +293,12 @@ int bdrv_snapshot_goto(BlockDriverState *bs, } /* - * fallback_ptr is &bs->file or &bs->backing. *fallback_ptr - * was closed above and set to NULL, but the .bdrv_open() call - * has opened it again, because we set the respective option - * (with the qdict_put_str() call above). - * Assert that .bdrv_open() has attached some child on - * *fallback_ptr, and that it has attached the one we wanted - * it to (i.e., fallback_bs). + * fallback was a primary child. It was closed above and set to NULL, + * but the .bdrv_open() call has opened it again, because we set the + * respective option (with the qdict_put_str() call above). + * Assert that .bdrv_open() has attached some BDS as primary child. */ - assert(*fallback_ptr && fallback_bs == (*fallback_ptr)->bs); + assert(bdrv_primary_bs(bs) == fallback_bs); bdrv_unref(fallback_bs); return ret; } From patchwork Fri Dec 3 20:25:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6EE01C433F5 for ; Fri, 3 Dec 2021 20:31:53 +0000 (UTC) Received: from localhost ([::1]:41988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFDk-0003Tx-Df for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:31:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8j-0000mR-Fp; Fri, 03 Dec 2021 15:26:42 -0500 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:27177 helo=EUR04-HE1-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 1mtF8X-0001ct-1e; Fri, 03 Dec 2021 15:26:35 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lGvjHj0JasZP3XhpvujiChPMjY++GlVWL6oxE/3NCfUu7+izvjXdvCV+jkEiI6i+A583LYuV3D0vqGFpFV+g+anpbVjbRVtxYoCDRcTbPWg4UllJfyZOfbU3XmVUgIPkZfs6AZIkjuGDfVQ88f4O0G8C2pUv4XCwCZ/xd/xBTWX/1RXPyBH3BRV9w9A/K/NlPmdbCgaqalwgkWCHT4VJex90FsjiOmpSJCqzPIKyjYUp4yMcaWY+agIwoPAz2iRlDxh9eVX2BhtkstQ0GqWqVRPxkJm08tPcnAn+5ckOj6NDMmNHTg4wELAQ6ckBe+WdMerD/6dHSz0moODslerM2A== 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=uZvGX4zovZ9qw9xr/gKSNZRrvZVtKBZCYKmmnfizP34=; b=SO14lw1fwnzbGT9PTr3+HMW18V+RtwsKJSlMOlFYAoKjPvkGy8OBDUMCnPnvqJN6h34DNnCsfyoKNv9xvJSlxfDkdIy/jNupYl1v4DKkGwcbLhakJ/wBgGMxyQn1T0o3rleZsjU1curYuL/CV/y9YjHHryUkw+RNB6oHBRhvc4HzQjwyhOsgL20qgaZwpQfr0f1Vc3JvCbuX4Pj7ynQGc2qEi/PvYlUrkYKOYRKKvY/MWSNx5T8+iHjD2cViHe2bKiTxPNhbAuVpbuZFuG2FIURSAMagC89m9mQBQJxCFEFk/xADICMNHfFZEixjkAes9FTKL9bY54VZePIU4SxMCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=uZvGX4zovZ9qw9xr/gKSNZRrvZVtKBZCYKmmnfizP34=; b=DJKryJ0BE1e7V3SBVsJcbNM+YR8fjCXI58k+W0Vy7x/+RYGYVK/1E0rMj03b8JpjakYYTBCfq4MALe3/gZwV3gHyo8l9IUqrG87BE7Ir1ts2RMRp0Gm/zDqdx+GwsI7n03SZLjqfBWVCzVpLUCAYlXlQkF5tdwSN/jv8O2N7IAo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB4068.eurprd08.prod.outlook.com (2603:10a6:208:12b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16; Fri, 3 Dec 2021 20:26:23 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:23 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com Subject: [PATCH 09/14] Revert "block: Let replace_child_noperm free children" Date: Fri, 3 Dec 2021 21:25:48 +0100 Message-Id: <20211203202553.3231580-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8b6ba73a-c7da-45ce-2e07-08d9b69b2c4d X-MS-TrafficTypeDiagnostic: AM0PR08MB4068: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:989; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BspJ1PfxvMlm+5S48VzN3O6EKUiZsj7L4954Wh3sKAY/nBQoZV5NwsQf6GxbJiV8oncKX4z+S5s/dn56U5W+nAWnjiQ5GR+BzupwsOZOrNa+5vOquS74jJ+ThaEDiLrSRk04gIlnHnpLMHYEz6/8y1NHPJGFGHP+RkUVPTT4+5aIJ9qYjjNXD+nJQbomZd8kQa6AC+pD5iWMClVdFCe4UetHmxfQdwdEuhJ9C4UUfgOTBGtyUzfMz50ulQAQBUiSlIiYjbbImmoQqAa3w2CAMvU8kLpw5xYUq789VoXC3hFOh3l0Ge49xZv93A+tW+dWsLB+ABhamg5jpRvTOT0WRFp2EjB7xaPQ5H7I8zztoHfLE5+pBdYruvoshG8FjdvmG3T7jQ4n1vAmVqczLKtsDQnTCEwEw+hdid5ubpmVpsTwZuPsIhsh1k+kr9yOdnCvZ2EMnle4TqWve7txZRW9thvPgfsupJZ/7tq2RqXx9Dy1S5YKDJ1Jykr90lLJwob6aqpDoSpQccIf8B9ODqqF2zF6vlbn221RX9c7vM9Hsfrvg3rvjPhPtP3Y74VQ7zVLmfKJWTH0ZEMf/+AY2miqUIMlSDRaSmwK6iN8IV8hlg1Oul8ZFwizf9ws72DAB3R3+KLNX08BLL6Q757KKrbN0kVekDJGeNgx3+LrvoDRr4DWR5nXKdZ8ng8QhyYe12qat12WztORwPe8KHqcwnOkjQ== 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:(4636009)(366004)(1076003)(107886003)(83380400001)(26005)(6916009)(8936002)(2616005)(66556008)(2906002)(508600001)(6506007)(6666004)(38350700002)(66946007)(66476007)(38100700002)(52116002)(186003)(316002)(4326008)(6512007)(36756003)(6486002)(956004)(8676002)(5660300002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fih13V7O4bbO1rAtHnSRoru82shgk/0+Pj/1e2aaA+HNRSWAVHyDrKDxjZDQatA2LqXPBxtBfW4hKvI9tmDI3GdQT8HEb86VOrtYEJmdaKqoiBKpTQNoGzOUYdiNYygjzyJt+/tDQ+iIH36+y3sv010OAZ30l3GhaXsjOFwGdhbQvHfGXzRxu0TMeL4ImcAtnThbGiwyInNXlOIR04O3aegUgh7rVDClOBH/CpUTNwXWIBCIauaTj+nAqEh7MCmto5ZgO0IRKu+LfGQQdgH9niFTSDXbjG0xVSU7r+O8lcfrpoQ2Fivlmj83lehOPlXQKFAhN6Ri/zA8/udNMXFHT1wet2mHJ2VsnFxvOi8wkdeZnilFQAQ1ECmekqFE2EIK1BmxOjYVAWa4Z04Hfo8CDim8brwTUXLXHf0MNqOUsqDlbOyVpFdsP6cE9xrIyhLvlSbTYaMHzJSOM2m6duIi/tt8nkYRqXk763+v5a0H7VnLTEYeh1r543fbZiH3U39hFO6nlVjJUv6TywcynyZUnzG5Sap/DPc/Q26qWHAxFCVnpq21pfIfpqtyBJ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U+e+J1pgI4Z79a2Uj0BxQCS5yqvUxID5DbE6vk/mjmA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b6ba73a-c7da-45ce-2e07-08d9b69b2c4d X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:22.9824 (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: OPhQGGwOo8H4KCVnbkBWC3tzn8Lm7AIh29hF8aSGtR6xsq5K6yFMza+TMvkwaHGiILHquh7DPoLbToq6BSHgbT6g1W6YLPEOB7TdaaKF/1s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4068 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are going to reimplement this behavior (clear bs->file / bs->backing pointers automatically when child->bs is cleared) in a nicer way. This reverts commit b0a9f6fed3d80de610dcd04a7e66f9f30a04174f. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 102 +++++++++++++------------------------------------------- 1 file changed, 23 insertions(+), 79 deletions(-) diff --git a/block.c b/block.c index a97720c5eb..69c20c729a 100644 --- a/block.c +++ b/block.c @@ -87,10 +87,8 @@ static BlockDriverState *bdrv_open_inherit(const char *filename, static bool bdrv_recurse_has_child(BlockDriverState *bs, BlockDriverState *child); -static void bdrv_child_free(BdrvChild *child); static void bdrv_replace_child_noperm(BdrvChild **child, - BlockDriverState *new_bs, - bool free_empty_child); + BlockDriverState *new_bs); static void bdrv_remove_file_or_backing_child(BlockDriverState *bs, BdrvChild *child, Transaction *tran); @@ -2258,16 +2256,12 @@ typedef struct BdrvReplaceChildState { BdrvChild *child; BdrvChild **childp; BlockDriverState *old_bs; - bool free_empty_child; } BdrvReplaceChildState; static void bdrv_replace_child_commit(void *opaque) { BdrvReplaceChildState *s = opaque; - if (s->free_empty_child && !s->child->bs) { - bdrv_child_free(s->child); - } bdrv_unref(s->old_bs); } @@ -2284,26 +2278,22 @@ static void bdrv_replace_child_abort(void *opaque) * modify the BdrvChild * pointer we indirectly pass to it, i.e. it * will not modify s->child. From that perspective, it does not matter * whether we pass s->childp or &s->child. + * (TODO: Right now, bdrv_replace_child_noperm() never modifies that + * pointer anyway (though it will in the future), so at this point it + * absolutely does not matter whether we pass s->childp or &s->child.) * (2) If new_bs is not NULL, s->childp will be NULL. We then cannot use * it here. * (3) If new_bs is NULL, *s->childp will have been NULLed by * bdrv_replace_child_tran()'s bdrv_replace_child_noperm() call, and we * must not pass a NULL *s->childp here. + * (TODO: In its current state, bdrv_replace_child_noperm() will not + * have NULLed *s->childp, so this does not apply yet. It will in the + * future.) * * So whether new_bs was NULL or not, we cannot pass s->childp here; and in * any case, there is no reason to pass it anyway. */ - bdrv_replace_child_noperm(&s->child, s->old_bs, true); - /* - * The child was pre-existing, so s->old_bs must be non-NULL, and - * s->child thus must not have been freed - */ - assert(s->child != NULL); - if (!new_bs) { - /* As described above, *s->childp was cleared, so restore it */ - assert(s->childp != NULL); - *s->childp = s->child; - } + bdrv_replace_child_noperm(&s->child, s->old_bs); bdrv_unref(new_bs); } @@ -2320,44 +2310,30 @@ static TransactionActionDrv bdrv_replace_child_drv = { * * The function doesn't update permissions, caller is responsible for this. * - * (*childp)->bs must not be NULL. - * * Note that if new_bs == NULL, @childp is stored in a state object attached * to @tran, so that the old child can be reinstated in the abort handler. * Therefore, if @new_bs can be NULL, @childp must stay valid until the * transaction is committed or aborted. * - * If @free_empty_child is true and @new_bs is NULL, the BdrvChild is - * freed (on commit). @free_empty_child should only be false if the - * caller will free the BDrvChild themselves (which may be important - * if this is in turn called in another transactional context). + * (TODO: The reinstating does not happen yet, but it will once + * bdrv_replace_child_noperm() NULLs *childp when new_bs is NULL.) */ static void bdrv_replace_child_tran(BdrvChild **childp, BlockDriverState *new_bs, - Transaction *tran, - bool free_empty_child) + Transaction *tran) { BdrvReplaceChildState *s = g_new(BdrvReplaceChildState, 1); *s = (BdrvReplaceChildState) { .child = *childp, .childp = new_bs == NULL ? childp : NULL, .old_bs = (*childp)->bs, - .free_empty_child = free_empty_child, }; tran_add(tran, &bdrv_replace_child_drv, s); - /* The abort handler relies on this */ - assert(s->old_bs != NULL); - if (new_bs) { bdrv_ref(new_bs); } - /* - * Pass free_empty_child=false, we will free the child (if - * necessary) in bdrv_replace_child_commit() (if our - * @free_empty_child parameter was true). - */ - bdrv_replace_child_noperm(childp, new_bs, false); + bdrv_replace_child_noperm(childp, new_bs); /* old_bs reference is transparently moved from *childp to @s */ } @@ -2729,22 +2705,8 @@ uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm) return permissions[qapi_perm]; } -/** - * Replace (*childp)->bs by @new_bs. - * - * If @new_bs is NULL, *childp will be set to NULL, too: BDS parents - * generally cannot handle a BdrvChild with .bs == NULL, so clearing - * BdrvChild.bs should generally immediately be followed by the - * BdrvChild pointer being cleared as well. - * - * If @free_empty_child is true and @new_bs is NULL, the BdrvChild is - * freed. @free_empty_child should only be false if the caller will - * free the BdrvChild themselves (this may be important in a - * transactional context, where it may only be freed on commit). - */ static void bdrv_replace_child_noperm(BdrvChild **childp, - BlockDriverState *new_bs, - bool free_empty_child) + BlockDriverState *new_bs) { BdrvChild *child = *childp; BlockDriverState *old_bs = child->bs; @@ -2781,9 +2743,6 @@ static void bdrv_replace_child_noperm(BdrvChild **childp, } child->bs = new_bs; - if (!new_bs) { - *childp = NULL; - } if (new_bs) { QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent); @@ -2813,10 +2772,6 @@ static void bdrv_replace_child_noperm(BdrvChild **childp, bdrv_parent_drained_end_single(child); drain_saldo++; } - - if (free_empty_child && !child->bs) { - bdrv_child_free(child); - } } /** @@ -2846,14 +2801,7 @@ static void bdrv_attach_child_common_abort(void *opaque) BdrvChild *child = *s->child; BlockDriverState *bs = child->bs; - /* - * Pass free_empty_child=false, because we still need the child - * for the AioContext operations on the parent below; those - * BdrvChildClass methods all work on a BdrvChild object, so we - * need to keep it as an empty shell (after this function, it will - * not be attached to any parent, and it will not have a .bs). - */ - bdrv_replace_child_noperm(s->child, NULL, false); + bdrv_replace_child_noperm(s->child, NULL); if (bdrv_get_aio_context(bs) != s->old_child_ctx) { bdrv_try_set_aio_context(bs, s->old_child_ctx, &error_abort); @@ -2875,6 +2823,7 @@ static void bdrv_attach_child_common_abort(void *opaque) bdrv_unref(bs); bdrv_child_free(child); + *s->child = NULL; } static TransactionActionDrv bdrv_attach_child_common_drv = { @@ -2952,9 +2901,7 @@ static int bdrv_attach_child_common(BlockDriverState *child_bs, } bdrv_ref(child_bs); - bdrv_replace_child_noperm(&new_child, child_bs, true); - /* child_bs was non-NULL, so new_child must not have been freed */ - assert(new_child != NULL); + bdrv_replace_child_noperm(&new_child, child_bs); *child = new_child; @@ -3013,7 +2960,8 @@ static void bdrv_detach_child(BdrvChild **childp) { BlockDriverState *old_bs = (*childp)->bs; - bdrv_replace_child_noperm(childp, NULL, true); + bdrv_replace_child_noperm(childp, NULL); + bdrv_child_free(*childp); if (old_bs) { /* @@ -5024,11 +4972,7 @@ static void bdrv_remove_file_or_backing_child(BlockDriverState *bs, } if (child->bs) { - /* - * Pass free_empty_child=false, we will free the child in - * bdrv_remove_filter_or_cow_child_commit() - */ - bdrv_replace_child_tran(childp, NULL, tran, false); + bdrv_replace_child_tran(childp, NULL, tran); } s = g_new(BdrvRemoveFilterOrCowChild, 1); @@ -5038,6 +4982,8 @@ static void bdrv_remove_file_or_backing_child(BlockDriverState *bs, .is_backing = (childp == &bs->backing), }; tran_add(tran, &bdrv_remove_filter_or_cow_child_drv, s); + + *childp = NULL; } /* @@ -5080,7 +5026,7 @@ static int bdrv_replace_node_noperm(BlockDriverState *from, * Passing a pointer to the local variable @c is fine here, because * @to is not NULL, and so &c will not be attached to the transaction. */ - bdrv_replace_child_tran(&c, to, tran, true); + bdrv_replace_child_tran(&c, to, tran); } return 0; @@ -5236,9 +5182,7 @@ int bdrv_replace_child_bs(BdrvChild *child, BlockDriverState *new_bs, bdrv_drained_begin(old_bs); bdrv_drained_begin(new_bs); - bdrv_replace_child_tran(&child, new_bs, tran, true); - /* @new_bs must have been non-NULL, so @child must not have been freed */ - assert(child != NULL); + bdrv_replace_child_tran(&child, new_bs, tran); found = g_hash_table_new(NULL, NULL); refresh_list = bdrv_topological_dfs(refresh_list, found, old_bs); From patchwork Fri Dec 3 20:25:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 970CEC433EF for ; Fri, 3 Dec 2021 20:31:15 +0000 (UTC) Received: from localhost ([::1]:38868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFD8-0001Jn-GI for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:31:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8m-0000nA-6I; Fri, 03 Dec 2021 15:26:44 -0500 Received: from mail-db8eur05on2098.outbound.protection.outlook.com ([40.107.20.98]:1792 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 1mtF8c-0001dZ-4n; Fri, 03 Dec 2021 15:26:43 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iCYJ9KZdy3AjbZmSZdTmqJMRQ9cETZL22ulHHfbCtdF2wWUtR35tFUqBEz43/9It0gH5o9Iw+5iOzEoAu1iEJLLckGsw6BTMwlROEzxdPHalqbjQj3efWKv8TU1E/ayzf/AsgVFrIcWClyqYvTGW1hOHF09Q8EK3VZxD7WBLaYTyRLA7P38KngXrP/xdv5wpMYVk5iLfDVww4iOLXQeBu7vVeAMYw/ro7voPeEyvKl3FqzCM2DVjL3Sc5nyTdlQnPvgHPgh7ZNegbQkIzmLfpdZoD8cNpPNUQvaocB0DgNuJ/epJgTkktdLzihK5T3YV8F/O2mZW9ZvZl15JOebpSw== 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=YoUKZY5FKOIdIUZUJQktFcRHljwq+//pgf/6H6t8gh0=; b=WDUNJMKU0gz246BKDceqRoep/wcEk6zBO0lSlL+u1T0BRKwwUVjHxD0+7fcZjJuRyoY4VaqCiWxQ6Bn4ffXJ3DwcT+SwvOTMH/eVS3+a3NxcazKERhsPdg7+VgSGtuV9GEgIhWCSuM1jtVCrC2XVsPwlBx589l0KRkP8i4aPgFGMZFPNpdoe0t7UOYUZwS3e7kE5IrGtwHr+DsPxXPl0U9wYkZz27Hg9bWWG+lBKgkfC909mTpOm9n5ZA/sJksMO7RDyJIVcQMJMgu2XlLJp30OfEcsqAaTNMpNfssAi5SwlE2bgZ6BH8SAp3OgxgCyFJEkVyeVzQMFVHhbCzxP2gA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=YoUKZY5FKOIdIUZUJQktFcRHljwq+//pgf/6H6t8gh0=; b=g/W55+TO1fdoKZJujuajnqBsQEVyBg/HYmPatYWl8JCupqgRuDDwVqmJs59Q0kpuNHMQdWccyC06Gd2AsIfzUKmZWwuIexaBcIypsEVtx1q6Rgi+bjxwRGOy2z8TB0WkWtTsiy6kECKh/CnCQlXMUacDN2IZbjBoAlT0nlvWpy0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB4068.eurprd08.prod.outlook.com (2603:10a6:208:12b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16; Fri, 3 Dec 2021 20:26:23 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:23 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com Subject: [PATCH 10/14] Revert "block: Let replace_child_tran keep indirect pointer" Date: Fri, 3 Dec 2021 21:25:49 +0100 Message-Id: <20211203202553.3231580-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 85dc4410-e055-4633-4105-08d9b69b2c96 X-MS-TrafficTypeDiagnostic: AM0PR08MB4068: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:901; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zPdUrSEHPfbOPb4O9Lg6G6ygvU3OZD1lKsEtZavtJGEpuy3r1WedHS49wraCHPnNXU3SI16w40zK5YU76yEJtmUj69tdvsUu1gocdpW+c4qju9eibHj4D1PfUzLf2kcaObOyhqaWB6mZSOZCG0igIv/Ymr0I8RFjwYW5wmn0HlIeAnGvIazqGWKixqsVtqvedkfbbGoKz984uhRc1lTgMoWo822bjlndJY2GjyLxkohcL8GErV0B0mQQSLGCk5CVwA5RViHd/BjCY1MBN3Kd0gCOovRJ935Vs+nyfcb2E42r4MPMR5c0FFCloAS1KQHVjJomkaBxb3ub+zfVU3jQSjfm8Vj7hMzT+37OmGW0vhsIryT2OObXCwFJBua3oh1sIkVLkFK1vI2EJ/Y7x9rcu0GlCJcMKN+YVbrhiFwoTQPcJMrqyh7wSJ+NiGBtHT0DANRKDtWzoNRKuIc0JcA5kVVmcUrUv6tgVliOKI31G5I2cgAbg7LaPyz1ZwIABeFtPLXzH4sOHhix2qV6C3KBrNWiGZJv/uXnnnpwE8JMzjUWY6krRsssEjKdtEnXhJAJWU9H+aM5BiLoQpLcNTm3aOVzcUdt7fCaSDLZPTBqVbOUEh/LZ1HmuhzwKipKMD9d2oqh/TmbXZ82IxCVB8s94yOFXuWa580CFIya9/I7qJ9mMSq61aMVsL+BglBBOgwa 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:(4636009)(366004)(1076003)(107886003)(83380400001)(26005)(6916009)(8936002)(2616005)(66556008)(2906002)(508600001)(6506007)(6666004)(38350700002)(66946007)(66476007)(38100700002)(52116002)(186003)(316002)(4326008)(6512007)(36756003)(6486002)(956004)(8676002)(5660300002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1GC2dVttmgnlqBbPnpMqMVv8n1jrlWHSqb5JRFkunbwrtieT+dQtivyGeQ/damkh2VsN/aAwB2GFIx0xJmN/DXevCWIjQwh+QWb4eYM+D3Wz+T500XYnlXv9mlErQj1p1Rr2eZ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NRs9i/kjXVkd2kyQF4ExCnFs/V3Ei8+4n2/coRZuS7yQH0M45SYy1P0eszbuFTRjGfA2QFsrXxCUz8NLNhbmj6gHZNPKaL1SR8JORiJ6bZ5AcZ5CfVDKm+5Dxm0uBOLzttC394agcxregTU9JyQidRi8bgfixfDBzrcEWTGgpIzpndI9LOAEgtJZzyovlUHyZ6/+x1zDgo3qss5nz3XhowGrYay7sOmmNPRsHY4f/GVbznRSDt+hqAd6urA8MKWHg9GUp3hLYPpiMYLJZhj4FrNJNX+RXL/tr5ovVEQJXj6clBpIb5cHbRo7PlIjysjWDzFrlh81d8Jr642NZFmQDJBTSRuHRpjIrLo8AMBFEcIUnve/3/bHw6p7cytxqxgU0i2bDe0UtcbyC5LpIL7Gyk3lBYSOqNTJrYcf4ZgwGKxeuxCk/p1QNNNzSZEJtRcwqh+/cv4roXOUJVCVI9ow== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85dc4410-e055-4633-4105-08d9b69b2c96 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:23.6226 (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: U2MutPTBoHE77D2fvqFiSroTglmtwAQpAW3dFN8Er8asdkENK8Eit2Iae+ToZooT8TNaiy+sMqaWOBkNML3gu8s+kD4v55fBdwKgGAHpLtc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4068 Received-SPF: pass client-ip=40.107.20.98; 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" That's a preparation to previously reverted "block: Let replace_child_noperm free children". Drop it too, we don't need it for a new approach. This reverts commit 82b54cf51656bf3cd5ed1ac549e8a1085a0e3290. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 83 +++++++-------------------------------------------------- 1 file changed, 10 insertions(+), 73 deletions(-) diff --git a/block.c b/block.c index 69c20c729a..3eec53796b 100644 --- a/block.c +++ b/block.c @@ -2254,7 +2254,6 @@ static int bdrv_drv_set_perm(BlockDriverState *bs, uint64_t perm, typedef struct BdrvReplaceChildState { BdrvChild *child; - BdrvChild **childp; BlockDriverState *old_bs; } BdrvReplaceChildState; @@ -2270,29 +2269,7 @@ static void bdrv_replace_child_abort(void *opaque) BdrvReplaceChildState *s = opaque; BlockDriverState *new_bs = s->child->bs; - /* - * old_bs reference is transparently moved from @s to s->child. - * - * Pass &s->child here instead of s->childp, because: - * (1) s->old_bs must be non-NULL, so bdrv_replace_child_noperm() will not - * modify the BdrvChild * pointer we indirectly pass to it, i.e. it - * will not modify s->child. From that perspective, it does not matter - * whether we pass s->childp or &s->child. - * (TODO: Right now, bdrv_replace_child_noperm() never modifies that - * pointer anyway (though it will in the future), so at this point it - * absolutely does not matter whether we pass s->childp or &s->child.) - * (2) If new_bs is not NULL, s->childp will be NULL. We then cannot use - * it here. - * (3) If new_bs is NULL, *s->childp will have been NULLed by - * bdrv_replace_child_tran()'s bdrv_replace_child_noperm() call, and we - * must not pass a NULL *s->childp here. - * (TODO: In its current state, bdrv_replace_child_noperm() will not - * have NULLed *s->childp, so this does not apply yet. It will in the - * future.) - * - * So whether new_bs was NULL or not, we cannot pass s->childp here; and in - * any case, there is no reason to pass it anyway. - */ + /* old_bs reference is transparently moved from @s to @s->child */ bdrv_replace_child_noperm(&s->child, s->old_bs); bdrv_unref(new_bs); } @@ -2309,32 +2286,22 @@ static TransactionActionDrv bdrv_replace_child_drv = { * Note: real unref of old_bs is done only on commit. * * The function doesn't update permissions, caller is responsible for this. - * - * Note that if new_bs == NULL, @childp is stored in a state object attached - * to @tran, so that the old child can be reinstated in the abort handler. - * Therefore, if @new_bs can be NULL, @childp must stay valid until the - * transaction is committed or aborted. - * - * (TODO: The reinstating does not happen yet, but it will once - * bdrv_replace_child_noperm() NULLs *childp when new_bs is NULL.) */ -static void bdrv_replace_child_tran(BdrvChild **childp, - BlockDriverState *new_bs, +static void bdrv_replace_child_tran(BdrvChild *child, BlockDriverState *new_bs, Transaction *tran) { BdrvReplaceChildState *s = g_new(BdrvReplaceChildState, 1); *s = (BdrvReplaceChildState) { - .child = *childp, - .childp = new_bs == NULL ? childp : NULL, - .old_bs = (*childp)->bs, + .child = child, + .old_bs = child->bs, }; tran_add(tran, &bdrv_replace_child_drv, s); if (new_bs) { bdrv_ref(new_bs); } - bdrv_replace_child_noperm(childp, new_bs); - /* old_bs reference is transparently moved from *childp to @s */ + bdrv_replace_child_noperm(&child, new_bs); + /* old_bs reference is transparently moved from @child to @s */ } /* @@ -4898,7 +4865,6 @@ static bool should_update_child(BdrvChild *c, BlockDriverState *to) typedef struct BdrvRemoveFilterOrCowChild { BdrvChild *child; - BlockDriverState *bs; bool is_backing; } BdrvRemoveFilterOrCowChild; @@ -4928,19 +4894,10 @@ static void bdrv_remove_filter_or_cow_child_commit(void *opaque) bdrv_child_free(s->child); } -static void bdrv_remove_filter_or_cow_child_clean(void *opaque) -{ - BdrvRemoveFilterOrCowChild *s = opaque; - - /* Drop the bs reference after the transaction is done */ - bdrv_unref(s->bs); - g_free(s); -} - static TransactionActionDrv bdrv_remove_filter_or_cow_child_drv = { .abort = bdrv_remove_filter_or_cow_child_abort, .commit = bdrv_remove_filter_or_cow_child_commit, - .clean = bdrv_remove_filter_or_cow_child_clean, + .clean = g_free, }; /* @@ -4958,11 +4915,6 @@ static void bdrv_remove_file_or_backing_child(BlockDriverState *bs, return; } - /* - * Keep a reference to @bs so @childp will stay valid throughout the - * transaction (required by bdrv_replace_child_tran()) - */ - bdrv_ref(bs); if (child == bs->backing) { childp = &bs->backing; } else if (child == bs->file) { @@ -4972,13 +4924,12 @@ static void bdrv_remove_file_or_backing_child(BlockDriverState *bs, } if (child->bs) { - bdrv_replace_child_tran(childp, NULL, tran); + bdrv_replace_child_tran(*childp, NULL, tran); } s = g_new(BdrvRemoveFilterOrCowChild, 1); *s = (BdrvRemoveFilterOrCowChild) { .child = child, - .bs = bs, .is_backing = (childp == &bs->backing), }; tran_add(tran, &bdrv_remove_filter_or_cow_child_drv, s); @@ -5004,8 +4955,6 @@ static int bdrv_replace_node_noperm(BlockDriverState *from, { BdrvChild *c, *next; - assert(to != NULL); - QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) { assert(c->bs == from); if (!should_update_child(c, to)) { @@ -5021,12 +4970,7 @@ static int bdrv_replace_node_noperm(BlockDriverState *from, c->name, from->node_name); return -EPERM; } - - /* - * Passing a pointer to the local variable @c is fine here, because - * @to is not NULL, and so &c will not be attached to the transaction. - */ - bdrv_replace_child_tran(&c, to, tran); + bdrv_replace_child_tran(c, to, tran); } return 0; @@ -5041,8 +4985,6 @@ static int bdrv_replace_node_noperm(BlockDriverState *from, * * With @detach_subchain=true @to must be in a backing chain of @from. In this * case backing link of the cow-parent of @to is removed. - * - * @to must not be NULL. */ static int bdrv_replace_node_common(BlockDriverState *from, BlockDriverState *to, @@ -5055,8 +4997,6 @@ static int bdrv_replace_node_common(BlockDriverState *from, BlockDriverState *to_cow_parent = NULL; int ret; - assert(to != NULL); - if (detach_subchain) { assert(bdrv_chain_contains(from, to)); assert(from != to); @@ -5112,9 +5052,6 @@ out: return ret; } -/** - * Replace node @from by @to (where neither may be NULL). - */ int bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, Error **errp) { @@ -5182,7 +5119,7 @@ int bdrv_replace_child_bs(BdrvChild *child, BlockDriverState *new_bs, bdrv_drained_begin(old_bs); bdrv_drained_begin(new_bs); - bdrv_replace_child_tran(&child, new_bs, tran); + bdrv_replace_child_tran(child, new_bs, tran); found = g_hash_table_new(NULL, NULL); refresh_list = bdrv_topological_dfs(refresh_list, found, old_bs); From patchwork Fri Dec 3 20:25:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 03262C433F5 for ; Fri, 3 Dec 2021 20:29:50 +0000 (UTC) Received: from localhost ([::1]:33494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFBm-0006Bo-0o for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:29:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8p-0000qc-Ep; Fri, 03 Dec 2021 15:26:48 -0500 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:27177 helo=EUR04-HE1-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 1mtF8m-0001ct-Af; Fri, 03 Dec 2021 15:26:47 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QLa7iLdRcbdIVek6WAxkWvIsbVOlMR37agdBbQIKrnTOCpKX5sK46zA2yL2466TaKtJjJ1ns5SYWCnOO0wFKND6iBcvewYsHQsLcF/rkAFSWK0HBUgucdaCWb+tBoMUgJb2pHRPUFEZwxrbcG2iS2PrkWEu83eEoZ407XDDquG63JVcMqJLS/RgcoZMLnPiQIALXraDcTqKVWRlmrw/8R/xumOAHebqlKYG/ymyAm8ZbO3cmnjC/jlAm8pKmHPqg/W/uhRgRB7sp0K/HZwiE9OO18ruOyyuQCaAcaBbnY7D6rhJ2nKsxFfJ+qrIfFe+U+lPyrVoZz1T5OUCn1lAkMQ== 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=OJoqopGf5qGIUuiqezCBrSKaFk9Ff2/5/1VjSep6xyA=; b=PQsfIPEkbu5UaOFYg5hR3/7NDLeEz1Cy3/WzzHqcqMobFF2BE1FM4r2hmIHduCr5F1ynSWauZ67CJdmp1ABroMIh4D99Sf3PKpZVgVi+4JdGwhoDfRlYKaPzYSsg7DhMiMLaliGJFi0gt///pgitxdYvx8CGkRYNAWZr+zIQiYURcootvTpxuQpgG5j9NV3HmuK/YLC7sMZCl1M9tRrM11aebzQY7ZPy1/9yG0z6EpwEcL0jItIrPa2S3YJf7c3rUMCdZ1cqXQTShCB5QHDKOSTaeZ9Xc75Tq4sT0PxnWOnHl5lX5wH2LdC56z0l6JrEhWRCoJGKKuhPucFitf8hMQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=OJoqopGf5qGIUuiqezCBrSKaFk9Ff2/5/1VjSep6xyA=; b=enHTp8YwLzxtTalkrDBmSGJ2ugC41eRqy2Q7gHkIB32+fBIyAYlJSLu76h8utJuhf/zEK4fP+nN6bSS6qpm7WoFlH45qS0NA1UYR03TXd+4adKw9uuDXiqVvsKLrCEU+EXK1SrROtCzRMPZH6XJP+JplYRaFux70tzu8gJ78ShU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB4068.eurprd08.prod.outlook.com (2603:10a6:208:12b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16; Fri, 3 Dec 2021 20:26:24 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:24 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com Subject: [PATCH 11/14] Revert "block: Restructure remove_file_or_backing_child()" Date: Fri, 3 Dec 2021 21:25:50 +0100 Message-Id: <20211203202553.3231580-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed72f4eb-b148-4be8-03af-08d9b69b2cf2 X-MS-TrafficTypeDiagnostic: AM0PR08MB4068: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:41; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dyjzl9Xj/C9J+LcDYh/AIaY8lQVlVfGUgtiG4pw/f5woUklAyZTlZwULW9LXm80HnPkC7BSvcD2u938sXJJbVTRT4w0h/uc3ytSqKFD6KyqRePSuuqbKKw9c6RoBPd1/iOzF6WIqELjixEJjHFZMlziEtkP5BhqJJVBxgGa3r57px13HnfQRaBeIMgcNuukKTWJmrTnEBtSDkuMl0HCKPVoHo2AgkouS5CL8FRUUGRJM2/LZwUOKn5nhONdn/+Ypeaupg+ez9WRZvM7+aEqVTTbjhTGgV4gEpVj3bmNLZuOYiBHPcD7Ti3Yq8OFUitNBjnGlUwHSfIzij+G6vU4HJO/7i1yem7jTDHJ66LJxxW8EaF/ZtSbdzelEXCW/NRIUqe7YBfAmY17V3j6HDdpMBEnj9IYupqaavUg+yj2mtzrim8EZ3Dk+ExICb5EO8yyESeTF31INL8KS6sC0DRvPGnHJS2CHUNAFOUgbN6HoGstPyNK4j+ic4LeDQrplGPi0ovKy45yvZYUoaZ70rGox9GaHdbHiO2VIzogrF4hkSrziLOXVoLrnu/cTybYWYSMlUBpqOwdIAfNeN95c6VqCSrHhZeY7u80tivsmODCF0wWVya+kmK29H2smGBqDGDKlHwo6GNUUSLCUZ/S9gz2g4YStFKz4FG7bCRbGaBvT+OaKkQuVyiWm+gsFuwoBCIcOLjadzj9GA8p0SDyoryzTwQ== 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:(4636009)(366004)(1076003)(107886003)(83380400001)(26005)(6916009)(8936002)(2616005)(66556008)(2906002)(508600001)(6506007)(6666004)(38350700002)(66946007)(66476007)(38100700002)(52116002)(186003)(316002)(4326008)(6512007)(36756003)(6486002)(956004)(8676002)(5660300002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CMFoazRZ4ttC2HHDyCHeNSlAeqVJtOx8mUIdRwtHxw16AEp65nE5hCDx8w9GClJssg90IWQUoV0aTmTUZGt/l9lVU9z/h2UN+8EUvdNQNLVPGhn1yq5LxMaABZboRbT/qfk29Jq18QnxaPh1/cANvmoIJMUAjFF6SBXAOR1zUtEhb6V533hQJYUaPwX37ovrsyqRcSZ519CtfMgSkm2pm2uJJaThtK0Zt7ElCKRzcuGj4OVgLs65idPvTKlhjui+Yb6QIgLOGV7StW41sFoQVom98ZbfNNT0AHbqeK297QCNMy+II8CjAvCNoHb/+t9XQg4sxVsfSZNSHINOgv7GCi7EPgyCtM/dtUTLzltu407HnYh/ncAsy4CvXZuTo6UVpVU4KqyuyEukfnNTW0H/jfas7eUGyXO7giJIE4nkJpVFnZT5y9hJp1JCz3eoq93cSosWfe7WoiouHvaH2sJKicVOAtSU1kOKjdnDbt5QpW6HX9Wv/urhhRc/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atO1Ey104JIvZMbIctM7Va8+WkVjerkBEMTlJD0NARcxMsFoDD8gp1qQx+JWbtpg6FOQkE22lqROgn53gYyCQ2qiABMA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed72f4eb-b148-4be8-03af-08d9b69b2cf2 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:24.1044 (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: guxqf16rVDahMBtZsljIlT6NWOLIIf7kr3rbZhcLT9fKqSgfF2L8qUYPQ2F1K8nvoMvJz36KF4H4KT1kBFFFUkhfwFA5WGaw87lGk1YQTuY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4068 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" That's a preparation to previously reverted "block: Let replace_child_noperm free children". Drop it too, we don't need it for a new approach. This reverts commit 562bda8bb41879eeda0bd484dd3d55134579b28e. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/block.c b/block.c index 3eec53796b..2ba95f71b9 100644 --- a/block.c +++ b/block.c @@ -4908,33 +4908,30 @@ static void bdrv_remove_file_or_backing_child(BlockDriverState *bs, BdrvChild *child, Transaction *tran) { - BdrvChild **childp; BdrvRemoveFilterOrCowChild *s; + assert(child == bs->backing || child == bs->file); + if (!child) { return; } - if (child == bs->backing) { - childp = &bs->backing; - } else if (child == bs->file) { - childp = &bs->file; - } else { - g_assert_not_reached(); - } - if (child->bs) { - bdrv_replace_child_tran(*childp, NULL, tran); + bdrv_replace_child_tran(child, NULL, tran); } s = g_new(BdrvRemoveFilterOrCowChild, 1); *s = (BdrvRemoveFilterOrCowChild) { .child = child, - .is_backing = (childp == &bs->backing), + .is_backing = (child == bs->backing), }; tran_add(tran, &bdrv_remove_filter_or_cow_child_drv, s); - *childp = NULL; + if (s->is_backing) { + bs->backing = NULL; + } else { + bs->file = NULL; + } } /* From patchwork Fri Dec 3 20:25:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ADA97C433F5 for ; Fri, 3 Dec 2021 20:31:22 +0000 (UTC) Received: from localhost ([::1]:39562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFDF-0001o9-Qk for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:31:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8p-0000qf-Pb; Fri, 03 Dec 2021 15:26:48 -0500 Received: from mail-db8eur05on2098.outbound.protection.outlook.com ([40.107.20.98]:1792 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 1mtF8m-0001dZ-PA; Fri, 03 Dec 2021 15:26:47 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kos3GJs1LGk2FzWYupP3RwMt+DKGSiUnAUvcai7XyrvEluNeB/Po2APKLce8y4goYfmIHtRbY5MF1FaUQDprcL8+vm7uNYjDnBS1dRxNW1HS41VBVN8qCLCbWVGCzssIBTktRzvJ4hTgl3Oos8aCZ6erZlwhBTZObzrZvC5un5xgY/qOIkJbSbHzveYhBQYUJjJiz6/Npl7vAbmjDyzO0MEnca1thZjGzY74WJi7w0q+6KJx5fl6wsPySE3GbvlJrpvq50jifjiyV2HwR2WOvN5PmHE0T7uIRtQbvEe7KiptVYkmbJrc/pGy9nMn4Nm6VXCBRbYTkCA/qoPNvGrK/A== 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=yxZ2vevgJOjfF5pRJ8pzbUZw0NDFtRQXzFlllmoJbgY=; b=eJdhgFAER6Y+Hi2aZxBYpha3lem9SGrmF4jYKCcWWiolr5toM9kOUSzAtLo7owBguqmPYNuCaiPzc8cw8DcCWk8yAP0gVU07xXElVMAJq23zQG240WovM22lUCE0LqfOvJPPt1j/fmODl8XANrYZ7bO2qAG4AC8MGEsjUOxEKlHy0r7DNUIAtLs3PK1LvPW9ZXY0ki4dIT2OGx4eXv9J445FpWCDMn7Pa74qEU2ee87CVnP219piQoo4XaFRIx+TXsS4J/hdU+v2ZqXKeSD3R8rAyBBuKsOr8bA8nZSFl3Xas6hrZW/2k+OT8cDaNIbpbFZ6/TcJRG9tsoJsormvjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=yxZ2vevgJOjfF5pRJ8pzbUZw0NDFtRQXzFlllmoJbgY=; b=dh8qLUc5TnrLBKg41OlhbfdbKgRkYUtDUFUbZQd5Vwh45MwHPwDBRpJmKIFinlfEtoj8hcgi69tHapR0S9VpSWL7bBX4sx0BJUc+/zQclYZFUukvmF7SvY4dzqIk1UU27JDxEYVtk3QcIw5tZ/FSZo1xWvw4ZZLBXZlVJhqhdTk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB4068.eurprd08.prod.outlook.com (2603:10a6:208:12b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16; Fri, 3 Dec 2021 20:26:24 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:24 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com Subject: [PATCH 12/14] Revert "block: Pass BdrvChild ** to replace_child_noperm" Date: Fri, 3 Dec 2021 21:25:51 +0100 Message-Id: <20211203202553.3231580-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e68d5a4a-52ed-4773-bb91-08d9b69b2d32 X-MS-TrafficTypeDiagnostic: AM0PR08MB4068: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:36; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LvI49ss2KDWVRsxHKQw5Td7q8wj3eaICr+/DNbugTsrLizDrxrSb/9EPeCMhXIb/z7u2f2XxdyatxUsfwsjhxtnQ5P+9nwjoMtsSN383vfQ/qeXiS04QkA/sgPO9mGgjwBHDcQrYMx9vamfq+Fo7BWY3HvfTxmVO3Sq8kJKAix9aGEXoa0NIklTrl+tVkSfCVhcpWooKqFu07oCNogDimGBGtADCOCI0rVkLihP1EafZB95eOsJ2PR/YcgH/6fYtcppKXQmhv34HJ1tuit3rMUkKJKQLPAHKzu0M/SYZk0jpwzkGWDKVdDUQ3x7rvXUDZVZFv8AQ6gtRiuZLSBotO0HNQIFRIHB8gf6DqruX4Heg2+AewRDHAXd/g9FXXoaQTCKv51Yr0VQ2K8umMNRWTzDzg4SdFyuz5CAc88hoe9OcqcsXGy7crRQazae1S7uETFjnXLqxDvTK90L6Y9OxOjnjlU8Erd40zHlrDoVxe2sI1KD6UkFExolnu1kwaPbShYrZ9XhfXhi3NCmXJXEFFtPA1XT12tDTNxt8b4yJAFBLXZ8yxkRwwi7D7vjWtm5Px3sE1LH2taacjqMN7Vqu0n6u9cW/Piup3r+8qaL654m94O0lV2+xFkJAhsIwZNBe9pdLZgmL0Y0J8UQBTqch+z0e/exTXfcZEuUoPTF8SjKBBDVFtjYzL0AkVYXfG48kQAgImEA0ll2ojfBmdj11DQ== 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:(4636009)(366004)(1076003)(107886003)(83380400001)(26005)(6916009)(8936002)(2616005)(66556008)(2906002)(508600001)(6506007)(6666004)(38350700002)(66946007)(66476007)(38100700002)(52116002)(186003)(316002)(4326008)(6512007)(36756003)(6486002)(956004)(8676002)(5660300002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KXSb8JOtK7evCky7c25duAFl9gOIZ5qQJPisyp85/8dMwPLH8nAalhBSltTPeDPiqiIZOXGVqdl4J4Y7YY/p453fiZFOsAEWJ8ZSbmYt47jjqUINLSvL2gFeM6T08eGODwC2VPBZ0pLKEBAsMsj4ZVfiGQ1Z9+mLmyTnrd7p8dTChFDF1sVJZpr/Lh5yk4ZueO+W6Wh+vkPlac+YMdxVPx6VaEkIUwBcSifcWL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0pVWEs9oS+Dsg59FlTghKZ8gMXCpDUpf7dQPzdq2jScXKnPGV21tarGa09BDt5kRmJ8k+a7UwDHCaJKJphQzJs+is1MkD3bILdkIg8H5ehV+IWlbAIx0C1i4/4eVmwevrZFTfkwfSmRRZCCG49V2YEBll/37NI04r9hhKBbX6wACVITWI4YSVbynQVAg9wGZpwcxQNNK8T6QT/tI0rhMPbhMSR59gc2wHPIFQvzxWGK+bBXdg7OWaP5G0V8rMVqKuMrMa5IhdIK4Dy+bAjs83NwqQWN2eYFO88oyZrzHKNChCm/gPOWGminC23LsL/9h7aeScZcowYL8Y7axsYpp08qC8XWGmCmNDgMt7Disx9Tg0B+j2/4HpV8hmlPb4t8x1w== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e68d5a4a-52ed-4773-bb91-08d9b69b2d32 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:24.7566 (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: y+zz/6bqAXRZcfCn2156/yh3oOMaueyClZhz7OjdbWVi7Er0NLGHXci+77kRqexq71Bj9vqmzgBo8RxBVOOrniYc0/oohSbTH2hPJfNvVck= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4068 Received-SPF: pass client-ip=40.107.20.98; 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" That's a preparation to previously reverted "block: Let replace_child_noperm free children". Drop it too, we don't need it for a new approach. This reverts commit be64bbb0149748f3999c49b13976aafb8330ea86. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/block.c b/block.c index 2ba95f71b9..d57d7a80ab 100644 --- a/block.c +++ b/block.c @@ -87,7 +87,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename, static bool bdrv_recurse_has_child(BlockDriverState *bs, BlockDriverState *child); -static void bdrv_replace_child_noperm(BdrvChild **child, +static void bdrv_replace_child_noperm(BdrvChild *child, BlockDriverState *new_bs); static void bdrv_remove_file_or_backing_child(BlockDriverState *bs, BdrvChild *child, @@ -2270,7 +2270,7 @@ static void bdrv_replace_child_abort(void *opaque) BlockDriverState *new_bs = s->child->bs; /* old_bs reference is transparently moved from @s to @s->child */ - bdrv_replace_child_noperm(&s->child, s->old_bs); + bdrv_replace_child_noperm(s->child, s->old_bs); bdrv_unref(new_bs); } @@ -2300,7 +2300,7 @@ static void bdrv_replace_child_tran(BdrvChild *child, BlockDriverState *new_bs, if (new_bs) { bdrv_ref(new_bs); } - bdrv_replace_child_noperm(&child, new_bs); + bdrv_replace_child_noperm(child, new_bs); /* old_bs reference is transparently moved from @child to @s */ } @@ -2672,10 +2672,9 @@ uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm) return permissions[qapi_perm]; } -static void bdrv_replace_child_noperm(BdrvChild **childp, +static void bdrv_replace_child_noperm(BdrvChild *child, BlockDriverState *new_bs) { - BdrvChild *child = *childp; BlockDriverState *old_bs = child->bs; int new_bs_quiesce_counter; int drain_saldo; @@ -2768,7 +2767,7 @@ static void bdrv_attach_child_common_abort(void *opaque) BdrvChild *child = *s->child; BlockDriverState *bs = child->bs; - bdrv_replace_child_noperm(s->child, NULL); + bdrv_replace_child_noperm(child, NULL); if (bdrv_get_aio_context(bs) != s->old_child_ctx) { bdrv_try_set_aio_context(bs, s->old_child_ctx, &error_abort); @@ -2868,7 +2867,7 @@ static int bdrv_attach_child_common(BlockDriverState *child_bs, } bdrv_ref(child_bs); - bdrv_replace_child_noperm(&new_child, child_bs); + bdrv_replace_child_noperm(new_child, child_bs); *child = new_child; @@ -2923,12 +2922,12 @@ static int bdrv_attach_child_noperm(BlockDriverState *parent_bs, return 0; } -static void bdrv_detach_child(BdrvChild **childp) +static void bdrv_detach_child(BdrvChild *child) { - BlockDriverState *old_bs = (*childp)->bs; + BlockDriverState *old_bs = child->bs; - bdrv_replace_child_noperm(childp, NULL); - bdrv_child_free(*childp); + bdrv_replace_child_noperm(child, NULL); + bdrv_child_free(child); if (old_bs) { /* @@ -3034,7 +3033,7 @@ void bdrv_root_unref_child(BdrvChild *child) BlockDriverState *child_bs; child_bs = child->bs; - bdrv_detach_child(&child); + bdrv_detach_child(child); bdrv_unref(child_bs); } From patchwork Fri Dec 3 20:25:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A2BEEC433F5 for ; Fri, 3 Dec 2021 20:37:24 +0000 (UTC) Received: from localhost ([::1]:57572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFJ5-0005cB-Hb for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:37:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8t-0000zi-GQ; Fri, 03 Dec 2021 15:26:51 -0500 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:27177 helo=EUR04-HE1-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 1mtF8q-0001ct-3n; Fri, 03 Dec 2021 15:26:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wc7dklqTpAKYdJJOQHKrEX6xztI05XmdMURD1zTpvZF8iKs603Pi3SqR686cXTFJQVQt13H3PU0+RmrVLZBIEnK/+7UlJxD3gwWO1Dyhqv+2FO0l+tdd3tDtbuook3t7nh9FLyP1A7q/SIiQylUDx4PmLVkSVCGXD52squbIyfKjGNgrL1wPvscu42ItPU5nd443QifyH5Z4rUYjpZF+t2c3zB7OfSBCaZ2FaIWc3OqHEbKhAULjt5wm1txpMTlVsqQWmYJZfeU5k0wwmZQHAiSEkngTa91JsJ9SmXDijLf4R9tRB6KJcKnhTI2b6lEK10rL1ukJ1l6Suf3j+dVZLw== 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=kc7qBEWxtgA6+M8pXOOBJg1yZJz9VgtKzv5IQWLbO34=; b=J6Lq9+bh788DVjCLfzcZUKIBCMVNNmEcJCxBAEUCuHr5KyDDWoHoLOSffUrUJ4pMQOAQXOUHGtrxMzd7FlV5ehe9gINhWRCGpjMGv0bcH3tChy4etGP0QpOTbhvAWIPU/oOxTYrkMMc2syWDHIp3uPXnt+NhPokSPeDjYpEc0BUBt093xkRscnQ2cGJMtKWmVRyxGvGa1mYy2ZueCEHyZoT+c2K5LpenAjkivtTN8uMUxYDbC6N9nBHavBiu792ur5HeOqJ+XOg8p6sSQV5YsIma71XSHuHZbU7RSQ3HmU1ZT+uSW8gIU1fE1PBoA0YYYsH3BI1wPbiz1WLDAEXxxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=kc7qBEWxtgA6+M8pXOOBJg1yZJz9VgtKzv5IQWLbO34=; b=LdIK7XJDIJT9U+vmuTBcCM2U9zyyOdBXUjpk5Lp8fbiaNeiFuFs5iJIag52BwNEbT4URyRyyyGZfwjzYu1NFt3QeA9UGKWmc0lN06BsJA+JuWdS6xnVP+XExMgubBCHEUAeGQjEqAajNTmyCiQXLl8olLAnkfBisqxJaVfe7PDI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB4068.eurprd08.prod.outlook.com (2603:10a6:208:12b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16; Fri, 3 Dec 2021 20:26:25 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:25 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com Subject: [PATCH 13/14] block: Manipulate bs->file / bs->backing pointers in .attach/.detach Date: Fri, 3 Dec 2021 21:25:52 +0100 Message-Id: <20211203202553.3231580-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3546909-7aeb-4be7-7bac-08d9b69b2da1 X-MS-TrafficTypeDiagnostic: AM0PR08MB4068: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:551; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y4Ag5WAMDPojNlLP4QJjqtt8We+mMYAezUxA+QcCZ3ruLGU+LOxUDzzoq86fniUQOmMbC25FMYhQq0Oygv31vaV5NqJ1d1Y7DtLpbBunYPL9Whuprh5scdBkJWncrArhTm9XaAcVPJpGHvoSYNYl2HRnmlSfNAe66drNH6nq5NHJ/oWFohzZFoclsj4LZik9k0HvZ6475tMzN0/22E9gSxb0QFED651vyFSY5S3p22sRuTW8yAtVOKVXO8n8TqtAHQyRhZqUGD14XMaYUbWKLO10prK4B2Pr03LVUeGpriMr0J6NwbVrv4SErql+oMP8olDUfEQwLnavOGBiKK9YR/eD/53KGwZXaiGXWPDKVLY7L0FvOsuEiG1AvJ+Y+n1cdL8Ng17FGzzo4WqEqPInuD3OXyOsbedT52WKkBxKxwqeeYsyx5iqB14u2nKblbMXOdwt9vfpiiU+Vm5Cp/rzBHDdF6KkGSWPuNIqtNXRpNeEZ3fLUJduan46C2K14sz2CeLxuwsffGlpYwvLW+hK/yIRuhFveMDXokZqtZI63DH6DG2DkDw1sop9CMFKY/k+kaDhU4awC3c94TQjIpbVDMDjTIB1atRDoESf97nFQ7NHrS3TSh5h8SXlpq9A2E0XeJBGfYtH4HySE9FZsXk2pY1lhUuNYXpdT8IRC+U9ljjhoufsq9gK3mGpdNFq+uPOn7H49lRiic5bFEApp7QzJDFVgnkXgO6YTndLUUzYTPE= 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:(4636009)(366004)(1076003)(107886003)(83380400001)(26005)(6916009)(8936002)(2616005)(66556008)(2906002)(508600001)(6506007)(6666004)(38350700002)(66946007)(66476007)(38100700002)(52116002)(186003)(316002)(4326008)(6512007)(36756003)(6486002)(30864003)(956004)(8676002)(5660300002)(86362001)(142923001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3AuG9QcvW1t97dGn3eavJNFPw7u75jVnCB//EjJR/IQJ+kNGoliUNfck8hM1BbWgK2HYLxhbvk567m1ro5UuIgSxjjQ3HVJn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vIjPKi00HceISdZXY6Rjjp/rh288PT43MKAyHF+nFlx7711cRUdqzB9AxmA/TbRfr3rH/23Y0qHA8ZreGVGmv/kpL2uU3dMUleADrKTQy0FA932OSEy5qoJyl7GdkFbq/q5tZeZXfenZXaZbGe55/AVLyUI7mG+/EcEkk2np6AUJL2KvwimAG0lMZwlvC0FhOQGT8tjwBv5d1XFUPVJbWC6yeYVNs4lSr/+j9yeTrxZHVbjX316f01q0P84Mp+yf9hZmbrEAmYoIEUOcuFgpCDXxknnyesHHfKqmygU1/tpUCQMJZAP4zbVzv9H0LnIRESKAXqDHsEXBmBfRqFhD7QnmxFpnlbS8s8oGhqFtBy9F2aWEZGxE5+bEv4WEmcqDvbXkjCOtcowU94jVaYFMD6B6gettWAoT+0mbjw+5PXuEAybWItzn1IXuxoLNVSrVnEAfOZ0N8zDoHyhbDgHLXlp/yav6idLy2zF/BwDwPpTLOHGyew9UKYpMx5JIewrGIaLS2QRKtUDOAvt8Q== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3546909-7aeb-4be7-7bac-08d9b69b2da1 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:25.2634 (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: Ycq5yf41xCEShn38KlQag+sTlGdIj5UeMwP0INc3LGyubXlFq1tSO9ZC2SAcDZBwNDfuZ+vd1G6naq5us2n2vAYF38WubgDKBVKQBSEs00Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4068 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" bs->file and bs->backing are a kind of duplication of part of bs->children. But very useful diplication, so let's not drop them at all:) We should manage bs->file and bs->backing in same place, where we manage bs->children, to keep them in sync. Moreover, generic io paths are unprepared to BdrvChild without a bs, so it's double good to clear bs->file / bs->backing when we detach the child. Detach is simple: if we detach bs->file or bs->backing child, just set corresponding field to NULL. Attach is a bit more complicated. But we still can precisely detect should we set one of bs->file / bs->backing or not: - if role is BDRV_CHILD_COW, we definitely deal with bs->backing - else, if role is BDRV_CHILD_FILTERED (it must be also BDRV_CHILD_PRIMARY), it's a filtered child. Use bs->drv->filtered_child_is_backing to chose the pointer field to modify. - else, if role is BDRV_CHILD_PRIMARY, we deal with bs->file - in all other cases, it's neither bs->backing nor bs->file. It's some other child and we shouldn't care OK. This change brings one more good thing: we can (and should) get rid of all indirect pointers in the block-graph-change transactions: bdrv_attach_child_common() stores BdrvChild** into transaction to clear it on abort. bdrv_attach_child_common() has two callers: bdrv_attach_child_noperm() just pass-through this feature, bdrv_root_attach_child() doesn't need the feature. Look at bdrv_attach_child_noperm() callers: - bdrv_attach_child() doesn't need the feature - bdrv_set_file_or_backing_noperm() uses the feature to manage bs->file and bs->backing, we don't want it anymore - bdrv_append() uses the feature to manage bs->backing, again we don't want it anymore So, we should drop this stuff! Great! We still keep BdrvChild** argument to return the child and int return value, and not move to simply returning BdrvChild*, as we don't want to lose int return values. However we don't require *@child to be NULL anymore, and even allow @child to be NULL, if caller don't need the new child pointer. Finally, we now set .file / .backing automatically in generic code and want to restring setting them by hand outside of .attach/.detach. So, this patch cleanups all remaining places where they were set. To find such places I use: git grep '\->file =' git grep '\->backing =' git grep '&.*\' git grep '&.*\' Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 15 +++- block.c | 155 ++++++++++++++++------------------- block/raw-format.c | 4 +- block/snapshot.c | 1 - tests/unit/test-bdrv-drain.c | 10 +-- 5 files changed, 88 insertions(+), 97 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 919e33de5f..4ea800e589 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -937,9 +937,6 @@ struct BlockDriverState { QDict *full_open_options; char exact_filename[PATH_MAX]; - BdrvChild *backing; - BdrvChild *file; - /* I/O Limits */ BlockLimits bl; @@ -992,7 +989,19 @@ struct BlockDriverState { * which can affect this node by changing these defaults). This is always a * parent node of this node. */ BlockDriverState *inherits_from; + + /* + * @backing and @file are some of @children or NULL. All these three fields + * (@file, @backing and @children) are modified only in + * bdrv_child_cb_attach() and bdrv_child_cb_detach(). + * + * See also comment in include/block/block.h, to learn how backing and file + * are connected with BdrvChildRole. + */ QLIST_HEAD(, BdrvChild) children; + BdrvChild *backing; + BdrvChild *file; + QLIST_HEAD(, BdrvChild) parents; QDict *options; diff --git a/block.c b/block.c index d57d7a80ab..0c6bbc9b0b 100644 --- a/block.c +++ b/block.c @@ -1388,9 +1388,33 @@ static void bdrv_child_cb_attach(BdrvChild *child) BlockDriverState *bs = child->opaque; QLIST_INSERT_HEAD(&bs->children, child, next); + if (bs->drv->is_filter | (child->role & BDRV_CHILD_FILTERED)) { + /* + * Here we handle filters and block/raw-format.c when it behave like + * filter. + */ + assert(!(child->role & BDRV_CHILD_COW)); + if (child->role & (BDRV_CHILD_PRIMARY | BDRV_CHILD_FILTERED)) { + assert(child->role & BDRV_CHILD_PRIMARY); + assert(child->role & BDRV_CHILD_FILTERED); + assert(!bs->backing); + assert(!bs->file); - if (child->role & BDRV_CHILD_COW) { + if (bs->drv->filtered_child_is_backing) { + bs->backing = child; + } else { + bs->file = child; + } + } + } else if (child->role & BDRV_CHILD_COW) { + assert(bs->drv->supports_backing); + assert(!(child->role & BDRV_CHILD_PRIMARY)); + assert(!bs->backing); + bs->backing = child; bdrv_backing_attach(child); + } else if (child->role & BDRV_CHILD_PRIMARY) { + assert(!bs->file); + bs->file = child; } bdrv_apply_subtree_drain(child, bs); @@ -1407,6 +1431,12 @@ static void bdrv_child_cb_detach(BdrvChild *child) bdrv_unapply_subtree_drain(child, bs); QLIST_REMOVE(child, next); + if (child == bs->backing) { + assert(child != bs->file); + bs->backing = NULL; + } else if (child == bs->file) { + bs->file = NULL; + } } static int bdrv_child_cb_update_filename(BdrvChild *c, BlockDriverState *base, @@ -1604,7 +1634,7 @@ open_failed: bs->drv = NULL; if (bs->file != NULL) { bdrv_unref_child(bs, bs->file); - bs->file = NULL; + assert(!bs->file); } g_free(bs->opaque); bs->opaque = NULL; @@ -2756,7 +2786,7 @@ static void bdrv_child_free(BdrvChild *child) } typedef struct BdrvAttachChildCommonState { - BdrvChild **child; + BdrvChild *child; AioContext *old_parent_ctx; AioContext *old_child_ctx; } BdrvAttachChildCommonState; @@ -2764,32 +2794,30 @@ typedef struct BdrvAttachChildCommonState { static void bdrv_attach_child_common_abort(void *opaque) { BdrvAttachChildCommonState *s = opaque; - BdrvChild *child = *s->child; - BlockDriverState *bs = child->bs; + BlockDriverState *bs = s->child->bs; - bdrv_replace_child_noperm(child, NULL); + bdrv_replace_child_noperm(s->child, NULL); if (bdrv_get_aio_context(bs) != s->old_child_ctx) { bdrv_try_set_aio_context(bs, s->old_child_ctx, &error_abort); } - if (bdrv_child_get_parent_aio_context(child) != s->old_parent_ctx) { + if (bdrv_child_get_parent_aio_context(s->child) != s->old_parent_ctx) { GSList *ignore; /* No need to ignore `child`, because it has been detached already */ ignore = NULL; - child->klass->can_set_aio_ctx(child, s->old_parent_ctx, &ignore, - &error_abort); + s->child->klass->can_set_aio_ctx(s->child, s->old_parent_ctx, &ignore, + &error_abort); g_slist_free(ignore); ignore = NULL; - child->klass->set_aio_ctx(child, s->old_parent_ctx, &ignore); + s->child->klass->set_aio_ctx(s->child, s->old_parent_ctx, &ignore); g_slist_free(ignore); } bdrv_unref(bs); - bdrv_child_free(child); - *s->child = NULL; + bdrv_child_free(s->child); } static TransactionActionDrv bdrv_attach_child_common_drv = { @@ -2800,11 +2828,11 @@ static TransactionActionDrv bdrv_attach_child_common_drv = { /* * Common part of attaching bdrv child to bs or to blk or to job * - * Resulting new child is returned through @child. - * At start *@child must be NULL. - * @child is saved to a new entry of @tran, so that *@child could be reverted to - * NULL on abort(). So referenced variable must live at least until transaction - * end. + * If @child is not NULL, it's set to new created child. Note, that @child + * pointer is stored in the transaction and therefore not cleared on abort. + * Consider @child as part of return value: we may change the return value of + * the function to BdrvChild* and return child directly, but this way we lose + * different return codes. * * Function doesn't update permissions, caller is responsible for this. */ @@ -2820,8 +2848,6 @@ static int bdrv_attach_child_common(BlockDriverState *child_bs, AioContext *parent_ctx; AioContext *child_ctx = bdrv_get_aio_context(child_bs); - assert(child); - assert(*child == NULL); assert(child_class->get_parent_desc); new_child = g_new(BdrvChild, 1); @@ -2869,22 +2895,25 @@ static int bdrv_attach_child_common(BlockDriverState *child_bs, bdrv_ref(child_bs); bdrv_replace_child_noperm(new_child, child_bs); - *child = new_child; - BdrvAttachChildCommonState *s = g_new(BdrvAttachChildCommonState, 1); *s = (BdrvAttachChildCommonState) { - .child = child, + .child = new_child, .old_parent_ctx = parent_ctx, .old_child_ctx = child_ctx, }; tran_add(tran, &bdrv_attach_child_common_drv, s); + if (child) { + *child = new_child; + } + return 0; } /* - * Variable referenced by @child must live at least until transaction end. - * (see bdrv_attach_child_common() doc for details) + * If @child is not NULL, it's set to new created child. @child is a part of + * return value, not a part of transaction (see bdrv_attach_child_common() doc + * for details). * * Function doesn't update permissions, caller is responsible for this. */ @@ -2963,7 +2992,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, void *opaque, Error **errp) { int ret; - BdrvChild *child = NULL; + BdrvChild *child; Transaction *tran = tran_new(); ret = bdrv_attach_child_common(child_bs, child_name, child_class, @@ -2977,11 +3006,10 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, out: tran_finalize(tran, ret); - /* child is unset on failure by bdrv_attach_child_common_abort() */ - assert((ret < 0) == !child); bdrv_unref(child_bs); - return child; + + return ret < 0 ? NULL : child; } /* @@ -3003,7 +3031,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, Error **errp) { int ret; - BdrvChild *child = NULL; + BdrvChild *child; Transaction *tran = tran_new(); ret = bdrv_attach_child_noperm(parent_bs, child_bs, child_name, child_class, @@ -3019,12 +3047,10 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, out: tran_finalize(tran, ret); - /* child is unset on failure by bdrv_attach_child_common_abort() */ - assert((ret < 0) == !child); bdrv_unref(child_bs); - return child; + return ret < 0 ? NULL : child; } /* Callers must ensure that child->frozen is false. */ @@ -3221,9 +3247,7 @@ static int bdrv_set_file_or_backing_noperm(BlockDriverState *parent_bs, ret = bdrv_attach_child_noperm(parent_bs, child_bs, is_backing ? "backing" : "file", &child_of_bds, role, - is_backing ? &parent_bs->backing : - &parent_bs->file, - tran, errp); + NULL, tran, errp); if (ret < 0) { return ret; } @@ -3471,14 +3495,16 @@ int bdrv_open_file_child(const char *filename, /* commit_top and mirror_top don't use this function */ assert(!parent->drv->filtered_child_is_backing); - role = parent->drv->is_filter ? (BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY) : BDRV_CHILD_IMAGE; - parent->file = bdrv_open_child(filename, options, bdref_key, parent, - &child_of_bds, role, false, errp); + if (!bdrv_open_child(filename, options, bdref_key, parent, + &child_of_bds, role, false, errp)) + { + return -EINVAL; + } - return parent->file ? 0 : -EINVAL; + return 0; } /* @@ -4731,8 +4757,8 @@ static void bdrv_close(BlockDriverState *bs) bdrv_unref_child(bs, child); } - bs->backing = NULL; - bs->file = NULL; + assert(!bs->backing); + assert(!bs->file); g_free(bs->opaque); bs->opaque = NULL; qatomic_set(&bs->copy_on_read, 0); @@ -4862,41 +4888,13 @@ static bool should_update_child(BdrvChild *c, BlockDriverState *to) return ret; } -typedef struct BdrvRemoveFilterOrCowChild { - BdrvChild *child; - bool is_backing; -} BdrvRemoveFilterOrCowChild; - -static void bdrv_remove_filter_or_cow_child_abort(void *opaque) -{ - BdrvRemoveFilterOrCowChild *s = opaque; - BlockDriverState *parent_bs = s->child->opaque; - - if (s->is_backing) { - parent_bs->backing = s->child; - } else { - parent_bs->file = s->child; - } - - /* - * We don't have to restore child->bs here to undo bdrv_replace_child_tran() - * because that function is transactionable and it registered own completion - * entries in @tran, so .abort() for bdrv_replace_child_safe() will be - * called automatically. - */ -} - static void bdrv_remove_filter_or_cow_child_commit(void *opaque) { - BdrvRemoveFilterOrCowChild *s = opaque; - - bdrv_child_free(s->child); + bdrv_child_free(opaque); } static TransactionActionDrv bdrv_remove_filter_or_cow_child_drv = { - .abort = bdrv_remove_filter_or_cow_child_abort, .commit = bdrv_remove_filter_or_cow_child_commit, - .clean = g_free, }; /* @@ -4907,8 +4905,6 @@ static void bdrv_remove_file_or_backing_child(BlockDriverState *bs, BdrvChild *child, Transaction *tran) { - BdrvRemoveFilterOrCowChild *s; - assert(child == bs->backing || child == bs->file); if (!child) { @@ -4919,18 +4915,7 @@ static void bdrv_remove_file_or_backing_child(BlockDriverState *bs, bdrv_replace_child_tran(child, NULL, tran); } - s = g_new(BdrvRemoveFilterOrCowChild, 1); - *s = (BdrvRemoveFilterOrCowChild) { - .child = child, - .is_backing = (child == bs->backing), - }; - tran_add(tran, &bdrv_remove_filter_or_cow_child_drv, s); - - if (s->is_backing) { - bs->backing = NULL; - } else { - bs->file = NULL; - } + tran_add(tran, &bdrv_remove_filter_or_cow_child_drv, child); } /* @@ -5082,7 +5067,7 @@ int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, ret = bdrv_attach_child_noperm(bs_new, bs_top, "backing", &child_of_bds, bdrv_backing_role(bs_new), - &bs_new->backing, tran, errp); + NULL, tran, errp); if (ret < 0) { goto out; } diff --git a/block/raw-format.c b/block/raw-format.c index bda757fd19..29435d3ac4 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -456,8 +456,8 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, file_role = BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY; } - bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, - file_role, false, errp); + bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + file_role, false, errp); if (!bs->file) { return -EINVAL; } diff --git a/block/snapshot.c b/block/snapshot.c index 12fa0e3904..cb184d70b4 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -279,7 +279,6 @@ int bdrv_snapshot_goto(BlockDriverState *bs, /* .bdrv_open() will re-attach it */ bdrv_unref_child(bs, *fallback_ptr); - *fallback_ptr = NULL; ret = bdrv_snapshot_goto(fallback_bs, snapshot_id, errp); open_ret = drv->bdrv_open(bs, options, bs->open_flags, &local_err); diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c index 45edbd867f..cb0eac5a1e 100644 --- a/tests/unit/test-bdrv-drain.c +++ b/tests/unit/test-bdrv-drain.c @@ -1804,9 +1804,8 @@ static void test_drop_intermediate_poll(void) for (i = 0; i < 3; i++) { if (i) { /* Takes the reference to chain[i - 1] */ - chain[i]->backing = bdrv_attach_child(chain[i], chain[i - 1], - "chain", &chain_child_class, - BDRV_CHILD_COW, &error_abort); + bdrv_attach_child(chain[i], chain[i - 1], "chain", + &chain_child_class, BDRV_CHILD_COW, &error_abort); } } @@ -2024,9 +2023,8 @@ static void do_test_replace_child_mid_drain(int old_drain_count, new_child_bs->total_sectors = 1; bdrv_ref(old_child_bs); - parent_bs->backing = bdrv_attach_child(parent_bs, old_child_bs, "child", - &child_of_bds, BDRV_CHILD_COW, - &error_abort); + bdrv_attach_child(parent_bs, old_child_bs, "child", &child_of_bds, + BDRV_CHILD_COW, &error_abort); for (i = 0; i < old_drain_count; i++) { bdrv_drained_begin(old_child_bs); From patchwork Fri Dec 3 20:25:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12655763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 633A7C433F5 for ; Fri, 3 Dec 2021 20:31:50 +0000 (UTC) Received: from localhost ([::1]:41788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mtFDh-0003M2-Gd for qemu-devel@archiver.kernel.org; Fri, 03 Dec 2021 15:31:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtF8u-00011i-6R; Fri, 03 Dec 2021 15:26:52 -0500 Received: from mail-db8eur05on2098.outbound.protection.outlook.com ([40.107.20.98]:1792 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 1mtF8r-0001dZ-4i; Fri, 03 Dec 2021 15:26:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iefV9s7CI9raWykNscSPkrbx0i3bT1UJTenT9K9So+GuRVQRn/2XEIlwHPPjjmLKbqBNOAUKO09FWhLx2BDEDfTdYQppwwpqHfKsCsfxM7mdEYphL7ZkU0+dcziOSgZy+8AEOtBcIsqXrkKvZdkSHreXGhwjs4AlfItuSk2j//oJ9wnpfiJAksHCBR1po4BFBxpdOW7WQBmCeWCYVG2xNQKBCWYOvriSW3Oo/n2ajG6Xuckh5V2MbJd1vcbmm2tlMM3YPZLfDmmNsb0lKGacyonjdz6zlYIvBRWD4eSZ99cEi0SrboXSdl/u5onynYorYi2h1avKvN2g4WficG8joQ== 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=UJmj01KFgYGt01mpFsopt3xuBF4uLFTukUjGF7gO8z8=; b=mXHnzOAkC+pM7o19yhFNEr+AauakJhgVI+M/epOiiSZj74N28tHD1+LM4JqiVV7yO7aDrXxBzl9OfM4Nc3lUAIFblY9OahfplG0EUpZle9eIk+LA7P27q1JQtgdnjeC9Hfje7uyZSGSYDu+UOe42KvHPhn/BjW89yUhdfAdQE+YHmFzxYi6MhkgTgq1inQ+Cu5XYSuJYgd/QjDcUa/wmkd0cqU0461jHGrpzSbnZ8ig+JuQD/Yc2ZNlvWgSB6Vtq2Gj6GcS4OfcGabiQZtmUwSWTIRMmFnpU7ng9lKD5Nls/i0NAf+SrFh4W7GP0zkXPETRabo77BkJywHfdBBW42Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; 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=UJmj01KFgYGt01mpFsopt3xuBF4uLFTukUjGF7gO8z8=; b=FoB66ZvsGEgRl/4GfYTHC4v4LJKE+omSQBsjkloGGo8ClKPcvgP09NCxtWrXRBpF064t/FUxX7hbqRjI0VbHiTP8xhEEw0DHL++hHweEjEV/FBna2tDOL5yHsys1wQMG5XyP/VVN7tYvNdRtcmOrbdldagVrrC2rjvP3y+1tN34= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM0PR08MB4068.eurprd08.prod.outlook.com (2603:10a6:208:12b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16; Fri, 3 Dec 2021 20:26:25 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::2078:5a2:1898:d83a%7]) with mapi id 15.20.4669.024; Fri, 3 Dec 2021 20:26:25 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, vsementsov@virtuozzo.com Subject: [PATCH 14/14] block/snapshot: drop indirection around bdrv_snapshot_fallback_ptr Date: Fri, 3 Dec 2021 21:25:53 +0100 Message-Id: <20211203202553.3231580-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203202553.3231580-1-vsementsov@virtuozzo.com> References: <20211203202553.3231580-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 Received: from kvm.ch-qa.sw.ru (130.117.225.5) by AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Fri, 3 Dec 2021 20:26:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1fb5f9b5-dfce-4598-74ff-08d9b69b2df2 X-MS-TrafficTypeDiagnostic: AM0PR08MB4068: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:291; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5orQHoH/4xBBi784t3KVnuvW9yK6cbMGMHE2DVE2aqlchg5fUXZBsMGVN50wQpNWnOHg/pVAvyi4NgAsEbJehvRyW12IqqLIfvk0ke9IZpMevkHxoXLX26tNqzMbRAty517s4OTuyX9PNmL26nTC1Oi293qSiCmQmByREb67BTGhl0NaJZ+lXKvmbRSunz9r48tLbDlYGECQayIo3v8fElfBfPnWhqOX0aCXOwci8V5Oh1I15jYsPUoQNuhtnNJCC+dzHZx8fAFsjb9ldRmURpI8UuYYjao9+gdUKEzNdk70pTj3UF7/dyd6F3HoGs84qZRxh4VH+BGoQQpqkZdQwChORlOToZc7NgXY9PqBQtiT4VP5Pal/g6pvqEY1JMPKJrB1Ur0WqEm0fVBKbIqVtNcJvXHIVuZ6AEe0Q7Kxy0T3Y4PnFd6UgH/4+rvSyjO+B/OJur7f4HgMsT5wcYl1TyE82AVIRgNOTp+o4vPwc4MEe75ew8g0lMoGG42xmlgQgpdq5fFNbOfS1Wjh0P6d3pQss1q9zMzj8y00rgY+jbIJrvd4qQqagXIDxOju6tA0j0g5Y8L18+90mmrI1rqUGu1QQmYiwmwnnNeoSN99J/Cedr9sap7JCAj4xMsyEVfpMC5VIDpEMUSvEMju/tDeQpksl65J8CZD+Y/qMhaJb4SUT+lETfuZTLRCcH0B1PwgANTGgsmo+Gba3+Nhs8h4rA== 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:(4636009)(366004)(1076003)(107886003)(83380400001)(26005)(6916009)(8936002)(2616005)(66556008)(2906002)(508600001)(6506007)(6666004)(38350700002)(66946007)(66476007)(38100700002)(52116002)(186003)(316002)(4326008)(6512007)(36756003)(6486002)(956004)(8676002)(5660300002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JnOftCNd/yZ6tzwNkVaDV9GhhnFO9GOpr5GP1a580ZDITrG8Vxk9amJGaV7EvM0AW3c0DQkY3UwKGLZfICbTFdQRuN81KjwhscwhRXQ9MZpfrhe4h18rrCoGDKIbTJedmYgTtE8V75l2sc9Y0Mh3BSJV9yGzeF8NMZRFEUdvOWJ+QbB8yC+solJNsbyKfWIGbUbIDvv63MUcr9yTvDkX3TsWUtRttRLJuV9z8Psd53vg3k/kPREA7MCFqwjRHM5nleqyogNcH51OSqYXbXozXixbM8YfCpfIpozRF8QHLNBfwksqyYmbObbl5Uso2S5opOhGwwgS4EWqpRwkNd1f8v5mdj5vIJzq36SkBNxGPsNN30qlZq83ok/YTgnF0BYQLojuTnFQs5BANpk448CmZYrRniNhCiyWXioZlNSW1xVj1vi/L41fQrpjVrC/2yLyLJpMEyjd1I/0o+NH7ycwnplkLGg/8glrmulOPMxwrLwqApfVFF6H9Xlgj3kxzKnwehk6DrawH6hqKqlARcrCkYu+Uc1bHqDO8tyBad4y1C1egn5iSzgPAr1wl895f8diSgaPlnrHwFtn0CQKq/auSKr7dZ3G4u68u8oJHDcJSX4QP9YznfoC35BOH+kYuUlzqqNarxiNArzE75UHHKM3AAIR7At/ANna6rs+5KaEyocNef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2 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 20:26:25.8956 (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: or7ptYQ5xTB2BIUj03xN3vY8kq7nt4icSe1QPRoUyi26FWLTZ4jkDspSWAnxY8wRuQsrw3UwU3zN5Tjoze0E+BQMgkJG4XkbQm921RJakwo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4068 Received-SPF: pass client-ip=40.107.20.98; 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now the indirection is not actually used, we can safely reduce it to simple pointer. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/snapshot.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/block/snapshot.c b/block/snapshot.c index cb184d70b4..e32f9cb2ad 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -148,34 +148,29 @@ bool bdrv_snapshot_find_by_id_and_name(BlockDriverState *bs, } /** - * Return a pointer to the child BDS pointer to which we can fall + * Return a pointer to child of given BDS to which we can fall * back if the given BDS does not support snapshots. * Return NULL if there is no BDS to (safely) fall back to. - * - * We need to return an indirect pointer because bdrv_snapshot_goto() - * has to modify the BdrvChild pointer. */ -static BdrvChild **bdrv_snapshot_fallback_ptr(BlockDriverState *bs) +static BdrvChild *bdrv_snapshot_fallback_ptr(BlockDriverState *bs) { - BdrvChild **fallback; - BdrvChild *child = bdrv_primary_child(bs); + BdrvChild *fallback = bdrv_primary_child(bs); + BdrvChild *child; /* We allow fallback only to primary child */ - if (!child) { + if (!fallback) { return NULL; } - fallback = (child == bs->file ? &bs->file : &bs->backing); - assert(*fallback == child); /* * Check that there are no other children that would need to be * snapshotted. If there are, it is not safe to fall back to - * *fallback. + * fallback. */ QLIST_FOREACH(child, &bs->children, next) { if (child->role & (BDRV_CHILD_DATA | BDRV_CHILD_METADATA | BDRV_CHILD_FILTERED) && - child != *fallback) + child != fallback) { return NULL; } @@ -186,8 +181,8 @@ static BdrvChild **bdrv_snapshot_fallback_ptr(BlockDriverState *bs) static BlockDriverState *bdrv_snapshot_fallback(BlockDriverState *bs) { - BdrvChild **child_ptr = bdrv_snapshot_fallback_ptr(bs); - return child_ptr ? (*child_ptr)->bs : NULL; + BdrvChild *child_ptr = bdrv_snapshot_fallback_ptr(bs); + return child_ptr ? child_ptr->bs : NULL; } int bdrv_can_snapshot(BlockDriverState *bs) @@ -230,7 +225,7 @@ int bdrv_snapshot_goto(BlockDriverState *bs, Error **errp) { BlockDriver *drv = bs->drv; - BdrvChild **fallback_ptr; + BdrvChild *fallback; int ret, open_ret; if (!drv) { @@ -251,13 +246,13 @@ int bdrv_snapshot_goto(BlockDriverState *bs, return ret; } - fallback_ptr = bdrv_snapshot_fallback_ptr(bs); - if (fallback_ptr) { + fallback = bdrv_snapshot_fallback_ptr(bs); + if (fallback) { QDict *options; QDict *file_options; Error *local_err = NULL; - BlockDriverState *fallback_bs = (*fallback_ptr)->bs; - char *subqdict_prefix = g_strdup_printf("%s.", (*fallback_ptr)->name); + BlockDriverState *fallback_bs = fallback->bs; + char *subqdict_prefix = g_strdup_printf("%s.", fallback->name); options = qdict_clone_shallow(bs->options); @@ -268,8 +263,8 @@ int bdrv_snapshot_goto(BlockDriverState *bs, qobject_unref(file_options); g_free(subqdict_prefix); - /* Force .bdrv_open() below to re-attach fallback_bs on *fallback_ptr */ - qdict_put_str(options, (*fallback_ptr)->name, + /* Force .bdrv_open() below to re-attach fallback_bs on fallback */ + qdict_put_str(options, fallback->name, bdrv_get_node_name(fallback_bs)); /* Now close bs, apply the snapshot on fallback_bs, and re-open bs */ @@ -278,7 +273,7 @@ int bdrv_snapshot_goto(BlockDriverState *bs, } /* .bdrv_open() will re-attach it */ - bdrv_unref_child(bs, *fallback_ptr); + bdrv_unref_child(bs, fallback); ret = bdrv_snapshot_goto(fallback_bs, snapshot_id, errp); open_ret = drv->bdrv_open(bs, options, bs->open_flags, &local_err);