From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqWhj-0005uF-Fp for qemu-devel@nongnu.org; Sun, 25 Oct 2015 21:36:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZqWhi-0000pS-KF for qemu-devel@nongnu.org; Sun, 25 Oct 2015 21:36:07 -0400 Date: Mon, 26 Oct 2015 09:35:56 +0800 From: Fam Zheng Message-ID: <20151026013556.GB28904@ad.usersys.redhat.com> References: <1445569694-2765-1-git-send-email-famz@redhat.com> <1445569694-2765-6-git-send-email-famz@redhat.com> <20151023151341.GE5977@stefanha-x1.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151023151341.GE5977@stefanha-x1.localdomain> Subject: Re: [Qemu-devel] [PATCH v7 05/10] block: Introduce "drained begin/end" API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, pbonzini@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org 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