|
|
1bdc94 |
From a89c41261dee7c365995d9f5f98bcdb543e42775 Mon Sep 17 00:00:00 2001
|
|
|
1bdc94 |
From: John Snow <jsnow@redhat.com>
|
|
|
1bdc94 |
Date: Mon, 10 Sep 2018 18:17:43 +0200
|
|
|
1bdc94 |
Subject: [PATCH 05/25] block/mirror: utilize job_exit shim
|
|
|
1bdc94 |
|
|
|
1bdc94 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
1bdc94 |
Message-id: <20180910181803.11781-6-jsnow@redhat.com>
|
|
|
1bdc94 |
Patchwork-id: 82098
|
|
|
1bdc94 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 05/25] block/mirror: utilize job_exit shim
|
|
|
1bdc94 |
Bugzilla: 1626061
|
|
|
1bdc94 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1bdc94 |
|
|
|
1bdc94 |
Change the manual deferment to mirror_exit into the implicit
|
|
|
1bdc94 |
callback to job_exit and the mirror_exit callback.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
This does change the order of some bdrv_unref calls and job_completed,
|
|
|
1bdc94 |
but thanks to the new context in which we call .exit, this is safe to
|
|
|
1bdc94 |
defer the possible flushing of any nodes to the job_finalize_single
|
|
|
1bdc94 |
cleanup stage.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
1bdc94 |
Message-id: 20180830015734.19765-6-jsnow@redhat.com
|
|
|
1bdc94 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
Reviewed-by: Jeff Cody <jcody@redhat.com>
|
|
|
1bdc94 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
(cherry picked from commit 7b508f6b7a38a8d9729772fa6e525da883fb120b)
|
|
|
1bdc94 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
1bdc94 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
1bdc94 |
---
|
|
|
1bdc94 |
block/mirror.c | 30 +++++++++++-------------------
|
|
|
1bdc94 |
1 file changed, 11 insertions(+), 19 deletions(-)
|
|
|
1bdc94 |
|
|
|
1bdc94 |
diff --git a/block/mirror.c b/block/mirror.c
|
|
|
1bdc94 |
index 459f944..0ab0822 100644
|
|
|
1bdc94 |
--- a/block/mirror.c
|
|
|
1bdc94 |
+++ b/block/mirror.c
|
|
|
1bdc94 |
@@ -480,25 +480,21 @@ static void mirror_wait_for_all_io(MirrorBlockJob *s)
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
-typedef struct {
|
|
|
1bdc94 |
- int ret;
|
|
|
1bdc94 |
-} MirrorExitData;
|
|
|
1bdc94 |
-
|
|
|
1bdc94 |
-static void mirror_exit(Job *job, void *opaque)
|
|
|
1bdc94 |
+static void mirror_exit(Job *job)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job);
|
|
|
1bdc94 |
BlockJob *bjob = &s->common;
|
|
|
1bdc94 |
- MirrorExitData *data = opaque;
|
|
|
1bdc94 |
AioContext *replace_aio_context = NULL;
|
|
|
1bdc94 |
BlockDriverState *src = s->source;
|
|
|
1bdc94 |
BlockDriverState *target_bs = blk_bs(s->target);
|
|
|
1bdc94 |
BlockDriverState *mirror_top_bs = s->mirror_top_bs;
|
|
|
1bdc94 |
Error *local_err = NULL;
|
|
|
1bdc94 |
+ int ret = job->ret;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
bdrv_release_dirty_bitmap(src, s->dirty_bitmap);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
- /* Make sure that the source BDS doesn't go away before we called
|
|
|
1bdc94 |
- * job_completed(). */
|
|
|
1bdc94 |
+ /* Make sure that the source BDS doesn't go away during bdrv_replace_node,
|
|
|
1bdc94 |
+ * before we can call bdrv_drained_end */
|
|
|
1bdc94 |
bdrv_ref(src);
|
|
|
1bdc94 |
bdrv_ref(mirror_top_bs);
|
|
|
1bdc94 |
bdrv_ref(target_bs);
|
|
|
1bdc94 |
@@ -524,7 +520,7 @@ static void mirror_exit(Job *job, void *opaque)
|
|
|
1bdc94 |
bdrv_set_backing_hd(target_bs, backing, &local_err);
|
|
|
1bdc94 |
if (local_err) {
|
|
|
1bdc94 |
error_report_err(local_err);
|
|
|
1bdc94 |
- data->ret = -EPERM;
|
|
|
1bdc94 |
+ ret = -EPERM;
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
@@ -534,7 +530,7 @@ static void mirror_exit(Job *job, void *opaque)
|
|
|
1bdc94 |
aio_context_acquire(replace_aio_context);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
- if (s->should_complete && data->ret == 0) {
|
|
|
1bdc94 |
+ if (s->should_complete && ret == 0) {
|
|
|
1bdc94 |
BlockDriverState *to_replace = src;
|
|
|
1bdc94 |
if (s->to_replace) {
|
|
|
1bdc94 |
to_replace = s->to_replace;
|
|
|
1bdc94 |
@@ -551,7 +547,7 @@ static void mirror_exit(Job *job, void *opaque)
|
|
|
1bdc94 |
bdrv_drained_end(target_bs);
|
|
|
1bdc94 |
if (local_err) {
|
|
|
1bdc94 |
error_report_err(local_err);
|
|
|
1bdc94 |
- data->ret = -EPERM;
|
|
|
1bdc94 |
+ ret = -EPERM;
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
if (s->to_replace) {
|
|
|
1bdc94 |
@@ -581,12 +577,11 @@ static void mirror_exit(Job *job, void *opaque)
|
|
|
1bdc94 |
blk_set_perm(bjob->blk, 0, BLK_PERM_ALL, &error_abort);
|
|
|
1bdc94 |
blk_insert_bs(bjob->blk, mirror_top_bs, &error_abort);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
- job_completed(job, data->ret);
|
|
|
1bdc94 |
-
|
|
|
1bdc94 |
- g_free(data);
|
|
|
1bdc94 |
bdrv_drained_end(src);
|
|
|
1bdc94 |
bdrv_unref(mirror_top_bs);
|
|
|
1bdc94 |
bdrv_unref(src);
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ job->ret = ret;
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
static void mirror_throttle(MirrorBlockJob *s)
|
|
|
1bdc94 |
@@ -686,7 +681,6 @@ static int mirror_flush(MirrorBlockJob *s)
|
|
|
1bdc94 |
static int coroutine_fn mirror_run(Job *job, Error **errp)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job);
|
|
|
1bdc94 |
- MirrorExitData *data;
|
|
|
1bdc94 |
BlockDriverState *bs = s->source;
|
|
|
1bdc94 |
BlockDriverState *target_bs = blk_bs(s->target);
|
|
|
1bdc94 |
bool need_drain = true;
|
|
|
1bdc94 |
@@ -896,14 +890,10 @@ immediate_exit:
|
|
|
1bdc94 |
g_free(s->in_flight_bitmap);
|
|
|
1bdc94 |
bdrv_dirty_iter_free(s->dbi);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
- data = g_malloc(sizeof(*data));
|
|
|
1bdc94 |
- data->ret = ret;
|
|
|
1bdc94 |
-
|
|
|
1bdc94 |
if (need_drain) {
|
|
|
1bdc94 |
bdrv_drained_begin(bs);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
- job_defer_to_main_loop(&s->common.job, mirror_exit, data);
|
|
|
1bdc94 |
return ret;
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
@@ -996,6 +986,7 @@ static const BlockJobDriver mirror_job_driver = {
|
|
|
1bdc94 |
.user_resume = block_job_user_resume,
|
|
|
1bdc94 |
.drain = block_job_drain,
|
|
|
1bdc94 |
.run = mirror_run,
|
|
|
1bdc94 |
+ .exit = mirror_exit,
|
|
|
1bdc94 |
.pause = mirror_pause,
|
|
|
1bdc94 |
.complete = mirror_complete,
|
|
|
1bdc94 |
},
|
|
|
1bdc94 |
@@ -1011,6 +1002,7 @@ static const BlockJobDriver commit_active_job_driver = {
|
|
|
1bdc94 |
.user_resume = block_job_user_resume,
|
|
|
1bdc94 |
.drain = block_job_drain,
|
|
|
1bdc94 |
.run = mirror_run,
|
|
|
1bdc94 |
+ .exit = mirror_exit,
|
|
|
1bdc94 |
.pause = mirror_pause,
|
|
|
1bdc94 |
.complete = mirror_complete,
|
|
|
1bdc94 |
},
|
|
|
1bdc94 |
--
|
|
|
1bdc94 |
1.8.3.1
|
|
|
1bdc94 |
|