From patchwork Fri Sep 18 18:19:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2951C43463 for ; Fri, 18 Sep 2020 18:28:04 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7FB4A21D42 for ; Fri, 18 Sep 2020 18:28:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="A5sc6T/l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FB4A21D42 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJL75-0005rL-B9 for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:28:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJKzU-0007FH-Tb; Fri, 18 Sep 2020 14:20:14 -0400 Received: from mail-eopbgr40122.outbound.protection.outlook.com ([40.107.4.122]:8096 helo=EUR03-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 1kJKzS-0004bq-TY; Fri, 18 Sep 2020 14:20:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dzp1oRWpvKqhWhJxvIBHE0LFGhQyjDdiOMVKhxreBOjwSe/0mBpZPSGIveM6dqUT2iyWBoIlQ7Hbq5mkooWy1MIiRrihPZGmxCFZ7Gxpn2fxzANmkv1T0hP2ntG+1BJ0o5XOwjD8427XQVamOez3AFdWMLu6VkuseOv49KjWZCQSciZcjCD76AbOKeJv26SfKPJtWzzWy06o/03LB5kC7nOQxRObkxpuTFsy8ALJEZA9OkE23FI5WFoYBf/IIjtBy1YGEcA/I64WTDVbb68BiVF1RrwkgSxy/UfxZXotG8tifOkPsjSJztEgilWoL2M8lseuaoPL6e0q9nyXB+bF2w== 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-SenderADCheck; bh=Z9ffJp3GBUYCdrFi6KtXODZCppuTk4IW7QXFxAvnO5Y=; b=dQpY6r4nx716yEo3v0IRu2U61/49lynvLmXhZboGX1r09LFrTqQBXKcg7XZwN5YOD/exagWsocWibtz7v0+MdoPmvnW04OYXpFlA9e1FF1gYfBFACkDUfhLa1bbrXTyA/tUrqRJsvtVWu/Wt27QKEsKoffKE6VjkOp7MnL68W5BFOUioUHACXPy6JJgSaUaNMj3Toth08wctokEV9VDCFP/tToMFRD3CaQNG2ZpMROaeNGtBgyN+e9yUsctc5OL79eFCZxsKuxqBP5XAvhR95yj9tXV0E03lEOM7/h0kGaRfcTiQrtyQ1NwQHKNfKYN1hWsSh4rNuQLiuI/oQ2C0XA== 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=Z9ffJp3GBUYCdrFi6KtXODZCppuTk4IW7QXFxAvnO5Y=; b=A5sc6T/lFlVo3NwptabZx9uMrOi0ndbVrjJzWIDpZ5WaHmtShDVeWxm3uIxRHzRAm/yF3lJopjZXjnMwk+KTsFsTYv9REgn5RZFbZf+MKniTCLYYx9PCn2cIJKaA0O8TKlQ2n7k9TGBS14myF+eQ5veVL9lx216MuDSifMGkRyM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:05 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:05 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 01/15] block: simplify comment to BDRV_REQ_SERIALISING Date: Fri, 18 Sep 2020 21:19:37 +0300 Message-Id: <20200918181951.21752-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:04 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c2926856-ff6b-4bfa-5c87-08d85bff773f X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y1yGL27zMoJynJp0FNDIiu5Xsq8ixEDa2ezrgcufUDAalX1j8xEAwmSJ28E+DgM2VDjNjIp1rx4ohe/Sgq0F+LKaPDVD/HCOCrMkNoY7vo1zY2E8JM0oe7L8Pju8pC5mY9cSCrvpNRlhKO9AiIAqKL93f7ubJq9mZevFm8EI6DZM2QosMC5asLaQXIFwXNgmW8ICSFhAaNxOdKse4y4z8Ws+d94KyEujeDFm0QVgV+7Fq5k3NP3GGA4Sg8WeBXoDviXX33JO37d0RGCueZ4nRLVfH7AvKoI7dd1Pdj0IR9MRN0DXM7gl/yakaUqMfgAfh1kWKMya/6gphJg+fCe1zIz/LP1jsWQZWY/t108sJw307KK8oJ28foClO3RCflOP X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39830400003)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 4Hb9c4Gj0jjsJ6NKYsluePgNufi4XFT6KL8D9xUe3C/0ddoGSSeXUe+EKDj4QewiVtt9TL/plRT96wYrYi2kc4sdFx7vygauYqhKuVjVmpVagLe8JBj4Kl/JbQ1DvfKpGv3QY0zxKT+TWlQO1RtGf8rFDFOHYtQXuf8IhjGSCludVj85jwLiUP32zaq7GgpAzkWwrEgKNowyuo2f41nrPYpXLwM1kKSzHsrwCdFE3ZJd/w4IYFkToKPZ4jN2XAVceozVHOOcll4xwGuDbMMt7HtV6N6poDTnj3S8qGLshxooLtnAre4fewPP2rZDQVMeJtcQj/R18gN7dLy/TZ+gGmPtGXW6/XZIOsW1L9xViKecemNZGQzC+OyjiHMzvYqzXKFwS7ke3wLNxN8IAzBSzS/I1/4AT7Sh5642yGSxkVqzElUsjUwVwop4jBC+dSAuNC7JcwB1+2y/45es24Ns4REtXw+8IECkCqt35UXoywPgXIrn9mno0qiOt+c78QpH6jtNscg3Dn9FYsLxUpvUP+eQVEZaGfUmiyQyZVdgKW2mQKkGglgN//QegDyoyNa10WJ6AsW/NE+G76pJcFy+Sq+d2ufQWIqn62UavSdAups8ENZUT6qU/0fHBakgb43HxB9uh3bbJUQmU2YJZqHIVQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c2926856-ff6b-4bfa-5c87-08d85bff773f X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:05.0863 (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: THaL75kgILaEbmFW6lKGljOxf6r7nCj8SNeLe/5piNAKl1qFJ975n34ZJywUO+pMibKRSK1M3kssSDqOvZix0fO2kn0dfGmZ6mJN72W1LWA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.122; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:06 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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.23 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" 1. BDRV_REQ_NO_SERIALISING doesn't exist already, don't mention it. 2. We are going to add one more user of BDRV_REQ_SERIALISING, so comment about backup becomes a bit confusing here. The use case in backup is documented in block/backup.c, so let's just drop duplication here. 3. The fact that BDRV_REQ_SERIALISING is only for write requests is omitted. Add a note. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia --- include/block/block.h | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 981ab5b314..ef948e3f34 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -53,16 +53,7 @@ typedef enum { * content. */ BDRV_REQ_WRITE_UNCHANGED = 0x40, - /* - * BDRV_REQ_SERIALISING forces request serialisation for writes. - * It is used to ensure that writes to the backing file of a backup process - * target cannot race with a read of the backup target that defers to the - * backing file. - * - * Note, that BDRV_REQ_SERIALISING is _not_ opposite in meaning to - * BDRV_REQ_NO_SERIALISING. A more descriptive name for the latter might be - * _DO_NOT_WAIT_FOR_SERIALISING, except that is too long. - */ + /* Forces request serialisation. Use only with write requests. */ BDRV_REQ_SERIALISING = 0x80, /* Execute the request only if the operation can be offloaded or otherwise From patchwork Fri Sep 18 18:19:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273370 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10A17C43464 for ; Fri, 18 Sep 2020 18:23:22 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 36C4620DD4 for ; Fri, 18 Sep 2020 18:23:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="Be1xUyQc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36C4620DD4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJL2W-0000jw-1q for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:23:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJKzY-0007GB-Jb; Fri, 18 Sep 2020 14:20:18 -0400 Received: from mail-eopbgr40122.outbound.protection.outlook.com ([40.107.4.122]:8096 helo=EUR03-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 1kJKzW-0004bq-HU; Fri, 18 Sep 2020 14:20:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vf7eK4VGLIZvHhavYHm8lBcjTENn8unfeVQklC848xUAoIYJ9C9WtaLYOYHVeDFvL+0DyvRi+ouqJQkifCU/dotgXlXsHP5gTvTty1tczocCE6E+fjFXSLOonDE7sxgYNPr4QEuXJ+mdxG2tKCv7pFYAS+HaSkJQdgOAqfs9javZDttzokmfGzG7tE4fKIRAMEr+AHSaiKBmGJJ4+HVDhgTsYeJFEKe7nILuW69D6Repd0WQzNzCP1vZbjfWjwrV3rH+TIOAqY5f3bEbujtQEO2xX2USParQ7TsaZ8TV5EB2+Sie38ANsuCObV0VCYvkdXQ4HbaWb3pLXhqHiJJOQQ== 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-SenderADCheck; bh=y8NLhSWjzvLoAdEPcy6v+2cO7JLMwXB4I3aVRrNXRwo=; b=WDX2qLrcnEv27/S4+GZMJWAhyetL6OnIbUaVObaaz/B5AUnYD3huTO95YAF3I9D6lAt5iSP9zDeaBABSwJ0qiP/XV0oh7QvQKutBR5lgOuF/ENUeo8yTKaVHxdS/HQVq/2IpPTefwdDN0O0qn5woSSvR1RNXrXTCxikD1yeaOZHOz2ocw88bwEnrmx0aU+KgF6sV2UCa1WJ2bSH6/jwcazchbeWO5+0Hhq+JpyBzy5lpQmLWNrhYgHJYxBzAUsg3qJGQYCW8VO6BdxAS3j1+uMTij0OUCiPrPSYi7qdqmgciUS+xAbt27u53OQTJNdM7+chrNBnxtb00A2TnAyC1ZQ== 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=y8NLhSWjzvLoAdEPcy6v+2cO7JLMwXB4I3aVRrNXRwo=; b=Be1xUyQcK5+dV7j+jQqvbGUxVBM//r+YNi3O16mzE+o+giakPoenJrz7y2hOjDyfHt8rXfbYb0JBkuRzh/csUWVdmJ5zybiKME0bbnLg6P5zRDMjBN09JPlHXKRv7VJ7MqD33/kn3q7De5Xb1BZkcvsX3Ise3wChDdw+TU5QaoQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:06 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:06 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, Paolo Bonzini Subject: [PATCH v6 02/15] block/io.c: drop assertion on double waiting for request serialisation Date: Fri, 18 Sep 2020 21:19:38 +0300 Message-Id: <20200918181951.21752-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:05 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 08a4f461-8c4f-4624-c055-08d85bff77dc X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7ko5mMpqLjU+a1NX6W3AB5tEPfl+L25Zqox7l9C8yLdf2iyUohgPLy3jcr5WebfKI8NW2iQs+FBML2ztKVotTUfA91evyKhMayTAY9j15XMQey7E3Iw9lA5rFBhU68NXH0EJHTtERixaf7jqc14DFJP103JgfhSbbE9mcaWTX1rdB53nE8jYVMNsfjGP8ABIiJbbUaLu13F04sTS8G8awP5pRoxSFsFflmBA3ou+YlqikiMzHCSiOOS/kPkuvx9JccdTqtpx4eJzEvGu4tzIiiFZiXD3Qj9HN3FCKKeRUfc6FR33NIDj9ITGYfxI3PfxXybzN2GQ8sC2kVpuW1KPQJ6PMWBvz0pL5D6WMU7rB9M++FCCTeKWk14fNu5mnZYL X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39830400003)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 8I6SmDWuJqvmFVt/Gir82h37fzwUPpDyvGoFMzc+5As9I6j+q2wa0iOtXyLUwWRpHfCll5Tr607jq1Y9DCeTE/hNU8M71z9O8mKavK3eSM9BKkfIcbWHQfpZjz9WPnE52Ti9Hzwje72AWTuoBZsO6fl9lYwdMHbf/l/H0fYJT4bZC7Rlk0Iwqd4yOJJQhNbw8RIzia+0/tR/zyPLWTj68FZGIjWn1/3lKH5dMDgod1RXrY1kiu8P9rrUmtIXlRzDQCE3jiCRp9Lrfiif3UcWYFoTVD0IlJj3dnbJB9/DsJKP4TfqgoqPKqj5FggouBvtgWTR0AxZM14wIbHq46vrLg+DIhbiA98G9lN0EwhjcorrD9Jyl1BnslVfGHTMRqwoan7t+fPGRX2+kSaNsGpEL0GPacXu3TSG+3bMiS5oCDXA8m9rmvMT5g+ScwxktqsSwSNkVSuxLmv8dwZffpVFutdYfB+HlOYSC/8fKaYKYC2tTX43UzcDkrjYw5ZHe1btRKtnLpGjgrrn8MmxEBxIl6FK0Tnn7e4IA9ym3TrtXZaDxiel9BTxhCo8aS9M5leT7XNnRpHxRfqbayN4qv/7RciZDaT16TSOd+DmRavAy4Gw5RKED3WHSCwc6ljjrYd8cEu/oP37GrdQ2tLUzJE8Ag== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08a4f461-8c4f-4624-c055-08d85bff77dc X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:06.1158 (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: /f/O6B0MmHEtkUYYfx2B023MmuJ+MXb4rEN2QRkIe6AQssy41tWYHYLPyYUzPhfVyHjNF2UySXQ5qKk2pv1R2CsXnEDorxEAkNIt7f5vGbA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.122; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:06 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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.23 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" The comments states, that on misaligned request we should have already been waiting. But for bdrv_padding_rmw_read, we called bdrv_mark_request_serialising with align = request_alignment, and now we serialise with align = cluster_size. So we may have to wait again with larger alignment. Note, that the only user of BDRV_REQ_SERIALISING is backup which issues cluster-aligned requests, so seems the assertion should not fire for now. But it's wrong anyway. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Paolo Bonzini --- block/io.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/block/io.c b/block/io.c index a2389bb38c..67617bb9b2 100644 --- a/block/io.c +++ b/block/io.c @@ -1881,7 +1881,6 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, BdrvTrackedRequest *req, int flags) { BlockDriverState *bs = child->bs; - bool waited; int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE); if (bs->read_only) { @@ -1893,15 +1892,7 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, assert(!(flags & ~BDRV_REQ_MASK)); if (flags & BDRV_REQ_SERIALISING) { - waited = bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs)); - /* - * For a misaligned request we should have already waited earlier, - * because we come after bdrv_padding_rmw_read which must be called - * with the request already marked as serialising. - */ - assert(!waited || - (req->offset == req->overlap_offset && - req->bytes == req->overlap_bytes)); + bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs)); } else { bdrv_wait_serialising_requests(req); } From patchwork Fri Sep 18 18:19:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273368 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8ED0CC43464 for ; Fri, 18 Sep 2020 18:26:38 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0D67221D7F for ; Fri, 18 Sep 2020 18:26:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="j61CWJPY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D67221D7F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJL5g-0004Gm-VN for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:26:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJKzg-0007K3-AJ; Fri, 18 Sep 2020 14:20:30 -0400 Received: from mail-eopbgr40094.outbound.protection.outlook.com ([40.107.4.94]:32391 helo=EUR03-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 1kJKzY-0004dZ-Os; Fri, 18 Sep 2020 14:20:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RFT2vGbxcX46G3TV7sMBfbITe3Y8V4rtuBq7dR6db5vrBNVamkrR1zPO+9chHem4E1Z4rIeg6mCP83NG2ikfEhFCZbbb5L/sUN5isSe0mz2TUrsjLTJmDy3QjwJanTsUq7MIbSGzwmJ12RXcuuAWJ9POu1nzLxNgxG4QYDdSQwdDnOkcw/D2+FjwUPt4hHH0QD3VKqG2pC99pO2OPAF3N/nixYU2FtioHj0VoRtnG7cQ5/NatyUexcdfAjvFTUhotY/oIRbVRpJvSaGJqk6XXZcKzEcae0+COehLNIS1/9aLGGVfCPohUWaEtwnpUpR8CTDrixIpBakhoa7eyYDhXg== 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-SenderADCheck; bh=dXZdwrj/9t/abLl6GSP7mG0tJiXgJv0q7ngCCct0T7o=; b=VBUnFT7AyaSp+7AV7E2O8Nr0e1z9EuKvWzmCait6vSthiFRO/lLu0KffursysfUN6F9K/C5DVY1wQJDklL38+E/d4MHqbK0izRZUdQdEviRqRc9MZu1kDprhz521CrDmaCHqbagi9wWTm/ntyhSoJ+lw65SV7wH7yT+/Oc+hlQdlgBvjRGyKRPDv5gt2Ats7pOhva971U2wA1a/xnNcSPXch3Hjx3xcSWfjhcA6ZVxfM0U0wPuT2p9xB8LaWPWpKQdRu0Ct2A/opR4i/Ed/IB/AoSWDdcf4BsTlow/YyC+ONjSDqrmUJ/OvNQ3CtAf3I3O5V/tixWj3x76krnvCl3g== 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=dXZdwrj/9t/abLl6GSP7mG0tJiXgJv0q7ngCCct0T7o=; b=j61CWJPYubHWN1mTxK7XCLJBo5WqwMzuFSUcm5mDyzSnSoUhugBAUkgwAefUKHJEf4Yo8twzB+c9BzpSg2Rit9+yyRjiHGq5QnKczcF7LbhoOKt4Pc67o7fuc/h6N39dbboBzND4VfM7ALKFraaDlzbT1VMrek43Fn6L3aFXo5o= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:07 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:07 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 03/15] block/io: split out bdrv_find_conflicting_request Date: Fri, 18 Sep 2020 21:19:39 +0300 Message-Id: <20200918181951.21752-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:06 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 94b77a62-3989-4f67-5e50-08d85bff7874 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q6atG4BOncKW/pK+56G0dMOtJa8RlaJA9/yGO3FgqQZerjlbkU887RnGnauiaXrMSxOlkgw5Q1xIyNQ/+VdMaUUw8/g76QIOZOAGMH2AV3tWkzf25b6RQBhXMv5sb+RQlh+pqV5MTRDSkkqW9gm0Hv88aXgl4LMnpvXcugVOE9IfyxEVNZlxLCpc/nz0eILGoQ20RfCJEQCOM1JIGeoxgSz08cdALPy7CNHgu7W3SeOY46gSe2bs75ruajEle6YhxzI0vPNrVjZpQ1wuTbd3fp80QEYGZTuIDAtV+1aSAjbdJB/exzdbVBvEPWow26MDEHZ+WJ+x8l2s6PHHwOqDS42SyAQCwUwqKWcIt2Obd4Sbohi/tspQDWp8Hs/C/QJx X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39830400003)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: cA6w96w309KadQL3mWa42lvogCxrlhUxJBFxODExJp1ymwJ6aE8sXNz2OAkAfag/rjlTCIW/XcfW64u/HwUK+UNxzECknYeTlPkfHkq7bHsZJ0eq+h7782DagQlJRweltaqi/2P3UgDjl1itYr0FFsruf1QyQ06RlIc8lKmsoOx7iHsRkHw2Vm4TGGdQshoVcmUwBnr+Qy9Gskowvj9nofJmnQeQw6Eb4yQC6uah8jqENYg/jIU0okRocRBJ2zTcx4LPO1D98iZWXrdefBWrUKzWWaUnJ+Q9a9y65XfaiYcaUwSw7QdDtP1zfs2tZahfyv+rIE7G/HXhlIFNgFqL/pXpu4C2WWVNm6il0jtpSy/bU8Vwd0GpLoM7/CbwqOuVXxBdNXGEQfjAoszUixqhSr+9q7WRUSRPQXH28Wtl82sCB4Yl1ECBkMUdUwUbFpsDePi6oEjMYZO54IXCObuRpUMK9Vg3yQROHDP3JJFMw2yMxMU3fE6yVEIZryv9L6sHIgOnDJYN9RkNSBvhZ54fPgqU6O24QCRcYDsuUo1tPozM98TTRlMUa7qfdxmLqBU0l56NrLz6mMzMGbP7QFEQq3nHmUHY20w89JQfbykztrevSxt9PcNiVdS1DxqwtGj4pAWBJQRAaktQ8fpw9hLgyA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94b77a62-3989-4f67-5e50-08d85bff7874 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:07.0825 (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: uyUrki1cF+CGPAsoP7WV14rAbkbOpZfCklaCEZQbFQ8SnwAPadN6Fxjgsd9eu+my8ajuxQ2bkWKxxNP4EQE1zgGSrdBcepOB87pH6j1el3o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.94; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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.23 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" To be reused in separate. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi --- block/io.c | 71 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/block/io.c b/block/io.c index 67617bb9b2..c58fd36091 100644 --- a/block/io.c +++ b/block/io.c @@ -727,43 +727,54 @@ static bool tracked_request_overlaps(BdrvTrackedRequest *req, return true; } +/* Called with self->bs->reqs_lock held */ +static BdrvTrackedRequest * +bdrv_find_conflicting_request(BdrvTrackedRequest *self) +{ + BdrvTrackedRequest *req; + + QLIST_FOREACH(req, &self->bs->tracked_requests, list) { + if (req == self || (!req->serialising && !self->serialising)) { + continue; + } + if (tracked_request_overlaps(req, self->overlap_offset, + self->overlap_bytes)) + { + /* + * Hitting this means there was a reentrant request, for + * example, a block driver issuing nested requests. This must + * never happen since it means deadlock. + */ + assert(qemu_coroutine_self() != req->co); + + /* + * If the request is already (indirectly) waiting for us, or + * will wait for us as soon as it wakes up, then just go on + * (instead of producing a deadlock in the former case). + */ + if (!req->waiting_for) { + return req; + } + } + } + + return NULL; +} + static bool coroutine_fn bdrv_wait_serialising_requests_locked(BlockDriverState *bs, BdrvTrackedRequest *self) { BdrvTrackedRequest *req; - bool retry; bool waited = false; - do { - retry = false; - QLIST_FOREACH(req, &bs->tracked_requests, list) { - if (req == self || (!req->serialising && !self->serialising)) { - continue; - } - if (tracked_request_overlaps(req, self->overlap_offset, - self->overlap_bytes)) - { - /* Hitting this means there was a reentrant request, for - * example, a block driver issuing nested requests. This must - * never happen since it means deadlock. - */ - assert(qemu_coroutine_self() != req->co); - - /* If the request is already (indirectly) waiting for us, or - * will wait for us as soon as it wakes up, then just go on - * (instead of producing a deadlock in the former case). */ - if (!req->waiting_for) { - self->waiting_for = req; - qemu_co_queue_wait(&req->wait_queue, &bs->reqs_lock); - self->waiting_for = NULL; - retry = true; - waited = true; - break; - } - } - } - } while (retry); + while ((req = bdrv_find_conflicting_request(self))) { + self->waiting_for = req; + qemu_co_queue_wait(&req->wait_queue, &bs->reqs_lock); + self->waiting_for = NULL; + waited = true; + } + return waited; } From patchwork Fri Sep 18 18:19:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273366 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3793DC43464 for ; Fri, 18 Sep 2020 18:29:34 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8F42921D42 for ; Fri, 18 Sep 2020 18:29:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="VPJyFTMc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F42921D42 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJL8W-0007gH-KT for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:29:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJKzg-0007K4-AF; Fri, 18 Sep 2020 14:20:30 -0400 Received: from mail-eopbgr40122.outbound.protection.outlook.com ([40.107.4.122]:8096 helo=EUR03-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 1kJKza-0004bq-Ex; Fri, 18 Sep 2020 14:20:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U9y834d9sRTFtrVjvsR7ntSVOLLV6z9baCGNBo2xQ4UcjqUy/+5q2ZPWM0yA/cJq2/HcC6A+0t9ZyStmziMO2513517y+i1IHXmOIMvog9L6Z9TloXJekr9mS0O5eWIQasK1QWiSUP0FeZOamaR/aLWet3/gfZuUb+KDYmBm+mLX8RW5Vy0PLhe1nbmFPafuwcqdpb8NyYEYtzOJ92sGZhL9myqsYaF8hcpoOAM+Alw9TU3vzkAkduvObTmswst3oVeQsJv7/QZD0OZamB6StVLzUcECNUioOTUPDnhL99XCQi5XTVdOC+Pgl7jcJtFzanAAsjC1OcF3RLmE0fX65A== 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-SenderADCheck; bh=gm93Qi+T6AU08KMubEm5erSARbQOXxuOvU6zNpSByg0=; b=YriIfsd4SAvkDE3z/31ZTajfZnZr3ClTVU4toJ1/ZYxEOK892pjZqI3oUmQk5ARyCPDOqN/9LJG+gXf56eJipB5Le0MWkF8ab43nmFtxrv3xBoS7uJ7TQNCJXx2bYNxF8/dbWIB/LxjLE93c75821j24h656JozH6nq3iX60xIrGaCXFOTs30H4qCFeRdGRQmlpLN8KtTOw37XDMfbDn2Dsiqpacz2zRnWl8JX4C9basxWx1sSY2HZ5q/20kkEzQP1qEDUcqvSMrCWULFyc0AO4LTOGvgDUqvj7yHn9cO3SDXtcT2MnPJcMKOmx2wjuwBYvY1wRqjU9aUW9PdRq5mQ== 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=gm93Qi+T6AU08KMubEm5erSARbQOXxuOvU6zNpSByg0=; b=VPJyFTMcCCFtxr2JwkPNazgZ3r6k1X8IBkUBNfJLUkJMa9vl+6vmZhRAZ4L9JgxipD9+22D+7uxiYRKnBPqyiMJl/byeK40/hmpBUCsdynmkoqIYC+Zgkv2Ny74SCPhPtnnY85bYaRe9DX1bpBV3vSt3JKRUzMzKKbWbhpnws50= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:08 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:08 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 04/15] block/io: bdrv_wait_serialising_requests_locked: drop extra bs arg Date: Fri, 18 Sep 2020 21:19:40 +0300 Message-Id: <20200918181951.21752-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:07 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c5b83bb-3b37-4005-9760-08d85bff7900 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oPVWzPDiXlx+lKOXqrMmPJOSh1oR0Ld52/C7mRu1co4DzKX/qPcFQ/rfIz14vGeTx/XmuTFgBrss6fhof/mwu2uVb7kkz9GxLGF0SY/ywra4SO7EgY/fbL6kS8RhQqpUhDm3iMFW+k8qnCQFdIL09aU1H+5/77Uj+jAsHwslX3tnF7O1LuTI9481mNfXzmpHLclmBb6AAVu14waj+vGa4PPyITog1SCPg02IWxpwyQQi0Wdism6m4OcPbjnsaCD+ffoYHEbXeAdHnEOMODGtET9Z6aGOnH6yuqdJNPrexbmmHSJrX/L9y85ndo1nWHakKq81un9xEIEtizWlayqnU4v3g5b0SVmD71zI+0FF23TIjpZpz4e6ZJB1a5qXRfG2 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39830400003)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(45080400002)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: W/p/3OGzB5Z77RL64DeiluoN+Upao0gLPohMTBC6CZO88ZIVo5fllpbIu8qCJIgFIpMDMMk6MFoDMC8HXG2u+lxIfjQ+OZ2pcGo/aLtaph0wqYpJMjmwzPzViD1MBvxajbIb/8nY9iQ8dnAxJe8zAbE8N3gt/88g/bCdLZNU1fJ+yxNjkGcQ22yiOfpU7QYk+47u+SdolmsQT+VDw1PL6K3TdBejayRly67gr8vvQgnYpZkCY4A5HepqkyxUcZG6l7jFNHFn1tFH3KkipjKkZFdq2syzffJkl2BqmG4To8f0KasRtNLoHMoE3ODnuRJ+Cgj0kioB17WFgKDJJfTcMj44uRS943yiDtF5xORK4jpgT0MCcILqcj8AGqRFgtoVbamxs/1yBnBzuI6hKKFFdg03nkQxjYgCBxiG+3Kl2L0DE+YD9qdBJvNeE6BZnlJ9RlN/NdTtbpUQedzIeDdO1OFBbSA1aQwbnt1WRniN1cxmlpXS/vR9W4ysdLGGKGlThgFGDNhwwiOh+I2gLgfHEbJ7rYa5gxvp6B1llCYYXhBgem3CBNjeW3PKOcncLJfhY9H5as7SvsSJcpsX4FXx/ZtoY38lDSId1Gr/f4cG4MX5NAxx6vBufjzW5aobz2v22/Rpw962l/IQ6xo3axhiaQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c5b83bb-3b37-4005-9760-08d85bff7900 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:08.3081 (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: w9/qbE6ARO/kWfqssdQF5jCYU2zlDo+/2KhhXtyERvQW6tyty5u2VwaQ5H086vrG/vSRDglVBn9fU7NRSJQd9xWbcza1VabX/VENzGVCUXk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.122; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:06 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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.23 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 is linked in req, so no needs to pass it separately. Most of tracked-requests API doesn't have bs argument. Actually, after this patch only tracked_request_begin has it, but it's for purpose. While being here, also add a comment about what "_locked" is. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi --- block/io.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/io.c b/block/io.c index c58fd36091..ab9ef7fd1a 100644 --- a/block/io.c +++ b/block/io.c @@ -761,16 +761,16 @@ bdrv_find_conflicting_request(BdrvTrackedRequest *self) return NULL; } +/* Called with self->bs->reqs_lock held */ static bool coroutine_fn -bdrv_wait_serialising_requests_locked(BlockDriverState *bs, - BdrvTrackedRequest *self) +bdrv_wait_serialising_requests_locked(BdrvTrackedRequest *self) { BdrvTrackedRequest *req; bool waited = false; while ((req = bdrv_find_conflicting_request(self))) { self->waiting_for = req; - qemu_co_queue_wait(&req->wait_queue, &bs->reqs_lock); + qemu_co_queue_wait(&req->wait_queue, &self->bs->reqs_lock); self->waiting_for = NULL; waited = true; } @@ -794,7 +794,7 @@ bool bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align) req->overlap_offset = MIN(req->overlap_offset, overlap_offset); req->overlap_bytes = MAX(req->overlap_bytes, overlap_bytes); - waited = bdrv_wait_serialising_requests_locked(bs, req); + waited = bdrv_wait_serialising_requests_locked(req); qemu_co_mutex_unlock(&bs->reqs_lock); return waited; } @@ -876,7 +876,7 @@ static bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self } qemu_co_mutex_lock(&bs->reqs_lock); - waited = bdrv_wait_serialising_requests_locked(bs, self); + waited = bdrv_wait_serialising_requests_locked(self); qemu_co_mutex_unlock(&bs->reqs_lock); return waited; From patchwork Fri Sep 18 18:19:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305040 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BED94C43463 for ; Fri, 18 Sep 2020 18:24:05 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id BFE1820DD4 for ; Fri, 18 Sep 2020 18:24:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="pnhNP4O8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BFE1820DD4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJL3D-0001JK-OS for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:24:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJL01-0007OZ-TE; Fri, 18 Sep 2020 14:20:48 -0400 Received: from mail-eopbgr40118.outbound.protection.outlook.com ([40.107.4.118]:41027 helo=EUR03-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 1kJKzp-0004nY-HX; Fri, 18 Sep 2020 14:20:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NS21SY2f1fZ4p98EML+ndfW+je4tAoTg12qKbCU16VsMElJAFavaBwqBjibBeuMWtl4e0DSusi5723DPwHZ2lfmngGyRKaUkqzkLwBOB7sCNHy/sqzRnJrW4aPDPURMYWLpRiXtTSUDIBMEKi05uzO9W/ou2peusf7oBRDszPGaloFjSp3v40lhcBskHaFVbHiHZ9QxJwLv/bW2f8HnVT3CFi9JwU5BVMct/JRsMicPbCoKvR5lTuTJ0303zFPnpW6DXpggZTfLxJYkK6EGrQ1dFX22sSiUKZrmfieGhcrEJIwD7ncrXZAY9S6beNEsGk3Skv7cm1R5qcQT8ag+ifg== 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-SenderADCheck; bh=XFBZkftLXX/Y3HnlWPhJKOZuo8TRJWRrZ+Ziw+DB6aI=; b=I0oiLIt9gLAX0tOEKNEOHJq7b0sQJBoIa9i4MRi9N4djK0+7J0iq+pa8RXPwtq7BEed1HvZh/WLe96g4ISgVZsZgX+CvHSEmNi8h9tT7l21NIM1WR5+a9D7lcWn35tVnYOck8Zw1iFKMpB0ryd2gz7wOs/32Oj4ve9uafXlDr9mZeFw1570L47zqb3xByGE2mbz6GlanpAwfZWTo3Es35Z5lE+V17hRSh6CgQ29CRPSvjK8t2xReT2oj6fNaO2hkXaSjVh742+Pw7W6gXmz8xY85Ee8HUjg38Y8Ex0aW8ZAksDwqWMGuoPLa7Q09JqxP9iLIwt8lRUbRUV7zCmET7A== 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=XFBZkftLXX/Y3HnlWPhJKOZuo8TRJWRrZ+Ziw+DB6aI=; b=pnhNP4O8VInriwlxDw54JnRna1kE70XrxvcWwgPEs56qoN/p8pl93DcoFdOXe6KKAFbXEUilxCn03Zoo3Nxuld5SSlD/55RBli5mPI8lUnY116WZt4/47W5Ok/MYYJ133FQjJn9Y3jxuoMVIDaUptVHSG/1W76ifk1F5B9Vogz4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:09 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:09 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 05/15] block: bdrv_mark_request_serialising: split non-waiting function Date: Fri, 18 Sep 2020 21:19:41 +0300 Message-Id: <20200918181951.21752-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:08 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1fbad14d-c543-4b3e-68bb-08d85bff79e3 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b4FrA8cbwNjE8ra0PGcOW9lFbttviwXNc2cyqdQpREXqWwJO9yDMHkuHnxp8CpNL+RcBPOLMhA5UfingSR7CASVmrbMnC8PrS7gqrW1JUv/ZomN+jz7jbBaKTP0IMW1l7uSRgY6/wm5H15IewJJDH9vtbO1+WxmdF1EU+eYE+0vfzfm3H+kXwFtOEGUBDKFFsL7yvsldJRCstu7/Ar5zUsunS1PC5VSu+Mvbi3Z/7t1nSlVK6YWgDTJLy2waW8k3vpu6boxyoodWfH8Lk5NeRsfARf7oNnC/Lm/PhAorLqMZTVx7g9Y9axS1az4KCoDblns8t7tMZ7V56DlIRf7TF4wi5oxjSjU3di1emaGNKJZLrgbuGBOmr6NN1W0xT+hD X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39830400003)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: mWkFK5drIQ4MZuzOWwgk+2soJE7JFAgnZx++nqzmZ4jJ/Q730bIKMDGU4a8X5i7PVporp745SHoSUAhk8RlbF0mSxc8BpnKJlC8jejUr+tvjHA5z002tK9Wu/pJqt+Xq7xtn+b+jhPmU2L+FgdtgnM/4fQphFcQlwFTEMS0pTWk30ml18mT1uEzizqcSXrimTFaHzT2M52c14OD7sFtYVNLfkwV+Yj+1F/4i+2OOQZoQCXXzN3FU8MtNNWz6mkKp6BNgK3d2LgnuD3xVRNPlwIe68zN3qdzjKcgSL8FKGQBYImnGJJdw6GY5gwWvSayvt1yO3FuXITBOglACoBsFsGR6tEi4MQOySu7c+1GMHCDbbguo4TKappIaABC1XjtAP2wlQL5H/40WTYz6h3T3wV/d29Z5pFQ/vbGng88RTSpF6E5Riip1fuU9YcRzKWjqfHgvk1vcL4l81doSwuqNrvMz+TwCu25GCLGAMi8ZjztfEs1RPO1Iz6Wm5ADX2dA+2J/5kqvpzQaMLS9SM1hBoss6R5PgAZPEct1FzFblp1KQSYhYddO5qzvVLsb3fZQ7T2M6n8AGkIkk43mSBKEh/fl+1XUMisycniozW30pcWOWsVqPPMFCNhgS4n4FIzYE9N7Q+vBzI0iOrFZ5B54cqg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1fbad14d-c543-4b3e-68bb-08d85bff79e3 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:09.4641 (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: F+GyL5lG9D7vLyBcvIXhZVwtP2qBNCHhDBhrTEi7H7EL1hZZN0NYZFQU9riTGvwG0XHJJd3/h8DYyKQ/PvPLgfxcVQY8km1evTwVRVSOtX0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.118; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:23 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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.23 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'll need a separate function, which will only "mark" request serialising with specified align but not wait for conflicting requests. So, it will be like old bdrv_mark_request_serialising(), before merging bdrv_wait_serialising_requests_locked() into it. To reduce the possible mess, let's do the following: Public function that does both marking and waiting will be called bdrv_make_request_serialising, and private function which will only "mark" will be called tracked_request_set_serialising(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- include/block/block_int.h | 3 ++- block/file-posix.c | 2 +- block/io.c | 35 +++++++++++++++++++++++------------ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 38cad9d15c..887b0668d8 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1052,7 +1052,8 @@ extern unsigned int bdrv_drain_all_count; void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent); void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_parent); -bool coroutine_fn bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align); +bool coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req, + uint64_t align); BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_request(BlockDriverState *bs); int get_tmp_filename(char *filename, int size); diff --git a/block/file-posix.c b/block/file-posix.c index c63926d592..37d9266f6a 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2953,7 +2953,7 @@ raw_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes, req->bytes = end - req->offset; req->overlap_bytes = req->bytes; - bdrv_mark_request_serialising(req, bs->bl.request_alignment); + bdrv_make_request_serialising(req, bs->bl.request_alignment); } #endif diff --git a/block/io.c b/block/io.c index ab9ef7fd1a..9b148bb8ea 100644 --- a/block/io.c +++ b/block/io.c @@ -778,15 +778,14 @@ bdrv_wait_serialising_requests_locked(BdrvTrackedRequest *self) return waited; } -bool bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align) +/* Called with req->bs->reqs_lock held */ +static void tracked_request_set_serialising(BdrvTrackedRequest *req, + uint64_t align) { - BlockDriverState *bs = req->bs; int64_t overlap_offset = req->offset & ~(align - 1); uint64_t overlap_bytes = ROUND_UP(req->offset + req->bytes, align) - overlap_offset; - bool waited; - qemu_co_mutex_lock(&bs->reqs_lock); if (!req->serialising) { atomic_inc(&req->bs->serialising_in_flight); req->serialising = true; @@ -794,9 +793,6 @@ bool bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align) req->overlap_offset = MIN(req->overlap_offset, overlap_offset); req->overlap_bytes = MAX(req->overlap_bytes, overlap_bytes); - waited = bdrv_wait_serialising_requests_locked(req); - qemu_co_mutex_unlock(&bs->reqs_lock); - return waited; } /** @@ -882,6 +878,21 @@ static bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self return waited; } +bool coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req, + uint64_t align) +{ + bool waited; + + qemu_co_mutex_lock(&req->bs->reqs_lock); + + tracked_request_set_serialising(req, align); + waited = bdrv_wait_serialising_requests_locked(req); + + qemu_co_mutex_unlock(&req->bs->reqs_lock); + + return waited; +} + static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset, size_t size) { @@ -1492,7 +1503,7 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, * with each other for the same cluster. For example, in copy-on-read * it ensures that the CoR read and write operations are atomic and * guest writes cannot interleave between them. */ - bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs)); + bdrv_make_request_serialising(req, bdrv_get_cluster_size(bs)); } else { bdrv_wait_serialising_requests(req); } @@ -1903,7 +1914,7 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, assert(!(flags & ~BDRV_REQ_MASK)); if (flags & BDRV_REQ_SERIALISING) { - bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs)); + bdrv_make_request_serialising(req, bdrv_get_cluster_size(bs)); } else { bdrv_wait_serialising_requests(req); } @@ -2069,7 +2080,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, padding = bdrv_init_padding(bs, offset, bytes, &pad); if (padding) { - bdrv_mark_request_serialising(req, align); + bdrv_make_request_serialising(req, align); bdrv_padding_rmw_read(child, req, &pad, true); @@ -2183,7 +2194,7 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, } if (bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, &pad)) { - bdrv_mark_request_serialising(&req, align); + bdrv_make_request_serialising(&req, align); bdrv_padding_rmw_read(child, &req, &pad, false); } @@ -3344,7 +3355,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact, * new area, we need to make sure that no write requests are made to it * concurrently or they might be overwritten by preallocation. */ if (new_bytes) { - bdrv_mark_request_serialising(&req, 1); + bdrv_make_request_serialising(&req, 1); } if (bs->read_only) { error_setg(errp, "Image is read-only"); From patchwork Fri Sep 18 18:19:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273369 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAACAC43464 for ; Fri, 18 Sep 2020 18:24:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2592220DD4 for ; Fri, 18 Sep 2020 18:24:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="VNbk10Bu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2592220DD4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJL3K-0001XY-3K for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:24:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJL05-0007Pl-OP; Fri, 18 Sep 2020 14:20:49 -0400 Received: from mail-eopbgr40094.outbound.protection.outlook.com ([40.107.4.94]:32391 helo=EUR03-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 1kJKzx-0004dZ-3P; Fri, 18 Sep 2020 14:20:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R/zVnyG6KsW9i+HoAYJUJbuzT6hikN2xQN6UM78vhHxHyOTp5vj8SH+XZhnU1KRBw6R/kmZ6Yzg81a7mhKn1VqrsbT/jpBTAA+FjycX3K0+EMWvtkp90XyQxvgr4lo4mO8Y+i0DvPp7rS1AiUOL3PNErr7VSZabdh84KQ1+2bRBWqtLUbTKYaZ0utdCKq9ZOj9BlwVhFFBEl0vog4CIXTZgv7JKuriHqA8McoPTHkMkMbdL4Tovougw+ioLIwd8tV6+PVeDZNqPAS/uHkG6v8puQcD01QyKQWjWkjBawzRog/lvFmru5eBcHHFZLsCCA3uo6DRCoeehxbaJwjTopCg== 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-SenderADCheck; bh=HQer89qlnroTIjR20IfVIS919Z4+wTqk+d3jeX+WZXY=; b=WkFMtxVvHga5SCgln4erTgmNM2lOcb+ujuXQPWRNJsahzbd3aE1KNiriW38U85Qif8Y1Ys4kZruaI8X2Lw0qzB9xc44X6IebfjULiIKuyfaYPvvQJuNXxntO750jmK2RstptVcjCG5ahiIbv+hEkySzVmLCutfdaaHl5R1FXlBUFWHJ+Ibp12q9Sbbkxv4Qg2B4aGF8l1D5Jqa0ILnPbqMMk9bA28oBUNcEwWPi+76fFFYNa5NTZCunss4sZRlpyhgL4OtsDsY7xrmfGQxTpQTlwsgdV5+R9Hbgn3PiqNgte3YLt0GoPF0oa0aQmLmv9AvDPrATQFHSSPYkMCr5DEg== 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=HQer89qlnroTIjR20IfVIS919Z4+wTqk+d3jeX+WZXY=; b=VNbk10Buogj5qAG/6mTlCNNgh8WKuARqQAwPWtsOdzBV/HTkZcQEycH2KZR1tQymeDm9zV83Ksv8uOZsmDLXtDgbuNaXw/v4LTkquEtCndbrJ/OWMF80lZCApvIo+Cp7GLbSWcwrWpwJXAqHkPAby9DsvE+usV28TYRsCNWDAkA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:10 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:10 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 06/15] block: introduce BDRV_REQ_NO_WAIT flag Date: Fri, 18 Sep 2020 21:19:42 +0300 Message-Id: <20200918181951.21752-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:09 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d30fd5a1-c6cb-435b-eed0-08d85bff7ab2 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:669; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S5NiX4Pi78pFkoXJPZQBWh9VLzrjLaYbd1JEcZU04fQRdLLNSljWkZrKc+r4sMsw01MWha218yXNAfDZciWkp70pI8fztR1JS2+4Ps2U7vVHsDNGMX9S7vyMxTV+7j6wA5GZaC5oSCyowG0Pw2GJQ9p7dZlLtzbliPG+lNke33l5Ggly1AwjhtPuPLVbkuugld41oeMlqp5u11kYHhdk8Rf++qGDjSjrGUM1WwvUSiKS6EAqAbAcEyHtABY+rSrBpWu5jsm474FgTAHxgcgkuX9hGcZQP2S+NvB+J2kAeI/VbGLshSSHdst/O+CrHLV9HRALhsUOAxxdHj9l7dDvcsCdsl7fthlHV0usyw+CvPA4MpKnqH6JmmL6Z9Yd/N4H X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39830400003)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: GV5oEtyRaIHu3H5Mhsi2wCAzbXqO8j4P8hPMAG4qaO29WE3cXEWITreVbxcwNvTKksT1eaJXdFO/dyKJTg9QG/RTKDQspjM8po9MrZmJoZcnP/IcBslNivURI36y9bswpEyxZbE8JC1ML/kr1Yz6varTGXGZMF+B3ftEuUcUmcGuh56qONgr+1KzIP8+mvsohSJLuyRwh0HXPIBCCZw2bV1s+oJP3JHCT8Twho750OCSQ8wQRQKHSr0B+ySm+ob9yimbVV4WQfP1zSvlT5sVZ2ip4mBOsV9zljJ/FQMLRYd5wwDnUFBVA4XlxnasRdm/haXP+WNPNRHPqQf4vLjbRnqL1wAbgBxUtOgargvzW/WaQbUaucbLXC1jIatmp9WnMXbtUe6VAcpWTT2ZXZTW3+ruTRlQakBxoBKnZ4jOlDwHjnN6jdsTTwrO2HwpKiB4JPbnt6kun/YAN8t2DLnvH0DwSK+8jBRi7VTUwiy5DWRtyF1U50LAoA60+sghG4BM7jY6mY2yuTAhBBl6pXgkOjc7RRJdzWXYlfU+ZTMzVqM6seaql3ZichpLW/NSxhpNWesJ7OWrfD2t8huLn0Wf4CDwy/iFYNM95tha4NvkGvtXgED9rx7FR37nCfT2UZl5nUByitz74jgBwgtYDhVwzQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d30fd5a1-c6cb-435b-eed0-08d85bff7ab2 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:10.8251 (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: bszmamVY3MtKpMOCtONfpYHl3DFhbwdCkC94rXGbG7qVTSpyuoeYPIIpAfFUW2kUxM5lFmG9r37VLukD6bQBoZ2KJCNBjUurXUVcVPW2b5w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.94; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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.23 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" Add flag to make serialising request no wait: if there are conflicting requests, just return error immediately. It's will be used in upcoming preallocate filter. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- include/block/block.h | 9 ++++++++- block/io.c | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index ef948e3f34..e7188fea05 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -67,8 +67,15 @@ typedef enum { * written to qiov parameter which may be NULL. */ BDRV_REQ_PREFETCH = 0x200, + + /* + * If we need to wait for other requests, just fail immediately. Used + * only together with BDRV_REQ_SERIALISING. + */ + BDRV_REQ_NO_WAIT = 0x400, + /* Mask of valid flags */ - BDRV_REQ_MASK = 0x3ff, + BDRV_REQ_MASK = 0x7ff, } BdrvRequestFlags; typedef struct BlockSizes { diff --git a/block/io.c b/block/io.c index 9b148bb8ea..fdcac4888e 100644 --- a/block/io.c +++ b/block/io.c @@ -1912,9 +1912,18 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, assert(!(bs->open_flags & BDRV_O_INACTIVE)); assert((bs->open_flags & BDRV_O_NO_IO) == 0); assert(!(flags & ~BDRV_REQ_MASK)); + assert(!((flags & BDRV_REQ_NO_WAIT) && !(flags & BDRV_REQ_SERIALISING))); if (flags & BDRV_REQ_SERIALISING) { - bdrv_make_request_serialising(req, bdrv_get_cluster_size(bs)); + QEMU_LOCK_GUARD(&bs->reqs_lock); + + tracked_request_set_serialising(req, bdrv_get_cluster_size(bs)); + + if ((flags & BDRV_REQ_NO_WAIT) && bdrv_find_conflicting_request(req)) { + return -EBUSY; + } + + bdrv_wait_serialising_requests_locked(req); } else { bdrv_wait_serialising_requests(req); } From patchwork Fri Sep 18 18:19:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31DD6C43463 for ; Fri, 18 Sep 2020 18:32:08 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 99993221EC for ; Fri, 18 Sep 2020 18:32:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="Z1BZXyHy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 99993221EC Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJLB0-0000rF-DW for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:32:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJL05-0007PX-Kz; Fri, 18 Sep 2020 14:20:49 -0400 Received: from mail-eopbgr40122.outbound.protection.outlook.com ([40.107.4.122]:8096 helo=EUR03-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 1kJKzx-0004bq-2l; Fri, 18 Sep 2020 14:20:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U00POU5+R4MxFivxJM+qUoYRUaytRiSG1+MAypl0bK4PyY20uGxJrdTozccKbbxmMppP8Iejmjv93zIX7Z4Pfk6GOQOm55NHMZYi6+Ud/4cV1UtjMesPlc+R5JNbzvu4sXkCOhV0M8Yg4078EiIZpnabe0DSo4usrnzuGtbrxsEY7++JOUA5TKWpy2BCmKAyJJe9SXDuuVQXu5GP4o08pQhEV8V/B/FklaJHGHLV7+yCyJsZQbzBdCBPelccbwyP7M/DLIMFZUeDaEe+kk8iSa0Rq3QSmNfL70OXa4odTwm6RlmFbPa34UviG2OxUFbqsdXl5W+itzDWSff2vzcWhw== 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-SenderADCheck; bh=cHUGkqGe89HhWhkUXB4TbywcCFFX9NQ/duPuWlFW7YA=; b=ktz1Z/KF2ECbFkoR3HUNScv3mfckhvMw9RWomGEbrGlLYiSsOSNPGzke4I2dH9B2C4S3EHQMhVWhdA+Yd0yl9sDWyOY0yw9cd9qX5pEOhVztYK6kuQTwS+uHnjyPKvLZypemMxf7pmFnb3X1mWZoQMr+wFif1IfG5O11blFbn+7lXvLHeTm2vy9URk1kypkgzI1fCGmLSRy2WmpyGuhJMv8SP/ByIUMJNAAX0Ik88+EJ2RBVIZlvCZx+GpZP7Fl6t3KkZUV0g4BOqNGBF91L6GV5Ymu6WkbacHU/kRQaADaF30GDIe88RXcRScqbEOFyJb0BDdPIyvA96M1PmoE+qw== 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=cHUGkqGe89HhWhkUXB4TbywcCFFX9NQ/duPuWlFW7YA=; b=Z1BZXyHyBWhJOsa1qBXsssrpjnBfufb7doSpClN26yaP65htV1aqq5erEqwiBaMfeVXMHlG70e2BKOy91/dqW/Z1ov98IMMgZ4cWP2IIUyohjbOWSNno8dGYsssCD0RV7cKX2zaa4lrwGjf6uNvxHfOCQiQnoGjeE+eCx8O18Ko= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:12 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:12 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 07/15] block: bdrv_check_perm(): process children anyway Date: Fri, 18 Sep 2020 21:19:43 +0300 Message-Id: <20200918181951.21752-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:11 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 443c538f-6aa1-4318-e0f6-08d85bff7b48 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6yiQkXFQIIg7sxcYip+y/WeVwlpeFuShZhI7/MJb+mGZCh3nrMd0GuncQ95yYR1RWkj9JNQQC9J33wXg1Qr1FJKCbhVkCGubYaK6xZrVKajHFBUtZ2ZVLpA4FYoKPaYv6DKAHuD74zt8q1kdaeTIbM0mz/poHPSOIFN4DeaK5YI8AEwOqq9YobuffOLN+Di+Oq2Pes/PR6jmjmO+1/a9GKGsB5/ZNtI4S9li/fy9Eddihn4iFfSpOCvjtIfTtZB6s/GNzCZveyfCKgdGNSFxBAxUTb+w5r6Y4JFHjysnQRdQqcZX9cs6Hpm6XJ7DHU7gqKb03nxzD4B4vjsTGcEpYpIs0Oegj+fSsmI7od7/lujw0PBegjcULeuXovZb8vOs X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39830400003)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Qo38O5+2E/ztE2Z6zNtxrhoskQBl1jgOSLM78rrtLc+MzqPJCfS1g3w2zrN8dhK4GBfPiQoOIXCCKTyfLlzyIGSYO8P9WqF8MqUbhcS8XMCXB+64jtscvWD45/pflugtAJ45ngxz6lhKH+l/h8fDfvK4blY2sh/fb51OuJQLTAEl5ReFPdA/KERHAq898o58QPes3Dme7dAw/qHf8O8ARaOeLyV+j7/nNvIuM+GMqfeHsbxXV2Ns5IhSRgQDENuSvPsKr8Ea8v6+u5GBvWY25a3M1q+ZAdB0NFzf23ZkW2AAm3eXUGEWBztCAFCVzu10yXR5Zc0f8sVe5Nh9W8FdpNrEu04lWxic6oWc68Zsia9fQf3N0x1M3Vf50PyK2hhyHzszzsqXfB1rTa0zZM+siEsoS/5LrSRgbH/aLPBU0yPTfVRvJ5iOZBgJFHnhGRHvpFrT0xoJP3f4tH0luFqEchY7SdEAgBYa8GDXl1vEJBn82pgjA4u3YBsVAGDRntwLFSYGnp1PpF1DHha9mML8O7WtfCCSyo1a2GsnE7pHzL8xbbrCuGJSRKWtp3KmclJ2qrVXqDlpjVvS7T/tcUYRaqxEIpYX3CTuQmyATWcMHIxNCsfwH2JsWCgxFCm4ePqpdxGFm0q9aaSfqqu/v+xgvw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 443c538f-6aa1-4318-e0f6-08d85bff7b48 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:12.0975 (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: H2sBzyXCJfVhM6DyB5o9eHHUL3hkj+BTSOKGbwBCGwDikKIPLrgbuOQLIKzT4w3WhxAWupvrG3GbnWjcRg/+mbz9n6aZG1ue73+vuWupNgY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.122; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:06 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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.23 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" Do generic processing even for drivers which define .bdrv_check_perm handler. It's needed for further preallocate filter: it will need to do additional action on bdrv_check_perm, but don't want to reimplement generic logic. The patch doesn't change existing behaviour: the only driver that implements bdrv_check_perm is file-posix, but it never has any children. Also, bdrv_set_perm() don't stop processing if driver has .bdrv_set_perm handler as well. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index 9538af4884..165c2d3cb2 100644 --- a/block.c +++ b/block.c @@ -1964,8 +1964,7 @@ static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_bs, /* * Check whether permissions on this node can be changed in a way that * @cumulative_perms and @cumulative_shared_perms are the new cumulative - * permissions of all its parents. This involves checking whether all necessary - * permission changes to child nodes can be performed. + * permissions of all its parents. * * Will set *tighten_restrictions to true if and only if new permissions have to * be taken or currently shared permissions are to be unshared. Otherwise, @@ -2047,8 +2046,11 @@ static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q, } if (drv->bdrv_check_perm) { - return drv->bdrv_check_perm(bs, cumulative_perms, - cumulative_shared_perms, errp); + ret = drv->bdrv_check_perm(bs, cumulative_perms, + cumulative_shared_perms, errp); + if (ret < 0) { + return ret; + } } /* Drivers that never have children can omit .bdrv_child_perm() */ From patchwork Fri Sep 18 18:19:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DDB2C43463 for ; Fri, 18 Sep 2020 18:34:35 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B6470206D9 for ; Fri, 18 Sep 2020 18:34:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="v9TEiA9d" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6470206D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJLDN-0003Yd-F4 for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:34:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJL0B-0007a2-RP; Fri, 18 Sep 2020 14:20:57 -0400 Received: from mail-eopbgr40118.outbound.protection.outlook.com ([40.107.4.118]:41027 helo=EUR03-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 1kJL05-0004nY-Pj; Fri, 18 Sep 2020 14:20:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kP3KKFKxFNViuQTLSbu42BloRlYFLTyEpLyiEuBsQPchLcTPPPFRmv4o242hjR15kgaqcNvie9QBwCu0W3Kj3vWFPCdtH3lm3Uby6sfxVUjjc/7oTmatoCPXEVJwhfXM6xfkfn9ef89X764xr6+eT0276Fjgg0KjuYuyAZpEe+lqQHf2R4m1unSLPXmqr+7kZaROj6hD5cosEI/p18ITnbEoeEXgqncYB00ZW4GjCfnp9NQ3O+BvqzjfhI1eqbbgfzUM8fv5emcHcg9DqzLo8Xdqs8H0mmphOdANIIcJApCf1k9BHQKc1/2to+0UGQvy/mLyLSsu/fhWSbOJUfoTKg== 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-SenderADCheck; bh=WFtDdBsLRaAa8u2s9iXVijeZsGRzBTN0x5Wv3n+u7Vo=; b=T2IK6Ao/49ZpsRPDMg8xQPgbxt0Pnhb7sZPEO0JaXYQ6N0B3JZq4NWKB/kOX92igJtMq2SAdY5HhNCAXpnZhiYYEt2UqBxfeg2bo656KZS1w6bbzJ+3qBLox86QuaC/MOiFVQP1iBOHwNFgZk4J+7wEx+OcDeP4CkDOIRRGYF17XHdHhor8JM0nm/z3znuZ59Fmz3WYKI5KGku4MgG+02J7WMJJqXuWxOEQmMm2B/tTp8Y6gw1Rpua839Jbf2WLao9OlSuVeknvSJ06hngEIAVv2mL9SqAzoExz8KCg68Vqk1xpkpyZNqXRcjDc644Rc1E2u6UpGQy9xJRVku0Tg+w== 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=WFtDdBsLRaAa8u2s9iXVijeZsGRzBTN0x5Wv3n+u7Vo=; b=v9TEiA9dF3rrp1ncP5Zvpl0fIBhWv71DtFybNVZjBW3h/1E2AqGrb3T9DGn9MX1FfMgToUy3DG0w6Ov/NXeneSTDTa5FISCjSpnLSxumbEUdekYuUZnortLnljqZ8zuFUaeV4+JsTTBxdgPjywhK3BvZFju5FQ23xG0ERS6Eb8c= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:13 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:13 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 08/15] block: introduce preallocate filter Date: Fri, 18 Sep 2020 21:19:44 +0300 Message-Id: <20200918181951.21752-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:12 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae79f881-b8c5-47f2-9d58-08d85bff7c01 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:64; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iGfEArPPwYrZXJD0W83j1Lp90AzU7FFQFaruO1BN8W9UDEg+n0oy+GW0BJXijnYBhO3V6XgNeP+PTn+QP0jxbiiOgY3xdZBaMa3WdqNj1VIBF/Ii00Z613TGjBxaG613yHZDjRbJggzH3XcnSZtjIgTq6ayx2pyOyxt4kamY3LuL0QKuuc9zydKIheqK2InYL2QWoSMEhZmLwC34viEMHDHLkVb2YLyKyQO9yK5/Zg9e/fcMPmwV8D7HqEC+01c91M5rg20E8knDTNfRAwPXoATBPHmK+vzYMYnPux0KOhphRaoJTbMuC8dLYLFhdjC2ub1bvM7pGk6mH5wyhL+LQSJSJDhF+I9Y0dfb4/9zFSCk1GXbzcBpB4Pb3Z6iaUfvNL7Z0zAbTqkcyBQWlLfAas8nFiJNORY9kKVFmXYqNGRYxUnFLhuJkEXoc8blQSwVqbfQLbKzV1IHTXr06kfk4U33+fvzgR7Xt5Tp6gynjEkTFUle/aLzvPVudmYspojT X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39830400003)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(30864003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: IYUMjbJT36KHo0w3RmlH8TpoIt/x6BDUg8YdzwoxtNCXWDC6+i5SDonEkw/GDbgphlQV5khG4uJXMHMClQaJhNcC0Ye/oWP2ntvYxJiv8WpnS7ATJh4Zba/jQbJAS4HLXH4YyaM7jo9fOjYocr+z5x/8Tx4a/mYF7qt9scs8QoWy4TwDoiFCIBLgvZrG7QwKriw2Ey3VWhxpivATJ7nobZ54GfpnaT9fOwJUXnCkQxvC4c2mgmAptPLNpUvaQ++wocF4YKwWwoGKI2tDlDtP5NgA77ALLQBZUutYRZWn4gEi6d28Oagx5hdxgNEOERCTa6AcovmrmdfvGn0W0xxpZkVO3RL1/DiXG09lIvwC4u8bnulYvPix3+UOCtg/TZnsMRiqI8bMAUGexdEVk3KwPAfzgY0+X+AG5VpqF894Y0eKI1LaQ5FAVAiFm6dehiPCya5y8rHFNx4smXzSpEhSJL03WUt0OcuPcKZ/1V76Mu0mqtnLY3UuNl2XCbMqFwW4pPPL6ZsU21Ukn1HaZWanqKhrGWXSvgFkXyqd2mhGmU4cuYa3Cbn5jVmrdmvx1Lb8NzlZ929Y4mabzcgDhu33MJD0FpPkM6bxYAcHoif7TxF8764nCLr8mJFQeOxAw13VKNr29WNoq5UA9kvx6s6Lnw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae79f881-b8c5-47f2-9d58-08d85bff7c01 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:13.1140 (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: 7U03Fn/kVRWjbgQcfZlZXfEbPHOlhtS3gT/WLgjk0/1WV5Id6JP2Cujtpa4/rOIBgjjqNrbf4Td8+Svv+85qdEoMdQWw0dnbMo1ULL5/Fa4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.118; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:23 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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.23 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" It's intended to be inserted between format and protocol nodes to preallocate additional space (expanding protocol file) on writes crossing EOF. It improves performance for file-systems with slow allocation. Signed-off-by: Vladimir Sementsov-Ogievskiy --- docs/system/qemu-block-drivers.rst.inc | 26 ++ qapi/block-core.json | 20 +- block/preallocate.c | 556 +++++++++++++++++++++++++ block/meson.build | 1 + 4 files changed, 602 insertions(+), 1 deletion(-) create mode 100644 block/preallocate.c diff --git a/docs/system/qemu-block-drivers.rst.inc b/docs/system/qemu-block-drivers.rst.inc index b052a6d14e..60a064b232 100644 --- a/docs/system/qemu-block-drivers.rst.inc +++ b/docs/system/qemu-block-drivers.rst.inc @@ -952,3 +952,29 @@ on host and see if there are locks held by the QEMU process on the image file. More than one byte could be locked by the QEMU instance, each byte of which reflects a particular permission that is acquired or protected by the running block driver. + +Filter drivers +~~~~~~~~~~~~~~ + +QEMU supports several filter drivers, which don't store any data, but perform +some additional tasks, hooking io requests. + +.. program:: filter-drivers +.. option:: preallocate + + The preallocate filter driver is intended to be inserted between format + and protocol nodes and preallocates some additional space + (expanding the protocol file) when writing past the file’s end. This can be + useful for file-systems with slow allocation. + + Supported options: + + .. program:: preallocate + .. option:: prealloc-align + + On preallocation, align the file length to this value (in bytes), default 1M. + + .. program:: preallocate + .. option:: prealloc-size + + How much to preallocate (in bytes), default 128M. diff --git a/qapi/block-core.json b/qapi/block-core.json index 2d94873ca0..c8030e19b4 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2819,7 +2819,7 @@ 'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', - 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', + 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', { 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' }, 'sheepdog', 'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] } @@ -3088,6 +3088,23 @@ 'data': { 'aes': 'QCryptoBlockOptionsQCow', 'luks': 'QCryptoBlockOptionsLUKS'} } +## +# @BlockdevOptionsPreallocate: +# +# Filter driver intended to be inserted between format and protocol node +# and do preallocation in protocol node on write. +# +# @prealloc-align: on preallocation, align file length to this number, +# default 1048576 (1M) +# +# @prealloc-size: how much to preallocate, default 134217728 (128M) +# +# Since: 5.2 +## +{ 'struct': 'BlockdevOptionsPreallocate', + 'base': 'BlockdevOptionsGenericFormat', + 'data': { '*prealloc-align': 'int', '*prealloc-size': 'int' } } + ## # @BlockdevOptionsQcow2: # @@ -3993,6 +4010,7 @@ 'null-co': 'BlockdevOptionsNull', 'nvme': 'BlockdevOptionsNVMe', 'parallels': 'BlockdevOptionsGenericFormat', + 'preallocate':'BlockdevOptionsPreallocate', 'qcow2': 'BlockdevOptionsQcow2', 'qcow': 'BlockdevOptionsQcow', 'qed': 'BlockdevOptionsGenericCOWFormat', diff --git a/block/preallocate.c b/block/preallocate.c new file mode 100644 index 0000000000..6510ad0149 --- /dev/null +++ b/block/preallocate.c @@ -0,0 +1,556 @@ +/* + * preallocate filter driver + * + * The driver performs preallocate operation: it is injected above + * some node, and before each write over EOF it does additional preallocating + * write-zeroes request. + * + * Copyright (c) 2020 Virtuozzo International GmbH. + * + * Author: + * Sementsov-Ogievskiy Vladimir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "qemu/osdep.h" + +#include "qapi/error.h" +#include "qemu/module.h" +#include "qemu/option.h" +#include "qemu/units.h" +#include "block/block_int.h" + + +typedef struct PreallocateOpts { + int64_t prealloc_size; + int64_t prealloc_align; +} PreallocateOpts; + +typedef struct BDRVPreallocateState { + PreallocateOpts opts; + + /* + * Track real data end, to crop preallocation on close. If < 0 the status is + * unknown. + * + * @data_end is a maximum of file size on open (or when we get write/resize + * permissions) and all write request ends after it. So it's safe to + * truncate to data_end if it is valid. + */ + int64_t data_end; + + /* + * Start of trailing preallocated area which reads as zero. May be smaller + * than data_end, if user does over-EOF write zero operation. If < 0 the + * status is unknown. + * + * If both @zero_start and @file_end are valid, the region + * [@zero_start, @file_end) is known to be preallocated zeroes. If @file_end + * is not valid, @zero_start doesn't make much sense. + */ + int64_t zero_start; + + /* + * Real end of file. Actually the cache for bdrv_getlength(bs->file->bs), + * to avoid extra lseek() calls on each write operation. If < 0 the status + * is unknown. + */ + int64_t file_end; + + /* + * All three states @data_end, @zero_start and @file_end are guaranteed to + * be invalid (< 0) when we don't have both exclusive BLK_PERM_RESIZE and + * BLK_PERM_WRITE permissions on file child. + */ +} BDRVPreallocateState; + +#define PREALLOCATE_OPT_PREALLOC_ALIGN "prealloc-align" +#define PREALLOCATE_OPT_PREALLOC_SIZE "prealloc-size" +static QemuOptsList runtime_opts = { + .name = "preallocate", + .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), + .desc = { + { + .name = PREALLOCATE_OPT_PREALLOC_ALIGN, + .type = QEMU_OPT_SIZE, + .help = "on preallocation, align file length to this number, " + "default 1M", + }, + { + .name = PREALLOCATE_OPT_PREALLOC_SIZE, + .type = QEMU_OPT_SIZE, + .help = "how much to preallocate, default 128M", + }, + { /* end of list */ } + }, +}; + +static bool preallocate_absorb_opts(PreallocateOpts *dest, QDict *options, + BlockDriverState *child_bs, Error **errp) +{ + QemuOpts *opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); + + if (!qemu_opts_absorb_qdict(opts, options, errp)) { + return false; + } + + dest->prealloc_align = + qemu_opt_get_size(opts, PREALLOCATE_OPT_PREALLOC_ALIGN, 1 * MiB); + dest->prealloc_size = + qemu_opt_get_size(opts, PREALLOCATE_OPT_PREALLOC_SIZE, 128 * MiB); + + qemu_opts_del(opts); + + if (!QEMU_IS_ALIGNED(dest->prealloc_align, BDRV_SECTOR_SIZE)) { + error_setg(errp, "prealloc-align parameter of preallocate filter " + "is not aligned to %llu", BDRV_SECTOR_SIZE); + return false; + } + + if (!QEMU_IS_ALIGNED(dest->prealloc_align, + child_bs->bl.request_alignment)) { + error_setg(errp, "prealloc-align parameter of preallocate filter " + "is not aligned to underlying node request alignment " + "(%" PRIi32 ")", child_bs->bl.request_alignment); + return false; + } + + return true; +} + +static int preallocate_open(BlockDriverState *bs, QDict *options, int flags, + Error **errp) +{ + BDRVPreallocateState *s = bs->opaque; + + /* + * s->data_end and friends should be initialized on permission update. + * For this to work, mark them invalid. + */ + 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; + } + + if (!preallocate_absorb_opts(&s->opts, options, bs->file->bs, errp)) { + return -EINVAL; + } + + bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED | + (BDRV_REQ_FUA & bs->file->bs->supported_write_flags); + + bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED | + ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & + bs->file->bs->supported_zero_flags); + + return 0; +} + +static void preallocate_close(BlockDriverState *bs) +{ + int ret; + BDRVPreallocateState *s = bs->opaque; + + if (s->data_end < 0) { + return; + } + + if (s->file_end < 0) { + s->file_end = bdrv_getlength(bs->file->bs); + if (s->file_end < 0) { + return; + } + } + + if (s->data_end < s->file_end) { + ret = bdrv_truncate(bs->file, s->data_end, true, PREALLOC_MODE_OFF, 0, + NULL); + s->file_end = ret < 0 ? ret : s->data_end; + } +} + + +/* + * Handle reopen. + * + * We must implement reopen handlers, otherwise reopen just don't work. Handle + * new options and don't care about preallocation state, as it is handled in + * set/check permission handlers. + */ + +static int preallocate_reopen_prepare(BDRVReopenState *reopen_state, + BlockReopenQueue *queue, Error **errp) +{ + PreallocateOpts *opts = g_new0(PreallocateOpts, 1); + + if (!preallocate_absorb_opts(opts, reopen_state->options, + reopen_state->bs->file->bs, errp)) { + g_free(opts); + return -EINVAL; + } + + reopen_state->opaque = opts; + + return 0; +} + +static void preallocate_reopen_commit(BDRVReopenState *state) +{ + BDRVPreallocateState *s = state->bs->opaque; + + s->opts = *(PreallocateOpts *)state->opaque; + + g_free(state->opaque); + state->opaque = NULL; +} + +static void preallocate_reopen_abort(BDRVReopenState *state) +{ + g_free(state->opaque); + state->opaque = NULL; +} + +static coroutine_fn int preallocate_co_preadv_part( + BlockDriverState *bs, uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, int flags) +{ + return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset, + flags); +} + +static int coroutine_fn preallocate_co_pdiscard(BlockDriverState *bs, + int64_t offset, int bytes) +{ + return bdrv_co_pdiscard(bs->file, offset, bytes); +} + +static bool can_write_resize(uint64_t perm) +{ + return (perm & BLK_PERM_WRITE) && (perm & BLK_PERM_RESIZE); +} + +static bool has_prealloc_perms(BlockDriverState *bs) +{ + BDRVPreallocateState *s = bs->opaque; + + if (can_write_resize(bs->file->perm)) { + assert(!(bs->file->shared_perm & BLK_PERM_WRITE)); + assert(!(bs->file->shared_perm & BLK_PERM_RESIZE)); + return true; + } + + assert(s->data_end < 0); + assert(s->zero_start < 0); + assert(s->file_end < 0); + return false; +} + +/* + * Call on each write. Returns true if @want_merge_zero is true and the region + * [offset, offset + bytes) is zeroed (as a result of this call or earlier + * preallocation). + * + * want_merge_zero is used to merge write-zero request with preallocation in + * one bdrv_co_pwrite_zeroes() call. + */ +static bool coroutine_fn handle_write(BlockDriverState *bs, int64_t offset, + int64_t bytes, bool want_merge_zero) +{ + BDRVPreallocateState *s = bs->opaque; + int64_t end = offset + bytes; + int64_t prealloc_start, prealloc_end; + int ret; + + if (!has_prealloc_perms(bs)) { + /* We don't have state neither should try to recover it */ + return false; + } + + if (s->data_end < 0) { + s->data_end = bdrv_getlength(bs->file->bs); + if (s->data_end < 0) { + return false; + } + + if (s->file_end < 0) { + s->file_end = s->data_end; + } + } + + if (end <= s->data_end) { + return false; + } + + /* We have valid s->data_end, and request writes beyond it. */ + + s->data_end = end; + if (s->zero_start < 0 || !want_merge_zero) { + s->zero_start = end; + } + + if (s->file_end < 0) { + s->file_end = bdrv_getlength(bs->file->bs); + if (s->file_end < 0) { + return false; + } + } + + /* Now s->data_end, s->zero_start and s->file_end are valid. */ + + if (end <= s->file_end) { + /* No preallocation needed. */ + return want_merge_zero && offset >= s->zero_start; + } + + /* Now we want new preallocation, as request writes beyond s->data_end. */ + + prealloc_start = want_merge_zero ? MIN(offset, s->file_end) : s->file_end; + prealloc_end = QEMU_ALIGN_UP(offset + bytes + s->opts.prealloc_size, + s->opts.prealloc_align); + s->file_end = end; + + ret = bdrv_co_pwrite_zeroes( + bs->file, prealloc_start, prealloc_end - prealloc_start, + BDRV_REQ_NO_FALLBACK | BDRV_REQ_SERIALISING | BDRV_REQ_NO_WAIT); + if (ret < 0) { + s->file_end = ret; + return false; + } + + s->file_end = prealloc_end; + return want_merge_zero; +} + +static int coroutine_fn preallocate_co_pwrite_zeroes(BlockDriverState *bs, + int64_t offset, int bytes, BdrvRequestFlags flags) +{ + bool want_merge_zero = + (flags & (BDRV_REQ_ZERO_WRITE | BDRV_REQ_NO_FALLBACK)) == flags; + if (handle_write(bs, offset, bytes, want_merge_zero)) { + return 0; + } + + return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); +} + +static coroutine_fn int preallocate_co_pwritev_part(BlockDriverState *bs, + uint64_t offset, + uint64_t bytes, + QEMUIOVector *qiov, + size_t qiov_offset, + int flags) +{ + handle_write(bs, offset, bytes, false); + + return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset, + flags); +} + +static int coroutine_fn +preallocate_co_truncate(BlockDriverState *bs, int64_t offset, + bool exact, PreallocMode prealloc, + BdrvRequestFlags flags, Error **errp) +{ + ERRP_GUARD(); + BDRVPreallocateState *s = bs->opaque; + int ret; + + if (s->data_end >= 0 && offset > s->data_end) { + if (s->file_end < 0) { + s->file_end = bdrv_getlength(bs->file->bs); + if (s->file_end < 0) { + error_setg(errp, "failed to get file length"); + return s->file_end; + } + } + + if (prealloc == PREALLOC_MODE_FALLOC) { + /* + * If offset <= s->file_end, the task is already done, just + * update s->file_end, to move part of "filter preallocation" + * to "preallocation requested by user". + * Otherwise just proceed to preallocate missing part. + */ + if (offset <= s->file_end) { + s->data_end = offset; + return 0; + } + } else { + /* + * We have to drop our preallocation, to + * - avoid "Cannot use preallocation for shrinking files" in + * case of offset < file_end + * - give PREALLOC_MODE_OFF a chance to keep small disk + * usage + * - give PREALLOC_MODE_FULL a chance to actually write the + * whole region as user expects + */ + if (s->file_end > s->data_end) { + ret = bdrv_co_truncate(bs->file, s->data_end, true, + PREALLOC_MODE_OFF, 0, errp); + if (ret < 0) { + s->file_end = ret; + error_prepend(errp, "preallocate-filter: failed to drop " + "write-zero preallocation: "); + return ret; + } + s->file_end = s->data_end; + } + } + + s->data_end = offset; + } + + ret = bdrv_co_truncate(bs->file, offset, exact, prealloc, flags, errp); + if (ret < 0) { + s->file_end = s->zero_start = s->data_end = ret; + return ret; + } + + if (has_prealloc_perms(bs)) { + s->file_end = s->zero_start = s->data_end = offset; + } + return 0; +} + +static int coroutine_fn preallocate_co_flush(BlockDriverState *bs) +{ + return bdrv_co_flush(bs->file->bs); +} + +static int64_t preallocate_getlength(BlockDriverState *bs) +{ + int64_t ret; + BDRVPreallocateState *s = bs->opaque; + + if (s->data_end >= 0) { + return s->data_end; + } + + ret = bdrv_getlength(bs->file->bs); + + if (has_prealloc_perms(bs)) { + s->file_end = s->zero_start = s->data_end = ret; + } + + return ret; +} + +static int preallocate_check_perm(BlockDriverState *bs, + uint64_t perm, uint64_t shared, Error **errp) +{ + BDRVPreallocateState *s = bs->opaque; + + if (s->data_end >= 0 && !can_write_resize(perm)) { + /* + * Loose permissions. + * We should truncate in check_perm, as in set_perm bs->file->perm will + * be already changed, and we should not violate it. + */ + if (s->file_end < 0) { + s->file_end = bdrv_getlength(bs->file->bs); + if (s->file_end < 0) { + error_setg(errp, "Failed to get file length"); + return s->file_end; + } + } + + if (s->data_end < s->file_end) { + int ret = bdrv_truncate(bs->file, s->data_end, true, + PREALLOC_MODE_OFF, 0, NULL); + if (ret < 0) { + error_setg(errp, "Failed to drop preallocation"); + s->file_end = ret; + return ret; + } + } + /* + * We will drop our permissions, as well as allow shared + * permissions, anyone will be able to change the child, so mark + * all states invalid. We'll regain control if get good permissions + * back. + */ + s->data_end = s->file_end = s->zero_start = -EINVAL; + } + + return 0; +} + +static void preallocate_set_perm(BlockDriverState *bs, + uint64_t perm, uint64_t shared) +{ + BDRVPreallocateState *s = bs->opaque; + + if (can_write_resize(perm) && s->data_end < 0) { + s->data_end = s->file_end = s->zero_start = + bdrv_getlength(bs->file->bs); + } +} + +static void preallocate_child_perm(BlockDriverState *bs, BdrvChild *c, + BdrvChildRole role, BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) +{ + bdrv_default_perms(bs, c, role, reopen_queue, perm, shared, nperm, nshared); + + if (can_write_resize(perm)) { + /* This should come by default, but let's enforce: */ + *nperm |= BLK_PERM_WRITE | BLK_PERM_RESIZE; + + /* + * Don't share, to keep our states s->file_end, s->data_end and + * s->zero_start valid. + */ + *nshared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); + } +} + +BlockDriver bdrv_preallocate_filter = { + .format_name = "preallocate", + .instance_size = sizeof(BDRVPreallocateState), + + .bdrv_getlength = preallocate_getlength, + .bdrv_open = preallocate_open, + .bdrv_close = preallocate_close, + + .bdrv_reopen_prepare = preallocate_reopen_prepare, + .bdrv_reopen_commit = preallocate_reopen_commit, + .bdrv_reopen_abort = preallocate_reopen_abort, + + .bdrv_co_preadv_part = preallocate_co_preadv_part, + .bdrv_co_pwritev_part = preallocate_co_pwritev_part, + .bdrv_co_pwrite_zeroes = preallocate_co_pwrite_zeroes, + .bdrv_co_pdiscard = preallocate_co_pdiscard, + .bdrv_co_flush = preallocate_co_flush, + .bdrv_co_truncate = preallocate_co_truncate, + + .bdrv_check_perm = preallocate_check_perm, + .bdrv_set_perm = preallocate_set_perm, + .bdrv_child_perm = preallocate_child_perm, + + .has_variable_length = true, + .is_filter = true, +}; + +static void bdrv_preallocate_init(void) +{ + bdrv_register(&bdrv_preallocate_filter); +} + +block_init(bdrv_preallocate_init); diff --git a/block/meson.build b/block/meson.build index a3e56b7cd1..367ec7a525 100644 --- a/block/meson.build +++ b/block/meson.build @@ -13,6 +13,7 @@ block_ss.add(files( 'block-copy.c', 'commit.c', 'copy-on-read.c', + 'preallocate.c', 'create.c', 'crypto.c', 'dirty-bitmap.c', From patchwork Fri Sep 18 18:19:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305038 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87005C43464 for ; Fri, 18 Sep 2020 18:27:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E1E2F22211 for ; Fri, 18 Sep 2020 18:27:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="dbmZnV72" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1E2F22211 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJL6i-00057x-P3 for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:27:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJL09-0007YJ-Dz; Fri, 18 Sep 2020 14:20:53 -0400 Received: from mail-eopbgr40122.outbound.protection.outlook.com ([40.107.4.122]:8096 helo=EUR03-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 1kJL06-0004bq-9F; Fri, 18 Sep 2020 14:20:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DtIeOu++b3EL/neZNydndoUZrg66aKijLhxMwR2R2yT7QayJfQYGL9EBjJhUFykzVpvy+HlYN1DtEr98E+J0TtB3TaIUl+I0s3w9Rl0xmQbs/3OOuc58dmuLItFPqiNBQrQVcUGqeMZP73JlRtRWIl0tjgF1TEubiObv4LIiUUahkzaX+SM5MaMcKuk9595qWVCtfJFiLYNuxnkh0NyAOkcQrdBYVEgty+BNavUluizEEg1cn5K0po22mWaFd9QQGDK72zVuPLrTZglsPLyalevrXVQZ9klYfH7BGNOdrC/0AXyS8nXl3Ay+W3rgwZ2vb17qxuT6UJRYrp/a6Co1aQ== 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-SenderADCheck; bh=DYasGo5hEM/BWvLHsEUSxKaQxPClGh+OelGjajwrA9I=; b=oHcHUDv8P2SvCqTvBt6oRqBUwtb3CF2iNzmebnUqxFYD2h3sD0anrrDIyDunhRKDUcG+a/SeIYzIXxFrauMTDaNlzMLQtWZoVEFj1INIA6EfhDXDO/CCxjcqmem4KdKKgY/2SOIjpHDS+eRd7ZREMGgOQFqBNnYU8nS/jg0s1Du0zWi+PPVeCW/G7ACCAqW5hAFimITbbBd997y0Eu1g6G7BFTwj4/bctP72QFycR4+pQxAL6V333eJbR7J528aPsEN9fkd36003qmzYnHGX8pjV3T/BxQnK+4neT/I07CJgnge/16PiuBkqA5TSD7ABpor5Dhqf34s3P5jMPmiLXg== 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=DYasGo5hEM/BWvLHsEUSxKaQxPClGh+OelGjajwrA9I=; b=dbmZnV72KaxQkcP/UwzS8R6inpCYiwhusiv+0GGLM6d6RMN6ijIYnc59kzh1PQ8XTTP1elWR/0MuiuW91fYGRN/vBeNjdf2zxklOzM3nZ30nnheEp8nz9MMOjn6N2hhQtfSNYyv1qwpHrhna6Dc4n5nTtMuTGELxJpmRRfV+pBY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:14 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:14 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 09/15] qemu-io: add preallocate mode parameter for truncate command Date: Fri, 18 Sep 2020 21:19:45 +0300 Message-Id: <20200918181951.21752-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:13 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1fef61f7-cd9c-48bb-78d4-08d85bff7c98 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M9/Ct3e4otTIhITHAlYLewQUMqhkOzEpUloFhjafawKcJx/KodBzC4bK/d1EWP3im+rw05A6SQouC7anzIuQ4Dfc2Bw7fq8wx9nx2r9sV0YY5psvCutvHPJKFXxEr7OokkHSknnQXVQzuSdlknUMvLfMIA24N9VYQmFHCJ2IYm5ox79CKfFarnxegEwB+GZ8T6tfa7UKrnnjLty0KKXe/IRHH5yxRhrmaTR+QTKYiJWBMyRqBuKv6gY5eF6ntuzD77KtpuWGGe0t9qVEgKa0lvrGn1cpNfyb23b8r1yV/iYNeLjWsVeQSbAfGq7FCRI5AKjFQ0Byvkjf3kCwGifLL+QN+hEjY1B9q12q62u9Rind9GCG7i/cLiMCoGHSDqXi X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39830400003)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 8e/PPmkQLSdhnMiRYOecxmu7jS8szuDWU2XppRCwg7I+P6Y54TvM8zCWmg+5nGCvMtPN3Bk19XfJSRf8CA3ZAWsScVJy9Li5zkkNvzkDcSXXizaYI0YTePRLjx1FENnjHYOta1EjETi8S9KgD7A+lNFBJqLaBho0xxR75VlZ+VBx5f52McXZ97pCYlbQMT6cHDBjoqf4tq5W0yl299lPF/DO3mrHpT0IWRX3XhglWaD75AGRkxlaN3A794HLy/1N/VNhfWsmb8yVseZWLxQTrH8LdUkbgBzVX+fT+euytJXxLmrDqJe0F0nRDFzcKiKzPbGpjuisiNi72MkpkG2iCIC5F5rucITCo+2KTvqjKSEC/m0q08/gG6I6dAxHcTQIMZ7wo9dsYHCTwulxDQ6quN9mDkA3oKwn2B060oPTRBlpbbVcDPw3gBa44T8Lw11spiR6jA40GUMDgR5BD8yl0PVwiL7RuSZMjR+H6JmS6Qgci0E1U1TNfJgapjhYTu0op33alf0yIHqRYdW4/YpuU9e38rNORNqYvg7IvJ0py5s/omBx/zdQ4Wy5S+SK1AjfhLXEcbcq/Hn/tzFCnWobYCXg+Kd0M7GMwy1a9Yi1yli/Japhqp5UAITY9FV/LGjsk2u2SioYbTiUfNlIWoyaYg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1fef61f7-cd9c-48bb-78d4-08d85bff7c98 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:13.9962 (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: Lu/GFPdjcqT6c3qHmOm0ai+wtRzJwZcFfq+56+uDHyTAsvsmFwVgF3lRQivqtb0bn6eHOb13qA1rcoM3jKM6RRhNS7tCT3tB93jsRIMV6m4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.122; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:06 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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.23 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" This will be used in further test. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- qemu-io-cmds.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index baeae86d8c..64f0246a71 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1698,13 +1698,42 @@ static const cmdinfo_t flush_cmd = { .oneline = "flush all in-core file state to disk", }; +static int truncate_f(BlockBackend *blk, int argc, char **argv); +static const cmdinfo_t truncate_cmd = { + .name = "truncate", + .altname = "t", + .cfunc = truncate_f, + .perm = BLK_PERM_WRITE | BLK_PERM_RESIZE, + .argmin = 1, + .argmax = 3, + .args = "[-m prealloc_mode] off", + .oneline = "truncates the current file at the given offset", +}; + static int truncate_f(BlockBackend *blk, int argc, char **argv) { Error *local_err = NULL; int64_t offset; - int ret; + int c, ret; + PreallocMode prealloc = PREALLOC_MODE_OFF; - offset = cvtnum(argv[1]); + while ((c = getopt(argc, argv, "m:")) != -1) { + switch (c) { + case 'm': + prealloc = qapi_enum_parse(&PreallocMode_lookup, optarg, + PREALLOC_MODE__MAX, NULL); + if (prealloc == PREALLOC_MODE__MAX) { + error_report("Invalid preallocation mode '%s'", optarg); + return -EINVAL; + } + break; + default: + qemuio_command_usage(&truncate_cmd); + return -EINVAL; + } + } + + offset = cvtnum(argv[optind]); if (offset < 0) { print_cvtnum_err(offset, argv[1]); return offset; @@ -1715,7 +1744,7 @@ static int truncate_f(BlockBackend *blk, int argc, char **argv) * exact=true. It is better to err on the "emit more errors" side * than to be overly permissive. */ - ret = blk_truncate(blk, offset, false, PREALLOC_MODE_OFF, 0, &local_err); + ret = blk_truncate(blk, offset, false, prealloc, 0, &local_err); if (ret < 0) { error_report_err(local_err); return ret; @@ -1724,17 +1753,6 @@ static int truncate_f(BlockBackend *blk, int argc, char **argv) return 0; } -static const cmdinfo_t truncate_cmd = { - .name = "truncate", - .altname = "t", - .cfunc = truncate_f, - .perm = BLK_PERM_WRITE | BLK_PERM_RESIZE, - .argmin = 1, - .argmax = 1, - .args = "off", - .oneline = "truncates the current file at the given offset", -}; - static int length_f(BlockBackend *blk, int argc, char **argv) { int64_t size; From patchwork Fri Sep 18 18:19:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC614C43463 for ; Fri, 18 Sep 2020 18:27:57 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6357521D42 for ; Fri, 18 Sep 2020 18:27:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="huGqeE3u" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6357521D42 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJL6y-0005dW-Eb for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:27:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJL0D-0007aq-PL; Fri, 18 Sep 2020 14:20:59 -0400 Received: from mail-eopbgr40094.outbound.protection.outlook.com ([40.107.4.94]:32391 helo=EUR03-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 1kJL06-0004dZ-FN; Fri, 18 Sep 2020 14:20:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SLtjpndc1c47oE3jEOTiH/o/nMUfhSJZGUevrNvcvn2aZGKP7OiGKa5Md8Wvehy5HvfM2Z/VYb9Jny3jZ0PcLHDwdMP2DHkQxOQmzIGHrQpXhFc5VXJxp/IODvkIHBteQiCqVKzAX+mw5MCkvSAGdUf6EqJu6jyN0QJyoxz0M+fbz8Vur8vc5mXO6sZDFjC3wfLXNhV5DLdOPn1WoKwTruwf+GJlMuc4eCwdPbYE/Wp1azdsikxkJ30+c+HtJUteq85oRxPLvNF8429VKAGvfn2let5sx5gXPUCJgAid23C+yXe+e40Yx5EKygXMdB3f6O/9kJ9E2BQwQW2IT2Zldg== 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-SenderADCheck; bh=Y/8tAEMFLkgUCLY2eVBGIwxG2EjF7nIftCv188u6gqc=; b=oUlRnyy9xZssLjv1MLqnucZYrLH5QsWGLYunwx5cIMjX7BvC7aYT46Xi7r5f7U5NT6USE8kiNYK9XwWLGLrgfFyC9RMhrOjCVS3YWerlObsf1cWBGphxkj3WdbBrR4ESDBICXP7IKtewoEfiRsVwrAexKUbq89OFe4RMI90blNVJIXolWdugH/HnABlTFFI6ucefn7hWUE4Ewo1n9NXhNcXjm3WumsWcU8c8zHBCz+CkUsxGM+tDrsFKeEVIfsn/l9C/8o6U7M6EKL2B641rNj2N6Ej9GM0RNl6k8wwPFthzIYC2lzuXYGcHHwyavQsK1o1LN29Ej6MEgIioiwsqXg== 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=Y/8tAEMFLkgUCLY2eVBGIwxG2EjF7nIftCv188u6gqc=; b=huGqeE3ur3YuCUnnJVG6pvG/Whfo33hy6q3SuFgk1NCPryzejMTDWs4Tc2bqXrDFM6SnhgGNuEvEKnGrb0/WsDV7/roxj7i1iypX79Qjk74i2RXI9h/kGcXrhH4QQVSpW21Pn7YA8oLs+6P+VbT8fmaHGHeSRVPdvr31J0CYtoU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:15 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:14 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 10/15] iotests: qemu_io_silent: support --image-opts Date: Fri, 18 Sep 2020 21:19:46 +0300 Message-Id: <20200918181951.21752-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:14 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e126972b-802d-4442-60af-08d85bff7d1f X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zkPBOfdCOa+7/gKcvRcLpWgqTEVWhqPMcTo1c4v6XmC/PC12dP5LXB6GyuIYqnk22RI8ax5SYirufjd7avGi+8VQVDeTEz/ps8nAFNk7Pe9ley/Zhogt7pUaxnGxpFm8tx4Q+a5jrjn9eaBzyA0wvLoGp8OJTmUNFeJsrxsIneCEaL2t/fhcJ4MfDsBw19ndeJbRXjbxo8UaZ6hbA1pO3PThaZAFZrfP60bbeJPGSjSLNwc+0q9MAJvSRyhqPWFZY4+/te9xoac3vDpogLzFQcpQajc0EUuHcnQClzkbwQnpdHeQYJbmi8TFClJ8QYSyFByvpjJdBThcuqYIW4HK9dv/GMDutxxym6FvmyiSl6c24BXOwQZCuv6VEm4d3XPj X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39830400003)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(4744005)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 0EV0D6mN36cy6uqD/JwL3gJEIjmL19z7YGoHBqgILB03qr6aeYcEJLcNIBuAcxKJU+neRIasSp54xtw/Hd+S8UsJvedjQesnAuoi6RPaXkl7a0v8O+86oEfMOnpVL9ieDgf27A/oK0oBClvXN1fvyh6g7j+fNiks6w/p30BU1GJoqwNgrFLO2l2U12HhozCV73EA4AGZE3YUOECehax+btph4qZ6riIm+DthEkTrJ/PWc/wRbqo3tGKgaxFU07ChKsavQSd+wPUAhOm0U8eJkSaedvjgNDqSPxgNTThGHYbgi8Y+LIsEU+oMj5eLXWwG5Hz8Hyf08/QiyVTKr4SBdVe+Z9+Y8puqtojf6aLXk6GerYYwO1HsA6G496lwq8RGJjPhwFuIbtZ49h0Z5zhyxWFkLLWDfcPPslJG8nIliaCbpymrHpM2AmVJnO2dCzhADmIRjAJWIZhiyMZNHBJRC4cG+sPDgIwxcaPu71MFck8zGMLu+4aOuMEpct165iW6nm+vej+5TgBqdTWhMQDJzWQxtQUpRuA9dvWvWBhj9rxzZPbHlip2JK+wBzeZVHpAMwOlqrizG7wW4c1UrDGYIKAoVselX4M9R9W5l+MZGr2uw5WxrKd/C6Dv3wX3iGyBb9inXpeGDExpoqhEzPmIYg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e126972b-802d-4442-60af-08d85bff7d1f X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:14.9131 (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: RwJcOZixP+U+fJJLRPyST1WZ6pkojpIto+ocPoSG1SpSKH8jA/1IbzoKVbwSQn1VOTLKIGw+Tx1S0Og4CrLO7LgjoCRHnY85fu4AkLFjPVU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.94; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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.23 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" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- tests/qemu-iotests/iotests.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 91e4a57126..3d48108f3a 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -197,7 +197,12 @@ def qemu_io_log(*args): def qemu_io_silent(*args): '''Run qemu-io and return the exit code, suppressing stdout''' - args = qemu_io_args + list(args) + if '-f' in args or '--image-opts' in args: + default_args = qemu_io_args_no_fmt + else: + default_args = qemu_io_args + + args = default_args + list(args) exitcode = subprocess.call(args, stdout=open('/dev/null', 'w')) if exitcode < 0: sys.stderr.write('qemu-io received signal %i: %s\n' % From patchwork Fri Sep 18 18:19:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305036 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2915C43464 for ; Fri, 18 Sep 2020 18:31:28 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id DEB50206A2 for ; Fri, 18 Sep 2020 18:31:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="uyQFsVB5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DEB50206A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJLAM-0000Hd-Ou for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:31:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJL0D-0007a9-EW; Fri, 18 Sep 2020 14:20:57 -0400 Received: from mail-eopbgr40122.outbound.protection.outlook.com ([40.107.4.122]:8096 helo=EUR03-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 1kJL0A-0004bq-1D; Fri, 18 Sep 2020 14:20:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a5gxV1lsvf/DLKzCsUdkBJPy8/G5jLF68D9QcSXtSf4ycMqkseyoAMI1VBDzLKTeoyJInFZwIcQdM7ZNPHryYRgtsu/pBdOPv040GbLG73cdPlYq0gqIpUX4fxX6SGTJtuUYjv6uyhwroDfi3nXy65A29y2g2vxXeaeYoq13zZ5hfsuPveTYN0B9w/kaRKOwrRyvzqttnfCGrOp2waYvEuPxudF39/GtoMl1zQ/P77gjzv4xxhbAsdhjzkDjJEZtJYnkKsGqx6cPH+M+TIlb9Mx5vg1XO+4+wrWzav/hg9gAXvjjOY4UmniiNa8rWmxuOuzdiyVV8NEZNsrD5UfUUA== 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-SenderADCheck; bh=VEUcVvT8Lw3DqzEreEtA4a5wMCTNnPpvL10ZLBJYeWk=; b=SiJK2p3Xl6NRb8YCCGckKqqRN/k2yCTEUCXvkwUtu8nIbvYaHTcsZYLwAkWqyheyRrTdU0VCGCXxDJHJm2s+fwHisUvLvJ5jb4MkEIpdxAxlDjF0nhktWeXYSgYTcgDXHT3QrXkYAv/sNiTZWitTf51NWhubLzQBlQMqE/vCuixrJF8RbdaexL7PfVpUKPF2s5vTOu2ZuebMb6gNPAbdhtTRM0whO4h8OrTlmoqMzZ/hbquzRKbypsOSEcM7OgxfxSVVylThU/E+i//2oeAI5nFaDGMaV0QnyS/Lhmzk3swLghul66UPPkUC5WxTJaBjxE2OgRQLn+xA8JFgPb2CIA== 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=VEUcVvT8Lw3DqzEreEtA4a5wMCTNnPpvL10ZLBJYeWk=; b=uyQFsVB5ZVvhYXBMNNW5m/9BK+OWD4daGfHKc7+KZLuErINvY0codbQuYNk8HM6j/x4vkOGaAkjmC4J5cCG2rs3fLZ65fUPB5uG3ENUoybgOm9ShX7TQC67fhxlji7ZZOQojH05bysp0ebnPbiB/CkWwYL4ijAYGgH68Qi02HOk= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:15 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:15 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 11/15] iotests: add 298 to test new preallocate filter driver Date: Fri, 18 Sep 2020 21:19:47 +0300 Message-Id: <20200918181951.21752-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:15 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 106c410d-2e5f-4f89-0e71-08d85bff7dac X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PMmnC78hbcJx0YOaRZWUe/vyeIKwpJJAJ2IgKbcpjQxLO9S3/8OcqbDX9AE2NdoOCkOk0DltOA+UKmQ4h5mkh+bQbiY+9NHbV/0fBMlWE10y6Css4W4uNsP9D3ddevWtOS1rspxvMxjp0fo3yRYJvPPoX6ZWISIi+U0PAta5PlQ/GG3yqXwJGSK7ydh5dmLk03uUvkXZuT9OqMrIAFr8pekxPIYbrA2JA0vRLjFhhu3+H6ER1kr0JYNx+i7puLu/LZ2TazIO/+JA3w9F/MMwkfB5l24OhmArum4pN7u13qeRR+vD8L57y0sWkP7IgNHCj7COauejWcABvyzPLBGzha54fzRSVmvfKNKvSHzQ61VF/Yk9k9TJffKbtZh8TX9zqLx9m2fpE3RLh2Sr+5FGzl2SKAxacALH0S1z1X/wEE3epbf2gh+xHWFY5NdWEaNZrEmeB+IzQQtsLy0CTTxGiP3fgQwmCoqH9I6myDAFsnxOZwGRBKGbAi8+FwJuspkA X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: AVs5xOTIso66JM4bhs5hfXlxnLCKSTa/6sXEk7JoaM8kCrB7FfmR/cQISw6qQumZGHdzpQRiCHKl+v73R2ZydD51u9Q3Gmft52A/bRwGIPP49xTYAKuz/tgHXu7RI0Z4dVRMrs3lRIC0uswZiXfMC2/qnPGLD4hl+xVXuYQLqp+OGQlepeXsBc22E0A/o2v5kdUSkRacSrwelxu/LdxsjjyDvFFhx1pDEMaPFM6WGiMxLKc4wAyTdyKoeY6eLguYUfe8KbeU61p2T1NenENR5WcAc5wLX2QcO/3jPymsC4HCHtI7sA6AJBQSgPiHEAaBJnJT5z9CxFoa2u5Cy5Mo13ItjrcOIhKjdP5CF531YA65j3Ga2EdHoWd2H2aXH83WQAYC9Wjji7cEZMMGka9zCFIooWhujL8jdzAgtZrOlQDRGmhKcUt4XkfjzHHFDUNXUPur0LBsc7FPQVmIPxXtEqbqaJQ6WoKtDCvXpQdTrry88gxi2HnFi65eIJO1GTBRlslctN1ymGtJc8b3MwqNUFaf9qR301sk18KfVZdbNkzFSNk9Y8g5NQR6U1iPVJcZUOoAfA483qMzh+4N1DQgXMfAzmrQjqZd35N6EGoOB4G5NX5NfuN5n2hiOjNGN8jH/IRIg+LwyxzPZdwkLNtfHg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 106c410d-2e5f-4f89-0e71-08d85bff7dac X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:15.8172 (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: UWmV0Iy/O9SODdzS3I/IjYBypvlDE1hlTQiisyArrHG5cI1jRa8LWxMxR9zQWyIewmMxQ+Jxi0D8FMJyKvcWUAv7av4iliQmrYcPFpFRwYc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.122; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:06 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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.23 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" Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/298 | 186 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/298.out | 5 + tests/qemu-iotests/group | 1 + 3 files changed, 192 insertions(+) create mode 100644 tests/qemu-iotests/298 create mode 100644 tests/qemu-iotests/298.out diff --git a/tests/qemu-iotests/298 b/tests/qemu-iotests/298 new file mode 100644 index 0000000000..fef10f6a7a --- /dev/null +++ b/tests/qemu-iotests/298 @@ -0,0 +1,186 @@ +#!/usr/bin/env python3 +# +# Test for preallocate filter +# +# Copyright (c) 2020 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import os +import iotests + +MiB = 1024 * 1024 +disk = os.path.join(iotests.test_dir, 'disk') +overlay = os.path.join(iotests.test_dir, 'overlay') +refdisk = os.path.join(iotests.test_dir, 'refdisk') +drive_opts = f'node-name=disk,driver={iotests.imgfmt},' \ + f'file.node-name=filter,file.driver=preallocate,' \ + f'file.file.node-name=file,file.file.filename={disk}' + + +class TestPreallocateBase(iotests.QMPTestCase): + def setUp(self): + iotests.qemu_img_create('-f', iotests.imgfmt, disk, str(10 * MiB)) + + def tearDown(self): + try: + self.check_small() + check = iotests.qemu_img_check(disk) + self.assertFalse('leaks' in check) + self.assertFalse('corruptions' in check) + self.assertEqual(check['check-errors'], 0) + finally: + os.remove(disk) + + def check_big(self): + self.assertTrue(os.path.getsize(disk) > 100 * MiB) + + def check_small(self): + self.assertTrue(os.path.getsize(disk) < 10 * MiB) + + +class TestQemuImg(TestPreallocateBase): + def test_qemu_img(self): + p = iotests.QemuIoInteractive('--image-opts', drive_opts) + + p.cmd('write 0 1M') + p.cmd('flush') + + self.check_big() + + p.close() + + +class TestPreallocateFilter(TestPreallocateBase): + def setUp(self): + super().setUp() + self.vm = iotests.VM().add_drive(path=None, opts=drive_opts) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + super().tearDown() + + def test_prealloc(self): + self.vm.hmp_qemu_io('drive0', 'write 0 1M') + self.check_big() + + def test_external_snapshot(self): + self.test_prealloc() + + result = self.vm.qmp('blockdev-snapshot-sync', node_name='disk', + snapshot_file=overlay, + snapshot_node_name='overlay') + self.assert_qmp(result, 'return', {}) + + # on reopen to r-o base preallocation should be dropped + self.check_small() + + self.vm.hmp_qemu_io('drive0', 'write 1M 1M') + + result = self.vm.qmp('block-commit', device='overlay') + self.assert_qmp(result, 'return', {}) + self.complete_and_wait() + + # commit of new megabyte should trigger preallocation + self.check_big() + + def test_reopen_opts(self): + result = self.vm.qmp('x-blockdev-reopen', **{ + 'node-name': 'disk', + 'driver': iotests.imgfmt, + 'file': { + 'node-name': 'filter', + 'driver': 'preallocate', + 'prealloc-size': 20 * MiB, + 'prealloc-align': 5 * MiB, + 'file': { + 'node-name': 'file', + 'driver': 'file', + 'filename': disk + } + } + }) + self.assert_qmp(result, 'return', {}) + + self.vm.hmp_qemu_io('drive0', 'write 0 1M') + self.assertTrue(os.path.getsize(disk) == 25 * MiB) + + +class TestTruncate(iotests.QMPTestCase): + def setUp(self): + iotests.qemu_img_create('-f', iotests.imgfmt, disk, str(10 * MiB)) + iotests.qemu_img_create('-f', iotests.imgfmt, refdisk, str(10 * MiB)) + + def tearDown(self): + os.remove(disk) + os.remove(refdisk) + + def do_test(self, prealloc_mode, new_size): + ret = iotests.qemu_io_silent('--image-opts', '-c', 'write 0 10M', '-c', + f'truncate -m {prealloc_mode} {new_size}', + drive_opts) + self.assertEqual(ret, 0) + + ret = iotests.qemu_io_silent('-f', iotests.imgfmt, '-c', 'write 0 10M', + '-c', + f'truncate -m {prealloc_mode} {new_size}', + refdisk) + self.assertEqual(ret, 0) + + stat = os.stat(disk) + refstat = os.stat(refdisk) + + # Probably we'll want preallocate filter to keep align to cluster when + # shrink preallocation, so, ignore small differece + self.assertLess(abs(stat.st_size - refstat.st_size), 64 * 1024) + + # Preallocate filter may leak some internal clusters (for example, if + # guest write far over EOF, skipping some clusters - they will remain + # fallocated, preallocate filter don't care about such leaks, it drops + # only trailing preallocation. + self.assertLess(abs(stat.st_blocks - refstat.st_blocks) * 512, + 1024 * 1024) + + def test_real_shrink(self): + self.do_test('off', '5M') + + def test_truncate_inside_preallocated_area__falloc(self): + self.do_test('falloc', '50M') + + def test_truncate_inside_preallocated_area__metadata(self): + self.do_test('metadata', '50M') + + def test_truncate_inside_preallocated_area__full(self): + self.do_test('full', '50M') + + def test_truncate_inside_preallocated_area__off(self): + self.do_test('off', '50M') + + def test_truncate_over_preallocated_area__falloc(self): + self.do_test('falloc', '150M') + + def test_truncate_over_preallocated_area__metadata(self): + self.do_test('metadata', '150M') + + def test_truncate_over_preallocated_area__full(self): + self.do_test('full', '150M') + + def test_truncate_over_preallocated_area__off(self): + self.do_test('off', '150M') + + +if __name__ == '__main__': + iotests.main(supported_fmts=['qcow2']) diff --git a/tests/qemu-iotests/298.out b/tests/qemu-iotests/298.out new file mode 100644 index 0000000000..fa16b5ccef --- /dev/null +++ b/tests/qemu-iotests/298.out @@ -0,0 +1,5 @@ +............. +---------------------------------------------------------------------- +Ran 13 tests + +OK diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index ff59cfd2d4..15d5f9619b 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -307,6 +307,7 @@ 295 rw 296 rw 297 meta +298 auto quick 299 auto quick 300 migration 301 backing quick From patchwork Fri Sep 18 18:19:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273364 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 765E4C43464 for ; Fri, 18 Sep 2020 18:34:39 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A1CA6206D9 for ; Fri, 18 Sep 2020 18:34:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="HYxw5LRS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1CA6206D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJLDR-0003h4-K2 for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:34:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJL0F-0007c6-Vf; Fri, 18 Sep 2020 14:21:01 -0400 Received: from mail-eopbgr40118.outbound.protection.outlook.com ([40.107.4.118]:41027 helo=EUR03-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 1kJL0C-0004nY-EO; Fri, 18 Sep 2020 14:20:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fkUuwR4++Yi+pzpB191hN7E9xehMP3/KBIuw8Pg5aWpovDHbnbeTh0FIjkmz3w1slTuA5xnq8H3ijtFwwZjuD33g1H0pXgF2yb+LbTftPYnytjNINkcTEl+iZqrouva7FBBHjbAwDWdmzyGAgUY/+MV0j7UjdHMdnUPxDRlLsG18QogMdXYYAPS6QbgfHgaz6WJVKkHHlkXVEtmIvvI11e3T4GTyJ+3vgE+a0kYCGPiZ+hjiMldWNNEk0NJPu1Izcp/ygONoCbeIkF9YYSjw8Aaa6FtjVAAacyj5sCKoZby3aZMjB/uFzlS26zwljqgs1YUlOdhsNW6shaWgL8tcAw== 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-SenderADCheck; bh=Yq8xuOhk5d5JLQAxmxNgkhhkjs/y4dVC0KUNG14nYtU=; b=mAw+eTHfLnq7zicAWWbGrI0X0HUVjBDNw72Ef3dT1MuhtlD02CTznL3OAcIewTrXYYVfJ6oa9MiOPU/qc8y7HMBSzPgo/KDTyeXknN9ZVw0yGZZgPjhW233gbp/tFMhy1yzj+FcVHILSGN+Ts17QjUpBO54KPBMbDqrYPM9PQHTmjER56u1Pe6sWqofgWFoHVt8TC8w799ED/CN8wbTyWKwlCSMubVrhJbBZt493kWWhVm1KRXWnX01WADqaHfyybDpqPH7e/cAqqcEoU7h/Fik7GTmLRkG7iWxyUqgCneslWpRxUITfTnaojZ5C8i6hJhQG9xVVN6HwpQ5VItAkog== 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=Yq8xuOhk5d5JLQAxmxNgkhhkjs/y4dVC0KUNG14nYtU=; b=HYxw5LRS9XXTpsAH3NgRn45Sk78TDZ4EoxvwVYNQEca/U90YJfQBFe7lKGnptzJtQwYVQ/CZwFheT07NjRiK4byX/WGgfNBQtp0zN+okt/ZtTeHNk91dNfdLUwpGmwv0AVVI2M62XoLrfIc5BKrX3m1RXvqCSN+c6SsoYKSIA74= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:16 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:16 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 12/15] scripts/simplebench: support iops Date: Fri, 18 Sep 2020 21:19:48 +0300 Message-Id: <20200918181951.21752-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:15 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 881f40e8-eccc-4667-a586-08d85bff7e39 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B4GA0XiDkEW0+9ilVlb1TxTnP4C1ITL287QIbeU74CR1h3MfUhAb39n7/khHWfM08zDiotO1hpXf/Wo59ZmwcUg6w7JTJz+bBq8C2K2KAyp9XT9h41hFkOitjChfmnbZIoVLE4v2r49qeTVTWwx3X8Xef3JqF6i/eZ2FboVs78bZizoKJ2HtZKxjCvTy4+5A7Q+CWxVAIZ50PKeMzXZRZ1E7/BUTFceFwLXFVkCeyTH+OXrt9xgNyuv6KHc8YGDlLzyNpZsicrNy7O2gBF1nbgdZZFdwR9ipAIM/fiWK9XyHZXqK4ve5I8re8fy7Ua5DeSo6l+NwS8llbpEWyy6k+fUNUDGRG10q7AhhLQfitVjliQW5ySHI1Dp0Q/JsKoOG X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: X4cd2fCU0J5bY40Y3xjlLkSKGwQx/wFEp041skomOsRW9xxHaq+CPmZ5sk5JXtgBwN4qokadqsP1MOX9zY7vlHHK61ZXbYn3Y+0V4n4nmwdt2878j20CRFAUoP9dX3wAQJt6xlyRPIbgsEFhnDedwg3aEamUTsSHpAXo2jOd8pN7+WA5d/SgPypsejoKOjxK5qIQ+IRcDOTOLdyiydMUEX0kEsMqfryYXCgjLjgj+lsDpZs5Hsqp8rxgsWpqtLwXPYsxb0duY4XABrg985V+FHfUGw+BO+KaqKnBZbIqXjzmh0YUP5TxA7jIcLuvGW0mMrFurgq+uy7Ez6RLWHEpX13H9mf175Fs2udfR2fjsbEVjGsTJgf5XTOO5P6NtXQkVh1D5oCeQLBGQ/mmSTeUn8nOiyPYMDl6WZotQPx9QSl8PsNa6ZYHVmdy9kuyyKx4A/j2n+Kg0n5KmRjAqXM88EG2RYT8vK6FZ5NATbcfiEKCXX61fDJZEfQBV50JVKzifjqePLPV/VRQb3oLW1uI6ioCSUkvG53c3QLXVYHjpDVZYhDCu1uydHjOolC8f7YZMmj+FBn3PaAwohkW+X+XM3FhGRSBRktyG38y46aRwKTTmuszM4o1uCn08TtqM2THTG1UOwQ6Rnp3OqEcYlMnkg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 881f40e8-eccc-4667-a586-08d85bff7e39 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:16.9024 (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: 6GKvOacYWZwta1/hZwsNEmhzfR2dmGSZKov/0NMjFk2DDXZhSE7oGRqaWIC7/mALioyIB1bPEIfRkL7lH4cZ1TAaOXZl52+LkkDiEKBwjaI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.118; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:23 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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.23 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" Support benchmarks returning not seconds but iops. We'll use it for further new test. Signed-off-by: Vladimir Sementsov-Ogievskiy --- scripts/simplebench/simplebench.py | 35 +++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simplebench.py index 59e7314ff6..716d7fe9b2 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -24,9 +24,12 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): test_func -- benchmarking function with prototype test_func(env, case), which takes test_env and test_case - arguments and returns {'seconds': int} (which is benchmark - result) on success and {'error': str} on error. Returned - dict may contain any other additional fields. + arguments and on success returns dict with 'seconds' or + 'iops' (or both) fields, specifying the benchmark result. + If both 'iops' and 'seconds' provided, the 'iops' is + considered the main, and 'seconds' is just an additional + info. On failure test_func should return {'error': str}. + Returned dict may contain any other additional fields. test_env -- test environment - opaque first argument for test_func test_case -- test case - opaque second argument for test_func count -- how many times to call test_func, to calculate average @@ -34,6 +37,7 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): Returns dict with the following fields: 'runs': list of test_func results + 'dimension': dimension of results, may be 'seconds' or 'iops' 'average': average seconds per run (exists only if at least one run succeeded) 'delta': maximum delta between test_func result and the average @@ -54,11 +58,20 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): result = {'runs': runs} - successed = [r for r in runs if ('seconds' in r)] + successed = [r for r in runs if ('seconds' in r or 'iops' in r)] if successed: - avg = sum(r['seconds'] for r in successed) / len(successed) + dim = 'iops' if ('iops' in successed[0]) else 'seconds' + if 'iops' in successed[0]: + assert all('iops' in r for r in successed) + dim = 'iops' + else: + assert all('seconds' in r for r in successed) + assert all('iops' not in r for r in successed) + dim = 'seconds' + avg = sum(r[dim] for r in successed) / len(successed) + result['dimension'] = dim result['average'] = avg - result['delta'] = max(abs(r['seconds'] - avg) for r in successed) + result['delta'] = max(abs(r[dim] - avg) for r in successed) if len(successed) < count: result['n-failed'] = count - len(successed) @@ -118,11 +131,17 @@ def ascii(results): """Return ASCII representation of bench() returned dict.""" from tabulate import tabulate + dim = None tab = [[""] + [c['id'] for c in results['envs']]] for case in results['cases']: row = [case['id']] for env in results['envs']: - row.append(ascii_one(results['tab'][case['id']][env['id']])) + res = results['tab'][case['id']][env['id']] + if dim is None: + dim = res['dimension'] + else: + assert dim == res['dimension'] + row.append(ascii_one(res)) tab.append(row) - return tabulate(tab) + return f'All results are in {dim}\n\n' + tabulate(tab) From patchwork Fri Sep 18 18:19:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 273363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8A14C43463 for ; Fri, 18 Sep 2020 18:37:24 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 07AAA21534 for ; Fri, 18 Sep 2020 18:37:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="MQoCDPG+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07AAA21534 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJLG6-0006O6-UE for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:37:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJL0I-0007eA-Bu; Fri, 18 Sep 2020 14:21:04 -0400 Received: from mail-eopbgr40122.outbound.protection.outlook.com ([40.107.4.122]:8096 helo=EUR03-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 1kJL0E-0004bq-0y; Fri, 18 Sep 2020 14:21:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ezcDu3StcuB8nXXQtp8pPoZZCUl0L/Gqxqb026H0mpN7K4XtzGQaJL8Gc69LJGW1Sy5AfxAj62vOl0b0HF9jORAKL8IWuUaoWB41Co+bJ/7hsO7DjIv1EtXzyftBx/6ZQe6Frxo4vSbMyU1eF0g7vjSbd27EtpBhNpqYBYGM0PJaaR8PTOcoSRON8CAcaI3nRhJ39pbo5srA0ghLmHdwq0iPdi0oTX+e6oneEAZQt6p0j04sX186wEUMEzNMu4IwpweAo1F0TXAZtueSNMMDU7/weSnkuqG00D1ulr9NEKVjEMY99QIpzkhCpddxoffWq9ChhQFfqAJnM/pT9Do9Qg== 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-SenderADCheck; bh=87uttaqzpRth4x7YWAAH+SS7sM4DtM54/AUpU+tyQa4=; b=S65XFbKLU4yrTOsEAxfOD98ybJZ1fMm+Km0m6RuZs9rB5hl0XQ0shkrTOqauIshdiMwJeYG+tH8Ls/Z45Af8wWnP9I1QJi1W4Bd6it9u2yQ1I5Q5xexZb3hVEZwiZiIrzRkyPgDaIKjML2uMt6Zpqkz2hNETmfCiTPkO5Yiad7uScZQafplQMjJ/3T1UevdznhPuRQo0j6wo+xF95DCa+cjUHlGbYSKwlhZkxbCnnx5tTwqOg2DsoN0ULm6W0MHb+80qkZLAhdi7d7qeYqaFfHyfdqIlrtoZ7CT2vxIrYTrMjwaosvWV267oavU9BcPrAqbYPt4+5ibVwbFTmouuqQ== 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=87uttaqzpRth4x7YWAAH+SS7sM4DtM54/AUpU+tyQa4=; b=MQoCDPG+AcEiQT84+/ddBa3QhswBDJ1zC+2ZNxteUe43szCf3twr3oM1SQAz3+ckiCAWxszV4wpX1eJXdvZ2GqaeXbKC/ZClrSbwR5ylP5Nb8Mh8GQPwC1sY9oeokrWGSQBvR4re/CuDK5u4qaA/r0vEjeXdDowe1NKyoYAjzoY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:18 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:18 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 13/15] scripts/simplebench: improve view of ascii table Date: Fri, 18 Sep 2020 21:19:49 +0300 Message-Id: <20200918181951.21752-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:17 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ba5d1928-aaee-4702-a862-08d85bff7edc X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:226; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /8CnixacOim1Me1FIDGO74woI78IRTQ1KDHUUDKXCFRs+4MfE4Ybp3pu6T12MCcg6Hjyz7MxsHxrORqT8Mlava5APwnOT7YpTvZLgfSm69hslZb1s7Y2zSZjP7CRsWBiMsdt+MD+MWXjUf/b6AJEkjP34e2Lot+YSIV/Ek7s8Mmt1ZbwqCGobxZth/ma6gzkLSNC5gAg/mNq+jgqODpV8TfcN9nLgBKMLPaSyLKyLHMSn7zwhWrZrpk3yCH2dfVAFjS50xvkAdcT+Zz3Ik05F8bEeEn/+WCc8ex/1rm+XIVhuI1Y7FxfEh6kNrJIIdlAcolfi062wuO3kedTxia3ri7a5hJxBc6GEA4BrBTe9YfNO6bNtXT90SxHjBalsVLd X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: I3HrnPRDRoufleOqSvowF39Bw1L6tGiZWxB6JiElDJkByC6an1ppmLhNQBmTHLi5civG1aAnxrjot7tP412Yba4fRu3jLDvR0NiQ+rZsfGF6+FCx7DvBMMQLnnAUhi+0G7TbG2o9NhcRUMGD7K+8gvbOsHi9ggYRjFhUtdmALGC5LAg0/BB52AoQ2JJhkmp8AnzBGVykj8gjpsYKa7+iNxpWz+SzrzHQ6EP6mL95waN/iW12HIfY85Lr3S4ocnS4zjT24N7NKYKLPbfJnA6GfMlGNrNn0uqbmfEzRXaCJ9lC/u0ZmCsJGDKuh0ll2hXVW9SWG8akAy+kq7vxibdR+V7HVIgcx2lEHVtMhhdcMnI+MeqaJQGlz1l7HbAuWiP5UDncJkHcr5mgfi8yjAfCDQPXTgnXIj48asJiKEPjmD7coN/k1E5fBNw7/1gCA/YmmBvCQwOZwYM7MSsR47x05va7PIf+C5uHZyulaLCV57NWDpzDmrsrD7Xc0+i9h44I3+w89QFU1T7E0ebqUdAVbBiZSVxJhWUzrJTpk/gLxjQRUmIzdbtqif13XpcANOVpDA/RD11p5pHXJ2nhjnO+M2+kgKFdYkmbaCo3RA4PQVZQOLn+85sQnRZbrR3JbWxGvt2N2btImjddHKWZWBYSXQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba5d1928-aaee-4702-a862-08d85bff7edc X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:17.8791 (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: NFl/sUFdEDmV/5pZKdBSy1B9R8mToliPwiO2uGUTjNpq8CJH3cqdi2OCl3PHQTvc807CX7yR4omuc0moyOim0oa6ugFUXB6HytLhv6pTenI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.122; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:06 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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.23 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" Introduce dynamic float precision and use percentage to show delta. Signed-off-by: Vladimir Sementsov-Ogievskiy --- scripts/simplebench/simplebench.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simplebench.py index 716d7fe9b2..56d3a91ea2 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -79,10 +79,34 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): return result +def format_float(x): + res = round(x) + if res >= 100: + return str(res) + + res = f'{x:.1f}' + if len(res) >= 4: + return res + + return f'{x:.2f}' + + +def format_percent(x): + x *= 100 + + res = round(x) + if res >= 10: + return str(res) + + return f'{x:.1f}' if res >= 1 else f'{x:.2f}' + + def ascii_one(result): """Return ASCII representation of bench_one() returned dict.""" if 'average' in result: - s = '{:.2f} +- {:.2f}'.format(result['average'], result['delta']) + avg = result['average'] + delta_pr = result['delta'] / avg + s = f'{format_float(avg)}±{format_percent(delta_pr)}%' if 'n-failed' in result: s += '\n({} failed)'.format(result['n-failed']) return s From patchwork Fri Sep 18 18:19:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AEBBC43464 for ; Fri, 18 Sep 2020 18:39:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A922121534 for ; Fri, 18 Sep 2020 18:39:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="CsC+P/wR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A922121534 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJLIb-0000jc-KA for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:39:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJL0K-0007ei-CD; Fri, 18 Sep 2020 14:21:06 -0400 Received: from mail-eopbgr40094.outbound.protection.outlook.com ([40.107.4.94]:32391 helo=EUR03-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 1kJL0G-0004dZ-8y; Fri, 18 Sep 2020 14:21:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EK5eR27YHOnXGlAvBcG1fMueiI0Ge0kMoNd+GNPHkRMpXOykI0LE0+DvyL/XPIkxvha6ImBBQgoFrCO594qulQ/yLG2jrnreAbPObKArlQyL4Dgf4efq1IcIKlKvsF2ruFP+RiNamh0OmunAxEAvVeAVIjMaBUjUXSo1nPTe7aCIZVNW71nuwmyJgyFj92GqLmOw4gE37u2shCnyuxveCK/2zXvep49SM5gHbEZqkJ5ng6QhVJwiu1/4jx7gSyhEip3N4DPqFCbanlH83KYLNNJhOiWx6/xa6VG5OsaKF+qjKhOJ+NWoZn1F2LNhziZWp+tVDZWUHuMvxrMugmpX5A== 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-SenderADCheck; bh=MaA6RrRANpRcdov7Gw6qp3pWulzXEsVWc/PNy6xwrbg=; b=aFaYU18MSRfCQ8eQSSoZXJHZF0toODHMFDXtTceHRw7wqN4VdJk+ZrLuFYBU8Ahyn+5UuKQgftX3W4Bg6e9sQkCmiBatufBtillOid0g4CiVLEnMzWJ2cwu6Yj36MdbjT5/Udw+Oxt7xPR/+A8vBeAkChSBjJo+4cNIbx8L1j1Yxcgtw3k28SRYgQL5KOyx9McTPGVleSyJgkVAg+yrGRu0nJxjYVSqY7EEHi+PbvjqAkUTGmZqr4OywnssWBmWPGR3HUGXmOVQAhFM8Sgc6jj0kaJhm6hM5MqKEkvNgzSL7LRj46SL+enqBEBHkAAvxdZoGjLxmVNlwQFhbK9vJYw== 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=MaA6RrRANpRcdov7Gw6qp3pWulzXEsVWc/PNy6xwrbg=; b=CsC+P/wRNw7bgHjUvpvv+7ASzZZfJAmZ+RCPfpnj7IwkDAaXC+gD3yQoyMevkp0dcpH3KGNSrhFdch3nzk5auY8ACQ64n2KTquw5T0phLP7f436+UKLVNstRvlIEKzDkiNkTmaJCE4aPeqTHDZ3M1M/1nMQ2fvkGBVXp16+8kEU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:18 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:18 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 14/15] scripts/simplebench: improve ascii table: add difference line Date: Fri, 18 Sep 2020 21:19:50 +0300 Message-Id: <20200918181951.21752-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:18 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 806d1ce3-8609-4895-6060-08d85bff7f78 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eaWir+/zNKHHVettEO9Pa+yTpQAH7nJRb5pCYcVPBChrlZBdbIaqrtiKc1iGoDOILd4R3/qi/rhmIBWb903G0pLD+u0oRsc7A3gy2cq5Bfl0HN2p0KWCGd3JyctUTqYWvz3CYGy8Be6QyQ/fLdwyUidLWVQXJEPSKRpPr//pSHFgxEz+vIX1CvQEcQUlrI/ULg5Btq4QFO7bdGXo2TewzntaHx6YjgeiolHDJ/+EaeKpU0+SqQXB/ZReKTMP36DSttAVhh+5X60YiKXJb3WRBHSmn+YIxF244hF53BOHPp54xt+Wr4ujNrpIspN6WNqKPIWv4yeOG0CvE1ML9QcoqQbUpB6IzKFWwvvfFyWouoyeNs7mBHA+AU80rJWqAVsK X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: jLCKStDn2IsgR2I4AILRzfZoWZNEZl3j83CbuAxr1VhATm20CKXM/t9Gvx2PtQEak8zRJ1k43snXk4sS8Il1NVu7Xoi7rUTKbQxk2Im+GzYUYcj84XuZHvZuUFQewFtXHGLzqr09kGVjmPgN/lQ6PCN+TrVGXZ0qV1AgZsUkP8ME2HD4uhgwLXDMyBw7tamonKAHvw9Kt4Zjecuc6qq5fDkZZhyWLeWcJBYLZCk2kN5xzfRP/3dcBlan3dZ8ZO4s2wVZSHTJEzl3AunOTzjlRDRVuaooOqPbB87F/UKlNOjPysW+vvZkqBNo63y1neqejTxLwqm9amxt0bn0ghdgd11N3K4R6in+GYFVkRY0D4w9LecS+PAlHM+wIqBtn4ANGw6qmUFIzXy5wPliUctr83kBSQc3YNdUNjORqJytmEZly867/vcTn/oAk72Ywf7APmhf88ayMOyDXPYaef9xTrC5a2NcRaairNCX+ybqRhkMaDOjz7Ld2t3JeCEiPZ7HmLK0+hFKp2t6SsvC6H6OAP+tVXgilhuEwym8jDul+hLvRdsePJUj0fAHZskR0ssF4LeRime5hYnJFaLSQo5q4+NyvAW8TZJ7OYJYOzP/UFzq7xcgJ6iWTSnjXRXm+NQvb88MQ8WN9svinWkJOPNAJw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 806d1ce3-8609-4895-6060-08d85bff7f78 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:18.8389 (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: MTryrD1aM50JFt3i+mcxNquZD44oO0JDwfikQo02grhUaVWF1/4SuREAEFgVyQw3lYjA/sP63nEPp/Qsxbn3BEosoL1BJWz5TbaMsWoLFno= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.94; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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.23 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" Performance improvements / degradations are usually discussed in percentage. Let's make the script calculate it for us. Signed-off-by: Vladimir Sementsov-Ogievskiy --- scripts/simplebench/simplebench.py | 46 +++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simplebench.py index 56d3a91ea2..0ff05a38b8 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -153,14 +153,22 @@ def bench(test_func, test_envs, test_cases, *args, **vargs): def ascii(results): """Return ASCII representation of bench() returned dict.""" - from tabulate import tabulate + import tabulate + + # We want leading whitespace for difference row cells (see below) + tabulate.PRESERVE_WHITESPACE = True dim = None - tab = [[""] + [c['id'] for c in results['envs']]] + tab = [ + # Environment columns are named A, B, ... + [""] + [chr(ord('A') + i) for i in range(len(results['envs']))], + [""] + [c['id'] for c in results['envs']] + ] for case in results['cases']: row = [case['id']] + case_results = results['tab'][case['id']] for env in results['envs']: - res = results['tab'][case['id']][env['id']] + res = case_results[env['id']] if dim is None: dim = res['dimension'] else: @@ -168,4 +176,34 @@ def ascii(results): row.append(ascii_one(res)) tab.append(row) - return f'All results are in {dim}\n\n' + tabulate(tab) + # Add row of difference between column. For each column starting from + # B we calculate difference with all previous columns. + row = ['', ''] # case name and first column + for i in range(1, len(results['envs'])): + cell = '' + env = results['envs'][i] + res = case_results[env['id']] + + if 'average' not in res: + # Failed result + row.append(cell) + continue + + for j in range(0, i): + env_j = results['envs'][j] + res_j = case_results[env_j['id']] + + if 'average' not in res_j: + # Failed result + cell += ' --' + continue + + col_j = chr(ord('A') + j) + avg_j = res_j['average'] + delta = (res['average'] - avg_j) / avg_j * 100 + delta_delta = (res['delta'] + res_j['delta']) / avg_j * 100 + cell += f' {col_j}{round(delta):+}±{round(delta_delta)}%' + row.append(cell) + tab.append(row) + + return f'All results are in {dim}\n\n' + tabulate.tabulate(tab) From patchwork Fri Sep 18 18:19:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 305034 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A016FC43463 for ; Fri, 18 Sep 2020 18:35:24 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D30B7206D9 for ; Fri, 18 Sep 2020 18:35:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="uXcWuzCM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D30B7206D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJLEA-0004Se-OL for qemu-devel@archiver.kernel.org; Fri, 18 Sep 2020 14:35:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJL0M-0007fx-El; Fri, 18 Sep 2020 14:21:07 -0400 Received: from mail-eopbgr40118.outbound.protection.outlook.com ([40.107.4.118]:41027 helo=EUR03-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 1kJL0H-0004nY-KJ; Fri, 18 Sep 2020 14:21:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QyRkXGGjjygKfjnoo3RiQvq8rSjtTgH33QQ1zG8JDw/4sYIzQ3MXcmLzSAwVvUPONlBJrZGCcoRe7mgVO74/N60ohDhh9yq//jOpQUDHMrPWbRZuRc3fQEVscBYo+C3dna56XS4tqo3v1CsWEZPK9VHcTcPcD23cO4z/dW3I0A7yOohPS/Rm3uctvghl8BYRrO5vakptq7HODwTJIK2b7s0Ftrv+cJBLemrcb/21ktrnYfIzX5uwTMT26NSSOZ3pErtCzxesEH5U9+upHt1NyNQII88qG2G6MR7cWnhHFe0CKghpP9TTUy0zr/tiOb2QXEjgJ32HtqyicnZVW5tTow== 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-SenderADCheck; bh=hGXx0477ugW7n4dPTvPsMlMEHRdvyN59tIlfSH9tDOo=; b=G3JpwVRdnu1TbsueyN2mpQkzv2zszRirmJtZH2DCE6+3sqEJtgmlYSTK/uC7dDuO2q6J/ljCJV6Iaoo++kq2tahFqL3ESRkiDpTgMFXAIz3m/LTyDNSj6xBFM9RiHVbr5HsTw0BPIlYdtsBnJvzBuX3pyUWt7IyepaGOf0AsHMs58C/c0X8AsSoQ73lpSJhV9FHTXaKc82yr09cWU9QLv13r4iTfL2XzeqTIIDQepKB323ik92uphhNeIyhvRtEM2bkaMul3pTxV09vRW6WWnmWAcGpfKfwnbehHYATKKPh36ed5FeowcT5JOlLqJxgE9atcBdrEjFhe73TsAzOAyA== 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=hGXx0477ugW7n4dPTvPsMlMEHRdvyN59tIlfSH9tDOo=; b=uXcWuzCM6TYN7ILQ0p3+djj1TfIcOAsFOOCY9F6JnP80udWl0sBDyWmfbGLd+UnHnJcNWB+rPFNGPbQk/bqFYyAnMQ8fiWHTzhYE3p35KSjlKYEIzRxtgnZTBVMN1GFmZuZUIkRleSREYeL90+HeI3RTI5054m8S3fLk5qmcaAI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1905.eurprd08.prod.outlook.com (2603:10a6:203:43::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 18:20:19 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b179:9641:7589:d692%8]) with mapi id 15.20.3370.019; Fri, 18 Sep 2020 18:20:19 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, armbru@redhat.com, eblake@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH v6 15/15] scripts/simplebench: add bench_prealloc.py Date: Fri, 18 Sep 2020 21:19:51 +0300 Message-Id: <20200918181951.21752-16-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200918181951.21752-1-vsementsov@virtuozzo.com> References: <20200918181951.21752-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.106) by AM4PR05CA0019.eurprd05.prod.outlook.com (2603:10a6:205::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Fri, 18 Sep 2020 18:20:19 +0000 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 27181466-6393-4b63-557e-08d85bff8007 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1905: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: keScvEvZxUXz21ggXQStW58rhCLFYppWbDmy0KNdV4414Ea9QupAY6CIdkf6J6z9JcdCuAl2iuQCj5vP4HEshSIrL0xl3W28O9UXGHY3q+g3syl1cmldVOGSxkGeJP9XC4d1pGRjdgJl15vLEFHw+sdum/3PKOqiziX791ZdWJ0K+9Cd0tv309XKL18zjCBvWiiGQEuqDrCFvIikW67q237HtvOU/SP3TvQHMRfkUg7G0npbUrcdK3iWNl9ig+k625frjUj5uKr3fn0ChRyNx1X7am2RFKZp/p9TiodD0yZuzM0QIUvuLp9CjNQcb/cawc6dWasy6UAo5oQYLjrmif+kY82CllLmgoQwAuOxkN6czGrXwTWOqdeqowsW/lkzdCmkZfCEUVbLrShParilR3xbvP8yMxREbSi+Y8ZHVBgWQEDbaViCO+PIjv27v5BUYomGITxYppD5UXU1qaszFq4jzR/npuHf4RjkjrYQMs3OYnFiOcdZ1DTskMeM2nkS X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(396003)(376002)(366004)(136003)(346002)(66556008)(8936002)(66946007)(66476007)(107886003)(6506007)(2616005)(5660300002)(2906002)(83380400001)(6486002)(956004)(6666004)(1076003)(186003)(8676002)(52116002)(4326008)(316002)(86362001)(6916009)(478600001)(26005)(36756003)(16526019)(6512007)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: GNoyOSFNF/esP0Ia/wR1AFkMVLPSyl07bVpQ1fojrujhy+YU+bJ830aA/wwxaZP0sszQ1ojnRE9TjDYmlu3zTqVQiu89MM8wBcH9oMWtTzxBLrjNqjqyKpCwld7eetXsG+EMyAtas/97ro6Yjvbsd7dCeOCQg/QCogLJYKGFUURpFxyr/x+BvEUMky/BgSxwRSjGiJoje6Q8LEe4zF1PRq5vXDU0ytLYHa13Cipch6ZUGmUouktuArQYl0YWZE7eg5hYxMw6bwrd9AnG+xznyN8UTCcb6DwhLKhtyuUc97IWU46hLVFJyukhja/FhuohMG/MmhT+wf5e4iKl171z7KpceewHkDdwbDdX8bulgnBBe6QftQYDY5lP+0eNCCGgjdlwPGJkn2AL/jLMKOdjQ8uxeJMgO5RdTrVEdH9YbdlIWz1odgmOYC0IOGHSScbhamQe9R5m4QyVV/0DYb2nLD8fD/olPkBzENJJF+t71U0aCSqvqjxHojTcKrMtWy+lRpdiXgOgb1qQIPbkfMoshO+V/2AuCFnwCCZ3sYck6eAwlo0gn+b1yNI+dqaSsPbfQSj01uF+BBJ21S5CygyY4j4BsP0b+aXK+PH5xK1RLJ9BwLTd90f6RIiV7oNA1gyKIHtwqKJSD+k01AML7+P3KQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27181466-6393-4b63-557e-08d85bff8007 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2020 18:20:19.7469 (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: CKX77NGqCO2xxMtNJy+0WLvqc9Y2xTrse8ze+lsucRvyTBpu27LTGYtjtzfOs6KiYGtFhZbL+V/7gVaZXeq04zHrXb0vT4Hssf9FjufB8CA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1905 Received-SPF: pass client-ip=40.107.4.118; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/18 14:20:23 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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.23 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" Benchmark for new preallocate filter. Example usage: ./bench_prealloc.py ../../build/qemu-img \ ssd-ext4:/path/to/mount/point \ ssd-xfs:/path2 hdd-ext4:/path3 hdd-xfs:/path4 The benchmark shows performance improvement (or degradation) when use new preallocate filter with qcow2 image. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- scripts/simplebench/bench_prealloc.py | 128 ++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100755 scripts/simplebench/bench_prealloc.py diff --git a/scripts/simplebench/bench_prealloc.py b/scripts/simplebench/bench_prealloc.py new file mode 100755 index 0000000000..fda4b3410e --- /dev/null +++ b/scripts/simplebench/bench_prealloc.py @@ -0,0 +1,128 @@ +#!/usr/bin/env python3 +# +# Benchmark preallocate filter +# +# Copyright (c) 2020 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +import sys +import os +import subprocess +import re + +import simplebench + + +def qemu_img_bench(args): + p = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + universal_newlines=True) + + if p.returncode == 0: + try: + m = re.search(r'Run completed in (\d+.\d+) seconds.', p.stdout) + return {'seconds': float(m.group(1))} + except Exception: + return {'error': f'failed to parse qemu-img output: {p.stdout}'} + else: + return {'error': f'qemu-img failed: {p.returncode}: {p.stdout}'} + + +def bench_func(env, case): + fname = f"{case['dir']}/prealloc-test.qcow2" + try: + os.remove(fname) + except OSError: + pass + + subprocess.run([env['qemu-img-binary'], 'create', '-f', 'qcow2', fname, + '16G'], stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, check=True) + + args = [env['qemu-img-binary'], 'bench', '-c', str(case['count']), + '-d', '64', '-s', case['block-size'], '-t', 'none', '-n', '-w'] + if env['prealloc']: + args += ['--image-opts', + 'driver=qcow2,file.driver=preallocate,file.file.driver=file,' + f'file.file.filename={fname}'] + else: + args += ['-f', 'qcow2', fname] + + return qemu_img_bench(args) + + +def auto_count_bench_func(env, case): + case['count'] = 100 + while True: + res = bench_func(env, case) + if 'error' in res: + return res + + if res['seconds'] >= 1: + break + + case['count'] *= 10 + + if res['seconds'] < 5: + case['count'] = round(case['count'] * 5 / res['seconds']) + res = bench_func(env, case) + if 'error' in res: + return res + + res['iops'] = case['count'] / res['seconds'] + return res + + +if __name__ == '__main__': + if len(sys.argv) < 2: + print(f'USAGE: {sys.argv[0]} ' + 'DISK_NAME:DIR_PATH ...') + exit(1) + + qemu_img = sys.argv[1] + + envs = [ + { + 'id': 'no-prealloc', + 'qemu-img-binary': qemu_img, + 'prealloc': False + }, + { + 'id': 'prealloc', + 'qemu-img-binary': qemu_img, + 'prealloc': True + } + ] + + aligned_cases = [] + unaligned_cases = [] + + for disk in sys.argv[2:]: + name, path = disk.split(':') + aligned_cases.append({ + 'id': f'{name}, aligned sequential 16k', + 'block-size': '16k', + 'dir': path + }) + unaligned_cases.append({ + 'id': f'{name}, unaligned sequential 64k', + 'block-size': '16k', + 'dir': path + }) + + result = simplebench.bench(auto_count_bench_func, envs, + aligned_cases + unaligned_cases, count=5) + print(simplebench.ascii(result))