|
|
ae23c9 |
From 84a7e1d25f5611e43e3781dda588b4306606c809 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Date: Tue, 26 Jun 2018 09:47:46 +0200
|
|
|
ae23c9 |
Subject: [PATCH 078/268] blockjob: do not cancel timer in resume
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180626094856.6924-4-kwolf@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 81089
|
|
|
ae23c9 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 03/73] blockjob: do not cancel timer in resume
|
|
|
ae23c9 |
Bugzilla: 1513543
|
|
|
ae23c9 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
From: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Currently the timer is cancelled and the block job is entered by
|
|
|
ae23c9 |
block_job_resume(). This behavior causes drain to run extra blockjob
|
|
|
ae23c9 |
iterations when the job was sleeping due to the ratelimit.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
This patch leaves the job asleep when block_job_resume() is called.
|
|
|
ae23c9 |
Jobs can still be forcibly woken up using block_job_enter(), which is
|
|
|
ae23c9 |
used to cancel jobs.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
After this patch drain no longer runs extra blockjob iterations. This
|
|
|
ae23c9 |
is the expected behavior that qemu-iotests 185 used to rely on. We
|
|
|
ae23c9 |
temporarily changed the 185 test output to make it pass for the QEMU
|
|
|
ae23c9 |
2.12 release but now it's time to address this issue.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Cc: QingFeng Hao <haoqf@linux.vnet.ibm.com>
|
|
|
ae23c9 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
ae23c9 |
Reviewed-by: QingFeng Hao <haoqf@linux.vnet.ibm.com>
|
|
|
ae23c9 |
Message-id: 20180508135436.30140-3-stefanha@redhat.com
|
|
|
ae23c9 |
Reviewed-by: Jeff Cody <jcody@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Jeff Cody <jcody@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit 4c7e813ce964e230bb55cf4afc862ccb091ca3a3)
|
|
|
ae23c9 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
blockjob.c | 22 +++++++++++++++-------
|
|
|
ae23c9 |
tests/qemu-iotests/185 | 5 +----
|
|
|
ae23c9 |
tests/qemu-iotests/185.out | 12 +++++-------
|
|
|
ae23c9 |
3 files changed, 21 insertions(+), 18 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/blockjob.c b/blockjob.c
|
|
|
ae23c9 |
index 27f957e..7064389 100644
|
|
|
ae23c9 |
--- a/blockjob.c
|
|
|
ae23c9 |
+++ b/blockjob.c
|
|
|
ae23c9 |
@@ -209,6 +209,18 @@ static void block_job_txn_del_job(BlockJob *job)
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+/* Assumes the block_job_mutex is held */
|
|
|
ae23c9 |
+static bool block_job_timer_pending(BlockJob *job)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ return timer_pending(&job->sleep_timer);
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+/* Assumes the block_job_mutex is held */
|
|
|
ae23c9 |
+static bool block_job_timer_not_pending(BlockJob *job)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ return !block_job_timer_pending(job);
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
static void block_job_pause(BlockJob *job)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
job->pause_count++;
|
|
|
ae23c9 |
@@ -221,7 +233,9 @@ static void block_job_resume(BlockJob *job)
|
|
|
ae23c9 |
if (job->pause_count) {
|
|
|
ae23c9 |
return;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
- block_job_enter(job);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ /* kick only if no timer is pending */
|
|
|
ae23c9 |
+ block_job_enter_cond(job, block_job_timer_not_pending);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
void block_job_ref(BlockJob *job)
|
|
|
ae23c9 |
@@ -651,12 +665,6 @@ static void block_job_completed_txn_success(BlockJob *job)
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
-/* Assumes the block_job_mutex is held */
|
|
|
ae23c9 |
-static bool block_job_timer_pending(BlockJob *job)
|
|
|
ae23c9 |
-{
|
|
|
ae23c9 |
- return timer_pending(&job->sleep_timer);
|
|
|
ae23c9 |
-}
|
|
|
ae23c9 |
-
|
|
|
ae23c9 |
void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
Error *local_err = NULL;
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/185 b/tests/qemu-iotests/185
|
|
|
ae23c9 |
index 975404c..9a2d317 100755
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/185
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/185
|
|
|
ae23c9 |
@@ -101,14 +101,11 @@ echo
|
|
|
ae23c9 |
# command to be received (after receiving the command, the rest runs
|
|
|
ae23c9 |
# synchronously, so jobs can arbitrarily continue or complete).
|
|
|
ae23c9 |
#
|
|
|
ae23c9 |
-# Jobs present while QEMU is terminating iterate once more due to
|
|
|
ae23c9 |
-# bdrv_drain_all().
|
|
|
ae23c9 |
-#
|
|
|
ae23c9 |
# The buffer size for commit and streaming is 512k (waiting for 8 seconds after
|
|
|
ae23c9 |
# the first request), for active commit and mirror it's large enough to cover
|
|
|
ae23c9 |
# the full 4M, and for backup it's the qcow2 cluster size, which we know is
|
|
|
ae23c9 |
# 64k. As all of these are at least as large as the speed, we are sure that the
|
|
|
ae23c9 |
-# offset advances exactly twice before qemu exits.
|
|
|
ae23c9 |
+# offset advances exactly once before qemu exits.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
_send_qemu_cmd $h \
|
|
|
ae23c9 |
"{ 'execute': 'block-commit',
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/185.out b/tests/qemu-iotests/185.out
|
|
|
ae23c9 |
index 992162f..57eaf8d 100644
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/185.out
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/185.out
|
|
|
ae23c9 |
@@ -20,7 +20,7 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q
|
|
|
ae23c9 |
{"return": {}}
|
|
|
ae23c9 |
{"return": {}}
|
|
|
ae23c9 |
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
|
|
|
ae23c9 |
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 1048576, "speed": 65536, "type": "commit"}}
|
|
|
ae23c9 |
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 524288, "speed": 65536, "type": "commit"}}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
=== Start active commit job and exit qemu ===
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -28,8 +28,7 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q
|
|
|
ae23c9 |
{"return": {}}
|
|
|
ae23c9 |
{"return": {}}
|
|
|
ae23c9 |
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
|
|
|
ae23c9 |
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "commit"}}
|
|
|
ae23c9 |
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "commit"}}
|
|
|
ae23c9 |
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "commit"}}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
=== Start mirror job and exit qemu ===
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -38,8 +37,7 @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 l
|
|
|
ae23c9 |
{"return": {}}
|
|
|
ae23c9 |
{"return": {}}
|
|
|
ae23c9 |
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
|
|
|
ae23c9 |
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}}
|
|
|
ae23c9 |
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}}
|
|
|
ae23c9 |
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
=== Start backup job and exit qemu ===
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -48,7 +46,7 @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 l
|
|
|
ae23c9 |
{"return": {}}
|
|
|
ae23c9 |
{"return": {}}
|
|
|
ae23c9 |
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
|
|
|
ae23c9 |
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 131072, "speed": 65536, "type": "backup"}}
|
|
|
ae23c9 |
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 65536, "speed": 65536, "type": "backup"}}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
=== Start streaming job and exit qemu ===
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -56,6 +54,6 @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 l
|
|
|
ae23c9 |
{"return": {}}
|
|
|
ae23c9 |
{"return": {}}
|
|
|
ae23c9 |
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
|
|
|
ae23c9 |
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 1048576, "speed": 65536, "type": "stream"}}
|
|
|
ae23c9 |
+{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 524288, "speed": 65536, "type": "stream"}}
|
|
|
ae23c9 |
No errors were found on the image.
|
|
|
ae23c9 |
*** done
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|