From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XZPNf-0007bh-11 for qemu-devel@nongnu.org; Wed, 01 Oct 2014 15:16:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XZPNY-0006Ql-T8 for qemu-devel@nongnu.org; Wed, 01 Oct 2014 15:16:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5103) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XZPNY-0006QX-MA for qemu-devel@nongnu.org; Wed, 01 Oct 2014 15:16:00 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s91JFx6H012153 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 1 Oct 2014 15:15:59 -0400 Message-ID: <542C52EB.3080909@redhat.com> Date: Wed, 01 Oct 2014 21:15:55 +0200 From: Max Reitz MIME-Version: 1.0 References: <1412182919-9550-1-git-send-email-stefanha@redhat.com> <1412182919-9550-7-git-send-email-stefanha@redhat.com> In-Reply-To: <1412182919-9550-7-git-send-email-stefanha@redhat.com> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 06/11] block: add bdrv_drain() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , Fam Zheng On 01.10.2014 19:01, Stefan Hajnoczi wrote: > Now that op blockers are in use, we can ensure that no other sources are > generating I/O on a BlockDriverState. Therefore it is possible to drain > requests for a single BDS. > > Signed-off-by: Stefan Hajnoczi > --- > block.c | 36 +++++++++++++++++++++++++++++------- > include/block/block.h | 1 + > 2 files changed, 30 insertions(+), 7 deletions(-) > > diff --git a/block.c b/block.c > index c5a251c..48305c4 100644 > --- a/block.c > +++ b/block.c > @@ -1918,6 +1918,34 @@ static bool bdrv_requests_pending(BlockDriverState *bs) > return false; > } > > +static bool bdrv_drain_one(BlockDriverState *bs) > +{ > + bool bs_busy; > + > + bdrv_flush_io_queue(bs); > + bdrv_start_throttled_reqs(bs); > + bs_busy = bdrv_requests_pending(bs); > + bs_busy |= aio_poll(bdrv_get_aio_context(bs), bs_busy); > + return bs_busy; > +} > + > +/* > + * Wait for pending requests to complete on a single BlockDriverState subtree > + * > + * See the warning in bdrv_drain_all(). This function can only be called if > + * you are sure nothing can generate I/O because you have op blockers > + * installed. Although that warning now sounds too harsh: "it is not possible to have a function to drain a single device's I/O queue." Apparently, under certain circumstances, it now *is* possible. ;-) Reviewed-by: Max Reitz