Blame SOURCES/kvm-block-don-t-keep-AioContext-acquired-after-drive_bac.patch

9bac43
From 73e2dea7d9da65e53aa05247324e069de75e0c71 Mon Sep 17 00:00:00 2001
9bac43
From: Stefan Hajnoczi <stefanha@redhat.com>
9bac43
Date: Fri, 22 Dec 2017 11:08:51 +0100
9bac43
Subject: [PATCH 33/42] block: don't keep AioContext acquired after
9bac43
 drive_backup_prepare()
9bac43
9bac43
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
9bac43
Message-id: <20171222110900.24813-12-stefanha@redhat.com>
9bac43
Patchwork-id: 78493
9bac43
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 11/20] block: don't keep AioContext acquired after drive_backup_prepare()
9bac43
Bugzilla: 1519721
9bac43
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9bac43
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9bac43
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
9bac43
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9bac43
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
9bac43
Reviewed-by: Eric Blake <eblake@redhat.com>
9bac43
Message-id: 20171206144550.22295-4-stefanha@redhat.com
9bac43
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9bac43
(cherry picked from commit 66d56054bca3c1c45861d18ea97f147f7d376d21)
9bac43
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9bac43
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
---
9bac43
 blockdev.c | 42 ++++++++++++++++++++++++++++++++++--------
9bac43
 1 file changed, 34 insertions(+), 8 deletions(-)
9bac43
9bac43
diff --git a/blockdev.c b/blockdev.c
9bac43
index 8bb23e9..c962b8a 100644
9bac43
--- a/blockdev.c
9bac43
+++ b/blockdev.c
9bac43
@@ -1888,7 +1888,6 @@ static void external_snapshot_clean(BlkActionState *common)
9bac43
 typedef struct DriveBackupState {
9bac43
     BlkActionState common;
9bac43
     BlockDriverState *bs;
9bac43
-    AioContext *aio_context;
9bac43
     BlockJob *job;
9bac43
 } DriveBackupState;
9bac43
 
9bac43
@@ -1900,6 +1899,7 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp)
9bac43
     DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
9bac43
     BlockDriverState *bs;
9bac43
     DriveBackup *backup;
9bac43
+    AioContext *aio_context;
9bac43
     Error *local_err = NULL;
9bac43
 
9bac43
     assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);
9bac43
@@ -1910,24 +1910,36 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp)
9bac43
         return;
9bac43
     }
9bac43
 
9bac43
-    /* AioContext is released in .clean() */
9bac43
-    state->aio_context = bdrv_get_aio_context(bs);
9bac43
-    aio_context_acquire(state->aio_context);
9bac43
+    aio_context = bdrv_get_aio_context(bs);
9bac43
+    aio_context_acquire(aio_context);
9bac43
+
9bac43
+    /* Paired with .clean() */
9bac43
     bdrv_drained_begin(bs);
9bac43
+
9bac43
     state->bs = bs;
9bac43
 
9bac43
     state->job = do_drive_backup(backup, common->block_job_txn, &local_err);
9bac43
     if (local_err) {
9bac43
         error_propagate(errp, local_err);
9bac43
-        return;
9bac43
+        goto out;
9bac43
     }
9bac43
+
9bac43
+out:
9bac43
+    aio_context_release(aio_context);
9bac43
 }
9bac43
 
9bac43
 static void drive_backup_commit(BlkActionState *common)
9bac43
 {
9bac43
     DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
9bac43
+    AioContext *aio_context;
9bac43
+
9bac43
+    aio_context = bdrv_get_aio_context(state->bs);
9bac43
+    aio_context_acquire(aio_context);
9bac43
+
9bac43
     assert(state->job);
9bac43
     block_job_start(state->job);
9bac43
+
9bac43
+    aio_context_release(aio_context);
9bac43
 }
9bac43
 
9bac43
 static void drive_backup_abort(BlkActionState *common)
9bac43
@@ -1935,18 +1947,32 @@ static void drive_backup_abort(BlkActionState *common)
9bac43
     DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
9bac43
 
9bac43
     if (state->job) {
9bac43
+        AioContext *aio_context;
9bac43
+
9bac43
+        aio_context = bdrv_get_aio_context(state->bs);
9bac43
+        aio_context_acquire(aio_context);
9bac43
+
9bac43
         block_job_cancel_sync(state->job);
9bac43
+
9bac43
+        aio_context_release(aio_context);
9bac43
     }
9bac43
 }
9bac43
 
9bac43
 static void drive_backup_clean(BlkActionState *common)
9bac43
 {
9bac43
     DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
9bac43
+    AioContext *aio_context;
9bac43
 
9bac43
-    if (state->aio_context) {
9bac43
-        bdrv_drained_end(state->bs);
9bac43
-        aio_context_release(state->aio_context);
9bac43
+    if (!state->bs) {
9bac43
+        return;
9bac43
     }
9bac43
+
9bac43
+    aio_context = bdrv_get_aio_context(state->bs);
9bac43
+    aio_context_acquire(aio_context);
9bac43
+
9bac43
+    bdrv_drained_end(state->bs);
9bac43
+
9bac43
+    aio_context_release(aio_context);
9bac43
 }
9bac43
 
9bac43
 typedef struct BlockdevBackupState {
9bac43
-- 
9bac43
1.8.3.1
9bac43