From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHr5J-0003wp-Qe for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:21:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHr5F-0002LI-Gy for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:21:41 -0400 References: <1466598927-5990-1-git-send-email-den@openvz.org> From: "Denis V. Lunev" Message-ID: <57725DBA.3080203@openvz.org> Date: Tue, 28 Jun 2016 14:21:30 +0300 MIME-Version: 1.0 In-Reply-To: <1466598927-5990-1-git-send-email-den@openvz.org> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit 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: qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: Jeff Cody , Kevin Wolf , Max Reitz On 06/22/2016 03:35 PM, 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 == MAX_IN_FLIGHT is wrong. > > The patch adds the check and throttling into mirror_iteration and fixes > the check in mirror_run() to be sure. > > 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(-) > > 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(MirrorBlockJob *s) > } > } > > + while (s->in_flight >= 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 < SLICE_TIME && > s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) { > - if (s->in_flight == MAX_IN_FLIGHT || s->buf_free_count == 0 || > + if (s->in_flight >= MAX_IN_FLIGHT || s->buf_free_count == 0 || > (cnt == 0 && s->in_flight > 0)) { > trace_mirror_yield(s, s->in_flight, s->buf_free_count, cnt); > mirror_wait_for_io(s); ping