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

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