On 29/11/18 11:42, Kevin Wolf wrote: > I guess in this specific instance we can just remove the locking from > mirror_read/write_complete becasue it's only locking an AioContext whose > lock we already hold anyway because we're in a Coroutine owned by the > AioContext, so yielding will release the lock and avoid the deadlock. > > But more generally, does this mean that it is never correct to have an > explicit aio_context_acquire/release() pair in coroutine context, at > least for all practical cases where you call things that could yield?
Yes. In fact, I remember asking Max to drop aio_context_acquire/release from mirror.c when he converted it to coroutines, but that must have fallen through the cracks. > And if you're inside a coroutine and want to access something in a > different AioContext, you need to drop out of the coroutine first? > If so, should aio_context_acquire() then assert that it's not called > from coroutine context? I'm not sure about that; there could be legitimate case in which the main thread acquires another context's lock. > Paolo, will this restriction of coroutines be solved for good when you > get your patches merged that remove the AioContext lock? Yes. Paolo