[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 27/40] throttle: Use bs->throttle_state instead of
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL v2 27/40] throttle: Use bs->throttle_state instead of bs->io_limits_enabled |
Date: |
Tue, 10 Nov 2015 15:09:27 +0100 |
From: Alberto Garcia <address@hidden>
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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 6 +++---
block/qapi.c | 2 +-
blockdev.c | 4 ++--
include/block/block_int.h | 5 ++++-
4 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/block.c b/block.c
index 3493501..cffac75 100644
--- a/block.c
+++ b/block.c
@@ -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 ec0f513..89d4274 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 7645d49..3598b01 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 6a3f64d..603145a 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.
--
1.8.3.1
- [Qemu-devel] [PULL v2 21/40] block: add tests for the 'blockdev-snapshot' command, (continued)
- [Qemu-devel] [PULL v2 21/40] block: add tests for the 'blockdev-snapshot' command, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 20/40] block: add a 'blockdev-snapshot' QMP command, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 26/40] throttle: Check for pending requests in throttle_group_unregister_bs(), Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 24/40] qcow2: avoid misaligned 64bit bswap, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 16/40] iotests: Add test for change-related QMP commands, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 23/40] qemu-iotests: Test the reopening of overlay_bs in 'block-commit', Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 28/40] block: Disallow snapshots if the overlay doesn't support backing files, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 29/40] block: Remove inner quotation marks in iotest 085, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 25/40] qemu-img: add check for zero-length job len, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 32/40] qemu-io: Check for trailing chars, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 27/40] throttle: Use bs->throttle_state instead of bs->io_limits_enabled,
Kevin Wolf <=
- [Qemu-devel] [PULL v2 33/40] qemu-io: Correct error messages, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 36/40] mirror: block all operations on the target image during the job, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 35/40] qemu-iotests: fix -valgrind option for check, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 30/40] block: test 'blockdev-snapshot' using a file BDS as the overlay, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 34/40] qemu-iotests: fix cleanup of background processes, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 37/40] block: Add blk_get_refcnt(), Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 31/40] qemu-io: fix cvtnum lval types, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 40/40] qcow2: Fix qcow2_get_cluster_offset() for zero clusters, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 38/40] block: Add 'x-blockdev-del' QMP command, Kevin Wolf, 2015/11/10
- [Qemu-devel] [PULL v2 39/40] iotests: Add tests for the x-blockdev-del command, Kevin Wolf, 2015/11/10