On 16/10/2016 18:40, Stefan Hajnoczi wrote: > > void bdrv_wakeup(BlockDriverState *bs) > > { > > + if (bs->wakeup) { > > + aio_bh_schedule_oneshot(qemu_get_aio_context(), dummy_bh_cb, NULL); > > + } > > } > > Why use a dummy BH instead of aio_notify()?
Originally I used aio_bh_schedule_oneshot() because aio_notify() is not enough for aio_poll() to return true. It's also true that I am not using anymore the result of aio_poll, though. Since this is not a fast path and it's not very much stressed by qemu-iotests, I think it's better if we can move towards making aio_notify() more or less an internal detail. If you prefer aio_notify(), however, I can look into that as well. Thanks, Paolo >> > void bdrv_dec_in_flight(BlockDriverState *bs) >> > diff --git a/include/block/block.h b/include/block/block.h >> > index ba4318b..72d5d8e 100644 >> > --- a/include/block/block.h >> > +++ b/include/block/block.h >> > @@ -343,9 +343,27 @@ void bdrv_drain_all(void); >> > #define bdrv_poll_while(bs, cond) ({ \ >> > bool waited_ = false; \ >> > BlockDriverState *bs_ = (bs); \ >> > - while ((cond)) { \ >> > - aio_poll(bdrv_get_aio_context(bs_), true); \ >> > - waited_ = true; \ >> > + AioContext *ctx_ = bdrv_get_aio_context(bs_); \ >> > + if (aio_context_in_iothread(ctx_)) { \ >> > + while ((cond)) { \ >> > + aio_poll(ctx_, true); \ >> > + waited_ = true; \ >> > + } \ >> > + } else { \ >> > + assert(qemu_get_current_aio_context() == \ >> > + qemu_get_aio_context()); \ > The assumption is that IOThread #1 will never call bdrv_poll_while() on > IOThread #2's AioContext. I believe that is true today. Is this what > you had in mind? > > Please add a comment since it's not completely obvious from the assert > expression. >