diff options
-rw-r--r-- | block.c | 6 | ||||
-rw-r--r-- | block/qapi.c | 2 | ||||
-rw-r--r-- | blockdev.c | 4 | ||||
-rw-r--r-- | include/block/block_int.h | 5 |
4 files changed, 10 insertions, 7 deletions
@@ -1907,7 +1907,7 @@ void bdrv_close(BlockDriverState *bs) } /* Disable I/O limits and drain all pending throttled requests */ - if (bs->io_limits_enabled) { + if (bs->throttle_state) { bdrv_io_limits_disable(bs); } @@ -3712,7 +3712,7 @@ void bdrv_detach_aio_context(BlockDriverState *bs) baf->detach_aio_context(baf->opaque); } - if (bs->io_limits_enabled) { + if (bs->throttle_state) { throttle_timers_detach_aio_context(&bs->throttle_timers); } if (bs->drv->bdrv_detach_aio_context) { @@ -3748,7 +3748,7 @@ void bdrv_attach_aio_context(BlockDriverState *bs, if (bs->drv->bdrv_attach_aio_context) { bs->drv->bdrv_attach_aio_context(bs, new_context); } - if (bs->io_limits_enabled) { + if (bs->throttle_state) { throttle_timers_attach_aio_context(&bs->throttle_timers, new_context); } diff --git a/block/qapi.c b/block/qapi.c index ec0f5139e2..89d4274177 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -64,7 +64,7 @@ BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs, Error **errp) info->backing_file_depth = bdrv_get_backing_file_depth(bs); info->detect_zeroes = bs->detect_zeroes; - if (bs->io_limits_enabled) { + if (bs->throttle_state) { ThrottleConfig cfg; throttle_group_get_config(bs, &cfg); diff --git a/blockdev.c b/blockdev.c index 7645d491cb..3598b01419 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2361,14 +2361,14 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, if (throttle_enabled(&cfg)) { /* Enable I/O limits if they're not enabled yet, otherwise * just update the throttling group. */ - if (!bs->io_limits_enabled) { + if (!bs->throttle_state) { bdrv_io_limits_enable(bs, has_group ? group : device); } else if (has_group) { bdrv_io_limits_update_group(bs, group); } /* Set the new throttling configuration */ bdrv_set_io_limits(bs, &cfg); - } else if (bs->io_limits_enabled) { + } else if (bs->throttle_state) { /* If all throttling settings are set to 0, disable I/O limits */ bdrv_io_limits_disable(bs); } diff --git a/include/block/block_int.h b/include/block/block_int.h index 6a3f64da12..603145a21d 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -390,7 +390,10 @@ struct BlockDriverState { /* number of in-flight serialising requests */ unsigned int serialising_in_flight; - /* I/O throttling */ + /* I/O throttling. + * throttle_state tells us if this BDS has I/O limits configured. + * io_limits_enabled tells us if they are currently being + * enforced, but it can be temporarily set to false */ CoQueue throttled_reqs[2]; bool io_limits_enabled; /* The following fields are protected by the ThrottleGroup lock. |