From patchwork Wed Jul 20 00:20:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 9238589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 101BC6075D for ; Wed, 20 Jul 2016 00:33:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F29191FF15 for ; Wed, 20 Jul 2016 00:33:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E643B26B4A; Wed, 20 Jul 2016 00:33:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 22BAC1FF15 for ; Wed, 20 Jul 2016 00:33:12 +0000 (UTC) Received: from localhost ([::1]:59754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPfRm-0007vn-RF for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Jul 2016 20:33:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPfGQ-0000Rl-7y for qemu-devel@nongnu.org; Tue, 19 Jul 2016 20:21:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPfGP-0000sG-3c for qemu-devel@nongnu.org; Tue, 19 Jul 2016 20:21:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56655) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPfGM-0000qv-KV; Tue, 19 Jul 2016 20:21:22 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4510A63E3A; Wed, 20 Jul 2016 00:21:22 +0000 (UTC) Received: from localhost (ovpn-112-23.phx2.redhat.com [10.3.112.23]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6K0LK5F022517 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Tue, 19 Jul 2016 20:21:21 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 19 Jul 2016 20:20:57 -0400 Message-Id: <1468974062-7726-10-git-send-email-jcody@redhat.com> In-Reply-To: <1468974062-7726-1-git-send-email-jcody@redhat.com> References: <1468974062-7726-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 20 Jul 2016 00:21:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/14] mirror: fix request throttling in drive-mirror X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Denis V. Lunev" 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 Reviewed-by: Max Reitz Message-id: 1466598927-5990-1-git-send-email-den@openvz.org CC: Jeff Cody CC: Kevin Wolf CC: Max Reitz Signed-off-by: Jeff Cody (cherry picked from commit e648dc95c28fbca12e67be26a1fc4b9a0676c3fe) --- block/mirror.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index f78186d..836a5d0 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -407,6 +407,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: @@ -695,7 +700,7 @@ static void coroutine_fn mirror_run(void *opaque) delta = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->last_pause_ns; if (delta < 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);