[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 6/6] block/block-copy: use aio-task-pool API
From: |
Max Reitz |
Subject: |
Re: [PATCH v2 6/6] block/block-copy: use aio-task-pool API |
Date: |
Tue, 28 Apr 2020 12:01:44 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
On 25.03.20 14:46, Vladimir Sementsov-Ogievskiy wrote:
> Run block_copy iterations in parallel in aio tasks.
>
> Changes:
> - BlockCopyTask becomes aio task structure. Add zeroes field to pass
> it to block_copy_do_copy
> - add call state - it's a state of one call of block_copy(), shared
> between parallel tasks. For now used only to keep information about
> first error: is it read or not.
> - convert block_copy_dirty_clusters to aio-task loop.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
> ---
> block/block-copy.c | 104 +++++++++++++++++++++++++++++++++++++++------
> 1 file changed, 91 insertions(+), 13 deletions(-)
Looks good, just some nits:
> diff --git a/block/block-copy.c b/block/block-copy.c
> index 910947cb43..9994598eb7 100644
> --- a/block/block-copy.c
> +++ b/block/block-copy.c
[...]
> @@ -225,6 +237,30 @@ void block_copy_set_progress_meter(BlockCopyState *s,
> ProgressMeter *pm)
> s->progress = pm;
> }
>
> +/* Takes ownership on @task */
*of
> +static coroutine_fn int block_copy_task_run(AioTaskPool *pool,
> + BlockCopyTask *task)
> +{
> + if (!pool) {
> + int ret = task->task.func(&task->task);
> +
> + g_free(task);
> + return ret;
> + }
> +
> + aio_task_pool_wait_slot(pool);
> + if (aio_task_pool_status(pool) < 0) {
> + co_put_to_shres(task->s->mem, task->bytes);
> + block_copy_task_end(task, -EAGAIN);
Hm, I think -ECANCELED might be better. Not that it really matters...
> + g_free(task);
> + return aio_task_pool_status(pool);
Here, too. (Here, there’s also the fact that this task doesn’t really
fail because of the same reason that the other task failed, so we should
have our own error code here.)
> + }
> +
> + aio_task_pool_start_task(pool, &task->task);
> +
> + return 0;
> +}
> +
> /*
> * block_copy_do_copy
> *
[...]
> @@ -519,25 +584,38 @@ static int coroutine_fn
> block_copy_dirty_clusters(BlockCopyState *s,
[...]
> +out:
> + if (aio) {
> + aio_task_pool_wait_all(aio);
> + if (ret == 0) {
> + ret = aio_task_pool_status(aio);
> + }
> + g_free(aio);
aio_task_pool_free()?
Max
signature.asc
Description: OpenPGP digital signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH v2 6/6] block/block-copy: use aio-task-pool API,
Max Reitz <=