[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 05/14] block/mirror.c: use of job helpers in drivers to av
From: |
Emanuele Giuseppe Esposito |
Subject: |
[RFC PATCH v2 05/14] block/mirror.c: use of job helpers in drivers to avoid TOC/TOU |
Date: |
Thu, 4 Nov 2021 10:53:25 -0400 |
Once job lock is used and aiocontext is removed, mirror has
to perform job operations under the same critical section,
using the helpers prepared in previous commit.
Note: at this stage, job_{lock/unlock} and job lock guard macros
are *nop*.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
block/mirror.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
index 00089e519b..f22fa7da6e 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -653,7 +653,7 @@ static int mirror_exit_common(Job *job)
BlockDriverState *target_bs;
BlockDriverState *mirror_top_bs;
Error *local_err = NULL;
- bool abort = job->ret < 0;
+ bool abort = job_has_failed(job);
int ret = 0;
if (s->prepared) {
@@ -1161,9 +1161,7 @@ static void mirror_complete(Job *job, Error **errp)
s->should_complete = true;
/* If the job is paused, it will be re-entered when it is resumed */
- if (!job->paused) {
- job_enter(job);
- }
+ job_enter_not_paused(job);
}
static void coroutine_fn mirror_pause(Job *job)
@@ -1182,7 +1180,7 @@ static bool mirror_drained_poll(BlockJob *job)
* from one of our own drain sections, to avoid a deadlock waiting for
* ourselves.
*/
- if (!s->common.job.paused && !job_is_cancelled(&job->job) && !s->in_drain)
{
+ if (job_not_paused_nor_cancelled(&s->common.job) && !s->in_drain) {
return true;
}
--
2.27.0
- [RFC PATCH v2 00/14] job: replace AioContext lock with job_mutex, Emanuele Giuseppe Esposito, 2021/11/04
- [RFC PATCH v2 03/14] job.h: define locked functions, Emanuele Giuseppe Esposito, 2021/11/04
- [RFC PATCH v2 02/14] job.h: categorize fields in struct Job, Emanuele Giuseppe Esposito, 2021/11/04
- [RFC PATCH v2 04/14] job.h: define unlocked functions, Emanuele Giuseppe Esposito, 2021/11/04
- [RFC PATCH v2 01/14] job.c: make job_lock/unlock public, Emanuele Giuseppe Esposito, 2021/11/04
- [RFC PATCH v2 05/14] block/mirror.c: use of job helpers in drivers to avoid TOC/TOU,
Emanuele Giuseppe Esposito <=
- [RFC PATCH v2 06/14] job.c: make job_event_* functions static, Emanuele Giuseppe Esposito, 2021/11/04
- [RFC PATCH v2 09/14] jobs: remove aiocontext locks since the functions are under BQL, Emanuele Giuseppe Esposito, 2021/11/04
- [RFC PATCH v2 08/14] aio-wait.h: introduce AIO_WAIT_WHILE_UNLOCKED, Emanuele Giuseppe Esposito, 2021/11/04
- [RFC PATCH v2 11/14] block_job_query: remove atomic read, Emanuele Giuseppe Esposito, 2021/11/04
- [RFC PATCH v2 10/14] jobs: protect jobs with job_lock/unlock, Emanuele Giuseppe Esposito, 2021/11/04
- [RFC PATCH v2 12/14] jobs: use job locks and helpers also in the unit tests, Emanuele Giuseppe Esposito, 2021/11/04
- [RFC PATCH v2 13/14] jobs: add job lock in find_* functions, Emanuele Giuseppe Esposito, 2021/11/04
- [RFC PATCH v2 07/14] job.c: move inner aiocontext lock in callbacks, Emanuele Giuseppe Esposito, 2021/11/04
- [RFC PATCH v2 14/14] job.c: enable job lock/unlock and remove Aiocontext locks, Emanuele Giuseppe Esposito, 2021/11/04