block: disable I/O throttling on sync api
PATCH v2 2/2 block: disable I/O throttling on sync api
From: Zhi Yong Wu <[email protected]>
--- block.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
block.c +10 -0
@@ -1477,6 +1477,12 @@ static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,qemu_iovec_init_external (&qiov, &iov,1 ); +if (bs->io_limits_enabled) { +fprintf (stderr,"Disabling I/O throttling on '%s' due " +"to synchronous I/O.\n" ,bdrv_get_device_name (bs)); +bdrv_io_limits_disable (bs); + } +if (qemu_in_coroutine ()) {/* Fast-path if already in coroutine context */ bdrv_rw_co_entry (&rwco);
@@ -1983,10 +1989,14 @@ static int guess_disk_lchs(BlockDriverState *bs,struct partition *p;uint32_t nr_sects;uint64_t nb_sectors; +bool enabled;bdrv_get_geometry (bs, &nb_sectors); + enabled = bs->io_limits_enabled; + bs->io_limits_enabled = false; ret =bdrv_read (bs,0 , buf,1 ); + bs->io_limits_enabled = enabled;if (ret <0 )return -1 ;/* test msdos magic */
Signature · 1 line
1.7.6
Quoted 7 lines · On Tue, Mar 27, 2012 at 07:43:17PM +0800, [email protected] wrote:
From: Zhi Yong Wu <[email protected]>
Signed-off-by Stefan Hajnoczi <[email protected]>Signed-off-by Zhi Yong Wu <[email protected]>--- block.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
I tested this successfully with if=virtio and if=ide.
block.c static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, · line 1479
Quoted 8 lines
block.c +0
-0@@ -1477,6 +1477,12 @@ static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,qemu_iovec_init_external (&qiov, &iov,1 );
Please add a comment explaining that synchronous I/O cannot be throttled because timers don't work in that context.
Quoted 11 lines
block.c +6
-0+if (bs->io_limits_enabled) { +fprintf (stderr,"Disabling I/O throttling on '%s' due " +"to synchronous I/O.\n" ,bdrv_get_device_name (bs)); +bdrv_io_limits_disable (bs); + } +if (qemu_in_coroutine ()) {/* Fast-path if already in coroutine context */ bdrv_rw_co_entry (&rwco);@@ -1983,10 +1989,14 @@ static int guess_disk_lchs(BlockDriverState *bs,struct partition *p;
block.c static int guess_disk_lchs(BlockDriverState *bs, · line 1999
Quoted 10 lines
block.c +4
-0uint32_t nr_sects;uint64_t nb_sectors; +bool enabled;bdrv_get_geometry (bs, &nb_sectors); + enabled = bs->io_limits_enabled; + bs->io_limits_enabled = false; ret =bdrv_read (bs,0 , buf,1 ); + bs->io_limits_enabled = enabled;
Please add a comment explaining that this function is called during startup, even for storage interfaces that use asynchronous I/O functions. Therefore we explicitly disable throttling *temporarily*, not permanently, here.
Stefan
Quoted 40 lines · Stefan Hajnoczi
Quoted 7 lines · On Tue, Mar 27, 2012 at 07:43:17PM +0800, [email protected] wrote:
From: Zhi Yong Wu <[email protected]>
Signed-off-by Stefan Hajnoczi <[email protected]>Signed-off-by Zhi Yong Wu <[email protected]>---
block.c | 10 ++++++++++1 files changed, 10 insertions(+), 0 deletions(-)I tested this successfully with if=virtio and if=ide.
block.c static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, · line 1479
Quoted 8 lines
block.c +0
-0@@ -1477,6 +1477,12 @@ static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, qemu_iovec_init_external(&qiov, &iov, 1);Please add a comment explaining that synchronous I/O cannot be throttled because timers don't work in that context.
Quoted 17 lines
block.c +7
-0+ if (bs->io_limits_enabled) { + fprintf(stderr, "Disabling I/O throttling on '%s' due " + "to synchronous I/O.\n", bdrv_get_device_name(bs)); + bdrv_io_limits_disable(bs); + } + if (qemu_in_coroutine()) { /* Fast-path if already in coroutine context */ bdrv_rw_co_entry(&rwco);@@ -1983,10 +1989,14 @@ static int guess_disk_lchs(BlockDriverState *bs, struct partition *p; uint32_t nr_sects; uint64_t nb_sectors; + bool enabled; bdrv_get_geometry(bs, &nb_sectors);
Quoted 9 lines
block.c static int guess_disk_lchs(BlockDriverState *bs, · line 1999
Quoted 4 lines
block.c +3
-0+ enabled = bs->io_limits_enabled; + bs->io_limits_enabled = false; ret = bdrv_read(bs, 0, buf, 1); + bs->io_limits_enabled = enabled;Please add a comment explaining that this function is called during startup, even for storage interfaces that use asynchronous I/O functions. Therefore we explicitly disable throttling *temporarily*, not permanently, here.
thanks for your comments, pls see v3.
Quoted 3 lines
Stefan
Signature · 3 lines
Regards, Zhi Yong Wu