[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v9 04/11] block: use the block job list in bdrv_
From: |
Max Reitz |
Subject: |
Re: [Qemu-block] [PATCH v9 04/11] block: use the block job list in bdrv_close() |
Date: |
Wed, 27 Apr 2016 14:14:18 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 |
On 04.04.2016 15:43, Alberto Garcia wrote:
> bdrv_close_all() cancels all block jobs by iterating over all
> BlockDriverStates. This patch simplifies the code by iterating
> directly over the block jobs using block_job_next().
>
> Signed-off-by: Alberto Garcia <address@hidden>
> ---
> block.c | 25 ++++++-------------------
> 1 file changed, 6 insertions(+), 19 deletions(-)
>
> diff --git a/block.c b/block.c
> index d36eb75..48638c9 100644
> --- a/block.c
> +++ b/block.c
> @@ -2182,8 +2182,7 @@ static void bdrv_close(BlockDriverState *bs)
>
> void bdrv_close_all(void)
> {
> - BlockDriverState *bs;
> - AioContext *aio_context;
> + BlockJob *job;
>
> /* Drop references from requests still in flight, such as canceled block
> * jobs whose AIO context has not been polled yet */
> @@ -2193,23 +2192,11 @@ void bdrv_close_all(void)
> blockdev_close_all_bdrv_states();
>
> /* Cancel all block jobs */
> - while (!QTAILQ_EMPTY(&all_bdrv_states)) {
> - QTAILQ_FOREACH(bs, &all_bdrv_states, bs_list) {
> - aio_context = bdrv_get_aio_context(bs);
> -
> - aio_context_acquire(aio_context);
> - if (bs->job) {
> - block_job_cancel_sync(bs->job);
> - aio_context_release(aio_context);
> - break;
> - }
> - aio_context_release(aio_context);
> - }
> -
> - /* All the remaining BlockDriverStates are referenced directly or
> - * indirectly from block jobs, so there needs to be at least one BDS
> - * directly used by a block job */
> - assert(bs);
> + while ((job = block_job_next(NULL))) {
> + AioContext *aio_context = bdrv_get_aio_context(job->bs);
> + aio_context_acquire(aio_context);
> + block_job_cancel_sync(job);
> + aio_context_release(aio_context);
> }
I'd like an assert(QTAILQ_EMPTY(&all_bdrv_states)) after this loop. This
is basically what the "assert(bs);" was for in the old version.
Apart from that, good patch.
Max
> }
>
>
signature.asc
Description: OpenPGP digital signature
- [Qemu-block] [PATCH for-2.7 v9 00/11] Support streaming to an intermediate layer, Alberto Garcia, 2016/04/04
- [Qemu-block] [PATCH v9 04/11] block: use the block job list in bdrv_close(), Alberto Garcia, 2016/04/04
- [Qemu-block] [PATCH v9 06/11] block: Support streaming to an intermediate layer, Alberto Garcia, 2016/04/04
- [Qemu-block] [PATCH v9 09/11] qemu-iotests: test streaming to an intermediate layer, Alberto Garcia, 2016/04/04
- [Qemu-block] [PATCH v9 01/11] block: keep a list of block jobs, Alberto Garcia, 2016/04/04
- [Qemu-block] [PATCH v9 10/11] qemu-iotests: test overlapping block-stream operations, Alberto Garcia, 2016/04/04