From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avOMN-0005Da-9G for qemu-devel@nongnu.org; Wed, 27 Apr 2016 08:14:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avOMM-0006zZ-BZ for qemu-devel@nongnu.org; Wed, 27 Apr 2016 08:14:27 -0400 References: <41bbdd98675b93ff0d4b4e745d942cfd5c16aa1f.1459776815.git.berto@igalia.com> From: Max Reitz Message-ID: <5720AD1A.4020504@redhat.com> Date: Wed, 27 Apr 2016 14:14:18 +0200 MIME-Version: 1.0 In-Reply-To: <41bbdd98675b93ff0d4b4e745d942cfd5c16aa1f.1459776815.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="NIR4rO2WlfvWxSmW7iBr7uspdf7Gh6rRv" Subject: Re: [Qemu-devel] [PATCH v9 04/11] block: use the block job list in bdrv_close() 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) --NIR4rO2WlfvWxSmW7iBr7uspdf7Gh6rRv Content-Type: multipart/mixed; boundary="9S9thAOglTB3scoxquWxUjk4OU3LWGEDp" From: Max Reitz To: Alberto Garcia , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Eric Blake , Stefan Hajnoczi Message-ID: <5720AD1A.4020504@redhat.com> Subject: Re: [PATCH v9 04/11] block: use the block job list in bdrv_close() References: <41bbdd98675b93ff0d4b4e745d942cfd5c16aa1f.1459776815.git.berto@igalia.com> In-Reply-To: <41bbdd98675b93ff0d4b4e745d942cfd5c16aa1f.1459776815.git.berto@igalia.com> --9S9thAOglTB3scoxquWxUjk4OU3LWGEDp Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 04.04.2016 15:43, Alberto Garcia wrote: > bdrv_close_all() cancels all block jobs by iterating over all > BlockDriverStates. This patch simplifies the code by iterating > directly over the block jobs using block_job_next(). >=20 > Signed-off-by: Alberto Garcia > --- > block.c | 25 ++++++------------------- > 1 file changed, 6 insertions(+), 19 deletions(-) >=20 > diff --git a/block.c b/block.c > index d36eb75..48638c9 100644 > --- a/block.c > +++ b/block.c > @@ -2182,8 +2182,7 @@ static void bdrv_close(BlockDriverState *bs) > =20 > void bdrv_close_all(void) > { > - BlockDriverState *bs; > - AioContext *aio_context; > + BlockJob *job; > =20 > /* Drop references from requests still in flight, such as canceled= block > * jobs whose AIO context has not been polled yet */ > @@ -2193,23 +2192,11 @@ void bdrv_close_all(void) > blockdev_close_all_bdrv_states(); > =20 > /* Cancel all block jobs */ > - while (!QTAILQ_EMPTY(&all_bdrv_states)) { > - QTAILQ_FOREACH(bs, &all_bdrv_states, bs_list) { > - aio_context =3D bdrv_get_aio_context(bs); > - > - aio_context_acquire(aio_context); > - if (bs->job) { > - block_job_cancel_sync(bs->job); > - aio_context_release(aio_context); > - break; > - } > - aio_context_release(aio_context); > - } > - > - /* All the remaining BlockDriverStates are referenced directly= or > - * indirectly from block jobs, so there needs to be at least o= ne BDS > - * directly used by a block job */ > - assert(bs); > + while ((job =3D block_job_next(NULL))) { > + AioContext *aio_context =3D bdrv_get_aio_context(job->bs); > + aio_context_acquire(aio_context); > + block_job_cancel_sync(job); > + aio_context_release(aio_context); > } I'd like an assert(QTAILQ_EMPTY(&all_bdrv_states)) after this loop. This is basically what the "assert(bs);" was for in the old version. Apart from that, good patch. Max > } > =20 >=20 --9S9thAOglTB3scoxquWxUjk4OU3LWGEDp-- --NIR4rO2WlfvWxSmW7iBr7uspdf7Gh6rRv 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 iQEcBAEBCAAGBQJXIK0aAAoJEDuxQgLoOKytsq4H/1HnfRAtwHKiwFIYkyozoocv OFS1p0zaOLfLP35HE059HoCGx8jzOHjd+9EafwUzDOZQMuFQ0JTrSF5fF6Dooeud IL6RMi84FZ7Xaor9+hyS2spWOv88kJXr94jXISdcqpwFLhmH/LjT8xyulr8/Ywfd BpaNf6FRHIS/eafDUp96VrsO33PMAeUot/rhwVq2DTRl9x1a13Ov/lS+t6UBC9Rs AKR3Xt5q1iv1jy/j12gXFkhuiLjiiKsJLAlNWQZLDJq7xJ/AUgjvFG2aSZnCB92h A7gHMWJKOMZw6U6Uw7pev+H/NDyD9736AKTFrwsHgBkvPV2IV2mcPODG4YfoXdU= =Fv65 -----END PGP SIGNATURE----- --NIR4rO2WlfvWxSmW7iBr7uspdf7Gh6rRv--