On Fri, 10/23 16:13, Stefan Hajnoczi wrote: > On Fri, Oct 23, 2015 at 11:08:09AM +0800, Fam Zheng wrote: > > +void bdrv_drained_begin(BlockDriverState *bs) > > +{ > > + if (!bs->quiesce_counter++) { > > + aio_disable_external(bdrv_get_aio_context(bs)); > > + } > > + bdrv_drain(bs); > > +} > > + > > +void bdrv_drained_end(BlockDriverState *bs) > > +{ > > + assert(bs->quiesce_counter > 0); > > + if (--bs->quiesce_counter > 0) { > > + return; > > + } > > + aio_enable_external(bdrv_get_aio_context(bs)); > > +} > > Why is quiesce_counter necessary? Can't we just rely on AioContext's > disable_external_cnt?
It was added because bdrv_drain was conditional in a previous version, so yes it can now be dropped, but we lose the explcitness of the assertion in bdrv_drained_end. I was thinking that more "assert(!bs->quiesce_counter)" can be useful in blk_aio_read/write etc.. Fam