From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bII2U-0002FM-0F for qemu-devel@nongnu.org; Wed, 29 Jun 2016 12:08:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bII2R-00009s-Sb for qemu-devel@nongnu.org; Wed, 29 Jun 2016 12:08:32 -0400 References: <1466598927-5990-1-git-send-email-den@openvz.org> From: Max Reitz Message-ID: <0bb6c31a-0fb4-175c-fa90-3827e666f6b5@redhat.com> Date: Wed, 29 Jun 2016 18:08:22 +0200 MIME-Version: 1.0 In-Reply-To: <1466598927-5990-1-git-send-email-den@openvz.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="7UFpra66pKIsVtGwWklpN9j73mWp00oOw" Subject: Re: [Qemu-devel] [PATCH 1/1] mirror: fix request throttling in drive-mirror List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" , qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: Jeff Cody , Kevin Wolf This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --7UFpra66pKIsVtGwWklpN9j73mWp00oOw From: Max Reitz To: "Denis V. Lunev" , qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: Jeff Cody , Kevin Wolf Message-ID: <0bb6c31a-0fb4-175c-fa90-3827e666f6b5@redhat.com> Subject: Re: [PATCH 1/1] mirror: fix request throttling in drive-mirror References: <1466598927-5990-1-git-send-email-den@openvz.org> In-Reply-To: <1466598927-5990-1-git-send-email-den@openvz.org> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 22.06.2016 14:35, Denis V. Lunev wrote: > There are 2 deficiencies here: > - mirror_iteration could start several requests inside. Thus we could > simply have more in_flight requests than MAX_IN_FLIGHT. > - keeping this in mind throttling in mirror_run which is checking > s->in_flight =3D=3D MAX_IN_FLIGHT is wrong. >=20 > The patch adds the check and throttling into mirror_iteration and fixes= > the check in mirror_run() to be sure. >=20 > Signed-off-by: Denis V. Lunev > CC: Jeff Cody > CC: Kevin Wolf > CC: Max Reitz > --- > block/mirror.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) >=20 > diff --git a/block/mirror.c b/block/mirror.c > index a04ed9c..e881ef6 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -399,6 +399,11 @@ static uint64_t coroutine_fn mirror_iteration(Mirr= orBlockJob *s) > } > } > =20 > + while (s->in_flight >=3D MAX_IN_FLIGHT) { > + trace_mirror_yield_in_flight(s, sector_num, s->in_flight);= > + mirror_wait_for_io(s); > + } > + > mirror_clip_sectors(s, sector_num, &io_sectors); > switch (mirror_method) { > case MIRROR_METHOD_COPY: > @@ -634,7 +639,7 @@ static void coroutine_fn mirror_run(void *opaque) > */ > if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - last_pause_ns < S= LICE_TIME && > s->common.iostatus =3D=3D BLOCK_DEVICE_IO_STATUS_OK) { > - if (s->in_flight =3D=3D MAX_IN_FLIGHT || s->buf_free_count= =3D=3D 0 || > + if (s->in_flight >=3D MAX_IN_FLIGHT || s->buf_free_count =3D= =3D 0 || > (cnt =3D=3D 0 && s->in_flight > 0)) { > trace_mirror_yield(s, s->in_flight, s->buf_free_count,= cnt); > mirror_wait_for_io(s); >=20 Using >=3D seems fine to me, but with the first hunk applied I can't imagine how s->in_flight should grow beyond MAX_IN_FLIGHT. Don't get me wrong, I myself like to use >=3D even where the > case should never happen, I'm just wondering if I'm missing something here. Reviewed-by: Max Reitz --7UFpra66pKIsVtGwWklpN9j73mWp00oOw 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 iQEvBAEBCAAZBQJXc/J2EhxtcmVpdHpAcmVkaGF0LmNvbQAKCRA7sUIC6DisrcBH CACi1RxMFRh7n2AP45m44NWekV36dOtFjOOyGf2U1pcpc7TgZJTn4NZtV5X0ga37 X6nbhYWl8Ai7sShERfKvi23JAQr8OnMtD9LFEa+2O7HAN1ewy8ztUiGttMi+wO/C NaWIJmWQ4a+TWZxuHLChl/a3fl7HcNTSe/3hQ5CXDoKjCneaGsmVbpIuaWqY12Ws 7NyTkbB6WkNFLiGFArhyzV+JKo/EFCm4sTNC60HUmgmqZlS87ejq/XBlCIl3uRUg miJu6glCiw/e7rw9Jzqdkbxz/x+LlYNojTJln8+LjXX/ypkBJXA+StucFkKJAraJ Nh7TWCHz8MKVujIahwrRUOIl =I5aV -----END PGP SIGNATURE----- --7UFpra66pKIsVtGwWklpN9j73mWp00oOw--