From nobody Fri May 10 03:04:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1600973898; cv=pass; d=zohomail.com; s=zohoarc; b=msrNHjUbln+SVaRV6uMkbg2U9ePi1em7QtuUNjLdWEvao1RCPOBwiJowWEyfTH9vMocpf3uE/K5aIr4UKvnqWkSJPWoM3f6Jiw01Xf9aQrlwmcJlgXAwKX3C3hcLsOb7Aax2j38hgnpwSIqaxLqnIyPxT7Og1RpRSWPVJrLDHA4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600973898; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cYqpEH297IGWkFRtD9+RMk5kfLYHxD2l9A+HPSnAJ1E=; b=L2T2/JAGy9loYfDfGquWmqjDuQ8xbDoinS5gTb14aEUOat7zimCA6NDF8by7Un3vuI27/ostduRNjdH+rubTtUeaRqYhl/8jWtR52/lq6XZ7+QPmXrc43cFFPyBhjzpGrvnjiQd6e8cQ+4RzfJYzDSrrevMfa5C0l9j//VphsWo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600973898448225.63223394131091; Thu, 24 Sep 2020 11:58:18 -0700 (PDT) Received: from localhost ([::1]:34920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLWRc-0003Je-SK for importer@patchew.org; Thu, 24 Sep 2020 14:58:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLWO9-00019y-J8; Thu, 24 Sep 2020 14:54:41 -0400 Received: from mail-eopbgr130114.outbound.protection.outlook.com ([40.107.13.114]:8257 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLWO7-0002O2-K2; Thu, 24 Sep 2020 14:54:41 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Thu, 24 Sep 2020 18:54:34 +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.033; Thu, 24 Sep 2020 18:54:34 +0000 Received: from kvm.sw.ru (185.215.60.94) by AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Thu, 24 Sep 2020 18:54:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aDjRdPJa2vuPky/KFF2jfzDzq0+7CmgMS2NVx59ECBPDe6x+qmxnrXUMTwOcAhSZtmXbP0YedSPL4VWaQWAM20H7LRhHOvhJ3iRV8EZ1QVFImYBtwS7zvDNey7alWvCBo/yZAzo6Bee+HPoF8QNNFP0gZR94oLPnFeOWd05ZHNvmDRCKZu7VxqoUiSUTFVwgEMtpDu/b+W1DxDjCQzUtQkMqD68lADPXf0USC9t2iDahoLrOb7oRTXFUdALkSwAv6GAw0nsAcFClS0KFq/e/rY/FMvjot3VHm6/CaLILHJqC57c2xHQgVoBTSxYjC++palTda53fCW4bJjsNpwMD0Q== 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=cYqpEH297IGWkFRtD9+RMk5kfLYHxD2l9A+HPSnAJ1E=; b=IVec6ND9OsfWS3F5y8gEhVnZ3wGKzcs/CXXW+IStbC2MQnhQYGtHpjkIiMdaB06dKXi1exOAiEC6wQj9ZZBpZz0HK9cnKnj1K5e50x9AeMBU/36Mspv73RG/KJkhIFC0MS0PS55O5dEWXrcGk7Ct+jwcMDAhihQcsN6sduM71tdUPgX/w593NQROmQdCNVcBblshJdDnVOMAC/wylLH/vVKk/6tu1pDMIolza+tvXZ6BKkytie22XJD0JA92gqzTydA/MKOfKfLoddmrThDUDB07AtLyRmmeFwqHSiKl+/uFT1iPo7uJ4zzUiDjtIHhIlN+741dMqwDT4nqLnTV42g== 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=cYqpEH297IGWkFRtD9+RMk5kfLYHxD2l9A+HPSnAJ1E=; b=H7I5wrUxjimoK5jawXoJnJV/iSab0ZW71Zknw87KUT2CvmntiW3HOrBOoUZEvt+R06t8nqJ4CbKdE7FxZx6o0q0MQqhvv5KyYpWs+2mF0caPsZSww10gFBXJApsJ4mTAR1WopSdNAMbqmdtK0jJOgkVv2fE67ap4ur9cn23j78Q= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, vsementsov@virtuozzo.com, eblake@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v9 1/7] block: return error-code from bdrv_invalidate_cache Date: Thu, 24 Sep 2020 21:54:08 +0300 Message-Id: <20200924185414.28642-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200924185414.28642-1-vsementsov@virtuozzo.com> References: <20200924185414.28642-1-vsementsov@virtuozzo.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.94] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1a7fbbba-9538-4016-f3bf-08d860bb4715 X-MS-TrafficTypeDiagnostic: AM6PR08MB4341: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:489; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 36DzF1346X0PuKHZcZy0bS4W4LZzERv0e1odRGIfLo2R+DUQhOYJQ+TP6a31A2ILAIvKSJbOIVsZLGb7gKR+mfs4j6x0OYKNi2HQA6btn8WwBAQ6rdJpYVacIg6ETx1fwnVPmyHMF9TgIdQS2G9oH5Z+lGs9+UsJiOY8y7AFASNO0fohbvfIUAnMUpjyIwzFLq0zz9SI7cjYaK9V9n2k/esUKLhiXVrlgr/QTc9B4C/v50DFTPx7eRdZEZaeEmTn4tOLtIRxnVGrE5dYwnKy3Du2pZWXDgzMxv+H377XdyYmuKGLjD1FzD2ADseoU00MTdm7M20o/Imb5b3mf86C3QWcj26Qog5yOtxCOVskMCj0bJnl13OTOX8/BYcpkAxe 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)(376002)(136003)(396003)(346002)(366004)(39840400004)(316002)(83380400001)(66476007)(6506007)(186003)(16526019)(5660300002)(2906002)(36756003)(6666004)(8936002)(8676002)(66946007)(2616005)(956004)(52116002)(6512007)(66556008)(86362001)(26005)(4326008)(478600001)(6916009)(1076003)(7416002)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: ok+psQ9yheokqXgHqp/iTA8n3/52iIjom1ceNGlqYLanxQWuEYce+5AByy4aS1ye0Yjj4m2XZMf6ILO4RRZ1uwEGHOmbqWqYkUF00IQT5Zk7yOwL16SNcXOUT1ywF2sOTXJfkLIL7xX7wc1+i/xaQC9rUL70GDbNM8ZAXy5Xz8sIpzdHMTQxvZpxrZ786WC/7d7X6GXN0eDAWbOWNuFrCjUMkMn5yZFwkvuQqezf4sACdvXXadP7KScNJHPHcqs+F07dLQE0tzqQugdFtfmtXYK9TlTTG2IQxtZhJeE2s+W0BVRI0uc40S9ptj/9NLVQicd2MLuSBbgn9CCFtDIp3EBMYnbrrJvjPPSAtYrGKw/I9xDv4B7Al5tQB16uNISaw4xV/3Xq03/SYRUA/TIGAorGgYZlSFIs2ToHfo9eIVtIqgpteJKXxGfE7+PXF/M/G7BLz5HTX1svy9hKn7v6F2kAN+a9rt3UCJf/K6iRWhGl7juDA8w78+u1DBVgJp101oR9hD4ZiuYQgaUkKuzGxJ+KwYuIk00SuUIfwx0M4swSmFlj7ut1DCHquXAe4Gumc033W3rL9z8w18IrOKes9ATwCxuaUXHodW10dK8yYlRZx/l4SXuCoKDHWg37fg3REpU+fmpakoF2Lf7VY/6pSw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a7fbbba-9538-4016-f3bf-08d860bb4715 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 18:54:34.2080 (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: UclNqJ5Gex4qGTccM420fgpV70US2ZJo5g/oXn02vHx16Egx2QA91puiDLBYvmzpP/Fzmrt+lq94hGhQ/yT8ygTDvqRyLiIV00DI9qrC7kY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.13.114; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 14:54:34 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) This is the only coroutine wrapper from block.c and block/io.c which doesn't return a value, so let's convert it to the common behavior, to simplify moving to generated coroutine wrappers in a further commit. Also, bdrv_invalidate_cache is a void function, returning error only through **errp parameter, which is considered to be bad practice, as it forces callers to define and propagate local_err variable, so conversion is good anyway. This patch leaves the conversion of .bdrv_co_invalidate_cache() driver callbacks and bdrv_invalidate_cache_all() for another day. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- include/block/block.h | 2 +- block.c | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 981ab5b314..81d591dd4c 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -460,7 +460,7 @@ void bdrv_aio_cancel_async(BlockAIOCB *acb); int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf); =20 /* Invalidate any cached metadata used by image formats */ -void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp); +int bdrv_invalidate_cache(BlockDriverState *bs, Error **errp); void bdrv_invalidate_cache_all(Error **errp); int bdrv_inactivate_all(void); =20 diff --git a/block.c b/block.c index 11ab55f80b..47b3845e14 100644 --- a/block.c +++ b/block.c @@ -5781,8 +5781,8 @@ void bdrv_init_with_whitelist(void) bdrv_init(); } =20 -static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, - Error **errp) +static int coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, + Error **errp) { BdrvChild *child, *parent; uint64_t perm, shared_perm; @@ -5791,14 +5791,14 @@ static void coroutine_fn bdrv_co_invalidate_cache(B= lockDriverState *bs, BdrvDirtyBitmap *bm; =20 if (!bs->drv) { - return; + return -ENOMEDIUM; } =20 QLIST_FOREACH(child, &bs->children, next) { bdrv_co_invalidate_cache(child->bs, &local_err); if (local_err) { error_propagate(errp, local_err); - return; + return -EINVAL; } } =20 @@ -5821,7 +5821,7 @@ static void coroutine_fn bdrv_co_invalidate_cache(Blo= ckDriverState *bs, ret =3D bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, NULL, e= rrp); if (ret < 0) { bs->open_flags |=3D BDRV_O_INACTIVE; - return; + return ret; } bdrv_set_perm(bs, perm, shared_perm); =20 @@ -5830,7 +5830,7 @@ static void coroutine_fn bdrv_co_invalidate_cache(Blo= ckDriverState *bs, if (local_err) { bs->open_flags |=3D BDRV_O_INACTIVE; error_propagate(errp, local_err); - return; + return -EINVAL; } } =20 @@ -5842,7 +5842,7 @@ static void coroutine_fn bdrv_co_invalidate_cache(Blo= ckDriverState *bs, if (ret < 0) { bs->open_flags |=3D BDRV_O_INACTIVE; error_setg_errno(errp, -ret, "Could not refresh total sector c= ount"); - return; + return ret; } } =20 @@ -5852,27 +5852,30 @@ static void coroutine_fn bdrv_co_invalidate_cache(B= lockDriverState *bs, if (local_err) { bs->open_flags |=3D BDRV_O_INACTIVE; error_propagate(errp, local_err); - return; + return -EINVAL; } } } + + return 0; } =20 typedef struct InvalidateCacheCo { BlockDriverState *bs; Error **errp; bool done; + int ret; } InvalidateCacheCo; =20 static void coroutine_fn bdrv_invalidate_cache_co_entry(void *opaque) { InvalidateCacheCo *ico =3D opaque; - bdrv_co_invalidate_cache(ico->bs, ico->errp); + ico->ret =3D bdrv_co_invalidate_cache(ico->bs, ico->errp); ico->done =3D true; aio_wait_kick(); } =20 -void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) +int bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) { Coroutine *co; InvalidateCacheCo ico =3D { @@ -5889,22 +5892,23 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Er= ror **errp) bdrv_coroutine_enter(bs, co); BDRV_POLL_WHILE(bs, !ico.done); } + + return ico.ret; } =20 void bdrv_invalidate_cache_all(Error **errp) { BlockDriverState *bs; - Error *local_err =3D NULL; BdrvNextIterator it; =20 for (bs =3D bdrv_first(&it); bs; bs =3D bdrv_next(&it)) { AioContext *aio_context =3D bdrv_get_aio_context(bs); + int ret; =20 aio_context_acquire(aio_context); - bdrv_invalidate_cache(bs, &local_err); + ret =3D bdrv_invalidate_cache(bs, errp); aio_context_release(aio_context); - if (local_err) { - error_propagate(errp, local_err); + if (ret < 0) { bdrv_next_cleanup(&it); return; } --=20 2.21.3 From nobody Fri May 10 03:04:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1600973970; cv=pass; d=zohomail.com; s=zohoarc; b=jaRu+j1hP4I/Pfcn5UBN3BNVCQkTVH6f11K9vxuClWWSt6fNZqZb1COTnnm3AFQ8c14/a4o6ysiZlW0jWGmW+66c3yRtH1FxoIBbCnVpthVExsEJwkLqtyy6kTjc5yZlpvNJLN0g9pGVBwnvOEoRmCTJMyLO8W5pAB+1EFexgEE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600973970; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vNj1Xx5ux0eVXqhoEZLTGQpTAmwFAjKTuBAOkZKF68U=; b=avTiJ4Rop+5RFirdAswMQ9KkoM03mwOd4RrZDOUZlUyG8ol27pFLhzKjQhwQgV1M3G+stgGIC6Y+fjdGzPVqkLF1T16RmwhgX6KVHmGRoquNip58Zuv2vqEU+uL/OUq9D5xZZl57RNsjVOCXaoftHZxIOE3wSbPme2cL9o4jW+w= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600973970571568.1999214912222; Thu, 24 Sep 2020 11:59:30 -0700 (PDT) Received: from localhost ([::1]:39718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLWSn-0005N1-5B for importer@patchew.org; Thu, 24 Sep 2020 14:59:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLWOJ-0001Eo-0R; Thu, 24 Sep 2020 14:54:51 -0400 Received: from mail-eopbgr130114.outbound.protection.outlook.com ([40.107.13.114]:8257 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLWOA-0002O2-4y; Thu, 24 Sep 2020 14:54:50 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Thu, 24 Sep 2020 18:54:35 +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.033; Thu, 24 Sep 2020 18:54:35 +0000 Received: from kvm.sw.ru (185.215.60.94) by AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Thu, 24 Sep 2020 18:54:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I95F282aXrdP24mxXYKFPuUZvxZyJGNMtG8EqG1i+59DjwSfqnQv1rtJv1FYc4b3eIme2nw4XsibwoJd7ErDBBOJxRrnlMA8fIsIYtISSyeehXptvFBl0glxdnUjY7hHrED2yv8Q/OoYGnAvU24LSkpMDS3I4bJ2HWu38+BgR9KhROHYG0BhdCUoLmzdzhwIm2KBFaClS0k4YCGyfhuCklLh20QgtWL4LLjHLZnsEKVR9OP3P8nQFbQ3HARVT08jGWyC3IVIAtbQrXPhtpuFx4JRRySJkpq3U9eyoc7PoqNbkLWixsVyW650A8WoHBHnRsusVd24mtAMsOli9NZfGA== 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=vNj1Xx5ux0eVXqhoEZLTGQpTAmwFAjKTuBAOkZKF68U=; b=XtyH5KGhvhRBCw5WAslEzLiZo9vONBmSx2t18v2+WwHPMNkwUbn4T2CtILI4Amkk3gWHwYN8pXy1OK0v97VQJOFFMmm3By4tgPFF65BGPBzilWJ/WWAyUYyIMz9blUhhVELxTTfAltjC/WomMrs3yA9gGLXBy1SZyxeK90K0rqDr4ZQ/7Ais7HKHKYrAXi/j9aJTCDLKKOKhiCML03ckbXuVOCOT0HNfrV52CuTe5ujs7fwjTK8PIfcmI3Wm9RAbQaDeTM+k7q5VQsFfjX+7WNe48pcXuyaLmSSU5yu6LtfCCTnObY78og4kUQBRS4uy2OFY+v3UcFZi+mgwsokd9g== 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=vNj1Xx5ux0eVXqhoEZLTGQpTAmwFAjKTuBAOkZKF68U=; b=gazbYyJGLudJlYauZOHyPpAkGbx39mCMc4Ss8pjhqUE5KxwHir0oMcF7NBeFyEH10ZIAlVS8LH3TamYNM0UaRuV02WbtYPdlSzr0doyaJOuvo7d84aGrMfVOxJSu2jN1NHcgyDtmk+cRGmSZ/bCQ0JYY02/GfiIDTSSiinY5LK0= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, vsementsov@virtuozzo.com, eblake@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v9 2/7] block/io: refactor coroutine wrappers Date: Thu, 24 Sep 2020 21:54:09 +0300 Message-Id: <20200924185414.28642-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200924185414.28642-1-vsementsov@virtuozzo.com> References: <20200924185414.28642-1-vsementsov@virtuozzo.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.94] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 95961a05-4348-494d-fff7-08d860bb47a3 X-MS-TrafficTypeDiagnostic: AM6PR08MB4341: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:189; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jhQ3zUwUlQqd5zQUqvYVRl4IcGbazzdmTrRo5n4rW2qfXtSXmE+Kuh8yXToUJKeWKpTEARmR7r5Iz2W7ZmC3gCqyFXf6DZenjrpsVUTiqzVFG0mTLT+8mnMj0iHMOU+dzIOxiOwJV4EGcZm/tmm5DLrmJOF0cmw7w+1Kk0ZYSnn1Nc04Bgr1Y9Ev9wUHYWcDfdw1VFWSHi7Q7rgIZpMbI8bx3fEP7jHfXmc2WDHOh8PO0VnVOJRgJRr92SFMNhi6y7Fu6Zfhm31ILY7oMiq2tvzS7mTuA51XmeyD5zEyECuY/VX2kjJYJZwThYwtK3fK15ESz2s820a57Cu8QtBqfFCiwJPB286BPsDTBmgBD+RQk3ARR+vdUtevyTbPWgdc 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)(376002)(136003)(396003)(346002)(366004)(39840400004)(316002)(83380400001)(66476007)(6506007)(186003)(16526019)(5660300002)(2906002)(36756003)(6666004)(8936002)(8676002)(66946007)(2616005)(956004)(52116002)(6512007)(66556008)(86362001)(26005)(4326008)(478600001)(6916009)(1076003)(7416002)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 72w+KlUTUCAAuAIN6Hg9XNdPpeRiFbHmjVYn1uVFpKZ2AMUQnQaW5ZIpwALTEPBSPG+hAmwCnpnBK/SK0Hk6LmbjiJ2klO02B2t8DoOYSMxWPl/zjRo2xsbr7zGyK6vT4/Q1mpXmK0rUErXWJm2aDjCnH6hDUpB3WJ+P4KMri4NPC6QUGi7jtMZ3Jjct6sVNlOQK9hdrJxmXiVbij92vOjKUPWBktTrTgffeEQA9TDjGEWgr4xRADY46XzXV1dOECkqJ31zCtv4ggexzHWzL9Niv9AKKg0oKcmWflEA8siUTp9Qe/GxrU++k/s5ErY07D59lhNbiXxaxmKYqCgZyvTr/cnYO7Pmd/mv+QtAFKsZy9spdGD3NMKJqYVybs8sbg7Z1/iYUUhmy9sC+R+93BofTTWfqR/pzj+59rwxryz+gnkYtYaN3L4mbfwWCsg/7+wNHh9kmeZ9mSEn6OpriZIoAYByNSUEV4+SKnihEk9LuJws9Y7gLlQeF+ZLNzHFfarenXWgFpFLgk/JvV5cQ0RnU9910SqGYxQchA13GMeMoAc7nc54HYPXycmzfRTbwPoCep7eQQ+Xb8+53ZBsRbs2p/LPkpMmFw+eVO0vO3AeraHY4rN5VxpKPiK+xObGDmrdKWWin9e8Fm7Tlb3Lm/w== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95961a05-4348-494d-fff7-08d860bb47a3 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 18:54:35.1519 (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: ucev8Wd1tF92+bfglHCqShSgBCFTXBjO+GlskATAm70jWE2s++htpI8A6L9Mz7toS3ji7f093OsyTrvDNWY7kB2gyJZtyRcxnOlNzVAUXKU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.13.114; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 14:54:34 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Most of our coroutine wrappers already follow this convention: We have 'coroutine_fn bdrv_co_()' as the core function, and a wrapper 'bdrv_()' which does parameter packing and calls bdrv_run_co(). The only outsiders are the bdrv_prwv_co and bdrv_common_block_status_above wrappers. Let's refactor them to behave as the others, it simplifies further conversion of coroutine wrappers. This patch adds an indirection layer, but it will be compensated by a further commit, which will drop bdrv_co_prwv together with the is_write logic, to keep the read and write paths separate. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- block/io.c | 60 +++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/block/io.c b/block/io.c index a2389bb38c..24a7de3463 100644 --- a/block/io.c +++ b/block/io.c @@ -933,27 +933,31 @@ typedef struct RwCo { BdrvRequestFlags flags; } RwCo; =20 +static int coroutine_fn bdrv_co_prwv(BdrvChild *child, int64_t offset, + QEMUIOVector *qiov, bool is_write, + BdrvRequestFlags flags) +{ + if (is_write) { + return bdrv_co_pwritev(child, offset, qiov->size, qiov, flags); + } else { + return bdrv_co_preadv(child, offset, qiov->size, qiov, flags); + } +} + static int coroutine_fn bdrv_rw_co_entry(void *opaque) { RwCo *rwco =3D opaque; =20 - if (!rwco->is_write) { - return bdrv_co_preadv(rwco->child, rwco->offset, - rwco->qiov->size, rwco->qiov, - rwco->flags); - } else { - return bdrv_co_pwritev(rwco->child, rwco->offset, - rwco->qiov->size, rwco->qiov, - rwco->flags); - } + return bdrv_co_prwv(rwco->child, rwco->offset, rwco->qiov, + rwco->is_write, rwco->flags); } =20 /* * Process a vectored synchronous request using coroutines */ -static int bdrv_prwv_co(BdrvChild *child, int64_t offset, - QEMUIOVector *qiov, bool is_write, - BdrvRequestFlags flags) +static int bdrv_prwv(BdrvChild *child, int64_t offset, + QEMUIOVector *qiov, bool is_write, + BdrvRequestFlags flags) { RwCo rwco =3D { .child =3D child, @@ -971,8 +975,7 @@ int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, { QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, NULL, bytes); =20 - return bdrv_prwv_co(child, offset, &qiov, true, - BDRV_REQ_ZERO_WRITE | flags); + return bdrv_prwv(child, offset, &qiov, true, BDRV_REQ_ZERO_WRITE | fla= gs); } =20 /* @@ -1021,7 +1024,7 @@ int bdrv_preadv(BdrvChild *child, int64_t offset, QEM= UIOVector *qiov) { int ret; =20 - ret =3D bdrv_prwv_co(child, offset, qiov, false, 0); + ret =3D bdrv_prwv(child, offset, qiov, false, 0); if (ret < 0) { return ret; } @@ -1045,7 +1048,7 @@ int bdrv_pwritev(BdrvChild *child, int64_t offset, QE= MUIOVector *qiov) { int ret; =20 - ret =3D bdrv_prwv_co(child, offset, qiov, true, 0); + ret =3D bdrv_prwv(child, offset, qiov, true, 0); if (ret < 0) { return ret; } @@ -2449,14 +2452,15 @@ early_out: return ret; } =20 -static int coroutine_fn bdrv_co_block_status_above(BlockDriverState *bs, - BlockDriverState *base, - bool want_zero, - int64_t offset, - int64_t bytes, - int64_t *pnum, - int64_t *map, - BlockDriverState **file) +static int coroutine_fn +bdrv_co_common_block_status_above(BlockDriverState *bs, + BlockDriverState *base, + bool want_zero, + int64_t offset, + int64_t bytes, + int64_t *pnum, + int64_t *map, + BlockDriverState **file) { BlockDriverState *p; int ret =3D 0; @@ -2494,10 +2498,10 @@ static int coroutine_fn bdrv_block_status_above_co_= entry(void *opaque) { BdrvCoBlockStatusData *data =3D opaque; =20 - return bdrv_co_block_status_above(data->bs, data->base, - data->want_zero, - data->offset, data->bytes, - data->pnum, data->map, data->file); + return bdrv_co_common_block_status_above(data->bs, data->base, + data->want_zero, + data->offset, data->bytes, + data->pnum, data->map, data->= file); } =20 /* --=20 2.21.3 From nobody Fri May 10 03:04:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1600973964; cv=pass; d=zohomail.com; s=zohoarc; b=RkzhQ5S4k7HXGnkUdhV9C4qJ84/wF4XOD9Rc8qcKaL9lMjCyQVtzSDIm58HQ2BRNsCF5eSCMi4Nc5E+PQLi934Y+/b0kXtsjl/qZdmPSXUA7/GljJczVIKxfT9EzsjQnIk6FEn6u1uViV4TV7InYzRbihv2OkblzI7rq/xGYgfo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600973964; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/skAuJOQTLyYKoeUDzpb83EM/Hud8EtD+2+bhAhYGx8=; b=LPTSjYcpyHCt4KoZR3ntt+DHrIUkImBwfcIs8XPiPbZJDkt90HExW9roXpStff8Kzb2Fy37vRa2B/YA1UdYSkfAqEsDUvcc/FlAsJ4cpP06ZpGairCNQWBOIlM/uOr/eJET0cHcSu8axWw/hWJNk8ewoT3xfbSASWURlIAQJewc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600973964241422.63599633973445; Thu, 24 Sep 2020 11:59:24 -0700 (PDT) Received: from localhost ([::1]:39170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLWSg-00058K-Q1 for importer@patchew.org; Thu, 24 Sep 2020 14:59:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLWOU-0001JN-HY; Thu, 24 Sep 2020 14:55:02 -0400 Received: from mail-eopbgr130114.outbound.protection.outlook.com ([40.107.13.114]:8257 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLWOL-0002O2-3g; Thu, 24 Sep 2020 14:55:02 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Thu, 24 Sep 2020 18:54:36 +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.033; Thu, 24 Sep 2020 18:54:36 +0000 Received: from kvm.sw.ru (185.215.60.94) by AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Thu, 24 Sep 2020 18:54:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CnRVO8vYEMYCVLEFz4VoXxkh0JgNVSkQVZ2K6JCJzwdr4sDBh+xxjua2JwJr81weGL3OPvjyAqettg2mx2BWz6SkAgEP2jKKTYaLnReHY4cXDomTMuJ0/0iDw9q1yJ0pCfKKQ/lqDBGn0n75pDvTWETqGMr0EKkaBfqevFxaZ8O39KSdikrY8aT8+Qd0diZVqeA+kxftLgNjVmX/EkeDQreudlW1iNpV6jNLFoAuwZief1IxbzZZHm6xHlLOuSWq6Op7zatcXaqbJU1LW8bUEkHpxcOG3XPhckEbYs+oIzI4c7xoFBXG72K/JO6OFQiw2caiqEhROZKt/Mr9BW8d7Q== 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=/skAuJOQTLyYKoeUDzpb83EM/Hud8EtD+2+bhAhYGx8=; b=MrN8ogmwTEAUeqI0+ujef1bIloglQmYpRPYMefEpT6JFJtlrNKmXEGm3mq2krLaFxeKFwK+QRT4tYhAwP+LmQsTmMoV8IoyFLXJN/bNl1GX8dY664hwrKZzwZOhRCO191i5UcU9gU/jBTYw3PqRWZi85C5wjcDwwK8zm3cEBAXDh0BCkVXS/rGJaAOvbc3dnZ484njA4BSF2G/4DSZsCBoecPJbNiBvnoHK9oz2xNX/C+HI8vb4nJ0nIfVJmXyI3WVuh7dp1gmdSZ7g29M+EzxG63hjUoHwQHh4GqUp6mp5TNDZ9wMG860c+15gouC38kg0L308dZFFMwIs/K9J4/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=/skAuJOQTLyYKoeUDzpb83EM/Hud8EtD+2+bhAhYGx8=; b=SELJZ0Mn2ujHm8G08hb4DE67iTnGnU7LGXyvnAwKRrgyg87sK2xq/HMNxyT+PEPreL+IHVlYnHHZYo4taHXoSi9h3Aq+1XIRigZocob6S5lbY5PUMH28LLu3T/kpufyshG19ow9S/nQafegyuDHc9N4HXQs5zhyj4fchMmNVFb4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, vsementsov@virtuozzo.com, eblake@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v9 3/7] block: declare some coroutine functions in block/coroutines.h Date: Thu, 24 Sep 2020 21:54:10 +0300 Message-Id: <20200924185414.28642-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200924185414.28642-1-vsementsov@virtuozzo.com> References: <20200924185414.28642-1-vsementsov@virtuozzo.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.94] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7217b8b6-b215-481c-d215-08d860bb4837 X-MS-TrafficTypeDiagnostic: AM6PR08MB4341: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SYL3QvlCovmsz2mCovgG1TB5S0agNw612vdob9bmmfwh180cC5C0Y46zgZAS3Hffzrx1tHZ2SjFBdBEfoIoxkC0Tnsr3JgTkX3sh5T2U5Y3eKNhnsGHtEeQpZHmoAyWivTz0dbGPd6ffREogpaa7Wh5k9ZZZNZXTUsAn1Ng1l/eQ+JbJ2vbX1bl+U4WBfnjpd7KxSbyyGMBM+V3S12BFL5vmA6CDsEdlFZICJHIv3YAKrInqWAwiiTNxX7YquQ6JRrL7Tnc1EyGuc0lzX1Yqua77QVpGcCA848luSIPXvVqSMUPl58wuPSfv3viVEU+DYAMgZ8YFNUNRzVB2DHQfIKmi4XFcH9W6YmxgtXJkj4/Kl2tJ05tfsC9hew4ntH89 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)(376002)(136003)(396003)(346002)(366004)(39840400004)(316002)(83380400001)(66476007)(6506007)(186003)(16526019)(5660300002)(2906002)(36756003)(6666004)(8936002)(8676002)(66946007)(2616005)(956004)(52116002)(6512007)(66556008)(86362001)(26005)(4326008)(478600001)(6916009)(1076003)(7416002)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: qixFXKNyugNl/b6I9BJMyOSMJ3xBZ25NY5sVPs23O5GZiHnqkbeh628xDnDuaOnl95LM6+5r6vz0hoOM3fR6th0itZ76sjYAESvxJ51vdaP3XF+cNfEFvDo8tgu+1D093gOtxBvY9bxNJpaeBX4r90yxQByUPkFHC7Aw03z66ytUvhQ2BkXObr8O57ZBmYYdr2mu2mOc1oM2fHQ7jI56EalTfM0h5v96FgPSEz+GnHguLd+hvHScogXIWrjLYEAwsaTz4FSu5exYPK6cP6g2EapVIA2lWHJF9WuP4Eg55F5VgF3m+JndXranPvTO1TcFfJQGRXdOPBOMzTIC7M3xdJjmHPzs0K5ycSBhPIYXhCQmor7v4LLlpkv1ePe+KdkEfG2wRoQSj6zA0NIfTGIZ7S05MwVOvxsU8S5MOusnuub7bCJW5nN3Z6qk8C+tVpbRW8J4R79gwEiB0hFUfWgAenwdjjxG2YacKQJkN1aisO1jb3oXoxmsqh5hO5xmxHnzutcMedX2ILE/wab17frpdocpm4yrGhsX6R7aHO5tKaVt8KK8QPxeK0wi7pBBEHQ8yFEBq+9aULwYi0Q/Ka4sEtvr15f/iWIP3MPtAoaBrhc9V1JP+bPY2Of3UzntCB6nHuM7zxXuR1H3p94S6eBKDA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7217b8b6-b215-481c-d215-08d860bb4837 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 18:54:36.1237 (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: jdo5KXqscCk+qJSyZ5mXQ9Xqhk//LMuf7qTZJiDfDW6IQNs4Y8yzbgv5KOhQx163RY90QIM4nQxuQMtozxH+wDvpDAL9zPehqK9JDPDnWz4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.13.114; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 14:54:34 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) We are going to keep coroutine-wrappers code (structure-packing parameters, BDRV_POLL wrapper functions) in separate auto-generated files. So, we'll need a header with declaration of original _co_ functions, for those which are static now. As well, we'll need declarations for wrapper functions. Do these declarations now, as a preparation step. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- block/coroutines.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++ block.c | 8 +++--- block/io.c | 34 +++++++++++------------ 3 files changed, 88 insertions(+), 21 deletions(-) create mode 100644 block/coroutines.h diff --git a/block/coroutines.h b/block/coroutines.h new file mode 100644 index 0000000000..9ce1730a09 --- /dev/null +++ b/block/coroutines.h @@ -0,0 +1,67 @@ +/* + * Block layer I/O functions + * + * Copyright (c) 2003 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef BLOCK_COROUTINES_INT_H +#define BLOCK_COROUTINES_INT_H + +#include "block/block_int.h" + +int coroutine_fn bdrv_co_check(BlockDriverState *bs, + BdrvCheckResult *res, BdrvCheckMode fix); +int coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, Error **er= rp); + +int coroutine_fn +bdrv_co_prwv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov, + bool is_write, BdrvRequestFlags flags); +int +bdrv_prwv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov, + bool is_write, BdrvRequestFlags flags); + +int coroutine_fn +bdrv_co_common_block_status_above(BlockDriverState *bs, + BlockDriverState *base, + bool want_zero, + int64_t offset, + int64_t bytes, + int64_t *pnum, + int64_t *map, + BlockDriverState **file); +int +bdrv_common_block_status_above(BlockDriverState *bs, + BlockDriverState *base, + bool want_zero, + int64_t offset, + int64_t bytes, + int64_t *pnum, + int64_t *map, + BlockDriverState **file); + +int coroutine_fn +bdrv_co_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, + bool is_read); +int +bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, + bool is_read); + +#endif /* BLOCK_COROUTINES_INT_H */ diff --git a/block.c b/block.c index 47b3845e14..6e2bfb93d8 100644 --- a/block.c +++ b/block.c @@ -48,6 +48,7 @@ #include "qemu/timer.h" #include "qemu/cutils.h" #include "qemu/id.h" +#include "block/coroutines.h" =20 #ifdef CONFIG_BSD #include @@ -4676,8 +4677,8 @@ static void bdrv_delete(BlockDriverState *bs) * free of errors) or -errno when an internal error occurred. The results = of the * check are stored in res. */ -static int coroutine_fn bdrv_co_check(BlockDriverState *bs, - BdrvCheckResult *res, BdrvCheckMode = fix) +int coroutine_fn bdrv_co_check(BlockDriverState *bs, + BdrvCheckResult *res, BdrvCheckMode fix) { if (bs->drv =3D=3D NULL) { return -ENOMEDIUM; @@ -5781,8 +5782,7 @@ void bdrv_init_with_whitelist(void) bdrv_init(); } =20 -static int coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, - Error **errp) +int coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, Error **er= rp) { BdrvChild *child, *parent; uint64_t perm, shared_perm; diff --git a/block/io.c b/block/io.c index 24a7de3463..897139a8b2 100644 --- a/block/io.c +++ b/block/io.c @@ -29,6 +29,7 @@ #include "block/blockjob.h" #include "block/blockjob_int.h" #include "block/block_int.h" +#include "block/coroutines.h" #include "qemu/cutils.h" #include "qapi/error.h" #include "qemu/error-report.h" @@ -933,9 +934,9 @@ typedef struct RwCo { BdrvRequestFlags flags; } RwCo; =20 -static int coroutine_fn bdrv_co_prwv(BdrvChild *child, int64_t offset, - QEMUIOVector *qiov, bool is_write, - BdrvRequestFlags flags) +int coroutine_fn bdrv_co_prwv(BdrvChild *child, int64_t offset, + QEMUIOVector *qiov, bool is_write, + BdrvRequestFlags flags) { if (is_write) { return bdrv_co_pwritev(child, offset, qiov->size, qiov, flags); @@ -955,9 +956,9 @@ static int coroutine_fn bdrv_rw_co_entry(void *opaque) /* * Process a vectored synchronous request using coroutines */ -static int bdrv_prwv(BdrvChild *child, int64_t offset, - QEMUIOVector *qiov, bool is_write, - BdrvRequestFlags flags) +int bdrv_prwv(BdrvChild *child, int64_t offset, + QEMUIOVector *qiov, bool is_write, + BdrvRequestFlags flags) { RwCo rwco =3D { .child =3D child, @@ -2452,7 +2453,7 @@ early_out: return ret; } =20 -static int coroutine_fn +int coroutine_fn bdrv_co_common_block_status_above(BlockDriverState *bs, BlockDriverState *base, bool want_zero, @@ -2509,12 +2510,12 @@ static int coroutine_fn bdrv_block_status_above_co_= entry(void *opaque) * * See bdrv_co_block_status_above() for details. */ -static int bdrv_common_block_status_above(BlockDriverState *bs, - BlockDriverState *base, - bool want_zero, int64_t offset, - int64_t bytes, int64_t *pnum, - int64_t *map, - BlockDriverState **file) +int bdrv_common_block_status_above(BlockDriverState *bs, + BlockDriverState *base, + bool want_zero, int64_t offset, + int64_t bytes, int64_t *pnum, + int64_t *map, + BlockDriverState **file) { BdrvCoBlockStatusData data =3D { .bs =3D bs, @@ -2630,7 +2631,7 @@ typedef struct BdrvVmstateCo { bool is_read; } BdrvVmstateCo; =20 -static int coroutine_fn +int coroutine_fn bdrv_co_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, bool is_read) { @@ -2663,9 +2664,8 @@ static int coroutine_fn bdrv_co_rw_vmstate_entry(void= *opaque) return bdrv_co_rw_vmstate(co->bs, co->qiov, co->pos, co->is_read); } =20 -static inline int -bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, - bool is_read) +int bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, + bool is_read) { BdrvVmstateCo data =3D { .bs =3D bs, --=20 2.21.3 From nobody Fri May 10 03:04:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1600974281; cv=pass; d=zohomail.com; s=zohoarc; b=nFYZpUkcDXO4jc/4CMCtrxeAdXJcs4u07585ClomemFc0dMo9Gm3liOi4rQcBfq+/DjbXAXso/vCxXatzjIRPydc1rV3SaaazDz3V+wyCWVR3lfOMb3+X0A02H7RcOPnbH4yX6Zb6cwqqQwuL5aPFXw13C19o0CXU4d1Rpt7bW4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600974281; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VbaM5n3KLXdAwn6sS+GyjAMrwvGQDJwjtDo5Psu5LYY=; b=W7h09EBK77ujO2NSfthb+SKS6+/bSaVkj9Zznnq5ITkWCVAMHHb2m275oZSvl4Z4a0JwNUVIXilganoRFoy/8PmS6fXuUdahqWbOflNNqVAHuMS33Q5mOlgDGXCqXqMpiqxnbZKvnFl7SbgGqmq5qWMt7F/dozqCi581X+ARva4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600974281284387.660755823999; Thu, 24 Sep 2020 12:04:41 -0700 (PDT) Received: from localhost ([::1]:47676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLWXn-0000Tm-Oh for importer@patchew.org; Thu, 24 Sep 2020 15:04:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLWOY-0001TH-AN; Thu, 24 Sep 2020 14:55:06 -0400 Received: from mail-eopbgr130114.outbound.protection.outlook.com ([40.107.13.114]:8257 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLWOV-0002O2-8F; Thu, 24 Sep 2020 14:55:05 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Thu, 24 Sep 2020 18:54:37 +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.033; Thu, 24 Sep 2020 18:54:37 +0000 Received: from kvm.sw.ru (185.215.60.94) by AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Thu, 24 Sep 2020 18:54:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CMSorFXEletaDkiglIcqvIeMAq2gFo/HrmJRY3xKsYfvu4CYRAKe1hhKayVMqZ68WjRzde89/gOKoIAx6fqgmBeyXFXtl7EJh1BWBl+1rlk+wMo4tfjvXEhWlgBUDfD+Vt5HZkENl1xukj4Ub8fs+9wnsyY2+fQ7rHf2cTQI5SLg5YUAdhlykV9Mlf+niBuTh9jU+rg9jUtAkpR0lxLbzuakootOs273w2ha6E2StA7o9MdbQBLOnj+26AKi44o5iXW5DfMasNppTqeu/+V1xwlLAQI0ZInFE+jFPlQge5nmjKo6sarYcAIK4sO5/ngf2yPswHAXTUbOLAcx54g6pw== 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=VbaM5n3KLXdAwn6sS+GyjAMrwvGQDJwjtDo5Psu5LYY=; b=S3pD4ZXmX4PIARa17P3Tdchyv2T9YsyzXJmKwFY0hLsElxceuED09GvkFhnLJlQ499y1rnk3xIvPgOkE801tDoL7oQL6D5vVgJ/QxPkPiV0QC3ckO0r7JXK4htal/mvoofxZLObKy30FS39K2jpEvXdI5xOqvc2XixoEJ0yOKBsXc2Q/WHEJxB64oI5ucQubsizsmupbHkc+PU1ziGt84m9TlD+zXjGwPufvthMcAfor/RzDc1fOaIompI/czqycrUsQ+HzTL9xh4Yqt9uQnS6s7S6ZSTT0vWxGZdAVS+JQr3KVxqHH71kOuXWuROlGC0miRRcDwiWJ4IK+V31OzVA== 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=VbaM5n3KLXdAwn6sS+GyjAMrwvGQDJwjtDo5Psu5LYY=; b=H1ygsUK5rNJsG9UwN6yMJpSstv7EqL6IdIfN0wErZQVcLHP1yL39ZhH6otuVbFSpvlaHh+H9NWWVxwmHbmLwUoxG4UeyXhfBjSn/XK39eADLGtwKSu4kXGuiuFd9oZzSV0nqvGC80k3npNGdt+QNuzAIUIWxq51kYKUgpyc2muY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, vsementsov@virtuozzo.com, eblake@redhat.com Subject: [PATCH v9 4/7] scripts: add block-coroutine-wrapper.py Date: Thu, 24 Sep 2020 21:54:11 +0300 Message-Id: <20200924185414.28642-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200924185414.28642-1-vsementsov@virtuozzo.com> References: <20200924185414.28642-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.94] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b5474063-a302-4865-de55-08d860bb48c5 X-MS-TrafficTypeDiagnostic: AM6PR08MB4341: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0CL9I4sVrqT9S1RujFaCyr7GINwL0pBZgP05CINRVgjgPSQiWFOXdM7dMFLKTeIK0oSEBBZ+7D/IkTD4f4g7FymoEIE2iqgALVBKizYe9gIZapsrDh7RWNl7g4DwmTMOHq1WDhuwBp6XnxmqvJl9XrBGZAi9lsayFZm5Pe/ZoLyvHjqLM/QGbGqYSSaetmrKPjh94eGG/kQRbtuioHzL9+vjwHm23RNVEOCozAUsbYiWO9R8CvXkDKC5kgis3d6bdovv3Pvgej8sYHMK+R2QpNzAcjx9e+1nyrxUQkXCijyok6hCMx9SscLmRwfwrnsOUNNHvITCv2dWH4cuRuL3sd/oZ3slJucHWlvD8oSTtAVHSfLfZR/DikfUZSQzS1KxQIySyB/ybfmWi5K4/cMt/c09ypRPm2YAZGtnxnnug4NBCXMg2NRgaZbFGtA8ag9xrBFaILhzeVgj/qO8kk9SAU90DGrTch5vwyNxWXD5s6sgWNlkedhCbwvW0RyYlZrp 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)(376002)(136003)(396003)(346002)(366004)(39840400004)(316002)(83380400001)(66476007)(6506007)(186003)(16526019)(5660300002)(2906002)(36756003)(6666004)(8936002)(8676002)(66946007)(2616005)(956004)(52116002)(6512007)(66556008)(86362001)(26005)(4326008)(478600001)(6916009)(1076003)(6486002)(30864003)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Y80rEh/FGLuaXoAEfaKkatJKsSEsnLOHIT9yQAibUtxfaphlmcLNeJvuQ4zoGS0m5FPUnpAKfTF5K2Ahod68USt1M4obhp3WvDoJXmU7DzbbLlhIQaUEmyi1i15Ty5SHhVE4IoYhGW6TpJAoMxjUlIZds6YrH8waM3wgnQnusbjdYKIJwvVASWiQJGBQfxzRDaaEVL2/4zU4jiAQpB+9z6hUg/TkcaXeCVQXBq2QInmfdoKphMvfkbROaRjxIvA16sROYbiTVHMm9ozLLhRuhI2XEfBWsj7fYQJyxEgZ/BvnbtUP0n3giv1hQlRMo+G9q5I5mfCzEynd+ZCBM7DFggms9qNKlRLFffVhk21TzeGfTO4ekwaAeJzIrisV7gJDP8H+oQwBJ6qW+wF6lWASkuTWBqoMkjKCZkb69oVSWDGdO0CedQOSkTzIdt0h+Ppf4C8+IRgGbR2m7Hrkesl0PuKNL0zECaXXt7GN76dbJvNK5f+F24kbdKYt1Afl0vr9xxzAvO3VeOT3kMsoS0hiO2s1PF1m7vzgiRwFgXVNFHfTB+jX0TA6cLZWgwzXSS+9hK4DrxK2r+ndbpRi5uM1W0WkTYRSCsKwCelhkPprqvOjkCG/yULG47NLnZJBstD4wpMQeL2EZBmFmQhAdCOZHg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5474063-a302-4865-de55-08d860bb48c5 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 18:54:37.1004 (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: 2kK/FAq98eK8P45dR+Qif8lC1uSrsYPTSkBzTGrfjFCMstOlS1DPLj48yfdemV+t2F9o09y0HawoJjrRDkKcYFqZRJacN54gORWU/oSC8o0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.13.114; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 14:54:34 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We have a very frequent pattern of creating a coroutine from a function with several arguments: - create a structure to pack parameters - create _entry function to call original function taking parameters from struct - do different magic to handle completion: set ret to NOT_DONE or EINPROGRESS or use separate bool field - fill the struct and create coroutine from _entry function with this struct as a parameter - do coroutine enter and BDRV_POLL_WHILE loop Let's reduce code duplication by generating coroutine wrappers. This patch adds scripts/block-coroutine-wrapper.py together with some friends, which will generate functions with declared prototypes marked by the 'generated_co_wrapper' specifier. The usage of new code generation is as follows: 1. define the coroutine function somewhere int coroutine_fn bdrv_co_NAME(...) {...} 2. declare in some header file int generated_co_wrapper bdrv_NAME(...); with same list of parameters (generated_co_wrapper is defined in "include/block/block.h"). 3. Make sure the block_gen_c delaration in block/meson.build mentions the file with your marker function. Still, no function is now marked, this work is for the following commit. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- docs/devel/block-coroutine-wrapper.rst | 54 +++++++ docs/devel/index.rst | 1 + block/block-gen.h | 49 +++++++ include/block/block.h | 10 ++ block/meson.build | 8 ++ scripts/block-coroutine-wrapper.py | 188 +++++++++++++++++++++++++ 6 files changed, 310 insertions(+) create mode 100644 docs/devel/block-coroutine-wrapper.rst create mode 100644 block/block-gen.h create mode 100644 scripts/block-coroutine-wrapper.py diff --git a/docs/devel/block-coroutine-wrapper.rst b/docs/devel/block-coro= utine-wrapper.rst new file mode 100644 index 0000000000..d09fff2cc5 --- /dev/null +++ b/docs/devel/block-coroutine-wrapper.rst @@ -0,0 +1,54 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +block-coroutine-wrapper +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +A lot of functions in QEMU block layer (see ``block/*``) can only be +called in coroutine context. Such functions are normally marked by the +coroutine_fn specifier. Still, sometimes we need to call them from +non-coroutine context; for this we need to start a coroutine, run the +needed function from it and wait for coroutine finish in +BDRV_POLL_WHILE() loop. To run a coroutine we need a function with one +void* argument. So for each coroutine_fn function which needs a +non-coroutine interface, we should define a structure to pack the +parameters, define a separate function to unpack the parameters and +call the original function and finally define a new interface function +with same list of arguments as original one, which will pack the +parameters into a struct, create a coroutine, run it and wait in +BDRV_POLL_WHILE() loop. It's boring to create such wrappers by hand, +so we have a script to generate them. + +Usage +=3D=3D=3D=3D=3D + +Assume we have defined the ``coroutine_fn`` function +``bdrv_co_foo()`` and need a non-coroutine interface for it, +called ``bdrv_foo()``. In this case the script can help. To +trigger the generation: + +1. You need ``bdrv_foo`` declaration somewhere (for example, in + ``block/coroutines.h``) with the ``generated_co_wrapper`` mark, + like this: + +.. code-block:: c + + int generated_co_wrapper bdrv_foo(); + +2. You need to feed this declaration to block-coroutine-wrapper script. + For this, add the .h (or .c) file with the declaration to the + ``input: files(...)`` list of ``block_gen_c`` target declaration in + ``block/meson.build`` + +You are done. During the build, coroutine wrappers will be generated in +``/block/block-gen.c``. + +Links +=3D=3D=3D=3D=3D + +1. The script location is ``scripts/block-coroutine-wrapper.py``. + +2. Generic place for private ``generated_co_wrapper`` declarations is + ``block/coroutines.h``, for public declarations: + ``include/block/block.h`` + +3. The core API of generated coroutine wrappers is placed in + (not generated) ``block/block-gen.h`` diff --git a/docs/devel/index.rst b/docs/devel/index.rst index 04773ce076..cb0abe1e69 100644 --- a/docs/devel/index.rst +++ b/docs/devel/index.rst @@ -31,3 +31,4 @@ Contents: reset s390-dasd-ipl clocks + block-coroutine-wrapper diff --git a/block/block-gen.h b/block/block-gen.h new file mode 100644 index 0000000000..f80cf4897d --- /dev/null +++ b/block/block-gen.h @@ -0,0 +1,49 @@ +/* + * Block coroutine wrapping core, used by auto-generated block/block-gen.c + * + * Copyright (c) 2003 Fabrice Bellard + * Copyright (c) 2020 Virtuozzo International GmbH + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef BLOCK_BLOCK_GEN_H +#define BLOCK_BLOCK_GEN_H + +#include "block/block_int.h" + +/* Base structure for argument packing structures */ +typedef struct BdrvPollCo { + BlockDriverState *bs; + bool in_progress; + int ret; + Coroutine *co; /* Keep pointer here for debugging */ +} BdrvPollCo; + +static inline int bdrv_poll_co(BdrvPollCo *s) +{ + assert(!qemu_in_coroutine()); + + bdrv_coroutine_enter(s->bs, s->co); + BDRV_POLL_WHILE(s->bs, s->in_progress); + + return s->ret; +} + +#endif /* BLOCK_BLOCK_GEN_H */ diff --git a/include/block/block.h b/include/block/block.h index 81d591dd4c..0f0ddc51b4 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -10,6 +10,16 @@ #include "block/blockjob.h" #include "qemu/hbitmap.h" =20 +/* + * generated_co_wrapper + * + * Function specifier, which does nothing but mark functions to be + * generated by scripts/block-coroutine-wrapper.py + * + * Read more in docs/devel/block-coroutine-wrapper.rst + */ +#define generated_co_wrapper + /* block.c */ typedef struct BlockDriver BlockDriver; typedef struct BdrvChild BdrvChild; diff --git a/block/meson.build b/block/meson.build index a3e56b7cd1..88ad73583a 100644 --- a/block/meson.build +++ b/block/meson.build @@ -107,6 +107,14 @@ module_block_h =3D custom_target('module_block.h', command: [module_block_py, '@OUTPUT0@', mod= src]) block_ss.add(module_block_h) =20 +wrapper_py =3D find_program('../scripts/block-coroutine-wrapper.py') +block_gen_c =3D custom_target('block-gen.c', + output: 'block-gen.c', + input: files('../include/block/block.h', + 'coroutines.h'), + command: [wrapper_py, '@OUTPUT@', '@INPUT@']) +block_ss.add(block_gen_c) + block_ss.add(files('stream.c')) =20 softmmu_ss.add(files('qapi-sysemu.c')) diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-w= rapper.py new file mode 100644 index 0000000000..505e070660 --- /dev/null +++ b/scripts/block-coroutine-wrapper.py @@ -0,0 +1,188 @@ +#! /usr/bin/env python3 +"""Generate coroutine wrappers for block subsystem. + +The program parses one or several concatenated c files from stdin, +searches for functions with the 'generated_co_wrapper' specifier +and generates corresponding wrappers on stdout. + +Usage: block-coroutine-wrapper.py generated-file.c FILE.[ch]... + +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 re +import subprocess +import json +from typing import Iterator + + +def prettify(code: str) -> str: + """Prettify code using clang-format if available""" + + try: + style =3D json.dumps({ + 'IndentWidth': 4, + 'BraceWrapping': {'AfterFunction': True}, + 'BreakBeforeBraces': 'Custom', + 'SortIncludes': False, + 'MaxEmptyLinesToKeep': 2, + }) + p =3D subprocess.run(['clang-format', f'-style=3D{style}'], check= =3DTrue, + encoding=3D'utf-8', input=3Dcode, + stdout=3Dsubprocess.PIPE) + return p.stdout + except FileNotFoundError: + return code + + +def gen_header(): + copyright =3D re.sub('^.*Copyright', 'Copyright', __doc__, flags=3Dre.= DOTALL) + copyright =3D re.sub('^(?=3D.)', ' * ', copyright.strip(), flags=3Dre.= MULTILINE) + copyright =3D re.sub('^$', ' *', copyright, flags=3Dre.MULTILINE) + return f"""\ +/* + * File is generated by scripts/block-coroutine-wrapper.py + * +{copyright} + */ + +#include "qemu/osdep.h" +#include "block/coroutines.h" +#include "block/block-gen.h" +#include "block/block_int.h"\ +""" + + +class ParamDecl: + param_re =3D re.compile(r'(?P' + r'(?P.*[ *])' + r'(?P[a-z][a-z0-9_]*)' + r')') + + def __init__(self, param_decl: str) -> None: + m =3D self.param_re.match(param_decl.strip()) + if m is None: + raise ValueError(f'Wrong parameter declaration: "{param_decl}"= ') + self.decl =3D m.group('decl') + self.type =3D m.group('type') + self.name =3D m.group('name') + + +class FuncDecl: + def __init__(self, return_type: str, name: str, args: str) -> None: + self.return_type =3D return_type.strip() + self.name =3D name.strip() + self.args =3D [ParamDecl(arg.strip()) for arg in args.split(',')] + + def gen_list(self, format: str) -> str: + return ', '.join(format.format_map(arg.__dict__) for arg in self.a= rgs) + + def gen_block(self, format: str) -> str: + return '\n'.join(format.format_map(arg.__dict__) for arg in self.a= rgs) + + +# Match wrappers declared with a generated_co_wrapper mark +func_decl_re =3D re.compile(r'^int\s*generated_co_wrapper\s*' + r'(?P[a-z][a-z0-9_]*)' + r'\((?P[^)]*)\);$', re.MULTILINE) + + +def func_decl_iter(text: str) -> Iterator: + for m in func_decl_re.finditer(text): + yield FuncDecl(return_type=3D'int', + name=3Dm.group('wrapper_name'), + args=3Dm.group('args')) + + +def snake_to_camel(func_name: str) -> str: + """ + Convert underscore names like 'some_function_name' to camel-case like + 'SomeFunctionName' + """ + words =3D func_name.split('_') + words =3D [w[0].upper() + w[1:] for w in words] + return ''.join(words) + + +def gen_wrapper(func: FuncDecl) -> str: + assert func.name.startswith('bdrv_') + assert not func.name.startswith('bdrv_co_') + assert func.return_type =3D=3D 'int' + assert func.args[0].type in ['BlockDriverState *', 'BdrvChild *'] + + name =3D 'bdrv_co_' + func.name[5:] + bs =3D 'bs' if func.args[0].type =3D=3D 'BlockDriverState *' else 'chi= ld->bs' + struct_name =3D snake_to_camel(name) + + return f"""\ +/* + * Wrappers for {name} + */ + +typedef struct {struct_name} {{ + BdrvPollCo poll_state; +{ func.gen_block(' {decl};') } +}} {struct_name}; + +static void coroutine_fn {name}_entry(void *opaque) +{{ + {struct_name} *s =3D opaque; + + s->poll_state.ret =3D {name}({ func.gen_list('s->{name}') }); + s->poll_state.in_progress =3D false; + + aio_wait_kick(); +}} + +int {func.name}({ func.gen_list('{decl}') }) +{{ + if (qemu_in_coroutine()) {{ + return {name}({ func.gen_list('{name}') }); + }} else {{ + {struct_name} s =3D {{ + .poll_state.bs =3D {bs}, + .poll_state.in_progress =3D true, + +{ func.gen_block(' .{name} =3D {name},') } + }}; + + s.poll_state.co =3D qemu_coroutine_create({name}_entry, &s); + + return bdrv_poll_co(&s.poll_state); + }} +}}""" + + +def gen_wrappers(input_code: str) -> str: + res =3D '' + for func in func_decl_iter(input_code): + res +=3D '\n\n\n' + res +=3D gen_wrapper(func) + + return prettify(res) # prettify to wrap long lines + + +if __name__ =3D=3D '__main__': + if len(sys.argv) < 3: + exit(f'Usage: {sys.argv[0]} OUT_FILE.c IN_FILE.[ch]...') + + with open(sys.argv[1], 'w') as f_out: + f_out.write(gen_header()) + for fname in sys.argv[2:]: + with open(fname) as f_in: + f_out.write(gen_wrappers(f_in.read())) + f_out.write('\n') --=20 2.21.3 From nobody Fri May 10 03:04:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1600974287; cv=pass; d=zohomail.com; s=zohoarc; b=EbYADtAbGmGFu3tU7AE1YhTkvhIWWRkAMIm5iWZolhhmgrvqmAUimhMfeZpMOLB+IrqhGWgRei6Y+FX+PBXc3hVhqO2FrzSVztaOB0Aeoe7NzviKZz3LvPRqHt68wEHSfkkZ6qEeFmleelK31vSGLCKpWdNTAWAixp1Qw2LnlFI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600974287; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hXQQGTzo02j8An8WJoIXxuJeMPbVrK5DY7DM23C0WiY=; b=WCx22qpEu6+vzab8/k5gDnLgxxSZjyNC4R0L5N0ddV8BQk76bIjLB+pMfBuuJj4ueQ4smZT60SS31+pGbHsCOvzZpnQMjCGjWNcP8xTHiLNvNMuetj32Qa7Q0lHfOu6ugb3U/Dom9dvtN0VCO1QyBI6nhireUAqKE9fQ9wuvRCA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600974287966843.8962564839746; Thu, 24 Sep 2020 12:04:47 -0700 (PDT) Received: from localhost ([::1]:48058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLWXu-0000dC-E0 for importer@patchew.org; Thu, 24 Sep 2020 15:04:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLWOe-0001WZ-8y; Thu, 24 Sep 2020 14:55:12 -0400 Received: from mail-eopbgr130114.outbound.protection.outlook.com ([40.107.13.114]:8257 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLWOZ-0002O2-1f; Thu, 24 Sep 2020 14:55:11 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Thu, 24 Sep 2020 18:54:38 +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.033; Thu, 24 Sep 2020 18:54:38 +0000 Received: from kvm.sw.ru (185.215.60.94) by AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Thu, 24 Sep 2020 18:54:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QQB7RnjEBow6k4TDCgvha68UzjMxcCd0e2pKBYn6R6zsPALrxUaMX1CK6/7RDgjN5pBt5ENmpdysxTwMMulXLaw6C31cdvgy3cOKreYL82KA8edrAGqWcaoiG6lT0eaNsMvmaVWIY6PlSGSxpV/07emUJZLyrKURdodmFuumaET5JK8fa9OQN8FwTtzcUPwxs+cKLECoCM/ZNugG5VtFRye4FaDlM9sSLXeQFIwJK5GB/2ojGO5nVIexE+o/yIZNAm/jDkTS9JrkGtZC9+5PAKxNIL27m1A7P/Q2XJsnuaJRGbL+m2I9jAhMZ+Vp2RUoLCXgcx5ZkL70XGDXRkepQg== 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=hXQQGTzo02j8An8WJoIXxuJeMPbVrK5DY7DM23C0WiY=; b=cnYnM0GIFEtGCJZPmGrme0trYxLjlbnDcMF7sGUNWusijp3EZeiH9Lq/T1siTj2OR5rmM4/1xGSJbeP1g5dMfKQD8AvFW/tCuCyqKbOWB/uqLkLh+TTZpUqPzLlcaZRKCGtCEW6hmizeJwGMORoayOYmAt6uUZKi9hOFZzFDa5nJKsMH9uqiL/pljVWuMzAIJjMZiB4m3XqdtdvFdmxrVx0K5+Zmsss9+s6axlMiuRzDVzZIzEGgaCV5oI6apsD2+moTlcDv/h0AoHEKP62FAfyCJqbUUUMVpmERuSdDglwgv9NFIBu0REqOPT6K6D65ZdzpGk7C0hrY2zGeq4vddQ== 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=hXQQGTzo02j8An8WJoIXxuJeMPbVrK5DY7DM23C0WiY=; b=CWVe6wADJOWyhmMef+8bPzR8rMaF3v12M3dt5Jacvn6cMQbYADYAZ+Jgn0Sc5delfpyS1svwT8a85H0s6paKjyvUx9uhmcLmIiDl2LZJkNVoN+2+EcUy6i3vCO6Y3M+MmBx+j0Np72AnO/qKaeO31rl7NQaIiRNgwmvKOxKAc/I= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, vsementsov@virtuozzo.com, eblake@redhat.com Subject: [PATCH v9 5/7] block: generate coroutine-wrapper code Date: Thu, 24 Sep 2020 21:54:12 +0300 Message-Id: <20200924185414.28642-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200924185414.28642-1-vsementsov@virtuozzo.com> References: <20200924185414.28642-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.94] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8492b96d-7434-4483-3555-08d860bb495b X-MS-TrafficTypeDiagnostic: AM6PR08MB4341: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:196; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +AiuPFahtr5jzf2vVlHEtFnFmkkR7+O/CUqGwI8cdEqPRCiBOra6eXzKnljOcSxmemM1mH/les9LBvViTSMRdO9PWc5xrDdmP3HjfnlSDrhbIwOiCwpzpqcBg4tAjBTVOZ9Wf33FMoZldFynmpyyrqvxASAEyleGa89SZFQIQBgAO7MsLSQCYqgRMRmO3jEFLHKBOFxT6lJkocYyi0IOJ9nrcDTZ/nRLMIf0pEnJyhv+48957yEMYxsRhM0eP2zB0zIxGVB9JtAolcpXbIJKzy/3TgzUgrIVuLmGb78YL2FMdVbo4PzHcoWSKyrect/scyKXtSPuYcwyky9cgH8ARmM7mJpSai1NRFf4tOePV4s23+JmYUGh0yK+fD9sTmD8 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)(376002)(136003)(396003)(346002)(366004)(39840400004)(316002)(83380400001)(66476007)(6506007)(186003)(16526019)(5660300002)(2906002)(36756003)(6666004)(8936002)(8676002)(66946007)(2616005)(956004)(52116002)(6512007)(66556008)(86362001)(26005)(4326008)(478600001)(6916009)(1076003)(6486002)(30864003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: nE+8LNc2oc3Ol4VNCR53yROFh8q9T+xSpV1LITlz/AOTZqebpOPJwAX+xdJtOH15H/4TpvZkVVFCgJaFeOvbK55gVQXe/cbdPOpkJo8BjvvF3rHMMipfly4JukLoJJux+mKuqRb906mWR9ec68MgUCRn2h5PzzZ4ETDuX/E8anXvnER+ffkmUqBAus4bC2QBru+PgFOl0eqH8OcVFxMQKz+0g4UomAdLQUaYSHIuem2PzHkNZrImfYMiQQ+idvd1EnEOaReol74NXEl/7P5+LiyviDzn+TgJDDbplhOyv2aCDYTKHbS8uqYspDk7LjUKUqELfCdFPWvRxZKqGw3CL0BbNfu+jD0jzToqSOs4nog2B6Qpl7XpxOeYbj/Gz65nFzqa6eJ3Cc2ny+mg7frP4OzS65+Kr7Txv441gV6QwyXPihMUQd0fGQB4R4b2WNq+fLeBCNV9jlHnTVW+GpiXtyKYXe40sQEtRGqJkOIuEypa7jFDYn81h/UiE5UaW8sqnHM2C0cFv6kEMRwN8mkRuqmwhwh53mAwzUN7G3QJvaKi8HqIAwGUD/s3cA2EELScq+H04P0O8b/qTCiS63YUTwQAYt0CLSw3gMwnouXIyaydU71B0mOl/vJKTRkl9GrKQTXh99yNP+61tbv2Y+/fpQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8492b96d-7434-4483-3555-08d860bb495b X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 18:54:38.0602 (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: 7cFRqWCQXLDEjAdgBHGVoLf9LM0k+EvYflyI8z+edssoKfPAkLW881ds856tISXxaySAPLuuJGideeLH7iXIJIZKID0NtMsTrdtHf1HmFMI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.13.114; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 14:54:34 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" Use code generation implemented in previous commit to generated coroutine wrappers in block.c and block/io.c Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- block/coroutines.h | 6 +- include/block/block.h | 16 ++-- block.c | 73 --------------- block/io.c | 212 ------------------------------------------ 4 files changed, 13 insertions(+), 294 deletions(-) diff --git a/block/coroutines.h b/block/coroutines.h index 9ce1730a09..c62b3a2697 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -34,7 +34,7 @@ int coroutine_fn bdrv_co_invalidate_cache(BlockDriverStat= e *bs, Error **errp); int coroutine_fn bdrv_co_prwv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov, bool is_write, BdrvRequestFlags flags); -int +int generated_co_wrapper bdrv_prwv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov, bool is_write, BdrvRequestFlags flags); =20 @@ -47,7 +47,7 @@ bdrv_co_common_block_status_above(BlockDriverState *bs, int64_t *pnum, int64_t *map, BlockDriverState **file); -int +int generated_co_wrapper bdrv_common_block_status_above(BlockDriverState *bs, BlockDriverState *base, bool want_zero, @@ -60,7 +60,7 @@ bdrv_common_block_status_above(BlockDriverState *bs, int coroutine_fn bdrv_co_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, bool is_read); -int +int generated_co_wrapper bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, bool is_read); =20 diff --git a/include/block/block.h b/include/block/block.h index 0f0ddc51b4..f2d85f2cf1 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -403,8 +403,9 @@ void bdrv_refresh_filename(BlockDriverState *bs); int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool e= xact, PreallocMode prealloc, BdrvRequestFlags = flags, Error **errp); -int bdrv_truncate(BdrvChild *child, int64_t offset, bool exact, - PreallocMode prealloc, BdrvRequestFlags flags, Error **e= rrp); +int generated_co_wrapper +bdrv_truncate(BdrvChild *child, int64_t offset, bool exact, + PreallocMode prealloc, BdrvRequestFlags flags, Error **errp); =20 int64_t bdrv_nb_sectors(BlockDriverState *bs); int64_t bdrv_getlength(BlockDriverState *bs); @@ -446,7 +447,8 @@ typedef enum { BDRV_FIX_ERRORS =3D 2, } BdrvCheckMode; =20 -int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode f= ix); +int generated_co_wrapper bdrv_check(BlockDriverState *bs, BdrvCheckResult = *res, + BdrvCheckMode fix); =20 /* The units of offset and total_work_size may be chosen arbitrarily by the * block driver; total_work_size may change during the course of the amend= ment @@ -470,12 +472,13 @@ void bdrv_aio_cancel_async(BlockAIOCB *acb); int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf); =20 /* Invalidate any cached metadata used by image formats */ -int bdrv_invalidate_cache(BlockDriverState *bs, Error **errp); +int generated_co_wrapper bdrv_invalidate_cache(BlockDriverState *bs, + Error **errp); void bdrv_invalidate_cache_all(Error **errp); int bdrv_inactivate_all(void); =20 /* Ensure contents are flushed to disk. */ -int bdrv_flush(BlockDriverState *bs); +int generated_co_wrapper bdrv_flush(BlockDriverState *bs); int coroutine_fn bdrv_co_flush(BlockDriverState *bs); int bdrv_flush_all(void); void bdrv_close_all(void); @@ -490,7 +493,8 @@ void bdrv_drain_all(void); AIO_WAIT_WHILE(bdrv_get_aio_context(bs_), \ cond); }) =20 -int bdrv_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes); +int generated_co_wrapper bdrv_pdiscard(BdrvChild *child, int64_t offset, + int64_t bytes); int bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes); int bdrv_has_zero_init_1(BlockDriverState *bs); int bdrv_has_zero_init(BlockDriverState *bs); diff --git a/block.c b/block.c index 6e2bfb93d8..de056c695a 100644 --- a/block.c +++ b/block.c @@ -4691,43 +4691,6 @@ int coroutine_fn bdrv_co_check(BlockDriverState *bs, return bs->drv->bdrv_co_check(bs, res, fix); } =20 -typedef struct CheckCo { - BlockDriverState *bs; - BdrvCheckResult *res; - BdrvCheckMode fix; - int ret; -} CheckCo; - -static void coroutine_fn bdrv_check_co_entry(void *opaque) -{ - CheckCo *cco =3D opaque; - cco->ret =3D bdrv_co_check(cco->bs, cco->res, cco->fix); - aio_wait_kick(); -} - -int bdrv_check(BlockDriverState *bs, - BdrvCheckResult *res, BdrvCheckMode fix) -{ - Coroutine *co; - CheckCo cco =3D { - .bs =3D bs, - .res =3D res, - .ret =3D -EINPROGRESS, - .fix =3D fix, - }; - - if (qemu_in_coroutine()) { - /* Fast-path if already in coroutine context */ - bdrv_check_co_entry(&cco); - } else { - co =3D qemu_coroutine_create(bdrv_check_co_entry, &cco); - bdrv_coroutine_enter(bs, co); - BDRV_POLL_WHILE(bs, cco.ret =3D=3D -EINPROGRESS); - } - - return cco.ret; -} - /* * Return values: * 0 - success @@ -5860,42 +5823,6 @@ int coroutine_fn bdrv_co_invalidate_cache(BlockDrive= rState *bs, Error **errp) return 0; } =20 -typedef struct InvalidateCacheCo { - BlockDriverState *bs; - Error **errp; - bool done; - int ret; -} InvalidateCacheCo; - -static void coroutine_fn bdrv_invalidate_cache_co_entry(void *opaque) -{ - InvalidateCacheCo *ico =3D opaque; - ico->ret =3D bdrv_co_invalidate_cache(ico->bs, ico->errp); - ico->done =3D true; - aio_wait_kick(); -} - -int bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) -{ - Coroutine *co; - InvalidateCacheCo ico =3D { - .bs =3D bs, - .done =3D false, - .errp =3D errp - }; - - if (qemu_in_coroutine()) { - /* Fast-path if already in coroutine context */ - bdrv_invalidate_cache_co_entry(&ico); - } else { - co =3D qemu_coroutine_create(bdrv_invalidate_cache_co_entry, &ico); - bdrv_coroutine_enter(bs, co); - BDRV_POLL_WHILE(bs, !ico.done); - } - - return ico.ret; -} - void bdrv_invalidate_cache_all(Error **errp) { BlockDriverState *bs; diff --git a/block/io.c b/block/io.c index 897139a8b2..c1360ba57d 100644 --- a/block/io.c +++ b/block/io.c @@ -890,50 +890,6 @@ static int bdrv_check_byte_request(BlockDriverState *b= s, int64_t offset, return 0; } =20 -typedef int coroutine_fn BdrvRequestEntry(void *opaque); -typedef struct BdrvRunCo { - BdrvRequestEntry *entry; - void *opaque; - int ret; - bool done; - Coroutine *co; /* Coroutine, running bdrv_run_co_entry, for debugging = */ -} BdrvRunCo; - -static void coroutine_fn bdrv_run_co_entry(void *opaque) -{ - BdrvRunCo *arg =3D opaque; - - arg->ret =3D arg->entry(arg->opaque); - arg->done =3D true; - aio_wait_kick(); -} - -static int bdrv_run_co(BlockDriverState *bs, BdrvRequestEntry *entry, - void *opaque) -{ - if (qemu_in_coroutine()) { - /* Fast-path if already in coroutine context */ - return entry(opaque); - } else { - BdrvRunCo s =3D { .entry =3D entry, .opaque =3D opaque }; - - s.co =3D qemu_coroutine_create(bdrv_run_co_entry, &s); - bdrv_coroutine_enter(bs, s.co); - - BDRV_POLL_WHILE(bs, !s.done); - - return s.ret; - } -} - -typedef struct RwCo { - BdrvChild *child; - int64_t offset; - QEMUIOVector *qiov; - bool is_write; - BdrvRequestFlags flags; -} RwCo; - int coroutine_fn bdrv_co_prwv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov, bool is_write, BdrvRequestFlags flags) @@ -945,32 +901,6 @@ int coroutine_fn bdrv_co_prwv(BdrvChild *child, int64_= t offset, } } =20 -static int coroutine_fn bdrv_rw_co_entry(void *opaque) -{ - RwCo *rwco =3D opaque; - - return bdrv_co_prwv(rwco->child, rwco->offset, rwco->qiov, - rwco->is_write, rwco->flags); -} - -/* - * Process a vectored synchronous request using coroutines - */ -int bdrv_prwv(BdrvChild *child, int64_t offset, - QEMUIOVector *qiov, bool is_write, - BdrvRequestFlags flags) -{ - RwCo rwco =3D { - .child =3D child, - .offset =3D offset, - .qiov =3D qiov, - .is_write =3D is_write, - .flags =3D flags, - }; - - return bdrv_run_co(child->bs, bdrv_rw_co_entry, &rwco); -} - int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, int bytes, BdrvRequestFlags flags) { @@ -2247,18 +2177,6 @@ int bdrv_flush_all(void) return result; } =20 - -typedef struct BdrvCoBlockStatusData { - BlockDriverState *bs; - BlockDriverState *base; - bool want_zero; - int64_t offset; - int64_t bytes; - int64_t *pnum; - int64_t *map; - BlockDriverState **file; -} BdrvCoBlockStatusData; - /* * Returns the allocation status of the specified sectors. * Drivers not implementing the functionality are assumed to not support @@ -2494,43 +2412,6 @@ bdrv_co_common_block_status_above(BlockDriverState *= bs, return ret; } =20 -/* Coroutine wrapper for bdrv_block_status_above() */ -static int coroutine_fn bdrv_block_status_above_co_entry(void *opaque) -{ - BdrvCoBlockStatusData *data =3D opaque; - - return bdrv_co_common_block_status_above(data->bs, data->base, - data->want_zero, - data->offset, data->bytes, - data->pnum, data->map, data->= file); -} - -/* - * Synchronous wrapper around bdrv_co_block_status_above(). - * - * See bdrv_co_block_status_above() for details. - */ -int bdrv_common_block_status_above(BlockDriverState *bs, - BlockDriverState *base, - bool want_zero, int64_t offset, - int64_t bytes, int64_t *pnum, - int64_t *map, - BlockDriverState **file) -{ - BdrvCoBlockStatusData data =3D { - .bs =3D bs, - .base =3D base, - .want_zero =3D want_zero, - .offset =3D offset, - .bytes =3D bytes, - .pnum =3D pnum, - .map =3D map, - .file =3D file, - }; - - return bdrv_run_co(bs, bdrv_block_status_above_co_entry, &data); -} - int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map, BlockDriverState **file) @@ -2624,13 +2505,6 @@ int bdrv_is_allocated_above(BlockDriverState *top, return 0; } =20 -typedef struct BdrvVmstateCo { - BlockDriverState *bs; - QEMUIOVector *qiov; - int64_t pos; - bool is_read; -} BdrvVmstateCo; - int coroutine_fn bdrv_co_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, bool is_read) @@ -2657,26 +2531,6 @@ bdrv_co_rw_vmstate(BlockDriverState *bs, QEMUIOVecto= r *qiov, int64_t pos, return ret; } =20 -static int coroutine_fn bdrv_co_rw_vmstate_entry(void *opaque) -{ - BdrvVmstateCo *co =3D opaque; - - return bdrv_co_rw_vmstate(co->bs, co->qiov, co->pos, co->is_read); -} - -int bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, - bool is_read) -{ - BdrvVmstateCo data =3D { - .bs =3D bs, - .qiov =3D qiov, - .pos =3D pos, - .is_read =3D is_read, - }; - - return bdrv_run_co(bs, bdrv_co_rw_vmstate_entry, &data); -} - int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf, int64_t pos, int size) { @@ -2752,11 +2606,6 @@ void bdrv_aio_cancel_async(BlockAIOCB *acb) /**************************************************************/ /* Coroutine block device emulation */ =20 -static int coroutine_fn bdrv_flush_co_entry(void *opaque) -{ - return bdrv_co_flush(opaque); -} - int coroutine_fn bdrv_co_flush(BlockDriverState *bs) { BdrvChild *primary_child =3D bdrv_primary_child(bs); @@ -2880,24 +2729,6 @@ early_exit: return ret; } =20 -int bdrv_flush(BlockDriverState *bs) -{ - return bdrv_run_co(bs, bdrv_flush_co_entry, bs); -} - -typedef struct DiscardCo { - BdrvChild *child; - int64_t offset; - int64_t bytes; -} DiscardCo; - -static int coroutine_fn bdrv_pdiscard_co_entry(void *opaque) -{ - DiscardCo *rwco =3D opaque; - - return bdrv_co_pdiscard(rwco->child, rwco->offset, rwco->bytes); -} - int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes) { @@ -3012,17 +2843,6 @@ out: return ret; } =20 -int bdrv_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes) -{ - DiscardCo rwco =3D { - .child =3D child, - .offset =3D offset, - .bytes =3D bytes, - }; - - return bdrv_run_co(child->bs, bdrv_pdiscard_co_entry, &rwco); -} - int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf) { BlockDriver *drv =3D bs->drv; @@ -3424,35 +3244,3 @@ out: =20 return ret; } - -typedef struct TruncateCo { - BdrvChild *child; - int64_t offset; - bool exact; - PreallocMode prealloc; - BdrvRequestFlags flags; - Error **errp; -} TruncateCo; - -static int coroutine_fn bdrv_truncate_co_entry(void *opaque) -{ - TruncateCo *tco =3D opaque; - - return bdrv_co_truncate(tco->child, tco->offset, tco->exact, - tco->prealloc, tco->flags, tco->errp); -} - -int bdrv_truncate(BdrvChild *child, int64_t offset, bool exact, - PreallocMode prealloc, BdrvRequestFlags flags, Error **e= rrp) -{ - TruncateCo tco =3D { - .child =3D child, - .offset =3D offset, - .exact =3D exact, - .prealloc =3D prealloc, - .flags =3D flags, - .errp =3D errp, - }; - - return bdrv_run_co(child->bs, bdrv_truncate_co_entry, &tco); -} --=20 2.21.3 From nobody Fri May 10 03:04:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1600974102; cv=pass; d=zohomail.com; s=zohoarc; b=j44BU8uIgyXLP/XaWbcyzSr+3IAfgZbg2IzJS05SMWpUJ7+vmP901UPX0mdqUYUnz7Ow1dPl++dCJLPkQ9ztn4xfeS68pJ8amAurYIXJ6NEVO2ODovBWgBYSwA/l9i9AXUOthH3VY2wYZUREMh67dxA4JhxA+u4GX6FYacirvL4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600974102; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5fVBxh3jYMtrTLoaq1T3U6Sg9xkddLgahe7TZ5lrX40=; b=QzS+2lCTDGLVc6siiHHXT6bikrkUremmh9Y2cS0aUSH+x2MpKGlVq+1HqUWuvWh4CSWc2viJmwYp4C+zQnSWC0jtfjG9HyIyN2U7zIw5AwavZc0cmXC7QJYglkoFC+2D8bG2SPr0FpIh8SAsJxn2BjpMXdHBWMtlNu44r9sQWlc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600974102147536.8454857230234; Thu, 24 Sep 2020 12:01:42 -0700 (PDT) Received: from localhost ([::1]:43426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLWUu-0006yy-Ln for importer@patchew.org; Thu, 24 Sep 2020 15:01:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLWOh-0001da-CB; Thu, 24 Sep 2020 14:55:15 -0400 Received: from mail-eopbgr130114.outbound.protection.outlook.com ([40.107.13.114]:8257 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLWOf-0002O2-2q; Thu, 24 Sep 2020 14:55:14 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Thu, 24 Sep 2020 18:54:39 +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.033; Thu, 24 Sep 2020 18:54:39 +0000 Received: from kvm.sw.ru (185.215.60.94) by AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Thu, 24 Sep 2020 18:54:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jU7OHaVTl4h89G8SKtixHOIUbTF7tumtD6rMZa4t1uZ1pZPdCiqC1BSkFDJJrodNYrKmeBjTrwZtModRlyQ2B5ePCIqRC/wdaQs/pQtGHlXbIa2cAUVVEo0xZU1rbm6qerntUibMB7a5AZwTDdC+dLkwnYXKwPHE8dgj42Z0Gwo3Jq4mV98UVgNtm/SubCdpXMgwHy38dsvHSA3vuk65+N9WhcfXIFxdJSoZx3bE1DlTogYV+NmitP6GZirsb+FQVTCo3LfbHxhAHIWCj3XDCRycvDKIiYokNNAXKybU4DmF4KLt4pBeOQZhx60DdlpVrTfoOdmJpmSoM76SJlNabg== 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=5fVBxh3jYMtrTLoaq1T3U6Sg9xkddLgahe7TZ5lrX40=; b=PKfo32JljYQ/7U3nbMMN+GZBDNCEp0tjBRRpTxNsrWfIlSBnyEsZzD/HFsMPKjPNDpl2eub6Z03c8gKSqhSlDmoV3v7twJMFHCePQh9/NvFOxf9zjb5N7fKpOaGUQzFclMzNqoTCWK9lO5LAqAELr+Jp84lSOS8HSLpFFdrNWi+mYZemmqC5T7uFQTyZ+OPzB2FzvoS71W06n2uiCRHZ2IhzvjGvZuJtPF+5tf861vdaKRlQwUYTnjXRrgJjYQy8txNQtCOUuQKQtRrTCF6ShzVcAFmT/0j0bk3LB8WUF206vJAYbpB09YX1+RDHu7WZaxMRRymfOwIeN/EDVR0IKA== 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=5fVBxh3jYMtrTLoaq1T3U6Sg9xkddLgahe7TZ5lrX40=; b=McD+WCQjKDDEa1tbIXyJNmqzG8CfuGsCApAWXORRGRzMeMxnLwxY6F0TvgYITVl76wJawSvqOC7CdIcq4Ht+FGjGPH80zE0DKIA4BKq58n71jhsjmjgIQLnzvBtj/eOW3tqsb/b2FTNSYv+eUfiozbR7hZzNqwgjpZAnYWj/P2E= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, vsementsov@virtuozzo.com, eblake@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v9 6/7] block: drop bdrv_prwv Date: Thu, 24 Sep 2020 21:54:13 +0300 Message-Id: <20200924185414.28642-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200924185414.28642-1-vsementsov@virtuozzo.com> References: <20200924185414.28642-1-vsementsov@virtuozzo.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.94] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ab29f865-26fe-4b5d-c9f0-08d860bb49ef X-MS-TrafficTypeDiagnostic: AM6PR08MB4341: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1051; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7PLCcdZsrpjSdtBn/sGXtTgTk6TSjwYxLc6ZS7Mlh3cptCAsF3fVuOfjXQc9zEEObViz+hvhYGGdPGKacSSPxVQqbF9RSunBppOGo7fWGgA29ymE+42L5F7WbiRDkBRTe7H6dv58QPkQTrXw3aufLqJMi5sdSAIbHJvXurMXq+2VuQhTAQGz+lqPbhzH1QIPtNgEeuHGxerlhUQ3lW8uSGEMh8RwZANWrkwkWH2T9dmDd0VYEdzaTPQa2NLHkTH7Ssm7m8y2teuHbJE0i/9hx61IvJtDTJJIaVJJPVlZ/sibGvqWU2oYi9/LvFVUWNfHvdEzonbLtpwP8pRYaELQ1E8v9KqKH03MM81FrYneLxI= 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)(376002)(136003)(396003)(346002)(366004)(39840400004)(316002)(83380400001)(66476007)(6506007)(186003)(16526019)(5660300002)(2906002)(36756003)(6666004)(8936002)(8676002)(66946007)(2616005)(956004)(52116002)(6512007)(66556008)(86362001)(26005)(4326008)(478600001)(6916009)(1076003)(7416002)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: OT8VVpublzpWtT5eXRQOMIsrwzWkxGs3nXfUueVGIriWIjsU486VoIAKf1BanWKa0CJ+WHSMGH74D6Mdrn7NXUJfVp9ediUrruv8lhD0NUE3R4yP/063BMKXsxAdaTASEB3qqAnjjA7XB+kSNzvRIQpUyFy/3k0YGHeE7G7IYYQGofaoA4AVfRfZbGcmz7u8599JMJYVKujHP3rpeKuXTyClUjUlNpnJLFOymmH/gGAf7+oLcljCa8SEwmJouUHHRe4PHmKE2MPv76hgry9Ay83DZ69zOLDkfq/4VMPkLOhsKRhmvkLal/YJj430HWdh9Adf97QXt69eeQx/BYMNJilrVxanfehggMAqJMZk5WgI80bIS0v8dEQVKVRS1E2AluDH8eVHQGHEAapisbvjflMn3f+b3jXGdCkBasBsOh0MxAdRvPe29Bq396LolYe9+5wxN2dDEPVIXcHrlYqIoKHfwjxnIEFmUQloSwQ96k42RRwI033PB9t/cw6srJKUSM1wqs4x6YPyOYpA/xkgopDoBZ0W510g4gCEyDOA5pipE7OQaMtG45a53yKo9kan/5xGTEvOixldAgCVoIv083R0t42v43gFcB64Zy0jCiJn0RNAiGXmq4Pht3JPostWiSBy3l0L0V0NTL3Gxotw9Q== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab29f865-26fe-4b5d-c9f0-08d860bb49ef X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 18:54:39.0031 (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: Ni1e7p71tdCUmoRf7a5bcs7iXYOF2dc9MVeK0P0lKflR+hCs4vf8R4jnsTVDLNOeaq4lzh01d9ESZPSw4NVlC+YwTtBMVfNYX9UprE1SLOg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.13.114; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 14:54:34 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Now that we are not maintaining boilerplate code for coroutine wrappers, there is no more sense in keeping the extra indirection layer of bdrv_prwv(). Let's drop it and instead generate pure bdrv_preadv() and bdrv_pwritev(). Currently, bdrv_pwritev() and bdrv_preadv() are returning bytes on success, auto generated functions will instead return zero, as their _co_ prototype. Still, it's simple to make the conversion safe: the only external user of bdrv_pwritev() is test-bdrv-drain, and it is comfortable enough with bdrv_co_pwritev() instead. So prototypes are moved to local block/coroutines.h. Next, the only internal use is bdrv_pread() and bdrv_pwrite(), which are modified to return bytes on success. Of course, it would be great to convert bdrv_pread() and bdrv_pwrite() to return 0 on success. But this requires audit (and probably conversion) of all their users, let's leave it for another day refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- block/coroutines.h | 10 ++++----- include/block/block.h | 2 -- block/io.c | 49 ++++++++--------------------------------- tests/test-bdrv-drain.c | 2 +- 4 files changed, 15 insertions(+), 48 deletions(-) diff --git a/block/coroutines.h b/block/coroutines.h index c62b3a2697..6c63a819c9 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -31,12 +31,12 @@ int coroutine_fn bdrv_co_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix); int coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, Error **er= rp); =20 -int coroutine_fn -bdrv_co_prwv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov, - bool is_write, BdrvRequestFlags flags); int generated_co_wrapper -bdrv_prwv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov, - bool is_write, BdrvRequestFlags flags); +bdrv_preadv(BdrvChild *child, int64_t offset, unsigned int bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags); +int generated_co_wrapper +bdrv_pwritev(BdrvChild *child, int64_t offset, unsigned int bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags); =20 int coroutine_fn bdrv_co_common_block_status_above(BlockDriverState *bs, diff --git a/include/block/block.h b/include/block/block.h index f2d85f2cf1..eef4cceaf0 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -383,9 +383,7 @@ int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, int bytes, BdrvRequestFlags flags); int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags); int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int bytes); -int bdrv_preadv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov); int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf, int byt= es); -int bdrv_pwritev(BdrvChild *child, int64_t offset, QEMUIOVector *qiov); int bdrv_pwrite_sync(BdrvChild *child, int64_t offset, const void *buf, int count); /* diff --git a/block/io.c b/block/io.c index c1360ba57d..cd5b689473 100644 --- a/block/io.c +++ b/block/io.c @@ -890,23 +890,11 @@ static int bdrv_check_byte_request(BlockDriverState *= bs, int64_t offset, return 0; } =20 -int coroutine_fn bdrv_co_prwv(BdrvChild *child, int64_t offset, - QEMUIOVector *qiov, bool is_write, - BdrvRequestFlags flags) -{ - if (is_write) { - return bdrv_co_pwritev(child, offset, qiov->size, qiov, flags); - } else { - return bdrv_co_preadv(child, offset, qiov->size, qiov, flags); - } -} - int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, int bytes, BdrvRequestFlags flags) { - QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, NULL, bytes); - - return bdrv_prwv(child, offset, &qiov, true, BDRV_REQ_ZERO_WRITE | fla= gs); + return bdrv_pwritev(child, offset, bytes, NULL, + BDRV_REQ_ZERO_WRITE | flags); } =20 /* @@ -950,41 +938,19 @@ int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags= flags) } } =20 -/* return < 0 if error. See bdrv_pwrite() for the return codes */ -int bdrv_preadv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov) -{ - int ret; - - ret =3D bdrv_prwv(child, offset, qiov, false, 0); - if (ret < 0) { - return ret; - } - - return qiov->size; -} - /* See bdrv_pwrite() for the return codes */ int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int bytes) { + int ret; QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); =20 if (bytes < 0) { return -EINVAL; } =20 - return bdrv_preadv(child, offset, &qiov); -} - -int bdrv_pwritev(BdrvChild *child, int64_t offset, QEMUIOVector *qiov) -{ - int ret; + ret =3D bdrv_preadv(child, offset, bytes, &qiov, 0); =20 - ret =3D bdrv_prwv(child, offset, qiov, true, 0); - if (ret < 0) { - return ret; - } - - return qiov->size; + return ret < 0 ? ret : bytes; } =20 /* Return no. of bytes on success or < 0 on error. Important errors are: @@ -995,13 +961,16 @@ int bdrv_pwritev(BdrvChild *child, int64_t offset, QE= MUIOVector *qiov) */ int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf, int byt= es) { + int ret; QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); =20 if (bytes < 0) { return -EINVAL; } =20 - return bdrv_pwritev(child, offset, &qiov); + ret =3D bdrv_pwritev(child, offset, bytes, &qiov, 0); + + return ret < 0 ? ret : bytes; } =20 /* diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 1107271840..1595bbc92e 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -1872,7 +1872,7 @@ static int coroutine_fn bdrv_replace_test_co_preadv(B= lockDriverState *bs, } s->io_co =3D NULL; =20 - ret =3D bdrv_preadv(bs->backing, offset, qiov); + ret =3D bdrv_co_preadv(bs->backing, offset, bytes, qiov, 0); s->has_read =3D true; =20 /* Wake up drain_co if it runs */ --=20 2.21.3 From nobody Fri May 10 03:04:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1600974157; cv=pass; d=zohomail.com; s=zohoarc; b=VQ/txQup7BfeCfuJL3KouS7hBlZouEnus8gbgvLm7qmTDAVOfCs5m4W/UV8rIZOeF3xLHK2N0Ki1+PO+qlFo/bfPRawWiKDjfHR1K/4NanMX5UheQ3h4dxUbJzJlnPDnnHeHFuYU//PG2icpxvw8/UpOjlvnmBEYYSsEEEwRVXQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600974157; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HiHebYqNrRrCRFM5FZXBKZhy6PdvbjnSnTkFrQlzjC4=; b=M3mFZh+uIbf3DlrhdAKkanydKEsitEwy7ST+/VzlhqflwXhOd6aBHVaxY8CJA4+IlRS3saw7MWaiZFe+yWX0yJTrHFYTy050+R1RJmjhr/u/CpKwG5zOuWrhXxq9wmqXQ4II9/ebgFHuT8lo7o/eJ0o+P6bvU+QcAcu3bwCJQJg= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600974157716840.4935756690851; Thu, 24 Sep 2020 12:02:37 -0700 (PDT) Received: from localhost ([::1]:44134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLWVo-0007Mc-6O for importer@patchew.org; Thu, 24 Sep 2020 15:02:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLWOL-0001GM-36; Thu, 24 Sep 2020 14:54:53 -0400 Received: from mail-eopbgr80115.outbound.protection.outlook.com ([40.107.8.115]:8199 helo=EUR04-VI1-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 1kLWOA-0002OV-IY; Thu, 24 Sep 2020 14:54:52 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3159.eurprd08.prod.outlook.com (2603:10a6:209:46::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Thu, 24 Sep 2020 18:54:39 +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.033; Thu, 24 Sep 2020 18:54:39 +0000 Received: from kvm.sw.ru (185.215.60.94) by AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Thu, 24 Sep 2020 18:54:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XjnaKG99EMpdVUOnwEbDq7SmCDg3/tY86KdwbRNnkQFzXGzG/CH/lHluXlx8K6eOTF1pvyOLlFQR1+ndzS9SR//fjjDD8sTwzkRLzxNBLaNjF2Ax8i9x0qUjvmZ0og/Tqn760vltrMNqzDr9sv9iEpye8NU81Vm49ALBncHTtQD4Yl2hFdt5wu4FswLLkbLBFwybVXadEeAEAzmVBEX7INzBCf24JzrpWunzt7aFKKTIhzdeMAwmfMl46KMASa/hp7gJ3dAmSvTrZoqSYg8/mIVmeI+n6aL1UQ0pr6/C0+qzc9MAO51qWCZQU5gm31vxYKzfZK51uf9acVgsVlWtGA== 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=HiHebYqNrRrCRFM5FZXBKZhy6PdvbjnSnTkFrQlzjC4=; b=Sz3TJaUNFciJLpqvZAw/SNXTtSDNdR1YhMO82jLV38NObpC3UeJdwqxXvGBCJYY0QhSf1j2q0P/AUAebkCdRwtDzYyk7NZHkzyg6M0Ua4tZ1FQs4u6BWsISF4sgrDXW+Gu2dXeItzx8PRk43RNtmy6QUJSygvAHHgOtGqOaaIsCAW00qP265/aYu0RfuAgSOMjyfwF2LY7Pm8FhHrw/efWMbQ666W+6R+3AGDsVP9NN+s3mzLlTZAKpoEGVMoU7tzHGrksAGT2XYDdPBQtm8yV9deDbdQdm4AmT/q787OO8mMlzZuo415hUy9BZVsLs01jlMNzAjLhhW2f1QNJnv7w== 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=HiHebYqNrRrCRFM5FZXBKZhy6PdvbjnSnTkFrQlzjC4=; b=og8ZMLeGnPggnSOMGoewURM8+ir/PqjmOYOjQBsvF96b5Qsm9EgHU1IghzQf19gNWX2PPLEYhUhcwBueA+BVEe8sFNmiKArWQRuMYPu9pWMzsEu1CPc4DGUFqNwJdiWTvmjVsGMjAn5XQNXQXw549ngttQqBmqSTGh73HzXKB/E= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, vsementsov@virtuozzo.com, eblake@redhat.com Subject: [PATCH v9 7/7] block/io: refactor save/load vmstate Date: Thu, 24 Sep 2020 21:54:14 +0300 Message-Id: <20200924185414.28642-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200924185414.28642-1-vsementsov@virtuozzo.com> References: <20200924185414.28642-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM0PR05CA0082.eurprd05.prod.outlook.com (2603:10a6:208:136::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.94] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2e114505-b03f-402c-c271-08d860bb4a77 X-MS-TrafficTypeDiagnostic: AM6PR08MB3159: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:153; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lhMMUmRQObUsY79OaP/4s98N5toVOPOwX5kpCBOUvRO75kkyYC9g7MueJWXAXs5l3nh59sZ9twCm+TUt88AZ+5RDs3Q8peRrBusFKi6zf2QSDgOHhbH/Tz0nXpztk4Y7Qdktp2qPz0F2BxP9xW1PQJ7VdZX56VwDui+rvM0ynhpYlbp2l6/eGNENujisQpcBKPmmhWoznGdxKiHCGw6lvU+wyCbVBlgmadt5nR4BZOS9TDlwnEZf2WnLmrinH+sbsQ28/VwPwmW3UHoHUiCSj5d4ZpQpPX/txvLWzI/C88l3WKeo7P/IV6jbOl9wESe7oBEIMzZXQlT21ijOKmuDxAbAdSn0DRsoEaceIapceAiqvNpROfRt+w4z/3s3CkFa 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)(366004)(136003)(396003)(39850400004)(346002)(376002)(8676002)(186003)(86362001)(6916009)(66556008)(8936002)(478600001)(36756003)(83380400001)(956004)(6512007)(4326008)(16526019)(66476007)(5660300002)(66946007)(2906002)(6486002)(6666004)(6506007)(52116002)(26005)(1076003)(2616005)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: IL28E+BINdBW8pXf5CGkXicf/5x3VFOCmTkdUcEuJjMupCXJwFMVPpFCcsV4TOx7abXDcVSm7rXnHQ5GUZG1l8qxdXxMA68LHL6UAAu69nT+EJrhTZ9h7WFh3HrsNltEiMVwnOJskxqBeXFReHr/eBtgaFScRQXPYn2CQTGfXAfveE0QVU5bScebOeXcLxwUivj9wP7FpbjtfM5HEuptw/weA1YS2xrqRTFCWrNxs50jw45wnRUTYVKgNqLitsjL70+tIl8hnJoDJlUTWYDB4Ea/RZNKwiravxpb4E+ih0w1ehuHmAj5u+HuW3UgE2KtRAIMgKU3abUxLV5F6N9ojpWJAL8RhLulnJuavmJ6YnwNXbRuAawyjgGkeXFbqv5N0e//DH08lupB0pOBrG99rzA4mWWXWd6Fc5O8BScmt+SA/FtHihudV26euNpVzMsuYpLFees6fPuJoNgijrKXPi+XsYNNkI/zBYfWcl4u5cyRiPMc5rHIsBokwvuhu3tpOEU9UgUB9U6l3Mq/B9WFwAD8XbpGfLCjaama1CV6z2Upr+yj8P7yPpiUOgKf769l18nxSFyTDrYViHzx5SDiJsT0JBC5yL2mrf0ORw5pgddCpXe0e3MklSc1xDWBETC/CXRfGywVBqgZPe9bC7hRsQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e114505-b03f-402c-c271-08d860bb4a77 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 18:54:39.8573 (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: q4T3pjo66Y0AjvsUwUTwrwATiWqVdSNQsI4Wfj/bp79fmczF4GILKbWAjodnHmLcYBc4Mac7VbHvHWIvU8vlyr+ZrhrSzyEhcmv4JW7SE10= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3159 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.8.115; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 14:54:40 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" Like for read/write in a previous commit, drop extra indirection layer, generate directly bdrv_readv_vmstate() and bdrv_writev_vmstate(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi --- block/coroutines.h | 10 +++---- include/block/block.h | 6 ++-- block/io.c | 68 ++++++++++++++++++++++--------------------- 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/block/coroutines.h b/block/coroutines.h index 6c63a819c9..f69179f5ef 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -57,11 +57,9 @@ bdrv_common_block_status_above(BlockDriverState *bs, int64_t *map, BlockDriverState **file); =20 -int coroutine_fn -bdrv_co_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, - bool is_read); -int generated_co_wrapper -bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, - bool is_read); +int coroutine_fn bdrv_co_readv_vmstate(BlockDriverState *bs, + QEMUIOVector *qiov, int64_t pos); +int coroutine_fn bdrv_co_writev_vmstate(BlockDriverState *bs, + QEMUIOVector *qiov, int64_t pos); =20 #endif /* BLOCK_COROUTINES_INT_H */ diff --git a/include/block/block.h b/include/block/block.h index eef4cceaf0..8b87df69a1 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -572,8 +572,10 @@ int path_has_protocol(const char *path); int path_is_absolute(const char *path); char *path_combine(const char *base_path, const char *filename); =20 -int bdrv_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t p= os); -int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t = pos); +int generated_co_wrapper +bdrv_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos); +int generated_co_wrapper +bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos); int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf, int64_t pos, int size); =20 diff --git a/block/io.c b/block/io.c index cd5b689473..449b99b92c 100644 --- a/block/io.c +++ b/block/io.c @@ -2475,67 +2475,69 @@ int bdrv_is_allocated_above(BlockDriverState *top, } =20 int coroutine_fn -bdrv_co_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, - bool is_read) +bdrv_co_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t po= s) { BlockDriver *drv =3D bs->drv; BlockDriverState *child_bs =3D bdrv_primary_bs(bs); int ret =3D -ENOTSUP; =20 + if (!drv) { + return -ENOMEDIUM; + } + bdrv_inc_in_flight(bs); =20 - if (!drv) { - ret =3D -ENOMEDIUM; - } else if (drv->bdrv_load_vmstate) { - if (is_read) { - ret =3D drv->bdrv_load_vmstate(bs, qiov, pos); - } else { - ret =3D drv->bdrv_save_vmstate(bs, qiov, pos); - } + if (drv->bdrv_load_vmstate) { + ret =3D drv->bdrv_load_vmstate(bs, qiov, pos); } else if (child_bs) { - ret =3D bdrv_co_rw_vmstate(child_bs, qiov, pos, is_read); + ret =3D bdrv_co_readv_vmstate(child_bs, qiov, pos); } =20 bdrv_dec_in_flight(bs); + return ret; } =20 -int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf, - int64_t pos, int size) +int coroutine_fn +bdrv_co_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t p= os) { - QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, size); - int ret; + BlockDriver *drv =3D bs->drv; + BlockDriverState *child_bs =3D bdrv_primary_bs(bs); + int ret =3D -ENOTSUP; =20 - ret =3D bdrv_writev_vmstate(bs, &qiov, pos); - if (ret < 0) { - return ret; + if (!drv) { + return -ENOMEDIUM; } =20 - return size; -} + bdrv_inc_in_flight(bs); =20 -int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t = pos) -{ - return bdrv_rw_vmstate(bs, qiov, pos, false); + if (drv->bdrv_save_vmstate) { + ret =3D drv->bdrv_save_vmstate(bs, qiov, pos); + } else if (child_bs) { + ret =3D bdrv_co_writev_vmstate(child_bs, qiov, pos); + } + + bdrv_dec_in_flight(bs); + + return ret; } =20 -int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf, +int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf, int64_t pos, int size) { QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, size); - int ret; - - ret =3D bdrv_readv_vmstate(bs, &qiov, pos); - if (ret < 0) { - return ret; - } + int ret =3D bdrv_writev_vmstate(bs, &qiov, pos); =20 - return size; + return ret < 0 ? ret : size; } =20 -int bdrv_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t p= os) +int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf, + int64_t pos, int size) { - return bdrv_rw_vmstate(bs, qiov, pos, true); + QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, size); + int ret =3D bdrv_readv_vmstate(bs, &qiov, pos); + + return ret < 0 ? ret : size; } =20 /**************************************************************/ --=20 2.21.3 From nobody Fri May 10 03:04:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1601022866; cv=pass; d=zohomail.com; s=zohoarc; b=Gw0+wWzBdvW3Q/E4MrsJ3Xkk/bP8yMEEaAlYY68sOGN4NOlYLcpDnYlde48v5DTjA/V3vKlxQLGAFpr/KzjybgY5WYk+59dWQ/zToinWyBzu9j4A4CDVQAmFB1SXyIBLUsxGc/1NAHkKDGp52/9BVBAkmqgvNb8CD/Z1TJtSOSo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601022866; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jX4eQbe6FiREfNGi2H2IkuREZNQofxAklPBL+H87kKs=; b=O31qPFZehUJOZ0c39sYj4kXvHBeOGpmS5TUFsYTD5FkpMF9paYoK+CefnhU4eCGmK0f59gWal44YIoFcG6+SGsDUN86PYZKibAYu2Ie3h2Erd26TmIVwPRds/LxCEs98XJRHT5ylhdzZmlUmnYzvt1Y4WKSwnY/cq2SnsViVqE0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1601022866217543.8988284963231; Fri, 25 Sep 2020 01:34:26 -0700 (PDT) Received: from localhost ([::1]:39108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLjBQ-0005Rh-40 for importer@patchew.org; Fri, 25 Sep 2020 04:34:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLjA2-0004dF-QF; Fri, 25 Sep 2020 04:32:58 -0400 Received: from mail-eopbgr80104.outbound.protection.outlook.com ([40.107.8.104]:27495 helo=EUR04-VI1-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 1kLj9z-0002uh-Rc; Fri, 25 Sep 2020 04:32:57 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM7PR08MB5493.eurprd08.prod.outlook.com (2603:10a6:20b:102::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.17; Fri, 25 Sep 2020 08:32:51 +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.033; Fri, 25 Sep 2020 08:32:51 +0000 Received: from kvm.sw.ru (185.215.60.94) by FRYP281CA0010.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.13 via Frontend Transport; Fri, 25 Sep 2020 08:32:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GQ6UrwJkuY/zHsXoZPn+iieYE7Bund4PQdT7W/asElPmjY+3z4I+TeGGzAnrpOh2b9ZXVI7VUN1mcJxX2o4G4VX7DlsQemZyX7lVVXWh8tIkNsXDVEvJAtHmu7C1VgdLeWrC/7CZBosQichevm0RfnI6fQgcyTApoomCZc1CvH7xDAIK+HhJV+i03e62xZz/g1Jq9CsubR8hF2Yu0DTAOCzXJaPsc0Q6XpyFC322jpzg6ZSftyywsREjCKRiNVXPn69VioXey4jas04DBPqjSBBe+cnANNjye1CJ2V9B8g0895thVxBsyhqeRuX4ICazkT/DxGe0qA7IbUOYx7To3w== 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=jX4eQbe6FiREfNGi2H2IkuREZNQofxAklPBL+H87kKs=; b=O/uyYnUilRZgFbyzGZckhdq7hkJWTu5FDaQyCJaH0/a6z0CSKjH+w5Ez74Q7d8WbmKAaatzzSS6R1Zpni10kDKfwvpIko+faaQhbpqOS6/NKD9clvUdgBu5KE8gGDJkOn4NkDvRY1+QcrNGFRIEFlf7oQa1nY73uvj6ZtZ73q/Zdb+pFvj2BwU0sSEws1JWeH8Ey8Xd7Q4UNzAKTrQqfddGZdmx5ytS24DIMECR9DCHar1QPEWLnxVC80f2IzxgMbb+pM5I5YJqmfIg5N65GRl192KOCkueYq9r9eymKaYR97li0TCM4GCT7bLGZRDf5+AwcUsBICqjkn/I6leoDSA== 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=jX4eQbe6FiREfNGi2H2IkuREZNQofxAklPBL+H87kKs=; b=q/FPXJNsIqoKDn2oIKlnGn8cI3ynilkLeRvZUcRC7OEJaBNAa2+M5zzL+5pwYsK6oVHUvBOzD63JfS4dXjFDrpZVT/4lP47TsMWGmeG6eopx6tqG4WU8wen1eMmaweGfZfqvh06f0ba7hWbU+4dGYoF/8hOr1llbH4AQSBqmpgQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, vsementsov@virtuozzo.com, eblake@redhat.com Subject: [PATCH 0.5/7] include/block/block.h: drop non-ascii quotation mark Date: Fri, 25 Sep 2020 11:32:29 +0300 Message-Id: <20200925083229.2528-1-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200924185414.28642-1-vsementsov@virtuozzo.com> References: <20200924185414.28642-1-vsementsov@virtuozzo.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: FRYP281CA0010.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10::20) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.21.3 X-Originating-IP: [185.215.60.94] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 43ffdd21-35fc-4040-c0bd-08d8612d96fb X-MS-TrafficTypeDiagnostic: AM7PR08MB5493: 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: R7LV3x0/GkbZcdUAtoQwMRbp7X0BJzRtW1IbTNjsUtkL3z/VnIXIFa4ToY2BgnIWOcIZKMxBjb85yX2zdz9F5NG+oZyMIz5CgLCAb/xBnZg7oE9p0GdxruLqwyXhK5Zbm2h6hw3rIMtUG3XR3iCsSBfFOSTHf0mLDEDJ7y3+RsGXzyrCLFlfxWqHhgUJDz9+4xAYKOwY+sVbjD2m93q/Zckq+49xY2LeS3oD+RoOrutCXePf3rGtduawyFz4URZz9xPxjjkA76fjqXYwZq9VQshPw49Q8sUtPjdtwCLaPnv23QxritLUOM32C/lkbXaXWJMk5aF8twJ6iyMSXCyL4WJZla1nBJxgXuQhUzWyKG84sNKfum7advuhWHXHh/9m 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)(39850400004)(366004)(136003)(346002)(396003)(376002)(16526019)(26005)(6666004)(6512007)(1076003)(4326008)(6486002)(2906002)(66476007)(66556008)(478600001)(4744005)(83380400001)(36756003)(66946007)(2616005)(86362001)(8936002)(52116002)(316002)(8676002)(5660300002)(6506007)(6916009)(956004)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: MMXpDwa65pLmi1z1VrGEQu42a3/x/1Jek33PDEEqPw9YkHDbbFQ2ErDUeIWfAO6lMP9S8ahrGuRLtSFaTUBskv9co0k5ztAJSmQlCx0KH0p8xEQjoXpP7/5iYxarQrAU4utzHN8jX0iftnCYN+xy0kMlWXy7Ok/o2jk4I4614kfJ0/J96ZuNZJ1mypSW3R2+WpeO4P6oWG8cYAJjNxxiTqp2s9NgyH+kcsWcHVFkmpkfG61xBw9FSqpXADfUGS0Aff4vwFXNAhYNiDeic6siq9zkzldiH2snBi9X8JwNU/aJg/Ebk5cDL0QvXcBOGOuyQXSGEe/BhX9IQlLbTMVNaHUnlhhQZofux2LBdRRZeITolt86riU7zqb40SoKylxOWwRGleezkDZwIIG8nT8eGQz8/t+O97zKwGrF02OHzL/SHClrSNUk8z/N2FGd+zqhwtVrRLDAgL/ovwS2XbhehT/Zq8s8AY+ZjvmGAkopQckswr1J5ihVIQ/07pN7jar6F/UfsN3LhKg91pTAjOsiXk8RLrk/PICnPShAr9GvxN6TAmpKStLbhrsqsysJikS1juMEx8UL+bvKS73O6oi87Yo/+OqznoKXvi8stJpgOOg9AH30tJNG9hPRyKXRE+zuat08dcMy36wOg3OR3ufdEQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43ffdd21-35fc-4040-c0bd-08d8612d96fb X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 08:32:50.9181 (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: qpOASVNRh4i8P2R1arnf8okoghRqHochWe+dvwu6f75fIpuazZjN1uZiqleWqCsQxj2Ew4SMZlWuNqvYLHHaquEJOphg4swh7Y24iICVn7s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5493 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.8.104; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/25 04:32:52 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) This is the only non-ascii character in the file and it doesn't really needed here. Let's use normal "'" symbol for consistency with the rest 11 occurrences of "'" in the file. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/block/block.h b/include/block/block.h index 8b87df69a1..ce2ac39299 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -304,7 +304,7 @@ enum BdrvChildRoleBits { BDRV_CHILD_FILTERED =3D (1 << 2), =20 /* - * Child from which to read all data that isn=E2=80=99t allocated in t= he + * Child from which to read all data that isn't allocated in the * parent (i.e., the backing child); such data is copied to the * parent through COW (and optionally COR). * This field is mutually exclusive with DATA, METADATA, and --=20 2.21.3