From: Denis V. Lunev <[email protected]> block_copy_dirty_clusters() charges task->req.bytes to the shared memory pool for every task, but a COPY_WRITE_ZEROES task allocates no bounce buffer, so there is nothing to account for. Add block_copy_task_shres_bytes() and use it at all three call sites.
Zero tasks lose the throttling the pool gave them incidentally and are bounded only by BLOCK_COPY_MAX_WORKERS (64). Reviewed-by: Andrey Drobyshev <[email protected]> Signed-off-by: Denis V. Lunev <[email protected]> CC: Vladimir Sementsov-Ogievskiy <[email protected]> CC: John Snow <[email protected]> CC: Andrey Drobyshev <[email protected]> --- block/block-copy.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/block/block-copy.c b/block/block-copy.c index 1826c2e1c7..21ebe8aec2 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -453,6 +453,11 @@ void block_copy_set_progress_meter(BlockCopyState *s, ProgressMeter *pm) s->progress = pm; } +static uint64_t block_copy_task_shres_bytes(BlockCopyTask *task) +{ + return task->method == COPY_WRITE_ZEROES ? 0 : task->req.bytes; +} + /* * Takes ownership of @task * @@ -474,7 +479,7 @@ static coroutine_fn int block_copy_task_run(AioTaskPool *pool, aio_task_pool_wait_slot(pool); if (aio_task_pool_status(pool) < 0) { - co_put_to_shres(task->s->mem, task->req.bytes); + co_put_to_shres(task->s->mem, block_copy_task_shres_bytes(task)); block_copy_task_end(task, -ECANCELED); g_free(task); return -ECANCELED; @@ -605,7 +610,7 @@ static coroutine_fn int block_copy_task_entry(AioTask *task) progress_work_done(s->progress, t->req.bytes); } } - co_put_to_shres(s->mem, t->req.bytes); + co_put_to_shres(s->mem, block_copy_task_shres_bytes(t)); block_copy_task_end(t, ret); if (s->discard_source && ret == 0) { @@ -816,7 +821,7 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state) trace_block_copy_process(s, task->req.offset); - co_get_from_shres(s->mem, task->req.bytes); + co_get_from_shres(s->mem, block_copy_task_shres_bytes(task)); offset = task_end(task); bytes = end - offset; -- 2.53.0
