mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 09:13:55 -06:00
throttle: Use bs->throttle_state instead of bs->io_limits_enabled
There are two ways to check for I/O limits in a BlockDriverState: - bs->throttle_state: if this pointer is not NULL, it means that this BDS is member of a throttling group, its ThrottleTimers structure has been initialized and its I/O limits are ready to be applied. - bs->io_limits_enabled: if true it means that the throttle_state pointer is valid _and_ the limits are currently enabled. The latter is used in several places to check whether a BDS has I/O limits configured, but what it really checks is whether requests are being throttled or not. For example, io_limits_enabled can be temporarily set to false in cases like bdrv_read_unthrottled() without otherwise touching the throtting configuration of that BDS. This patch replaces bs->io_limits_enabled with bs->throttle_state in all cases where what we really want to check is the existence of I/O limits, not whether they are currently enabled or not. Signed-off-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
5ac724184c
commit
a0d64a61db
4 changed files with 10 additions and 7 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue