[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 05/11] block-coroutine-wrapper.py: default to main loop ai
From: |
Kevin Wolf |
Subject: |
Re: [PATCH v4 05/11] block-coroutine-wrapper.py: default to main loop aiocontext if function does not have a BlockDriverState parameter |
Date: |
Tue, 22 Nov 2022 09:27:18 +0100 |
Am 21.11.2022 um 16:52 hat Emanuele Giuseppe Esposito geschrieben:
> Am 21/11/2022 um 16:30 schrieb Kevin Wolf:
> > Am 16.11.2022 um 13:22 hat Emanuele Giuseppe Esposito geschrieben:
> >> Basically BdrvPollCo->bs is only used by bdrv_poll_co(), and the
> >> functions that it uses are both using bdrv_get_aio_context, that
> >> defaults to qemu_get_aio_context() if bs is NULL.
> >>
> >> Therefore pass NULL to BdrvPollCo to automatically generate a function
> >> that create and runs a coroutine in the main loop.
> >>
> >> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> >
> > It happens to work, but it's kind of ugly to call bdrv_coroutine_enter()
> > and BDRV_POLL_WHILE() with a NULL bs.
> >
> > How hard would it be to generate code that doesn't use these functions,
> > but directly aio_co_enter() and AIO_WAIT_WHILE() for wrappers that are
> > not related to a BDS?
> >
>
> At this point, I would get rid of s->poll_state.bs and instead use
> s->poll_state.aio_context. Then call directly aio_co_enter and
> AIO_WAIT_WHILE, as you suggested but just everywhere, without
> differentiating the cases.
Oh, yes, that's better.
> Then we would have something similar to what it is currently done with bs:
>
> if t == 'BlockDriverState *':
> bs = 'bdrv_get_aio_context(bs)'
> elif t == 'BdrvChild *':
> bs = 'bdrv_get_aio_context(child->bs)'
> elif t == 'BlockBackend *':
> bs = 'bdrv_get_aio_context(blk_bs(blk))'
blk_get_aio_context(blk) seems more correct.
> else:
> bs = 'qemu_get_aio_context()'
>
> I haven't tried it yet, but it should work.
Kevin
- Re: [PATCH v4 08/11] block: distinguish between bdrv_create running in coroutine and not, (continued)
[PATCH v4 05/11] block-coroutine-wrapper.py: default to main loop aiocontext if function does not have a BlockDriverState parameter, Emanuele Giuseppe Esposito, 2022/11/16
[PATCH v4 11/11] block/dirty-bitmap: convert coroutine-only functions to generated_co_wrapper_simple, Emanuele Giuseppe Esposito, 2022/11/16
[PATCH v4 06/11] block-coroutine-wrapper.py: support also basic return types, Emanuele Giuseppe Esposito, 2022/11/16
[PATCH v4 03/11] block-backend: replace bdrv_*_above with blk_*_above, Emanuele Giuseppe Esposito, 2022/11/16
[PATCH v4 04/11] block-coroutine-wrapper.py: introduce generated_co_wrapper_simple, Emanuele Giuseppe Esposito, 2022/11/16
[PATCH v4 09/11] block: bdrv_create_file is a coroutine_fn, Emanuele Giuseppe Esposito, 2022/11/16