From nobody Sat Jun 29 05:51:33 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=none dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1590611960; cv=pass; d=zohomail.com; s=zohoarc; b=gwidTKs5fRZzK1Vjnw5Hd05LstRK2xxqwj1REZ6zixT67EbUp1ThtKKsp8oS8VK56LSq1PmrB0Nmj0LCVOLv2lHIc3FchzpluTJxa7VxWJyuHnUJVICwa9+2AbRVOZffQoOPEbgXmFqp74xlaxoiGn5coKkTRqmwNEDo3N046LM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590611960; 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=9l1/Je0oKX1polil/IrnQHIDLaYdK+cWDoKIy1pfxsE=; b=R/Ba4DFjhLyUirfrvYSeIElxHUFJ1A/aE/k3Ymz0JOqJqiTq71AsMv4Raymovo0aQwpyANtNGhcuD5U9vGny5PrpPTOQ8crko56v9j+mt6uvX4f4XKU4zDUSmosO+wvmoZj8lsV/ve64B1vc2AG78EjCN7p1VXbFTFKvm37PNG8= 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=none 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 1590611960347385.67840221489735; Wed, 27 May 2020 13:39:20 -0700 (PDT) Received: from localhost ([::1]:42870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1je2pa-0006MY-Ux for importer@patchew.org; Wed, 27 May 2020 16:39:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1je2oL-0004db-1D; Wed, 27 May 2020 16:38:01 -0400 Received: from mail-am6eur05on2112.outbound.protection.outlook.com ([40.107.22.112]:57342 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1je2oJ-0007uz-PN; Wed, 27 May 2020 16:38:00 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM7PR08MB5336.eurprd08.prod.outlook.com (2603:10a6:20b:105::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.24; Wed, 27 May 2020 20:37:53 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::a408:2f0f:bc6c:d312]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::a408:2f0f:bc6c:d312%4]) with mapi id 15.20.3045.018; Wed, 27 May 2020 20:37:53 +0000 Received: from kvm.sw.ru (185.215.60.148) by AM0PR10CA0101.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.17 via Frontend Transport; Wed, 27 May 2020 20:37:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZKNR0FOieIaLnQlWNH7MKxjkNX8OufzIbQhhU5zBqS5G0RbVPMJGKZ4ggwFwKGwly4jCbt7v35WvvDUOu2FMkGfIOSXUJmObTE7vCJEO2eaav03PMm6favoHiX0APauGXVkebKCv5nZBiV1vVo2E2RgVTPqDV9bktnxTm09ItGIKw8cTdDFXstuEklS1calP0cBv7SSCegeJXXR5htEaMUNVu83SBosGyAgRTDmQY1gsJZsblTHHd+Rw7VhtOxXu/3/z7yQnu+c8wyI63s2ahmefHuuexwacmhcG63y0fKEj6OrEaSik/jAy2V7x8xYiLI0U+XQ2Mv23ebwXweZ1TA== 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=9l1/Je0oKX1polil/IrnQHIDLaYdK+cWDoKIy1pfxsE=; b=UTLVh5/g56xTg0NeJi95Zne8MtRE7Aw2bKWzP+BpsVcZsYX0wo8VfG4pYnE/T0uImT8mQOqRq6CClrEfUm6UhXk8AA6bvHG6+EBGDapwVHOt5PPL7mXDglYbrm3dM1YXHhlTfgrSlAYbWZMY89SCm1SciB8vHi++CUFUKxAdesWg7WwKTgPbh7tps98VAzoUD7GewzbwDhchwIMGvcMyVXUfwRI3AJc/jTDFmXShNHP5fOqpNX4qR6oovK+2RiCgXQd5mL8A0gEww6rdhx8q37fFdFhXHNl2iB7BPMM/9rG1PKJ0alYnKtizVjiFS40jwug0ATjX8LBkTDsXr1Lx1A== 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=9l1/Je0oKX1polil/IrnQHIDLaYdK+cWDoKIy1pfxsE=; b=JnLgTb1Xrh3soK3Sf2VfGjdO5pJwUwvxU8L+e0icNkioUgxOfO2qVSwqJomC8nb4TqnTi/5i0KmrSdgnNiQRRalF1AJXyIjjq/mVEN4UntgiybCNQh0n93h68V/OZMmbu+kYMaos2GA0cBgf1KdbeoGbVAJNwCKX6bDZQgziVbk= 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 Subject: [PATCH v5 5/7] block: generate coroutine-wrapper code Date: Wed, 27 May 2020 23:37:31 +0300 Message-Id: <20200527203733.16129-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200527203733.16129-1-vsementsov@virtuozzo.com> References: <20200527203733.16129-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM0PR10CA0101.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::18) 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.0 X-Originating-IP: [185.215.60.148] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6d4f6c2c-2184-4ae1-9ec8-08d8027dd4a6 X-MS-TrafficTypeDiagnostic: AM7PR08MB5336: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:353; X-Forefront-PRVS: 04163EF38A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wXg2MmWdYmG2Woy1Llxbof2sOUGDbCnqntinulPbw3Jzfg/lPlD0FZ/6JNgrj5qe04cl/zD5/NOL+fE+CzYebutD7w2Hf8sXyLqW2W6rP7v0oQyyAKKdZg5V/wC0nN0qUVndlePiJlaETo7NC5/1ftaTnUm+4XX7wIaw/BU4X6L5SIgSdHijphesV7B2VFbYGuunrq1tGKp9u9wc3srZksWGBLKSgqZp2+rorVKLNr5hRtKwzT3faMAPBw7q4WbmbZ97JSYn7sIreB9urFsr4ajem811BYu1QXa1fR/Ake8fqLoKM67dpKoyj//kxBNFiqJYlTTuL1RJfr8qpvc6ug== 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; SFTY:; SFS:(4636009)(346002)(366004)(396003)(39850400004)(376002)(136003)(956004)(66556008)(66946007)(66476007)(8676002)(6486002)(6512007)(1076003)(478600001)(186003)(316002)(5660300002)(6916009)(30864003)(2616005)(6506007)(8936002)(16526019)(26005)(2906002)(6666004)(83380400001)(36756003)(4326008)(52116002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: J/MyL6EAasNtoMi3DuxhQqp/s0JcPpTfknrTBzc0B98BOVLLlGzTRqQ5KBvvrVol6UWdJWVz+YgW5YL3uCQga9NeFHAlP7qupSa3fWpbs+jZTHVYNOHTdG9jpxgc2CQ8NX5Dm8/yyzbuY8kuyQMkdgwyN5NySFk13wrM8mTEpWTt/H7d5OxKlBhb1Q/YHJQiOp53u2MPgf3fgCXmmtRksMPf+dl6P56urYstDJkloTOwlIlcu+m/45GDlZqwHopabpARCxtmDnHBlCAMGL8tVPTco+vRxBP3Bc/8QYBHfHm3Tk3Hj86AIvk6zZ/DzZ6vU8A4kogE108W29XgKfMwXplSm1m8OoBNvre8P70/r/t6On+DkqHMLxgELqTXvzCFPw5hbGiaJt13nobsgk93fcDrX+b/ng1uWl01dxGIGJg/8/vtZmR/ZP3Hbod1x5dXkLZvzGiAtQf50SzaQsIcsvKg17o4K/jnE9OIBS6+ZNU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d4f6c2c-2184-4ae1-9ec8-08d8027dd4a6 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2020 20:37:53.6957 (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: xFqKoZYT+4E8D6NZnWdbixWqXI9aDhxBiN9SpJRGAOaIyqMSwUxln1PAYlZJqREn2ctrzOjro9FVTQJdaA9iedDCobM1P3x4Uc1g6lI0+dE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5336 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.22.112; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/27 16:37:50 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, ehabkost@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, crosa@redhat.com, den@openvz.org 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 --- block/coroutines.h | 7 +- include/block/block.h | 17 ++- block.c | 73 ------------ block/io.c | 260 ------------------------------------------ 4 files changed, 15 insertions(+), 342 deletions(-) diff --git a/block/coroutines.h b/block/coroutines.h index 9ce1730a09..145a2d2645 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -26,6 +26,7 @@ #define BLOCK_COROUTINES_INT_H =20 #include "block/block_int.h" +#include "block/generated-co-wrapper.h" =20 int coroutine_fn bdrv_co_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix); @@ -34,7 +35,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 +48,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 +61,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 46965a7780..46c8b7816e 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -9,6 +9,7 @@ #include "block/dirty-bitmap.h" #include "block/blockjob.h" #include "qemu/hbitmap.h" +#include "block/generated-co-wrapper.h" =20 /* block.c */ typedef struct BlockDriver BlockDriver; @@ -398,8 +399,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); @@ -441,7 +443,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 @@ -464,12 +467,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); @@ -484,7 +488,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 2ca9267729..3046696f30 100644 --- a/block.c +++ b/block.c @@ -4640,43 +4640,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 @@ -5723,42 +5686,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 f5b6ce3bf6..f9700cc897 100644 --- a/block/io.c +++ b/block/io.c @@ -892,15 +892,6 @@ static int bdrv_check_byte_request(BlockDriverState *b= s, int64_t offset, return 0; } =20 -typedef struct RwCo { - BdrvChild *child; - int64_t offset; - QEMUIOVector *qiov; - bool is_write; - int ret; - BdrvRequestFlags flags; -} RwCo; - int coroutine_fn bdrv_co_prwv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov, bool is_write, BdrvRequestFlags flags) @@ -912,43 +903,6 @@ int coroutine_fn bdrv_co_prwv(BdrvChild *child, int64_= t offset, } } =20 -static void coroutine_fn bdrv_rw_co_entry(void *opaque) -{ - RwCo *rwco =3D opaque; - - rwco->ret =3D bdrv_co_prwv(rwco->child, rwco->offset, rwco->qiov, - rwco->is_write, rwco->flags); - aio_wait_kick(); -} - -/* - * Process a vectored synchronous request using coroutines - */ -int bdrv_prwv(BdrvChild *child, int64_t offset, - QEMUIOVector *qiov, bool is_write, - BdrvRequestFlags flags) -{ - Coroutine *co; - RwCo rwco =3D { - .child =3D child, - .offset =3D offset, - .qiov =3D qiov, - .is_write =3D is_write, - .ret =3D NOT_DONE, - .flags =3D flags, - }; - - if (qemu_in_coroutine()) { - /* Fast-path if already in coroutine context */ - bdrv_rw_co_entry(&rwco); - } else { - co =3D qemu_coroutine_create(bdrv_rw_co_entry, &rwco); - bdrv_coroutine_enter(child->bs, co); - BDRV_POLL_WHILE(child->bs, rwco.ret =3D=3D NOT_DONE); - } - return rwco.ret; -} - int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, int bytes, BdrvRequestFlags flags) { @@ -2223,20 +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; - int ret; - bool done; -} BdrvCoBlockStatusData; - int coroutine_fn bdrv_co_block_status_from_file(BlockDriverState *bs, bool want_zero, int64_t offset, @@ -2488,56 +2428,6 @@ bdrv_co_common_block_status_above(BlockDriverState *= bs, return ret; } =20 -/* Coroutine wrapper for bdrv_block_status_above() */ -static void coroutine_fn bdrv_block_status_above_co_entry(void *opaque) -{ - BdrvCoBlockStatusData *data =3D opaque; - - data->ret =3D bdrv_co_common_block_status_above(data->bs, data->base, - data->want_zero, - data->offset, data->byte= s, - data->pnum, data->map, - data->file); - data->done =3D true; - aio_wait_kick(); -} - -/* - * 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) -{ - Coroutine *co; - 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, - .done =3D false, - }; - - if (qemu_in_coroutine()) { - /* Fast-path if already in coroutine context */ - bdrv_block_status_above_co_entry(&data); - } else { - co =3D qemu_coroutine_create(bdrv_block_status_above_co_entry, &da= ta); - bdrv_coroutine_enter(bs, co); - BDRV_POLL_WHILE(bs, !data.done); - } - return data.ret; -} - int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map, BlockDriverState **file) @@ -2631,14 +2521,6 @@ int bdrv_is_allocated_above(BlockDriverState *top, return 0; } =20 -typedef struct BdrvVmstateCo { - BlockDriverState *bs; - QEMUIOVector *qiov; - int64_t pos; - bool is_read; - int ret; -} BdrvVmstateCo; - int coroutine_fn bdrv_co_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, bool is_read) @@ -2664,34 +2546,6 @@ bdrv_co_rw_vmstate(BlockDriverState *bs, QEMUIOVecto= r *qiov, int64_t pos, return ret; } =20 -static void coroutine_fn bdrv_co_rw_vmstate_entry(void *opaque) -{ - BdrvVmstateCo *co =3D opaque; - co->ret =3D bdrv_co_rw_vmstate(co->bs, co->qiov, co->pos, co->is_read); - aio_wait_kick(); -} - -int bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, - bool is_read) -{ - if (qemu_in_coroutine()) { - return bdrv_co_rw_vmstate(bs, qiov, pos, is_read); - } else { - BdrvVmstateCo data =3D { - .bs =3D bs, - .qiov =3D qiov, - .pos =3D pos, - .is_read =3D is_read, - .ret =3D -EINPROGRESS, - }; - Coroutine *co =3D qemu_coroutine_create(bdrv_co_rw_vmstate_entry, = &data); - - bdrv_coroutine_enter(bs, co); - BDRV_POLL_WHILE(bs, data.ret =3D=3D -EINPROGRESS); - return data.ret; - } -} - int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf, int64_t pos, int size) { @@ -2767,20 +2621,6 @@ void bdrv_aio_cancel_async(BlockAIOCB *acb) /**************************************************************/ /* Coroutine block device emulation */ =20 -typedef struct FlushCo { - BlockDriverState *bs; - int ret; -} FlushCo; - - -static void coroutine_fn bdrv_flush_co_entry(void *opaque) -{ - FlushCo *rwco =3D opaque; - - rwco->ret =3D bdrv_co_flush(rwco->bs); - aio_wait_kick(); -} - int coroutine_fn bdrv_co_flush(BlockDriverState *bs) { int current_gen; @@ -2893,40 +2733,6 @@ early_exit: return ret; } =20 -int bdrv_flush(BlockDriverState *bs) -{ - Coroutine *co; - FlushCo flush_co =3D { - .bs =3D bs, - .ret =3D NOT_DONE, - }; - - if (qemu_in_coroutine()) { - /* Fast-path if already in coroutine context */ - bdrv_flush_co_entry(&flush_co); - } else { - co =3D qemu_coroutine_create(bdrv_flush_co_entry, &flush_co); - bdrv_coroutine_enter(bs, co); - BDRV_POLL_WHILE(bs, flush_co.ret =3D=3D NOT_DONE); - } - - return flush_co.ret; -} - -typedef struct DiscardCo { - BdrvChild *child; - int64_t offset; - int64_t bytes; - int ret; -} DiscardCo; -static void coroutine_fn bdrv_pdiscard_co_entry(void *opaque) -{ - DiscardCo *rwco =3D opaque; - - rwco->ret =3D bdrv_co_pdiscard(rwco->child, rwco->offset, rwco->bytes); - aio_wait_kick(); -} - int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes) { @@ -3041,28 +2847,6 @@ out: return ret; } =20 -int bdrv_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes) -{ - Coroutine *co; - DiscardCo rwco =3D { - .child =3D child, - .offset =3D offset, - .bytes =3D bytes, - .ret =3D NOT_DONE, - }; - - if (qemu_in_coroutine()) { - /* Fast-path if already in coroutine context */ - bdrv_pdiscard_co_entry(&rwco); - } else { - co =3D qemu_coroutine_create(bdrv_pdiscard_co_entry, &rwco); - bdrv_coroutine_enter(child->bs, co); - BDRV_POLL_WHILE(child->bs, rwco.ret =3D=3D NOT_DONE); - } - - return rwco.ret; -} - int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf) { BlockDriver *drv =3D bs->drv; @@ -3460,47 +3244,3 @@ out: =20 return ret; } - -typedef struct TruncateCo { - BdrvChild *child; - int64_t offset; - bool exact; - PreallocMode prealloc; - BdrvRequestFlags flags; - Error **errp; - int ret; -} TruncateCo; - -static void coroutine_fn bdrv_truncate_co_entry(void *opaque) -{ - TruncateCo *tco =3D opaque; - tco->ret =3D bdrv_co_truncate(tco->child, tco->offset, tco->exact, - tco->prealloc, tco->flags, tco->errp); - aio_wait_kick(); -} - -int bdrv_truncate(BdrvChild *child, int64_t offset, bool exact, - PreallocMode prealloc, BdrvRequestFlags flags, Error **e= rrp) -{ - Coroutine *co; - TruncateCo tco =3D { - .child =3D child, - .offset =3D offset, - .exact =3D exact, - .prealloc =3D prealloc, - .flags =3D flags, - .errp =3D errp, - .ret =3D NOT_DONE, - }; - - if (qemu_in_coroutine()) { - /* Fast-path if already in coroutine context */ - bdrv_truncate_co_entry(&tco); - } else { - co =3D qemu_coroutine_create(bdrv_truncate_co_entry, &tco); - bdrv_coroutine_enter(child->bs, co); - BDRV_POLL_WHILE(child->bs, tco.ret =3D=3D NOT_DONE); - } - - return tco.ret; -} --=20 2.21.0