[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 3/3] blockdev: acquire AioContext in block_set_i
From: |
Benoît Canet |
Subject: |
Re: [Qemu-devel] [PATCH 3/3] blockdev: acquire AioContext in block_set_io_throttle |
Date: |
Wed, 14 May 2014 17:11:12 +0200 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
The Wednesday 14 May 2014 à 16:22:47 (+0200), Stefan Hajnoczi wrote :G
> The block_set_io_throttle QMP and HMP commands modify I/O throttling
> limits for block devices.
>
> Acquire the BlockDriverState's AioContext to protect against race
> conditions with an IOThread that is running I/O for this device.
>
> Cc: Benoît Canet <address@hidden>
> Signed-off-by: Stefan Hajnoczi <address@hidden>
> ---
> blockdev.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/blockdev.c b/blockdev.c
> index 7810e9f..e0f1978 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1663,6 +1663,7 @@ void qmp_block_set_io_throttle(const char *device,
> int64_t bps, int64_t bps_rd,
> {
> ThrottleConfig cfg;
> BlockDriverState *bs;
> + AioContext *aio_context;
>
> bs = bdrv_find(device);
> if (!bs) {
> @@ -1706,6 +1707,9 @@ void qmp_block_set_io_throttle(const char *device,
> int64_t bps, int64_t bps_rd,
> return;
> }
>
> + aio_context = bdrv_get_aio_context(bs);
> + aio_context_acquire(aio_context);
> +
> if (!bs->io_limits_enabled && throttle_enabled(&cfg)) {
> bdrv_io_limits_enable(bs);
> } else if (bs->io_limits_enabled && !throttle_enabled(&cfg)) {
> @@ -1715,6 +1719,8 @@ void qmp_block_set_io_throttle(const char *device,
> int64_t bps, int64_t bps_rd,
> if (bs->io_limits_enabled) {
> bdrv_set_io_limits(bs, &cfg);
> }
> +
> + aio_context_release(aio_context);
> }
>
> int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
> --
> 1.9.0
>
Reviewed-by: Benoit Canet <address@hidden>
- [Qemu-devel] [PATCH 0/3] throttle: use AioContext for dataplane support, Stefan Hajnoczi, 2014/05/14
- [Qemu-devel] [PATCH 1/3] throttle: add throttle_detach/attach_aio_context(), Stefan Hajnoczi, 2014/05/14
- [Qemu-devel] [PATCH 2/3] throttle: add detach/attach test case, Stefan Hajnoczi, 2014/05/14
- [Qemu-devel] [PATCH 3/3] blockdev: acquire AioContext in block_set_io_throttle, Stefan Hajnoczi, 2014/05/14
- Re: [Qemu-devel] [PATCH 3/3] blockdev: acquire AioContext in block_set_io_throttle,
Benoît Canet <=
- Re: [Qemu-devel] [PATCH 0/3] throttle: use AioContext for dataplane support, Benoît Canet, 2014/05/14
- Re: [Qemu-devel] [PATCH 0/3] throttle: use AioContext for dataplane support, Benoît Canet, 2014/05/14