[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 16/24] block/block-copy: add max_chunk and max_workers paramters
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[RFC 16/24] block/block-copy: add max_chunk and max_workers paramters |
Date: |
Fri, 15 Nov 2019 17:14:36 +0300 |
They will be used for backup.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
include/block/block-copy.h | 5 +++++
block/block-copy.c | 9 +++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
index 407de7e520..8fc27156b3 100644
--- a/include/block/block-copy.h
+++ b/include/block/block-copy.h
@@ -47,6 +47,11 @@ int coroutine_fn block_copy(BlockCopyState *s, int64_t
start, uint64_t bytes,
/*
* Run block-copy in a coroutine, return state pointer. If finished early
* returns NULL (@cb is called anyway).
+ *
+ * @max_workers means maximum of parallel coroutines to execute sub-requests,
+ * must be > 0.
+ *
+ * @max_chunk means maximum length for one IO operation. Zero means unlimited.
*/
BlockCopyCallState *block_copy_async(BlockCopyState *s,
int64_t offset, int64_t bytes,
diff --git a/block/block-copy.c b/block/block-copy.c
index 0b41afd30d..f28f3b8b6c 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -32,6 +32,8 @@ typedef struct BlockCopyCallState {
BlockCopyState *s;
int64_t offset;
int64_t bytes;
+ int max_workers;
+ int64_t max_chunk;
BlockCopyAsyncCallbackFunc cb;
/* State */
@@ -393,7 +395,7 @@ static BlockCopyTask *block_copy_task_create(BlockCopyState
*s,
assert(bdrv_dirty_bitmap_get(s->copy_bitmap, offset));
- bytes = MIN(bytes, s->copy_size);
+ bytes = MIN(bytes, MIN_NON_ZERO(s->copy_size, call_state->max_chunk));
next_zero = bdrv_dirty_bitmap_next_zero(s->copy_bitmap, offset, bytes);
if (next_zero >= 0) {
assert(next_zero > offset); /* offset is dirty */
@@ -578,7 +580,7 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state)
co_get_from_shres(s->mem, task->bytes);
if (!aio && task->bytes != bytes) {
- aio = aio_task_pool_new(BLOCK_COPY_MAX_WORKERS);
+ aio = aio_task_pool_new(call_state->max_workers);
}
offset += task->bytes;
@@ -655,6 +657,7 @@ int coroutine_fn block_copy(BlockCopyState *s, int64_t
start, uint64_t bytes,
.s = s,
.offset = start,
.bytes = bytes,
+ .max_workers = BLOCK_COPY_MAX_WORKERS,
};
int ret = block_copy_common(&call_state);
@@ -686,6 +689,8 @@ BlockCopyCallState *block_copy_async(BlockCopyState *s,
.offset = offset,
.bytes = bytes,
.cb = cb,
+ .max_workers = max_workers ?: BLOCK_COPY_MAX_WORKERS,
+ .max_chunk = max_chunk,
};
qemu_coroutine_enter(co);
--
2.21.0
- [RFC 00/24] backup performance: block_status + async, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 12/24] block/block-copy: move block_copy_task_create down, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 03/24] block/block-copy: factor out block_copy_find_inflight_req, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 20/24] job: call job_enter from job_user_pause, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 19/24] blockjob: add set_speed to BlockJobDriver, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 16/24] block/block-copy: add max_chunk and max_workers paramters,
Vladimir Sementsov-Ogievskiy <=
- [RFC 09/24] block/block-copy: alloc task on each iteration, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 15/24] block/block-copy: implement block_copy_async, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 23/24] python: add qemu/bench_block_job.py, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 17/24] block/block-copy: add ratelimit to block-copy, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 14/24] block/block-copy: More explicit call_state, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 18/24] block/block-copy: add block_copy_cancel, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 01/24] block/block-copy: specialcase first copy_range request, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 05/24] block/block-copy: rename start to offset in interfaces, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 24/24] python: benchmark new backup architecture, Vladimir Sementsov-Ogievskiy, 2019/11/15
- [RFC 08/24] block/block-copy: rename in-flight requests to tasks, Vladimir Sementsov-Ogievskiy, 2019/11/15