From patchwork Mon Jul 23 20:17:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EW234pbT"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDYM5BnKz9ryn for ; Tue, 24 Jul 2018 07:05:58 +1000 (AEST) Received: from localhost ([::1]:36621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi1i-0001bi-64 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:05:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJk-0002wf-D7 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJi-0004ix-Kc for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:28 -0400 Received: from mail-oi0-x22d.google.com ([2607:f8b0:4003:c06::22d]:33578) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJi-0004id-9R; Mon, 23 Jul 2018 16:20:26 -0400 Received: by mail-oi0-x22d.google.com with SMTP id l10-v6so3502204oii.0; Mon, 23 Jul 2018 13:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=2NCI05YrlmA0ejKuml36wSlszTeWhz3k1PhwBumEZuI=; b=EW234pbTvBmSKMMoorCLyQovnVr/cm5d+yu6RRA2vCIGOIeRF2Lg9kxxpOO+MLtkt8 gKs1a++cUsx3wWByAK41KhhVTwB1vQZezY/+oqhwxGy8TxPGD/x2Px0flfRQOg0Amr5g HxvtBuz3z/mcR4iRsDC7sphz08AsCv4qFdFDxPrUDsL8Xcr6OXlNM2+6aYMFqMM5Po2P PkaUI0MOPSY3PYXBOrueU8P3Hb9LVk6AjEnGSWeInaKXsyzdTnOWCt5AE2lhfWH6VKDW HztC6Y81ofafjA4dt1scGm4aJkKv7ensTIiIrhU6oTMFirHcAs7hCHkcdHcSUqeFauYa 3ZPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=2NCI05YrlmA0ejKuml36wSlszTeWhz3k1PhwBumEZuI=; b=qLJAggoV0JKhpEfTw2Bn+4xBe9D05Zdvs3F9A59WN0lLC0i/j2+UfbHFJuMIKRzXFg YG+rjWOq0Wz7DnyvCC0Q3UUqU3D1KFQdb1YzNjr1bH38fRZm/6gx7uIIr6pwVaAbEtGX RzNiaLNS6ldCFQXIsN/z79FyZWJyq41j6X1knSg1mopB5gbrg5EytKBcnHbLw9OyaD3/ Xe5Jd04cBoEAi0SnRGkE43vOB10xbwx7m9flOU3jxujGhrvxjH6nJ7yMVYBUA2+gdE52 sFV1AOf6uDD/fFR2/PmVguUAjUma6UdrgqsZ422v51IhBJcKtwNHVEb1FPjdelZaMaDp +PTA== X-Gm-Message-State: AOUpUlEo5+DrUOGIwjEks1CklI4ZL9BjzVVjKY70Y/Z/0+7bD9I4mH2s 5lwxkcGTb3DE+jjX2kXVhWEUYDzZ7Po= X-Google-Smtp-Source: AAOMgpe3+51AzWCwQn9MNXJ8qavCJw/zVe6kOd2antnT8dJkVwpEJpSPrcZnW2HglxQ02mDC1EaX+Q== X-Received: by 2002:aca:d5d3:: with SMTP id m202-v6mr283303oig.93.1532377225098; Mon, 23 Jul 2018 13:20:25 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id u18-v6sm6620552oiv.10.2018.07.23.13.20.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:24 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:02 -0500 Message-Id: <20180723201748.25573-54-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22d Subject: [Qemu-devel] [PATCH 53/99] block/mirror: honor ratelimit again 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: Kevin Wolf , Liang Li , qemu-stable@nongnu.org, Stefan Hajnoczi , Jeff Cody Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi Commit b76e4458b1eb3c32e9824fe6aa51f67d2b251748 ("block/mirror: change the semantic of 'force' of block-job-cancel") accidentally removed the ratelimit in the mirror job. Reintroduce the ratelimit but keep the block-job-cancel force=true behavior that was added in commit b76e4458b1eb3c32e9824fe6aa51f67d2b251748. Note that block_job_sleep_ns() returns immediately when the job is cancelled. Therefore it's safe to unconditionally call block_job_sleep_ns() - a cancelled job does not sleep. This commit fixes the non-deterministic qemu-iotests 185 output. The test relies on the ratelimit to make the job sleep until the 'quit' command is processed. Previously the job could complete before the 'quit' command was received since there was no ratelimit. Cc: Liang Li Cc: Jeff Cody Cc: Kevin Wolf Signed-off-by: Stefan Hajnoczi Message-id: 20180424123527.19168-1-stefanha@redhat.com Signed-off-by: Jeff Cody (cherry picked from commit ddc4115efdfa6619689fe18871aa2d37890b3463) Signed-off-by: Michael Roth --- block/mirror.c | 8 +++++--- tests/qemu-iotests/185.out | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 820f512c7b..9436a8d5ee 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -868,12 +868,14 @@ static void coroutine_fn mirror_run(void *opaque) } ret = 0; + + if (s->synced && !should_complete) { + delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); + } trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); + block_job_sleep_ns(&s->common, delay_ns); if (block_job_is_cancelled(&s->common) && s->common.force) { break; - } else if (!should_complete) { - delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); - block_job_sleep_ns(&s->common, delay_ns); } s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); } diff --git a/tests/qemu-iotests/185.out b/tests/qemu-iotests/185.out index 2c4b04de73..992162f418 100644 --- a/tests/qemu-iotests/185.out +++ b/tests/qemu-iotests/185.out @@ -36,9 +36,9 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q {"return": {}} Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} === Start backup job and exit qemu ===