From nobody Mon Feb 9 04:31:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1573827684; cv=none; d=zoho.com; s=zohoarc; b=De/BVb0XC7yVfoBhP5Ym1E91vIL7n/Yp/OnsEYhGamBMvlIwrfqkVJc7Y1d3E2EkxAXF2bLJB1P0Q9F9MOCKLuhhYoDasaccMo8Ny70xaZ15KIPufh3ibgVU4PfyD4Ym5T+fCuidnzcCnfAj7hx9XokWHqGUCyTcBGIicIiDLaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573827684; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X7iSr2Fay9LlADuftKugGbnHLx7TSqoupFS7ksW1TNc=; b=E6GqexyzqiqJ6pA2JKsTvpBE0RxtuBI5m+vPjfrKXQuSZoG5rfN/i7HoH5Nkb9cFl5p2BPAisZnZRMNaF1nmh+UFVE0CwQ2+xFMbzV+StKrzxG9gQRVuZW6u5NqaGvUP7bAXrU1+YT+yfbx+xQoZBbDZ5TH4RrYvi9DqRrWNh6o= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1573827684522703.5831538506205; Fri, 15 Nov 2019 06:21:24 -0800 (PST) Received: from localhost ([::1]:39823 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVcTS-0001jb-Tj for importer@patchew.org; Fri, 15 Nov 2019 09:21:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58986) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVcNK-0004cw-E9 for qemu-devel@nongnu.org; Fri, 15 Nov 2019 09:15:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVcNJ-0001x2-7C for qemu-devel@nongnu.org; Fri, 15 Nov 2019 09:15:02 -0500 Received: from relay.sw.ru ([185.231.240.75]:47428) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iVcNG-0001rq-II; Fri, 15 Nov 2019 09:14:58 -0500 Received: from vovaso.qa.sw.ru ([10.94.3.0] helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1iVcNB-0006WW-EG; Fri, 15 Nov 2019 17:14:53 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [RFC 16/24] block/block-copy: add max_chunk and max_workers paramters Date: Fri, 15 Nov 2019 17:14:36 +0300 Message-Id: <20191115141444.24155-17-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191115141444.24155-1-vsementsov@virtuozzo.com> References: <20191115141444.24155-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, ehabkost@redhat.com, wencongyang2@huawei.com, xiechanglong.d@gmail.com, armbru@redhat.com, qemu-devel@nongnu.org, jsnow@redhat.com, crosa@redhat.com, den@openvz.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" They will be used for backup. Signed-off-by: Vladimir Sementsov-Ogievskiy --- 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 s= tart, 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-reques= ts, + * must be > 0. + * + * @max_chunk means maximum length for one IO operation. Zero means unlimi= ted. */ 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; =20 /* State */ @@ -393,7 +395,7 @@ static BlockCopyTask *block_copy_task_create(BlockCopyS= tate *s, =20 assert(bdrv_dirty_bitmap_get(s->copy_bitmap, offset)); =20 - bytes =3D MIN(bytes, s->copy_size); + bytes =3D MIN(bytes, MIN_NON_ZERO(s->copy_size, call_state->max_chunk)= ); next_zero =3D bdrv_dirty_bitmap_next_zero(s->copy_bitmap, offset, byte= s); if (next_zero >=3D 0) { assert(next_zero > offset); /* offset is dirty */ @@ -578,7 +580,7 @@ block_copy_dirty_clusters(BlockCopyCallState *call_stat= e) co_get_from_shres(s->mem, task->bytes); =20 if (!aio && task->bytes !=3D bytes) { - aio =3D aio_task_pool_new(BLOCK_COPY_MAX_WORKERS); + aio =3D aio_task_pool_new(call_state->max_workers); } =20 offset +=3D task->bytes; @@ -655,6 +657,7 @@ int coroutine_fn block_copy(BlockCopyState *s, int64_t = start, uint64_t bytes, .s =3D s, .offset =3D start, .bytes =3D bytes, + .max_workers =3D BLOCK_COPY_MAX_WORKERS, }; =20 int ret =3D block_copy_common(&call_state); @@ -686,6 +689,8 @@ BlockCopyCallState *block_copy_async(BlockCopyState *s, .offset =3D offset, .bytes =3D bytes, .cb =3D cb, + .max_workers =3D max_workers ?: BLOCK_COPY_MAX_WORKERS, + .max_chunk =3D max_chunk, }; =20 qemu_coroutine_enter(co); --=20 2.21.0