On 11/12/18 17:43, Vladimir Sementsov-Ogievskiy wrote: > + ThreadPool *pool = aio_get_thread_pool(bdrv_get_aio_context(bs)); > + > + while (s->nb_threads >= QCOW2_MAX_THREADS) { > + qemu_co_queue_wait(&s->thread_task_queue, NULL); > + } > + > + s->nb_threads++; > + ret = thread_pool_submit_co(pool, func, arg); > + s->nb_threads--; > + > + qemu_co_queue_next(&s->thread_task_queue);
What lock is protecting this manipulation? I'd rather avoid adding more users of the AioContext lock, especially manipulation of CoQueues. One possibility is to do the s->lock unlock/lock here, and then also rely on that in patch 8. Paolo