diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2021-01-17 00:46:46 +0300 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2021-01-26 14:36:37 +0100 |
commit | 26be9d62dd5f5268b814da24fd8e8b5c5b999ebe (patch) | |
tree | ef5f3e5e0f64753915c83bbf84a34a3e940cba21 /block/block-copy.c | |
parent | de4641b46b020c5b332175f80e8bfe3d352888e8 (diff) | |
download | qemu-26be9d62dd5f5268b814da24fd8e8b5c5b999ebe.zip |
block/block-copy: add max_chunk and max_workers parameters
They will be used for backup.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20210116214705.822267-5-vsementsov@virtuozzo.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/block-copy.c')
-rw-r--r-- | block/block-copy.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/block/block-copy.c b/block/block-copy.c index 74655b86f8..35213bd832 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -34,6 +34,8 @@ typedef struct BlockCopyCallState { BlockCopyState *s; int64_t offset; int64_t bytes; + int max_workers; + int64_t max_chunk; BlockCopyAsyncCallbackFunc cb; void *cb_opaque; @@ -148,10 +150,11 @@ static BlockCopyTask *block_copy_task_create(BlockCopyState *s, int64_t offset, int64_t bytes) { BlockCopyTask *task; + int64_t max_chunk = MIN_NON_ZERO(s->copy_size, call_state->max_chunk); if (!bdrv_dirty_bitmap_next_dirty_area(s->copy_bitmap, offset, offset + bytes, - s->copy_size, &offset, &bytes)) + max_chunk, &offset, &bytes)) { return NULL; } @@ -623,7 +626,7 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state) bytes = end - offset; if (!aio && bytes) { - aio = aio_task_pool_new(BLOCK_COPY_MAX_WORKERS); + aio = aio_task_pool_new(call_state->max_workers); } ret = block_copy_task_run(aio, task); @@ -701,6 +704,7 @@ int coroutine_fn block_copy(BlockCopyState *s, int64_t start, int64_t bytes, .s = s, .offset = start, .bytes = bytes, + .max_workers = BLOCK_COPY_MAX_WORKERS, }; int ret = block_copy_common(&call_state); @@ -719,6 +723,7 @@ static void coroutine_fn block_copy_async_co_entry(void *opaque) BlockCopyCallState *block_copy_async(BlockCopyState *s, int64_t offset, int64_t bytes, + int max_workers, int64_t max_chunk, BlockCopyAsyncCallbackFunc cb, void *cb_opaque) { @@ -728,6 +733,8 @@ BlockCopyCallState *block_copy_async(BlockCopyState *s, .s = s, .offset = offset, .bytes = bytes, + .max_workers = max_workers, + .max_chunk = max_chunk, .cb = cb, .cb_opaque = cb_opaque, |