qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, mreitz@redhat.com, kwolf@redhat.com,
	jsnow@redhat.com, vsementsov@virtuozzo.com, pbonzini@redhat.com,
	stefanha@redhat.com, eesposit@redhat.com,
	peter.maydell@linaro.org
Subject: [PULL 02/10] block-copy: let ratelimit handle a speed of 0
Date: Fri, 25 Jun 2021 15:59:58 +0300	[thread overview]
Message-ID: <20210625130006.276511-3-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20210625130006.276511-1-vsementsov@virtuozzo.com>

From: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20210614081130.22134-3-eesposit@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/block-copy.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/block/block-copy.c b/block/block-copy.c
index 5808cfe657..020f9846d8 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -114,7 +114,6 @@ typedef struct BlockCopyState {
 
     SharedResource *mem;
 
-    uint64_t speed;
     RateLimit rate_limit;
 } BlockCopyState;
 
@@ -647,21 +646,19 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state)
             task->copy_range = false;
         }
 
-        if (s->speed) {
-            if (!call_state->ignore_ratelimit) {
-                uint64_t ns = ratelimit_calculate_delay(&s->rate_limit, 0);
-                if (ns > 0) {
-                    block_copy_task_end(task, -EAGAIN);
-                    g_free(task);
-                    qemu_co_sleep_ns_wakeable(&call_state->sleep,
-                                              QEMU_CLOCK_REALTIME, ns);
-                    continue;
-                }
+        if (!call_state->ignore_ratelimit) {
+            uint64_t ns = ratelimit_calculate_delay(&s->rate_limit, 0);
+            if (ns > 0) {
+                block_copy_task_end(task, -EAGAIN);
+                g_free(task);
+                qemu_co_sleep_ns_wakeable(&call_state->sleep,
+                                          QEMU_CLOCK_REALTIME, ns);
+                continue;
             }
-
-            ratelimit_calculate_delay(&s->rate_limit, task->bytes);
         }
 
+        ratelimit_calculate_delay(&s->rate_limit, task->bytes);
+
         trace_block_copy_process(s, task->offset);
 
         co_get_from_shres(s->mem, task->bytes);
@@ -853,10 +850,7 @@ void block_copy_set_skip_unallocated(BlockCopyState *s, bool skip)
 
 void block_copy_set_speed(BlockCopyState *s, uint64_t speed)
 {
-    s->speed = speed;
-    if (speed > 0) {
-        ratelimit_set_speed(&s->rate_limit, speed, BLOCK_COPY_SLICE_TIME);
-    }
+    ratelimit_set_speed(&s->rate_limit, speed, BLOCK_COPY_SLICE_TIME);
 
     /*
      * Note: it's good to kick all call states from here, but it should be done
-- 
2.29.2



  parent reply	other threads:[~2021-06-25 13:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-25 12:59 [PULL 00/10] Block Jobs patches Vladimir Sementsov-Ogievskiy
2021-06-25 12:59 ` [PULL 01/10] ratelimit: treat zero speed as unlimited Vladimir Sementsov-Ogievskiy
2021-06-25 12:59 ` Vladimir Sementsov-Ogievskiy [this message]
2021-06-25 12:59 ` [PULL 03/10] blockjob: let ratelimit handle a speed of 0 Vladimir Sementsov-Ogievskiy
2021-06-25 13:00 ` [PULL 04/10] progressmeter: protect with a mutex Vladimir Sementsov-Ogievskiy
2021-06-25 13:00 ` [PULL 05/10] co-shared-resource: " Vladimir Sementsov-Ogievskiy
2021-06-25 13:00 ` [PULL 06/10] block-copy: small refactor in block_copy_task_entry and block_copy_common Vladimir Sementsov-Ogievskiy
2021-06-25 13:00 ` [PULL 07/10] block-copy: streamline choice of copy_range vs. read/write Vladimir Sementsov-Ogievskiy
2021-06-25 13:00 ` [PULL 08/10] block-copy: move progress_set_remaining in block_copy_task_end Vladimir Sementsov-Ogievskiy
2021-06-25 13:00 ` [PULL 09/10] block-copy: add CoMutex lock Vladimir Sementsov-Ogievskiy
2021-06-25 13:00 ` [PULL 10/10] block-copy: atomic .cancelled and .finished fields in BlockCopyCallState Vladimir Sementsov-Ogievskiy
2021-06-28 16:09 ` [PULL 00/10] Block Jobs patches Peter Maydell
2021-06-28 16:19   ` Vladimir Sementsov-Ogievskiy
2021-06-28 21:26     ` Eric Blake
2021-06-28 20:03 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210625130006.276511-3-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=eesposit@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).