[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 7/8] block: bdrv_create is never called in coroutine context
From: |
Emanuele Giuseppe Esposito |
Subject: |
[PATCH v3 7/8] block: bdrv_create is never called in coroutine context |
Date: |
Wed, 16 Nov 2022 03:50:49 -0500 |
Delete the if case and make sure it won't be called again
in coroutines.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
block.c | 37 ++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/block.c b/block.c
index dcac28756c..7a4ce7948c 100644
--- a/block.c
+++ b/block.c
@@ -563,30 +563,25 @@ static void coroutine_fn bdrv_create_co_entry(void
*opaque)
int bdrv_create(BlockDriver *drv, const char* filename,
QemuOpts *opts, Error **errp)
{
+ Coroutine *co;
+ CreateCo cco = {
+ .drv = drv,
+ .filename = g_strdup(filename),
+ .opts = opts,
+ .ret = NOT_DONE,
+ .err = NULL,
+ };
GLOBAL_STATE_CODE();
+ assert(!qemu_in_coroutine());
- if (qemu_in_coroutine()) {
- /* Fast-path if already in coroutine context */
- return bdrv_co_create(drv, filename, opts, errp);
- } else {
- Coroutine *co;
- CreateCo cco = {
- .drv = drv,
- .filename = g_strdup(filename),
- .opts = opts,
- .ret = NOT_DONE,
- .err = NULL,
- };
-
- co = qemu_coroutine_create(bdrv_create_co_entry, &cco);
- qemu_coroutine_enter(co);
- while (cco.ret == NOT_DONE) {
- aio_poll(qemu_get_aio_context(), true);
- }
- error_propagate(errp, cco.err);
- g_free(cco.filename);
- return cco.ret;
+ co = qemu_coroutine_create(bdrv_create_co_entry, &cco);
+ qemu_coroutine_enter(co);
+ while (cco.ret == NOT_DONE) {
+ aio_poll(qemu_get_aio_context(), true);
}
+ error_propagate(errp, cco.err);
+ g_free(cco.filename);
+ return cco.ret;
}
/**
--
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, 2022/11/16
- [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 <=
- Re: [PATCH v3 0/8] Still more coroutine and various fixes in block layer, Emanuele Giuseppe Esposito, 2022/11/16