|
|
357786 |
From a0b03467a363f0e6804042925ea1df8ef56f8a46 Mon Sep 17 00:00:00 2001
|
|
|
357786 |
From: John Snow <jsnow@redhat.com>
|
|
|
357786 |
Date: Mon, 10 Sep 2018 18:17:42 +0200
|
|
|
357786 |
Subject: [PATCH 04/25] block/commit: utilize job_exit shim
|
|
|
357786 |
|
|
|
357786 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
357786 |
Message-id: <20180910181803.11781-5-jsnow@redhat.com>
|
|
|
357786 |
Patchwork-id: 82110
|
|
|
357786 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 04/25] block/commit: utilize job_exit shim
|
|
|
357786 |
Bugzilla: 1626061
|
|
|
357786 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
357786 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
357786 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
Change the manual deferment to commit_complete into the implicit
|
|
|
357786 |
callback to job_exit, renaming commit_complete to commit_exit.
|
|
|
357786 |
|
|
|
357786 |
This conversion does change the timing of when job_completed is
|
|
|
357786 |
called to after the bdrv_replace_node and bdrv_unref calls, which
|
|
|
357786 |
could have implications for bjob->blk which will now be put down
|
|
|
357786 |
after this cleanup.
|
|
|
357786 |
|
|
|
357786 |
Kevin highlights that we did not take any permissions for that backend
|
|
|
357786 |
at job creation time, so it is safe to reorder these operations.
|
|
|
357786 |
|
|
|
357786 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
357786 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
357786 |
Message-id: 20180830015734.19765-5-jsnow@redhat.com
|
|
|
357786 |
Reviewed-by: Jeff Cody <jcody@redhat.com>
|
|
|
357786 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
357786 |
(cherry picked from commit f369b48dc4095861223f9bc4329935599e03b1c5)
|
|
|
357786 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
357786 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
357786 |
---
|
|
|
357786 |
block/commit.c | 22 +++++-----------------
|
|
|
357786 |
1 file changed, 5 insertions(+), 17 deletions(-)
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/commit.c b/block/commit.c
|
|
|
357786 |
index af7579d..25b3cb8 100644
|
|
|
357786 |
--- a/block/commit.c
|
|
|
357786 |
+++ b/block/commit.c
|
|
|
357786 |
@@ -68,19 +68,13 @@ static int coroutine_fn commit_populate(BlockBackend *bs, BlockBackend *base,
|
|
|
357786 |
return 0;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
-typedef struct {
|
|
|
357786 |
- int ret;
|
|
|
357786 |
-} CommitCompleteData;
|
|
|
357786 |
-
|
|
|
357786 |
-static void commit_complete(Job *job, void *opaque)
|
|
|
357786 |
+static void commit_exit(Job *job)
|
|
|
357786 |
{
|
|
|
357786 |
CommitBlockJob *s = container_of(job, CommitBlockJob, common.job);
|
|
|
357786 |
BlockJob *bjob = &s->common;
|
|
|
357786 |
- CommitCompleteData *data = opaque;
|
|
|
357786 |
BlockDriverState *top = blk_bs(s->top);
|
|
|
357786 |
BlockDriverState *base = blk_bs(s->base);
|
|
|
357786 |
BlockDriverState *commit_top_bs = s->commit_top_bs;
|
|
|
357786 |
- int ret = data->ret;
|
|
|
357786 |
bool remove_commit_top_bs = false;
|
|
|
357786 |
|
|
|
357786 |
/* Make sure commit_top_bs and top stay around until bdrv_replace_node() */
|
|
|
357786 |
@@ -91,10 +85,10 @@ static void commit_complete(Job *job, void *opaque)
|
|
|
357786 |
* the normal backing chain can be restored. */
|
|
|
357786 |
blk_unref(s->base);
|
|
|
357786 |
|
|
|
357786 |
- if (!job_is_cancelled(job) && ret == 0) {
|
|
|
357786 |
+ if (!job_is_cancelled(job) && job->ret == 0) {
|
|
|
357786 |
/* success */
|
|
|
357786 |
- ret = bdrv_drop_intermediate(s->commit_top_bs, base,
|
|
|
357786 |
- s->backing_file_str);
|
|
|
357786 |
+ job->ret = bdrv_drop_intermediate(s->commit_top_bs, base,
|
|
|
357786 |
+ s->backing_file_str);
|
|
|
357786 |
} else {
|
|
|
357786 |
/* XXX Can (or should) we somehow keep 'consistent read' blocked even
|
|
|
357786 |
* after the failed/cancelled commit job is gone? If we already wrote
|
|
|
357786 |
@@ -117,9 +111,6 @@ static void commit_complete(Job *job, void *opaque)
|
|
|
357786 |
* bdrv_set_backing_hd() to fail. */
|
|
|
357786 |
block_job_remove_all_bdrv(bjob);
|
|
|
357786 |
|
|
|
357786 |
- job_completed(job, ret);
|
|
|
357786 |
- g_free(data);
|
|
|
357786 |
-
|
|
|
357786 |
/* If bdrv_drop_intermediate() didn't already do that, remove the commit
|
|
|
357786 |
* filter driver from the backing chain. Do this as the final step so that
|
|
|
357786 |
* the 'consistent read' permission can be granted. */
|
|
|
357786 |
@@ -137,7 +128,6 @@ static void commit_complete(Job *job, void *opaque)
|
|
|
357786 |
static int coroutine_fn commit_run(Job *job, Error **errp)
|
|
|
357786 |
{
|
|
|
357786 |
CommitBlockJob *s = container_of(job, CommitBlockJob, common.job);
|
|
|
357786 |
- CommitCompleteData *data;
|
|
|
357786 |
int64_t offset;
|
|
|
357786 |
uint64_t delay_ns = 0;
|
|
|
357786 |
int ret = 0;
|
|
|
357786 |
@@ -210,9 +200,6 @@ static int coroutine_fn commit_run(Job *job, Error **errp)
|
|
|
357786 |
out:
|
|
|
357786 |
qemu_vfree(buf);
|
|
|
357786 |
|
|
|
357786 |
- data = g_malloc(sizeof(*data));
|
|
|
357786 |
- data->ret = ret;
|
|
|
357786 |
- job_defer_to_main_loop(&s->common.job, commit_complete, data);
|
|
|
357786 |
return ret;
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
@@ -224,6 +211,7 @@ static const BlockJobDriver commit_job_driver = {
|
|
|
357786 |
.user_resume = block_job_user_resume,
|
|
|
357786 |
.drain = block_job_drain,
|
|
|
357786 |
.run = commit_run,
|
|
|
357786 |
+ .exit = commit_exit,
|
|
|
357786 |
},
|
|
|
357786 |
};
|
|
|
357786 |
|
|
|
357786 |
--
|
|
|
357786 |
1.8.3.1
|
|
|
357786 |
|