Blame SOURCES/kvm-block-mirror-honor-ratelimit-again.patch

357786
From 294916c8fdc6fdd221543c70b716e31591315379 Mon Sep 17 00:00:00 2001
357786
From: Max Reitz <mreitz@redhat.com>
357786
Date: Mon, 18 Jun 2018 14:47:34 +0200
357786
Subject: [PATCH 24/54] block/mirror: honor ratelimit again
357786
357786
RH-Author: Max Reitz <mreitz@redhat.com>
357786
Message-id: <20180618144736.29873-2-mreitz@redhat.com>
357786
Patchwork-id: 80747
357786
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 1/3] block/mirror: honor ratelimit again
357786
Bugzilla: 1572856
357786
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
357786
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
357786
RH-Acked-by: John Snow <jsnow@redhat.com>
357786
357786
From: Stefan Hajnoczi <stefanha@redhat.com>
357786
357786
Commit b76e4458b1eb3c32e9824fe6aa51f67d2b251748 ("block/mirror: change
357786
the semantic of 'force' of block-job-cancel") accidentally removed the
357786
ratelimit in the mirror job.
357786
357786
Reintroduce the ratelimit but keep the block-job-cancel force=true
357786
behavior that was added in commit
357786
b76e4458b1eb3c32e9824fe6aa51f67d2b251748.
357786
357786
Note that block_job_sleep_ns() returns immediately when the job is
357786
cancelled.  Therefore it's safe to unconditionally call
357786
block_job_sleep_ns() - a cancelled job does not sleep.
357786
357786
This commit fixes the non-deterministic qemu-iotests 185 output.  The
357786
test relies on the ratelimit to make the job sleep until the 'quit'
357786
command is processed.  Previously the job could complete before the
357786
'quit' command was received since there was no ratelimit.
357786
357786
Cc: Liang Li <liliang.opensource@gmail.com>
357786
Cc: Jeff Cody <jcody@redhat.com>
357786
Cc: Kevin Wolf <kwolf@redhat.com>
357786
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
357786
Message-id: 20180424123527.19168-1-stefanha@redhat.com
357786
Signed-off-by: Jeff Cody <jcody@redhat.com>
357786
(cherry picked from commit ddc4115efdfa6619689fe18871aa2d37890b3463)
357786
Signed-off-by: Max Reitz <mreitz@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 block/mirror.c             | 8 +++++---
357786
 tests/qemu-iotests/185.out | 2 +-
357786
 2 files changed, 6 insertions(+), 4 deletions(-)
357786
357786
diff --git a/block/mirror.c b/block/mirror.c
357786
index 820f512..9436a8d 100644
357786
--- a/block/mirror.c
357786
+++ b/block/mirror.c
357786
@@ -868,12 +868,14 @@ static void coroutine_fn mirror_run(void *opaque)
357786
         }
357786
 
357786
         ret = 0;
357786
+
357786
+        if (s->synced && !should_complete) {
357786
+            delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0);
357786
+        }
357786
         trace_mirror_before_sleep(s, cnt, s->synced, delay_ns);
357786
+        block_job_sleep_ns(&s->common, delay_ns);
357786
         if (block_job_is_cancelled(&s->common) && s->common.force) {
357786
             break;
357786
-        } else if (!should_complete) {
357786
-            delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0);
357786
-            block_job_sleep_ns(&s->common, delay_ns);
357786
         }
357786
         s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
357786
     }
357786
diff --git a/tests/qemu-iotests/185.out b/tests/qemu-iotests/185.out
357786
index 2c4b04d..992162f 100644
357786
--- a/tests/qemu-iotests/185.out
357786
+++ b/tests/qemu-iotests/185.out
357786
@@ -36,9 +36,9 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q
357786
 {"return": {}}
357786
 Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16
357786
 {"return": {}}
357786
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}}
357786
 {"return": {}}
357786
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
357786
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}}
357786
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}}
357786
 
357786
 === Start backup job and exit qemu ===
357786
-- 
357786
1.8.3.1
357786