[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 8/8] block/dirty-bitmap: remove unnecessary qemu_in_coroutine(
From: |
Emanuele Giuseppe Esposito |
Subject: |
[PATCH v3 8/8] block/dirty-bitmap: remove unnecessary qemu_in_coroutine() case |
Date: |
Wed, 16 Nov 2022 03:50:50 -0500 |
Some functions check if they are running in a coroutine, calling
the coroutine callback directly if it's the case.
Except that no coroutine calls such functions, therefore that case
can be removed.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
block/dirty-bitmap.c | 66 +++++++++++++++++++-------------------------
1 file changed, 29 insertions(+), 37 deletions(-)
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index bf3dc0512a..8092d08261 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -418,24 +418,20 @@ bdrv_co_remove_persistent_dirty_bitmap_entry(void *opaque)
int bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name,
Error **errp)
{
- if (qemu_in_coroutine()) {
- return bdrv_co_remove_persistent_dirty_bitmap(bs, name, errp);
- } else {
- Coroutine *co;
- BdrvRemovePersistentDirtyBitmapCo s = {
- .bs = bs,
- .name = name,
- .errp = errp,
- .ret = -EINPROGRESS,
- };
-
- co =
qemu_coroutine_create(bdrv_co_remove_persistent_dirty_bitmap_entry,
- &s);
- bdrv_coroutine_enter(bs, co);
- BDRV_POLL_WHILE(bs, s.ret == -EINPROGRESS);
-
- return s.ret;
- }
+ Coroutine *co;
+ BdrvRemovePersistentDirtyBitmapCo s = {
+ .bs = bs,
+ .name = name,
+ .errp = errp,
+ .ret = -EINPROGRESS,
+ };
+ assert(!qemu_in_coroutine());
+ co = qemu_coroutine_create(bdrv_co_remove_persistent_dirty_bitmap_entry,
+ &s);
+ bdrv_coroutine_enter(bs, co);
+ BDRV_POLL_WHILE(bs, s.ret == -EINPROGRESS);
+
+ return s.ret;
}
bool
@@ -494,25 +490,21 @@ bool bdrv_can_store_new_dirty_bitmap(BlockDriverState
*bs, const char *name,
uint32_t granularity, Error **errp)
{
IO_CODE();
- if (qemu_in_coroutine()) {
- return bdrv_co_can_store_new_dirty_bitmap(bs, name, granularity, errp);
- } else {
- Coroutine *co;
- BdrvCanStoreNewDirtyBitmapCo s = {
- .bs = bs,
- .name = name,
- .granularity = granularity,
- .errp = errp,
- .in_progress = true,
- };
-
- co = qemu_coroutine_create(bdrv_co_can_store_new_dirty_bitmap_entry,
- &s);
- bdrv_coroutine_enter(bs, co);
- BDRV_POLL_WHILE(bs, s.in_progress);
-
- return s.ret;
- }
+ Coroutine *co;
+ BdrvCanStoreNewDirtyBitmapCo s = {
+ .bs = bs,
+ .name = name,
+ .granularity = granularity,
+ .errp = errp,
+ .in_progress = true,
+ };
+ assert(!qemu_in_coroutine());
+ co = qemu_coroutine_create(bdrv_co_can_store_new_dirty_bitmap_entry,
+ &s);
+ bdrv_coroutine_enter(bs, co);
+ BDRV_POLL_WHILE(bs, s.in_progress);
+
+ return s.ret;
}
void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
--
2.31.1
- [PATCH v3 0/8] Still more coroutine and various fixes in block layer, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH v3 3/8] block-backend: replace bdrv_*_above with blk_*_above, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH v3 5/8] block/vmdk: add missing coroutine_fn annotations, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH v3 6/8] block: bdrv_create_file is a coroutine_fn, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH v3 2/8] nbd/server.c: add missing coroutine_fn annotations, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH v3 8/8] block/dirty-bitmap: remove unnecessary qemu_in_coroutine() case,
Emanuele Giuseppe Esposito <=
- [PATCH v3 4/8] block: distinguish between bdrv_create running in coroutine and not, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH v3 1/8] block-copy: add missing coroutine_fn annotations, Emanuele Giuseppe Esposito, 2022/11/16
- [PATCH v3 7/8] block: bdrv_create is never called in coroutine context, Emanuele Giuseppe Esposito, 2022/11/16
- Re: [PATCH v3 0/8] Still more coroutine and various fixes in block layer, Emanuele Giuseppe Esposito, 2022/11/16