From nobody Tue May 14 18:16:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677250189684990.9871975346314; Fri, 24 Feb 2023 06:49:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVZNS-0007dq-PE; Fri, 24 Feb 2023 09:48:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNQ-0007bl-O6; Fri, 24 Feb 2023 09:48:48 -0500 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNO-0002pI-DY; Fri, 24 Feb 2023 09:48:48 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id F06C34852B; Fri, 24 Feb 2023 15:48:35 +0100 (CET) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, den@virtuozzo.com, t.lamprecht@proxmox.com, alexander.ivanov@virtuozzo.com Subject: [PATCH 1/9] blockjob: introduce block-job-change QMP command Date: Fri, 24 Feb 2023 15:48:17 +0100 Message-Id: <20230224144825.466375-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230224144825.466375-1-f.ebner@proxmox.com> References: <20230224144825.466375-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1677250191597100003 Content-Type: text/plain; charset="utf-8" which will allow changing job-type-specific options after job creation. In the JobVerbTable, the same allow bits as for set-speed are used, because set-speed could be considered an existing change command. Signed-off-by: Fiona Ebner --- Tried to go more general at first with a 'job-change' command, but I couldn't figure out a way to avoid mutual inclusion between block-core.json and job.json. blockdev.c | 14 ++++++++++++++ blockjob.c | 20 ++++++++++++++++++++ include/block/blockjob.h | 11 +++++++++++ include/block/blockjob_int.h | 5 +++++ job.c | 1 + qapi/block-core.json | 26 ++++++++++++++++++++++++++ qapi/job.json | 4 +++- 7 files changed, 80 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index d7b5c18f0a..ceb367dcb8 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3416,6 +3416,20 @@ void qmp_block_job_dismiss(const char *id, Error **e= rrp) job_dismiss_locked(&job, errp); } =20 +void qmp_block_job_change(BlockJobChangeOptions *opts, Error **errp) +{ + BlockJob *job; + + JOB_LOCK_GUARD(); + job =3D find_block_job_locked(opts->id, errp); + + if (!job) { + return; + } + + block_job_change_locked(job, opts, errp); +} + void qmp_change_backing_file(const char *device, const char *image_node_name, const char *backing_file, diff --git a/blockjob.c b/blockjob.c index 659c3cb9de..b933d1c631 100644 --- a/blockjob.c +++ b/blockjob.c @@ -319,6 +319,26 @@ static bool block_job_set_speed(BlockJob *job, int64_t= speed, Error **errp) return block_job_set_speed_locked(job, speed, errp); } =20 +void block_job_change_locked(BlockJob *job, BlockJobChangeOptions *opts, + Error **errp) +{ + const BlockJobDriver *drv =3D block_job_driver(job); + + GLOBAL_STATE_CODE(); + + if (job_apply_verb_locked(&job->job, JOB_VERB_CHANGE, errp)) { + return; + } + + if (drv->change) { + job_unlock(); + drv->change(job, opts, errp); + job_lock(); + } else { + error_setg(errp, "Job type does not support change"); + } +} + int64_t block_job_ratelimit_get_delay(BlockJob *job, uint64_t n) { IO_CODE(); diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 058b0c824c..d8b80d9625 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -172,6 +172,17 @@ bool block_job_has_bdrv(BlockJob *job, BlockDriverStat= e *bs); */ bool block_job_set_speed_locked(BlockJob *job, int64_t speed, Error **errp= ); =20 +/** + * block_job_change_locked: + * @job: The job to change. + * @opt: The new options. + * @errp: Error object. + * + * Change the job according to opts. + */ +void block_job_change_locked(BlockJob *job, BlockJobChangeOptions *opts, + Error **errp); + /** * block_job_query_locked: * @job: The job to get information about. diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h index f008446285..055bee5020 100644 --- a/include/block/blockjob_int.h +++ b/include/block/blockjob_int.h @@ -67,6 +67,11 @@ struct BlockJobDriver { void (*attached_aio_context)(BlockJob *job, AioContext *new_context); =20 void (*set_speed)(BlockJob *job, int64_t speed); + + /* + * Change the @job's options according to @opts. + */ + void (*change)(BlockJob *job, BlockJobChangeOptions *opts, Error **err= p); }; =20 /* diff --git a/job.c b/job.c index 72d57f0934..99a2e54b54 100644 --- a/job.c +++ b/job.c @@ -80,6 +80,7 @@ bool JobVerbTable[JOB_VERB__MAX][JOB_STATUS__MAX] =3D { [JOB_VERB_COMPLETE] =3D {0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0}, [JOB_VERB_FINALIZE] =3D {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, [JOB_VERB_DISMISS] =3D {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, + [JOB_VERB_CHANGE] =3D {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}, }; =20 /* Transactional group of jobs */ diff --git a/qapi/block-core.json b/qapi/block-core.json index 7f331eb8ea..714cabd49d 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2964,6 +2964,32 @@ { 'command': 'block-job-finalize', 'data': { 'id': 'str' }, 'allow-preconfig': true } =20 +## +# @BlockJobChangeOptions: +# +# Block job options that can be changed after job creation. +# +# @id: The job identifier +# +# @type: The job type +# +# Since 8.0 +## +{ 'union': 'BlockJobChangeOptions', + 'base': { 'id': 'str', 'type': 'JobType' }, + 'discriminator': 'type', + 'data': {} } + +## +# @block-job-change: +# +# Change the block job's options. +# +# Since: 8.0 +## +{ 'command': 'block-job-change', + 'data': 'BlockJobChangeOptions', 'boxed': true } + ## # @BlockdevDiscardOptions: # diff --git a/qapi/job.json b/qapi/job.json index d5f84e9615..7d9d328d7f 100644 --- a/qapi/job.json +++ b/qapi/job.json @@ -100,11 +100,13 @@ # # @finalize: see @job-finalize # +# @change: see @block-job-change (since 8.0) +# # Since: 2.12 ## { 'enum': 'JobVerb', 'data': ['cancel', 'pause', 'resume', 'set-speed', 'complete', 'dismiss', - 'finalize' ] } + 'finalize', 'change' ] } =20 ## # @JOB_STATUS_CHANGE: --=20 2.30.2 From nobody Tue May 14 18:16:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677250358539790.6040731148967; Fri, 24 Feb 2023 06:52:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVZNT-0007eP-Cf; Fri, 24 Feb 2023 09:48:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNR-0007cB-Gf; Fri, 24 Feb 2023 09:48:49 -0500 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNP-0002pr-BK; Fri, 24 Feb 2023 09:48:49 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 8452B48525; Fri, 24 Feb 2023 15:48:35 +0100 (CET) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, den@virtuozzo.com, t.lamprecht@proxmox.com, alexander.ivanov@virtuozzo.com Subject: [PATCH 2/9] block/mirror: set actively_synced even after the job is ready Date: Fri, 24 Feb 2023 15:48:18 +0100 Message-Id: <20230224144825.466375-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230224144825.466375-1-f.ebner@proxmox.com> References: <20230224144825.466375-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1677250360179100003 Content-Type: text/plain; charset="utf-8" In preparation to allow switching from background to active mode. This ensures that setting actively_synced will not be missed when the switch happens after the job is ready. Signed-off-by: Fiona Ebner Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/mirror.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index ab326b67c9..ca87492fcc 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1046,9 +1046,9 @@ static int coroutine_fn mirror_run(Job *job, Error **= errp) * the target in a consistent state. */ job_transition_to_ready(&s->common.job); - if (s->copy_mode !=3D MIRROR_COPY_MODE_BACKGROUND) { - s->actively_synced =3D true; - } + } + if (s->copy_mode !=3D MIRROR_COPY_MODE_BACKGROUND) { + s->actively_synced =3D true; } =20 should_complete =3D s->should_complete || --=20 2.30.2 From nobody Tue May 14 18:16:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677250200485956.59129696113; Fri, 24 Feb 2023 06:50:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVZNU-0007fT-4k; Fri, 24 Feb 2023 09:48:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNR-0007cI-Mp; Fri, 24 Feb 2023 09:48:49 -0500 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNO-0002pJ-Eb; Fri, 24 Feb 2023 09:48:49 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id F3CEF4852C; Fri, 24 Feb 2023 15:48:35 +0100 (CET) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, den@virtuozzo.com, t.lamprecht@proxmox.com, alexander.ivanov@virtuozzo.com Subject: [PATCH 3/9] mirror: implement mirror_change method Date: Fri, 24 Feb 2023 15:48:19 +0100 Message-Id: <20230224144825.466375-4-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230224144825.466375-1-f.ebner@proxmox.com> References: <20230224144825.466375-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1677250201187100002 Content-Type: text/plain; charset="utf-8" which allows switching the @copy-mode from 'background' to 'write-blocking'. Once the job is in active mode, no new writes need to be registered in the dirty bitmap, because they are synchronously written to the target. But since the method is called from the monitor and IO might be happening in an iothread at the same time, a drained section is needed. This is useful for management applications, so they can start out in background mode to avoid limiting guest write speed and switch to active mode when certain criteria are fullfilled. Currently, the amount of information that can be used for those criteria is a bit limited, so the plan is to extend quering of block jobs to return more information relevant for mirror. Signed-off-by: Fiona Ebner --- Sorry, I still haven't fully grasped the drained logic. Is my rationale for the drained section correct? There also are some yield points in block/io.c, for example when the driver implements bdrv_aio_pwritev (file-win32 and null), and the bitmap is only updated after that. Is that another reason it's required? block/mirror.c | 38 ++++++++++++++++++++++++++++++++++++++ qapi/block-core.json | 13 ++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index ca87492fcc..961aaa5cd6 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1216,6 +1216,43 @@ static bool commit_active_cancel(Job *job, bool forc= e) return force || !job_is_ready(job); } =20 +static void mirror_change(BlockJob *job, BlockJobChangeOptions *opts, + Error **errp) +{ + MirrorBlockJob *s =3D container_of(job, MirrorBlockJob, common); + BlockJobChangeOptionsMirror *change_opts =3D &opts->u.mirror; + BlockDriverState *bs =3D s->mirror_top_bs->backing->bs; + AioContext *ctx =3D bdrv_get_aio_context(bs); + + if (s->copy_mode =3D=3D change_opts->copy_mode) { + return; + } + + if (s->copy_mode =3D=3D MIRROR_COPY_MODE_WRITE_BLOCKING) { + error_setg(errp, "Cannot switch away from copy mode 'write-blockin= g'"); + return; + } + + assert(s->copy_mode =3D=3D MIRROR_COPY_MODE_BACKGROUND && + change_opts->copy_mode =3D=3D MIRROR_COPY_MODE_WRITE_BLOCKING); + + /* + * Once the job is in active mode, no new writes need to be registered= in + * the dirty bitmap, because they are synchronously written to the tar= get. + * Ensure the bitmap is up-to-date first, using a drained section. + */ + s->in_drain =3D true; + aio_context_acquire(ctx); + bdrv_drained_begin(bs); + + s->copy_mode =3D MIRROR_COPY_MODE_WRITE_BLOCKING; + bdrv_disable_dirty_bitmap(s->dirty_bitmap); + + bdrv_drained_end(bs); + aio_context_release(ctx); + s->in_drain =3D false; +} + static const BlockJobDriver mirror_job_driver =3D { .job_driver =3D { .instance_size =3D sizeof(MirrorBlockJob), @@ -1230,6 +1267,7 @@ static const BlockJobDriver mirror_job_driver =3D { .cancel =3D mirror_cancel, }, .drained_poll =3D mirror_drained_poll, + .change =3D mirror_change, }; =20 static const BlockJobDriver commit_active_job_driver =3D { diff --git a/qapi/block-core.json b/qapi/block-core.json index 714cabd49d..f9f464b25a 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2964,6 +2964,17 @@ { 'command': 'block-job-finalize', 'data': { 'id': 'str' }, 'allow-preconfig': true } =20 +## +# @BlockJobChangeOptionsMirror: +# +# @copy-mode: Switch to this copy mode. Currenlty, only the switch from +# 'background' to 'write-blocking' is implemented. +# +# Since: 8.0 +## +{ 'struct': 'BlockJobChangeOptionsMirror', + 'data': { 'copy-mode' : 'MirrorCopyMode' } } + ## # @BlockJobChangeOptions: # @@ -2978,7 +2989,7 @@ { 'union': 'BlockJobChangeOptions', 'base': { 'id': 'str', 'type': 'JobType' }, 'discriminator': 'type', - 'data': {} } + 'data': { 'mirror': 'BlockJobChangeOptionsMirror' } } =20 ## # @block-job-change: --=20 2.30.2 From nobody Tue May 14 18:16:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677250200383405.9901331155073; Fri, 24 Feb 2023 06:50:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVZNT-0007eN-5u; Fri, 24 Feb 2023 09:48:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNQ-0007bk-JB; Fri, 24 Feb 2023 09:48:48 -0500 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNO-0002pH-Dk; Fri, 24 Feb 2023 09:48:48 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C20D14852A; Fri, 24 Feb 2023 15:48:35 +0100 (CET) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, den@virtuozzo.com, t.lamprecht@proxmox.com, alexander.ivanov@virtuozzo.com Subject: [PATCH 4/9] qapi/block-core: use JobType for BlockJobInfo's type Date: Fri, 24 Feb 2023 15:48:20 +0100 Message-Id: <20230224144825.466375-5-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230224144825.466375-1-f.ebner@proxmox.com> References: <20230224144825.466375-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1677250201179100001 Content-Type: text/plain; charset="utf-8" In preparation to turn BlockJobInfo into a union with @type as the discriminator. That requires it to be an enum. No functional change is intended. Signed-off-by: Fiona Ebner Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/monitor/block-hmp-cmds.c | 4 ++-- blockjob.c | 2 +- qapi/block-core.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index 6aa5f1be0c..76e3254e93 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -840,7 +840,7 @@ void hmp_info_block_jobs(Monitor *mon, const QDict *qdi= ct) } =20 while (list) { - if (strcmp(list->value->type, "stream") =3D=3D 0) { + if (list->value->type =3D=3D JOB_TYPE_STREAM) { monitor_printf(mon, "Streaming device %s: Completed %" PRId64 " of %" PRId64 " bytes, speed limit %" PRId64 " bytes/s\n", @@ -852,7 +852,7 @@ void hmp_info_block_jobs(Monitor *mon, const QDict *qdi= ct) monitor_printf(mon, "Type %s, device %s: Completed %" PRId64 " of %" PRId64 " bytes, speed limit %" PRId64 " bytes/s\n", - list->value->type, + JobType_str(list->value->type), list->value->device, list->value->offset, list->value->len, diff --git a/blockjob.c b/blockjob.c index b933d1c631..9bd51bc6ae 100644 --- a/blockjob.c +++ b/blockjob.c @@ -361,7 +361,7 @@ BlockJobInfo *block_job_query_locked(BlockJob *job, Err= or **errp) &progress_total); =20 info =3D g_new0(BlockJobInfo, 1); - info->type =3D g_strdup(job_type_str(&job->job)); + info->type =3D job_type(&job->job); info->device =3D g_strdup(job->job.id); info->busy =3D job->job.busy; info->paused =3D job->job.pause_count > 0; diff --git a/qapi/block-core.json b/qapi/block-core.json index f9f464b25a..c1ac6de238 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1343,7 +1343,7 @@ # Since: 1.1 ## { 'struct': 'BlockJobInfo', - 'data': {'type': 'str', 'device': 'str', 'len': 'int', + 'data': {'type': 'JobType', 'device': 'str', 'len': 'int', 'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'in= t', 'io-status': 'BlockDeviceIoStatus', 'ready': 'bool', 'status': 'JobStatus', --=20 2.30.2 From nobody Tue May 14 18:16:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677250222738770.5722820706285; Fri, 24 Feb 2023 06:50:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVZNV-0007hn-LO; Fri, 24 Feb 2023 09:48:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNT-0007eO-7E; Fri, 24 Feb 2023 09:48:51 -0500 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNR-0002r3-PP; Fri, 24 Feb 2023 09:48:50 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 245B24851B; Fri, 24 Feb 2023 15:48:36 +0100 (CET) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, den@virtuozzo.com, t.lamprecht@proxmox.com, alexander.ivanov@virtuozzo.com Subject: [PATCH 5/9] qapi/block-core: turn BlockJobInfo into a union Date: Fri, 24 Feb 2023 15:48:21 +0100 Message-Id: <20230224144825.466375-6-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230224144825.466375-1-f.ebner@proxmox.com> References: <20230224144825.466375-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1677250223298100001 Content-Type: text/plain; charset="utf-8" In preparation to additionally return job-type-specific information. Signed-off-by: Fiona Ebner Reviewed-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index c1ac6de238..adb43a4592 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1342,13 +1342,15 @@ # # Since: 1.1 ## -{ 'struct': 'BlockJobInfo', - 'data': {'type': 'JobType', 'device': 'str', 'len': 'int', +{ 'union': 'BlockJobInfo', + 'base': {'type': 'JobType', 'device': 'str', 'len': 'int', 'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'in= t', 'io-status': 'BlockDeviceIoStatus', 'ready': 'bool', 'status': 'JobStatus', 'auto-finalize': 'bool', 'auto-dismiss': 'bool', - '*error': 'str' } } + '*error': 'str' }, + 'discriminator': 'type', + 'data': {} } =20 ## # @query-block-jobs: --=20 2.30.2 From nobody Tue May 14 18:16:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677250251571812.660017671443; Fri, 24 Feb 2023 06:50:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVZNV-0007hM-C0; Fri, 24 Feb 2023 09:48:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNT-0007eS-Cd; Fri, 24 Feb 2023 09:48:51 -0500 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNR-0002r4-Px; Fri, 24 Feb 2023 09:48:51 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2A5E748522; Fri, 24 Feb 2023 15:48:36 +0100 (CET) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, den@virtuozzo.com, t.lamprecht@proxmox.com, alexander.ivanov@virtuozzo.com Subject: [PATCH 6/9] blockjob: query driver-specific info via a new 'query' driver method Date: Fri, 24 Feb 2023 15:48:22 +0100 Message-Id: <20230224144825.466375-7-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230224144825.466375-1-f.ebner@proxmox.com> References: <20230224144825.466375-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1677250253437100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fiona Ebner --- blockjob.c | 4 ++++ include/block/blockjob_int.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/blockjob.c b/blockjob.c index 9bd51bc6ae..5570890001 100644 --- a/blockjob.c +++ b/blockjob.c @@ -349,6 +349,7 @@ BlockJobInfo *block_job_query_locked(BlockJob *job, Err= or **errp) { BlockJobInfo *info; uint64_t progress_current, progress_total; + const BlockJobDriver *drv =3D block_job_driver(job); =20 GLOBAL_STATE_CODE(); =20 @@ -378,6 +379,9 @@ BlockJobInfo *block_job_query_locked(BlockJob *job, Err= or **errp) g_strdup(error_get_pretty(job->job.err)) : g_strdup(strerror(-job->job.ret)); } + if (drv->query) { + drv->query(job, info); + } return info; } =20 diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h index 055bee5020..e4543e9885 100644 --- a/include/block/blockjob_int.h +++ b/include/block/blockjob_int.h @@ -72,6 +72,11 @@ struct BlockJobDriver { * Change the @job's options according to @opts. */ void (*change)(BlockJob *job, BlockJobChangeOptions *opts, Error **err= p); + + /* + * Query information specific to this kind of block job. + */ + void (*query)(BlockJob *job, BlockJobInfo *info); }; =20 /* --=20 2.30.2 From nobody Tue May 14 18:16:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677250346948960.0001656776383; Fri, 24 Feb 2023 06:52:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVZNX-0007jE-Ic; Fri, 24 Feb 2023 09:48:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNU-0007gA-IE; Fri, 24 Feb 2023 09:48:52 -0500 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNS-0002rA-01; Fri, 24 Feb 2023 09:48:52 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 65D1E48526; Fri, 24 Feb 2023 15:48:36 +0100 (CET) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, den@virtuozzo.com, t.lamprecht@proxmox.com, alexander.ivanov@virtuozzo.com Subject: [PATCH 7/9] mirror: return mirror-specific information upon query Date: Fri, 24 Feb 2023 15:48:23 +0100 Message-Id: <20230224144825.466375-8-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230224144825.466375-1-f.ebner@proxmox.com> References: <20230224144825.466375-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1677250348144100001 Content-Type: text/plain; charset="utf-8" To start out, only actively-synced is returned. For example, this is useful for jobs that started out in background mode and switched to active mode. Once actively-synced is true, it's clear that the mode switch has been completed. Note that completion of the switch might happen much earlier, e.g. if the switch happens before the job is ready, once all background operations have finished. It's assumed that whether the disks are actively-synced or not is more interesting than whether the mode switch completed. That information can still be added if required in the future. Signed-off-by: Fiona Ebner --- block/mirror.c | 10 ++++++++++ qapi/block-core.json | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index 961aaa5cd6..02b5bd8bd2 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1253,6 +1253,15 @@ static void mirror_change(BlockJob *job, BlockJobCha= ngeOptions *opts, s->in_drain =3D false; } =20 +static void mirror_query(BlockJob *job, BlockJobInfo *info) +{ + MirrorBlockJob *s =3D container_of(job, MirrorBlockJob, common); + + info->u.mirror =3D (BlockJobInfoMirror) { + .actively_synced =3D s->actively_synced, + }; +} + static const BlockJobDriver mirror_job_driver =3D { .job_driver =3D { .instance_size =3D sizeof(MirrorBlockJob), @@ -1268,6 +1277,7 @@ static const BlockJobDriver mirror_job_driver =3D { }, .drained_poll =3D mirror_drained_poll, .change =3D mirror_change, + .query =3D mirror_query, }; =20 static const BlockJobDriver commit_active_job_driver =3D { diff --git a/qapi/block-core.json b/qapi/block-core.json index adb43a4592..07e0f30492 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1300,6 +1300,19 @@ { 'enum': 'MirrorCopyMode', 'data': ['background', 'write-blocking'] } =20 +## +# @BlockJobInfoMirror: +# +# Information specific to mirror block jobs. +# +# @actively-synced: Whether the source is actively synced to the target, i= .e. +# same data and new writes are done synchronously to bot= h. +# +# Since 8.0 +## +{ 'struct': 'BlockJobInfoMirror', + 'data': { 'actively-synced': 'bool' } } + ## # @BlockJobInfo: # @@ -1350,7 +1363,7 @@ 'auto-finalize': 'bool', 'auto-dismiss': 'bool', '*error': 'str' }, 'discriminator': 'type', - 'data': {} } + 'data': { 'mirror': 'BlockJobInfoMirror' } } =20 ## # @query-block-jobs: --=20 2.30.2 From nobody Tue May 14 18:16:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677250303533332.6984032030458; Fri, 24 Feb 2023 06:51:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVZNX-0007iz-02; Fri, 24 Feb 2023 09:48:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNU-0007fz-D6; Fri, 24 Feb 2023 09:48:52 -0500 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNR-0002rB-W2; Fri, 24 Feb 2023 09:48:52 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 4EB0B4851F; Fri, 24 Feb 2023 15:48:36 +0100 (CET) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, den@virtuozzo.com, t.lamprecht@proxmox.com, alexander.ivanov@virtuozzo.com Subject: [PATCH 8/9] mirror: return the remaining dirty bytes upon query Date: Fri, 24 Feb 2023 15:48:24 +0100 Message-Id: <20230224144825.466375-9-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230224144825.466375-1-f.ebner@proxmox.com> References: <20230224144825.466375-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1677250303748100001 Content-Type: text/plain; charset="utf-8" This can be used by management applications starting with a job in background mode to determine when the switch to active mode should happen. Suggested-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Fiona Ebner --- block/mirror.c | 1 + qapi/block-core.json | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index 02b5bd8bd2..ac83309b82 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1259,6 +1259,7 @@ static void mirror_query(BlockJob *job, BlockJobInfo = *info) =20 info->u.mirror =3D (BlockJobInfoMirror) { .actively_synced =3D s->actively_synced, + .remaining_dirty =3D bdrv_get_dirty_count(s->dirty_bitmap), }; } =20 diff --git a/qapi/block-core.json b/qapi/block-core.json index 07e0f30492..91594eace4 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1308,10 +1308,12 @@ # @actively-synced: Whether the source is actively synced to the target, i= .e. # same data and new writes are done synchronously to bot= h. # +# @remaining-dirty: How much of the source is dirty relative to the target. +# # Since 8.0 ## { 'struct': 'BlockJobInfoMirror', - 'data': { 'actively-synced': 'bool' } } + 'data': { 'actively-synced': 'bool', 'remaining-dirty': 'int64' } } =20 ## # @BlockJobInfo: --=20 2.30.2 From nobody Tue May 14 18:16:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677250274941855.412682511689; Fri, 24 Feb 2023 06:51:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVZNX-0007j9-FK; Fri, 24 Feb 2023 09:48:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNU-0007gO-Jw; Fri, 24 Feb 2023 09:48:52 -0500 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVZNS-0002sy-TE; Fri, 24 Feb 2023 09:48:52 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9AFBE48528; Fri, 24 Feb 2023 15:48:36 +0100 (CET) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, den@virtuozzo.com, t.lamprecht@proxmox.com, alexander.ivanov@virtuozzo.com Subject: [PATCH 9/9] mirror: return the total number of bytes sent upon query Date: Fri, 24 Feb 2023 15:48:25 +0100 Message-Id: <20230224144825.466375-10-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230224144825.466375-1-f.ebner@proxmox.com> References: <20230224144825.466375-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1677250275645100001 Content-Type: text/plain; charset="utf-8" This can be used by management applications starting with a job in background mode to determine when the switch to active mode should happen. While the same information is already there, as the job-agnostic @offset, it's not clear to users what the value means for mirror: it's documentet to be relative to @len only and @len is documented to be able to change in both directions while the job runs. Suggested-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Fiona Ebner --- block/mirror.c | 6 ++++++ qapi/block-core.json | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index ac83309b82..e7b4905b70 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -86,6 +86,9 @@ typedef struct MirrorBlockJob { int64_t active_write_bytes_in_flight; bool prepared; bool in_drain; + + /* Additional information intended for users (returned in mirror_query= ) */ + int64_t data_sent; } MirrorBlockJob; =20 typedef struct MirrorBDSOpaque { @@ -215,6 +218,7 @@ static void coroutine_fn mirror_iteration_done(MirrorOp= *op, int ret) } if (!s->initial_zeroing_ongoing) { job_progress_update(&s->common.job, op->bytes); + s->data_sent +=3D op->bytes; } } qemu_iovec_destroy(&op->qiov); @@ -1259,6 +1263,7 @@ static void mirror_query(BlockJob *job, BlockJobInfo = *info) =20 info->u.mirror =3D (BlockJobInfoMirror) { .actively_synced =3D s->actively_synced, + .data_sent =3D s->data_sent, .remaining_dirty =3D bdrv_get_dirty_count(s->dirty_bitmap), }; } @@ -1384,6 +1389,7 @@ do_sync_target_write(MirrorBlockJob *job, MirrorMetho= d method, job->active_write_bytes_in_flight -=3D bytes; if (ret >=3D 0) { job_progress_update(&job->common.job, bytes); + job->data_sent +=3D bytes; } else { BlockErrorAction action; =20 diff --git a/qapi/block-core.json b/qapi/block-core.json index 91594eace4..656be5ce2e 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1308,12 +1308,15 @@ # @actively-synced: Whether the source is actively synced to the target, i= .e. # same data and new writes are done synchronously to bot= h. # +# @data-sent: How much data was sent in total until now. +# # @remaining-dirty: How much of the source is dirty relative to the target. # # Since 8.0 ## { 'struct': 'BlockJobInfoMirror', - 'data': { 'actively-synced': 'bool', 'remaining-dirty': 'int64' } } + 'data': { 'actively-synced': 'bool', 'data-sent': 'int64', + 'remaining-dirty': 'int64' } } =20 ## # @BlockJobInfo: --=20 2.30.2