[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/12] mirror: Check job_is_cancelled() earlier
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PULL 09/12] mirror: Check job_is_cancelled() earlier |
Date: |
Tue, 21 Sep 2021 13:20:14 +0300 |
From: Hanna Reitz <hreitz@redhat.com>
We must check whether the job is force-cancelled early in our main loop,
most importantly before any `continue` statement. For example, we used
to have `continue`s before our current checking location that are
triggered by `mirror_flush()` failing. So, if `mirror_flush()` kept
failing, force-cancelling the job would not terminate it.
Jobs can be cancelled while they yield, and once they are
(force-cancelled), they should not generate new I/O requests.
Therefore, we should put the check after the last yield before
mirror_iteration() is invoked.
Buglink: https://gitlab.com/qemu-project/qemu/-/issues/462
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210907124245.143492-10-hreitz@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
block/mirror.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
index cfebe50845..1dbf648311 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1007,6 +1007,11 @@ static int coroutine_fn mirror_run(Job *job, Error
**errp)
job_pause_point(&s->common.job);
+ if (job_is_cancelled(&s->common.job)) {
+ ret = 0;
+ goto immediate_exit;
+ }
+
cnt = bdrv_get_dirty_count(s->dirty_bitmap);
/* cnt is the number of dirty bytes remaining and s->bytes_in_flight is
* the number of bytes currently being processed; together those are
@@ -1085,8 +1090,6 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
break;
}
- ret = 0;
-
if (job_is_ready(&s->common.job) && !should_complete) {
delay_ns = (s->in_flight == 0 &&
cnt == 0 ? BLOCK_JOB_SLICE_TIME : 0);
@@ -1094,9 +1097,6 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
trace_mirror_before_sleep(s, cnt, job_is_ready(&s->common.job),
delay_ns);
job_sleep_ns(&s->common.job, delay_ns);
- if (job_is_cancelled(&s->common.job)) {
- break;
- }
s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
}
--
2.29.2
- [PULL 00/12] jobs: mirror: Handle errors after READY cancel, Vladimir Sementsov-Ogievskiy, 2021/09/21
- [PULL 04/12] job: Force-cancel jobs in a failed transaction, Vladimir Sementsov-Ogievskiy, 2021/09/21
- [PULL 01/12] job: Context changes in job_completed_txn_abort(), Vladimir Sementsov-Ogievskiy, 2021/09/21
- [PULL 05/12] job: @force parameter for job_cancel_sync(), Vladimir Sementsov-Ogievskiy, 2021/09/21
- [PULL 02/12] mirror: Keep s->synced on error, Vladimir Sementsov-Ogievskiy, 2021/09/21
- [PULL 06/12] jobs: Give Job.force_cancel more meaning, Vladimir Sementsov-Ogievskiy, 2021/09/21
- [PULL 07/12] job: Add job_cancel_requested(), Vladimir Sementsov-Ogievskiy, 2021/09/21
- [PULL 09/12] mirror: Check job_is_cancelled() earlier,
Vladimir Sementsov-Ogievskiy <=
- [PULL 08/12] mirror: Use job_is_cancelled(), Vladimir Sementsov-Ogievskiy, 2021/09/21
- [PULL 03/12] mirror: Drop s->synced, Vladimir Sementsov-Ogievskiy, 2021/09/21
- [PULL 10/12] mirror: Stop active mirroring after force-cancel, Vladimir Sementsov-Ogievskiy, 2021/09/21
- [PULL 11/12] mirror: Do not clear .cancelled, Vladimir Sementsov-Ogievskiy, 2021/09/21
- [PULL 12/12] iotests: Add mirror-ready-cancel-error test, Vladimir Sementsov-Ogievskiy, 2021/09/21
- Re: [PULL 00/12] jobs: mirror: Handle errors after READY cancel, Richard Henderson, 2021/09/22