]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: remove timer canceling in throttle_config()
authorManos Pitsidianakis <el13635@mail.ntua.gr>
Sun, 2 Jul 2017 10:06:46 +0000 (13:06 +0300)
committerKevin Wolf <kwolf@redhat.com>
Tue, 18 Jul 2017 13:14:35 +0000 (15:14 +0200)
throttle_config() cancels the timers of the calling BlockBackend. This
doesn't make sense because other BlockBackends in the group remain
untouched. There's no need to cancel the timers in the one specific
BlockBackend so let's not do that. Throttled requests will run as
scheduled and future requests will follow the new configuration. This
also allows a throttle group's configuration to be changed even when it
has no members.

Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/throttle-groups.c
fsdev/qemu-fsdev-throttle.c
include/qemu/throttle.h
tests/test-throttle.c
util/throttle.c

index 71af3f72a1b611e30ea4258d9333f409e8c6a26e..890bfded3f2ded97947dd94709110c7e655ac3ba 100644 (file)
@@ -426,18 +426,10 @@ void throttle_group_restart_blk(BlockBackend *blk)
 void throttle_group_config(BlockBackend *blk, ThrottleConfig *cfg)
 {
     BlockBackendPublic *blkp = blk_get_public(blk);
-    ThrottleTimers *tt = &blkp->throttle_timers;
     ThrottleState *ts = blkp->throttle_state;
     ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts);
     qemu_mutex_lock(&tg->lock);
-    /* throttle_config() cancels the timers */
-    if (timer_pending(tt->timers[0])) {
-        tg->any_timer_armed[0] = false;
-    }
-    if (timer_pending(tt->timers[1])) {
-        tg->any_timer_armed[1] = false;
-    }
-    throttle_config(ts, tg->clock_type, tt, cfg);
+    throttle_config(ts, tg->clock_type, cfg);
     qemu_mutex_unlock(&tg->lock);
 
     throttle_group_restart_blk(blk);
index 453fb1efdeb0ab37ab95cb702492ec647e3e5336..49eebb5412b47661dc90f7ce3e6b4a7904f33fe0 100644 (file)
@@ -86,7 +86,7 @@ void fsdev_throttle_init(FsThrottle *fst)
                              fsdev_throttle_read_timer_cb,
                              fsdev_throttle_write_timer_cb,
                              fst);
-        throttle_config(&fst->ts, QEMU_CLOCK_REALTIME, &fst->tt, &fst->cfg);
+        throttle_config(&fst->ts, QEMU_CLOCK_REALTIME, &fst->cfg);
         qemu_co_queue_init(&fst->throttled_reqs[0]);
         qemu_co_queue_init(&fst->throttled_reqs[1]);
     }
index 8d2fd77d2b82426b88f62bcabd01f998ca379502..d056008c18f549a47beee1a0234a70ceaabf0753 100644 (file)
@@ -140,7 +140,6 @@ bool throttle_is_valid(ThrottleConfig *cfg, Error **errp);
 
 void throttle_config(ThrottleState *ts,
                      QEMUClockType clock_type,
-                     ThrottleTimers *tt,
                      ThrottleConfig *cfg);
 
 void throttle_get_config(ThrottleState *ts, ThrottleConfig *cfg);
index 2d9cd4647ce8192b8d050619ee7316eecdb48f43..768f11dfede706fa620e7cf3aecb9b57fead607c 100644 (file)
@@ -228,7 +228,7 @@ static void test_config_functions(void)
                          read_timer_cb, write_timer_cb, &ts);
     /* structure reset by throttle_init previous_leak should be null */
     g_assert(!ts.previous_leak);
-    throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &tt, &orig_cfg);
+    throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &orig_cfg);
 
     /* has previous leak been initialized by throttle_config ? */
     g_assert(ts.previous_leak);
@@ -486,7 +486,7 @@ static bool do_test_accounting(bool is_ops, /* are we testing bps or ops */
     throttle_init(&ts);
     throttle_timers_init(&tt, ctx, QEMU_CLOCK_VIRTUAL,
                          read_timer_cb, write_timer_cb, &ts);
-    throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &tt, &cfg);
+    throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &cfg);
 
     /* account a read */
     throttle_account(&ts, false, size);
index 3e948071ddc7e6736d0e86ec4bc9058c9b005057..b2a52b8b34157c1729a32e2741cc2820eec921d3 100644 (file)
@@ -388,24 +388,14 @@ static void throttle_unfix_bucket(LeakyBucket *bkt)
     }
 }
 
-/* take care of canceling a timer */
-static void throttle_cancel_timer(QEMUTimer *timer)
-{
-    assert(timer != NULL);
-
-    timer_del(timer);
-}
-
 /* Used to configure the throttle
  *
  * @ts: the throttle state we are working on
  * @clock_type: the group's clock_type
- * @tt: the throttle timers we use in this aio context
  * @cfg: the config to set
  */
 void throttle_config(ThrottleState *ts,
                      QEMUClockType clock_type,
-                     ThrottleTimers *tt,
                      ThrottleConfig *cfg)
 {
     int i;
@@ -417,10 +407,6 @@ void throttle_config(ThrottleState *ts,
     }
 
     ts->previous_leak = qemu_clock_get_ns(clock_type);
-
-    for (i = 0; i < 2; i++) {
-        throttle_cancel_timer(tt->timers[i]);
-    }
 }
 
 /* used to get config