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? void bdrv_drained_begin(BlockDriverState *bs) { aio_disable_external(bdrv_get_aio_context(bs)); bdrv_drain(bs); } void bdrv_drained_end(BlockDriverState *bs) { aio_enable_external(bdrv_get_aio_context(bs)); }