Blame SOURCES/kvm-block-commit-utilize-job_exit-shim.patch

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