From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMfXn-0005cs-6I for qemu-devel@nongnu.org; Wed, 27 Aug 2014 11:54:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMfXe-0002cP-Q0 for qemu-devel@nongnu.org; Wed, 27 Aug 2014 11:53:55 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:58775) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMfXe-0002cA-M0 for qemu-devel@nongnu.org; Wed, 27 Aug 2014 11:53:46 -0400 Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Aug 2014 11:53:45 -0400 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <53F80DC4.7030102@gmail.com> References: <53F80DC4.7030102@gmail.com> Message-ID: <20140827155339.21832.73704@loki> Date: Wed, 27 Aug 2014 10:53:39 -0500 Subject: Re: [Qemu-devel] [Qemu-stable] [PATCH] stream: fix the deadlock bug when stream finish List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Yu , qemu-stable@nongnu.org Cc: qemu-devel@nongnu.org Quoting Liu Yu (2014-08-22 22:43:00) > From: Liu Yu > = > The patch against branch stable-2.0 Hi Liu, 2.0.2 was the last planned released for stable-2.0. Are you still seeing th= is issue with 2.1.0 or master? 2.1.1 is release is planned for September 9th s= o we can work on getting this included there if it is. Also, please Cc: qemu-devel@nongnu.org even for stable patches. > = > In case VM does IO while we run a stream job. > When stream finishes, the stream coroutine drains all IOs before > close the unused image, in bdrv_drain_all() it may find > a pending request which is submitted by guest IO coroutine. > In order to wait the pending req finish, the subsequent aio_poll() > call poll() to wait the req. however, if the req is already done by > threadpool and is waiting for the callback, there is no chance to switch > back to guest IO coroutine to call the callback and so that the stream > coroutine waits in poll() all the time. > = > The patch detects the deadlock case above and switch back to iothread > coroutine to handle the callback, and work on the stream coroutine > after the pending req get finished. > = > Signed-off-by: Liu Yu > --- > the issue can be reproduced by > 1. guest does fio test > 2. while host runs virsh blockpull repeatedly > = > = > block.c | 27 ++++++++++++++++++++++++++- > 1 files changed, 26 insertions(+), 1 deletions(-) > = > diff --git a/block.c b/block.c > index 990a754..f8c1a8d 100644 > --- a/block.c > +++ b/block.c > @@ -1778,6 +1778,29 @@ static bool bdrv_requests_pending_all(void) > return false; > } > = > +static bool bdrv_request_coroutine_wait(void) > +{ > + BlockDriverState *bs; > + Coroutine *co; > + > + if (!qemu_in_coroutine()) > + return false; > + > + co =3D qemu_coroutine_self(); > + QTAILQ_FOREACH(bs, &bdrv_states, device_list) { > + if (!QLIST_EMPTY(&bs->tracked_requests)) { > + BdrvTrackedRequest *req =3D QLIST_FIRST(&bs->tracked_request= s); > + > + if(req->co =3D=3D co) > + continue; > + > + qemu_co_queue_wait(&req->wait_queue); > + return true; > + } > + } > + return false; > +} > + > /* > * Wait for pending requests to complete across all BlockDriverStates > * > @@ -1800,8 +1823,10 @@ void bdrv_drain_all(void) > QTAILQ_FOREACH(bs, &bdrv_states, device_list) { > bdrv_start_throttled_reqs(bs); > } > - > +recheck: > busy =3D bdrv_requests_pending_all(); > + if (busy && bdrv_request_coroutine_wait()) > + goto recheck; > busy |=3D aio_poll(qemu_get_aio_context(), busy); > } > } > -- = > 1.7.1