[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 5/5] block/block-copy: use aio-task-pool API
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
Re: [PATCH v3 5/5] block/block-copy: use aio-task-pool API |
Date: |
Wed, 29 Apr 2020 15:11:17 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 |
29.04.2020 14:55, Max Reitz wrote:
On 29.04.20 08:10, 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(-)
diff --git a/block/block-copy.c b/block/block-copy.c
index 5cf032c4d8..f5ef91f292 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
[...]
@@ -261,6 +278,30 @@ void block_copy_set_progress_meter(BlockCopyState *s,
ProgressMeter *pm)
s->progress = pm;
}
+/* Takes ownership on @task */
Still *of
Ohhh, very sorry for it, I really forget to update the patch :(
+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);
It looks like you may have missed my nit picks on v2 regarding this
patch, so I’m going to ask again whether -ECANCELED might be better here
(even though it still doesn’t really matter).
Hmm yes, sounds better in the context. And I don't see any specific usage of
it, and don't remember why I've chosen EAGAIN :) Let's use ECANCELED.
+ g_free(task);
+ return aio_task_pool_status(pool);
And whether it may be better to return a constant like -ECANCELED here,
because how a previous task failed shouldn’t really concern this task
(or its error code).
Looks correct, will change.
+ }
+
+ aio_task_pool_start_task(pool, &task->task);
+
+ return 0;
+}
+
/*
* block_copy_do_copy
*
[...]
@@ -525,25 +590,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);
I’d still prefer aio_task_pool_free().
a thousand apologies :(
--
Best regards,
Vladimir
- [PATCH v3 1/5] block/block-copy: rename in-flight requests to tasks, (continued)
[PATCH v3 3/5] block/block-copy: add state pointer to BlockCopyTask, Vladimir Sementsov-Ogievskiy, 2020/04/29
[PATCH v3 5/5] block/block-copy: use aio-task-pool API, Vladimir Sementsov-Ogievskiy, 2020/04/29