[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for-6.2 v3 07/12] job: Add job_cancel_requested()
From: |
Eric Blake |
Subject: |
Re: [PATCH for-6.2 v3 07/12] job: Add job_cancel_requested() |
Date: |
Fri, 6 Aug 2021 15:34:36 -0500 |
User-agent: |
NeoMutt/20210205-687-0ed190 |
On Fri, Aug 06, 2021 at 11:38:54AM +0200, Max Reitz wrote:
> Most callers of job_is_cancelled() actually want to know whether the job
> is on its way to immediate termination. For example, we refuse to pause
> jobs that are cancelled; but this only makes sense for jobs that are
> really actually cancelled.
>
> A mirror job that is cancelled during READY with force=false should
> absolutely be allowed to pause. This "cancellation" (which is actually
> a kind of completion) may take an indefinite amount of time, and so
> should behave like any job during normal operation. For example, with
> on-target-error=stop, the job should stop on write errors. (In
> contrast, force-cancelled jobs should not get write errors, as they
> should just terminate and not do further I/O.)
>
> Therefore, redefine job_is_cancelled() to only return true for jobs that
> are force-cancelled (which as of HEAD^ means any job that interprets the
> cancellation request as a request for immediate termination), and add
> job_cancel_requested() as the general variant, which returns true for
> any jobs which have been requested to be cancelled, whether it be
> immediately or after an arbitrarily long completion phase.
>
> Finally, here is a justification for how different job_is_cancelled()
> invocations are treated by this patch:
Thanks for this list; it's really thorough and helpful.
>
> Buglink: https://gitlab.com/qemu-project/qemu/-/issues/462
> Signed-off-by: Max Reitz <mreitz@redhat.com>
Although it is fixing a bug, the bug has been long-standing, so I
agree with your claim that this is 6.2 material.
> ---
> include/qemu/job.h | 8 +++++++-
> block/mirror.c | 10 ++++------
> job.c | 9 +++++++--
> 3 files changed, 18 insertions(+), 9 deletions(-)
>
> +++ b/job.c
> @@ -216,6 +216,11 @@ const char *job_type_str(const Job *job)
> }
>
> bool job_is_cancelled(Job *job)
> +{
> + return job->cancelled && job->force_cancel;
> +}
> +
> +bool job_cancel_requested(Job *job)
> {
> return job->cancelled;
> }
Works out rather nicely.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
- Re: [PATCH for-6.2 v3 04/12] job: Force-cancel jobs in a failed transaction, (continued)
- [PATCH for-6.2 v3 05/12] job: @force parameter for job_cancel_sync{, _all}(), Max Reitz, 2021/08/06
- [PATCH for-6.2 v3 06/12] jobs: Give Job.force_cancel more meaning, Max Reitz, 2021/08/06
- [PATCH for-6.2 v3 08/12] mirror: Use job_is_cancelled(), Max Reitz, 2021/08/06
- [PATCH for-6.2 v3 09/12] mirror: Check job_is_cancelled() earlier, Max Reitz, 2021/08/06
- [PATCH for-6.2 v3 07/12] job: Add job_cancel_requested(), Max Reitz, 2021/08/06
- Re: [PATCH for-6.2 v3 07/12] job: Add job_cancel_requested(),
Eric Blake <=
- [PATCH for-6.2 v3 10/12] mirror: Stop active mirroring after force-cancel, Max Reitz, 2021/08/06
- [PATCH for-6.2 v3 11/12] mirror: Do not clear .cancelled, Max Reitz, 2021/08/06
- [PATCH for-6.2 v3 12/12] iotests: Add mirror-ready-cancel-error test, Max Reitz, 2021/08/06