From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avOCx-0000r2-Kb for qemu-devel@nongnu.org; Wed, 27 Apr 2016 08:04:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avOCw-00045X-MK for qemu-devel@nongnu.org; Wed, 27 Apr 2016 08:04:43 -0400 References: From: Max Reitz Message-ID: <5720AAD1.9010607@redhat.com> Date: Wed, 27 Apr 2016 14:04:33 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="840Jmxic6gQuc0mxV4NDWtqbo9fwQfmLe" Subject: Re: [Qemu-devel] [PATCH v9 02/11] block: use the block job list in bdrv_drain_all() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alberto Garcia , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Eric Blake , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --840Jmxic6gQuc0mxV4NDWtqbo9fwQfmLe Content-Type: multipart/mixed; boundary="oQaXlfvi6GIsHXxgXDN6XibpuOH21PrG5" From: Max Reitz To: Alberto Garcia , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Eric Blake , Stefan Hajnoczi Message-ID: <5720AAD1.9010607@redhat.com> Subject: Re: [PATCH v9 02/11] block: use the block job list in bdrv_drain_all() References: In-Reply-To: --oQaXlfvi6GIsHXxgXDN6XibpuOH21PrG5 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 04.04.2016 15:43, Alberto Garcia wrote: > bdrv_drain_all() pauses all block jobs by using bdrv_next() to iterate > over all top-level BlockDriverStates. Therefore the code is unable to > find block jobs in other nodes. >=20 > This patch uses block_job_next() to iterate over all block jobs. >=20 > Signed-off-by: Alberto Garcia > --- > block/io.c | 21 ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) >=20 > diff --git a/block/io.c b/block/io.c > index c4869b9..884ed1e 100644 > --- a/block/io.c > +++ b/block/io.c > @@ -288,15 +288,21 @@ void bdrv_drain_all(void) > /* Always run first iteration so any pending completion BHs run */= > bool busy =3D true; > BlockDriverState *bs =3D NULL; > + BlockJob *job =3D NULL; > GSList *aio_ctxs =3D NULL, *ctx; > =20 > + while ((job =3D block_job_next(job))) { > + AioContext *aio_context =3D bdrv_get_aio_context(job->bs); > + > + aio_context_acquire(aio_context); > + block_job_pause(job); > + aio_context_release(aio_context); > + } > + > while ((bs =3D bdrv_next(bs))) { > AioContext *aio_context =3D bdrv_get_aio_context(bs); > =20 > aio_context_acquire(aio_context); > - if (bs->job) { > - block_job_pause(bs->job); > - } > bdrv_drain_recurse(bs); > aio_context_release(aio_context); > =20 > @@ -333,14 +339,11 @@ void bdrv_drain_all(void) > } > } > =20 > - bs =3D NULL; > - while ((bs =3D bdrv_next(bs))) { > - AioContext *aio_context =3D bdrv_get_aio_context(bs); > + while ((job =3D block_job_next(job))) { > + AioContext *aio_context =3D bdrv_get_aio_context(job->bs); Technically, the "bs =3D NULL;" before didn't do anything either. But in my opinion, it made the code more readable, therefore I'd really like a "job =3D NULL;" before this loop, too. But it's correct as it is, so: Reviewed-by: Max Reitz > =20 > aio_context_acquire(aio_context); > - if (bs->job) { > - block_job_resume(bs->job); > - } > + block_job_resume(job); > aio_context_release(aio_context); > } > g_slist_free(aio_ctxs); >=20 --oQaXlfvi6GIsHXxgXDN6XibpuOH21PrG5-- --840Jmxic6gQuc0mxV4NDWtqbo9fwQfmLe Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJXIKrRAAoJEDuxQgLoOKytpRMH/jlrLA5vGgiWT/4WZDf9fJpw SOKOf0ENBhdpCHqLK2WnqOJwm3oyKLURf6E3B5mpVzZpqE1xF7YXnAl1wWxA1/NH /dHs4X/kFYEagQk9sbmCCTzHezXh/8CphHPZj4tANGcb8mUoe7NLxOdXhnkOCYHo kt8xOvGAH5mMcsjYsX7oGnGnVvJi00Q0igwWIltJnOZRzlbH6bUmOo7s3UU2WLfa wq3g/jU3kuEqXqUpEQ0NDUiZjjLFaHj+e0GgryCt2OT5FaL1t7/GzNo0f2WBnSx/ dP5CYNLr1F0ikkeSI+qmByrPw6OoDi4UQWhR7Pmx9Lh4g+FzIBgDEAAdRFuXmmo= =zkUG -----END PGP SIGNATURE----- --840Jmxic6gQuc0mxV4NDWtqbo9fwQfmLe--