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