commit/stream: Reset delay_ns
authorKevin Wolf <kwolf@redhat.com>
Thu, 18 Jan 2018 20:23:52 +0000 (21:23 +0100)
committerKevin Wolf <kwolf@redhat.com>
Tue, 10 Apr 2018 14:33:47 +0000 (16:33 +0200)
Streaming and the commit block job only want to apply throttling when
they actually copied data instead of skipping it, so they made the
calculation of delay_ns conditional. However, delay_ns isn't reset when
skipping some sectors, so instead of not waiting, the old delay is
applied again.

Properly reset delay_ns where needed.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
block/commit.c
block/stream.c

index ab4fa3c3cfe552e221de2a43324c533eb38ca8c1..1432baeef48e750e1b7c16e91fd061f85ba0fa21 100644 (file)
@@ -202,6 +202,8 @@ static void coroutine_fn commit_run(void *opaque)
 
         if (copy && s->common.speed) {
             delay_ns = ratelimit_calculate_delay(&s->limit, n);
+        } else {
+            delay_ns = 0;
         }
     }
 
index f3b53f49e29786b1ce50d2a5a3cffbc114a99458..1a85708fcf9f6bdc294130bea9bd3a5700cb70a1 100644 (file)
@@ -188,6 +188,8 @@ static void coroutine_fn stream_run(void *opaque)
         s->common.offset += n;
         if (copy && s->common.speed) {
             delay_ns = ratelimit_calculate_delay(&s->limit, n);
+        } else {
+            delay_ns = 0;
         }
     }