|
|
902636 |
From da4ee4c0d56200042cb86f8ccd2777009bd82df3 Mon Sep 17 00:00:00 2001
|
|
|
902636 |
From: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
902636 |
Date: Fri, 7 Feb 2020 11:27:44 +0000
|
|
|
902636 |
Subject: [PATCH 11/18] blockdev: honor bdrv_try_set_aio_context() context
|
|
|
902636 |
requirements
|
|
|
902636 |
|
|
|
902636 |
RH-Author: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
902636 |
Message-id: <20200207112749.25073-5-slp@redhat.com>
|
|
|
902636 |
Patchwork-id: 93758
|
|
|
902636 |
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH v2 4/9] blockdev: honor bdrv_try_set_aio_context() context requirements
|
|
|
902636 |
Bugzilla: 1745606 1746217 1773517 1779036 1782111 1782175 1783965
|
|
|
902636 |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
902636 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
902636 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
902636 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
902636 |
|
|
|
902636 |
bdrv_try_set_aio_context() requires that the old context is held, and
|
|
|
902636 |
the new context is not held. Fix all the occurrences where it's not
|
|
|
902636 |
done this way.
|
|
|
902636 |
|
|
|
902636 |
Suggested-by: Max Reitz <mreitz@redhat.com>
|
|
|
902636 |
Signed-off-by: Sergio Lopez <slp@redhat.com>
|
|
|
902636 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
902636 |
(cherry picked from commit 3ea67e08832775a28d0bd2795f01bc77e7ea1512)
|
|
|
902636 |
Signed-off-by: Sergio Lopez <slp@redhat.com>
|
|
|
902636 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
902636 |
---
|
|
|
902636 |
blockdev.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
|
|
|
902636 |
1 file changed, 60 insertions(+), 8 deletions(-)
|
|
|
902636 |
|
|
|
902636 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
902636 |
index 152a0f7..1dacbc2 100644
|
|
|
902636 |
--- a/blockdev.c
|
|
|
902636 |
+++ b/blockdev.c
|
|
|
902636 |
@@ -1535,6 +1535,7 @@ static void external_snapshot_prepare(BlkActionState *common,
|
|
|
902636 |
DO_UPCAST(ExternalSnapshotState, common, common);
|
|
|
902636 |
TransactionAction *action = common->action;
|
|
|
902636 |
AioContext *aio_context;
|
|
|
902636 |
+ AioContext *old_context;
|
|
|
902636 |
int ret;
|
|
|
902636 |
|
|
|
902636 |
/* 'blockdev-snapshot' and 'blockdev-snapshot-sync' have similar
|
|
|
902636 |
@@ -1675,7 +1676,16 @@ static void external_snapshot_prepare(BlkActionState *common,
|
|
|
902636 |
goto out;
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
+ /* Honor bdrv_try_set_aio_context() context acquisition requirements. */
|
|
|
902636 |
+ old_context = bdrv_get_aio_context(state->new_bs);
|
|
|
902636 |
+ aio_context_release(aio_context);
|
|
|
902636 |
+ aio_context_acquire(old_context);
|
|
|
902636 |
+
|
|
|
902636 |
ret = bdrv_try_set_aio_context(state->new_bs, aio_context, errp);
|
|
|
902636 |
+
|
|
|
902636 |
+ aio_context_release(old_context);
|
|
|
902636 |
+ aio_context_acquire(aio_context);
|
|
|
902636 |
+
|
|
|
902636 |
if (ret < 0) {
|
|
|
902636 |
goto out;
|
|
|
902636 |
}
|
|
|
902636 |
@@ -1775,11 +1785,13 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp)
|
|
|
902636 |
BlockDriverState *target_bs;
|
|
|
902636 |
BlockDriverState *source = NULL;
|
|
|
902636 |
AioContext *aio_context;
|
|
|
902636 |
+ AioContext *old_context;
|
|
|
902636 |
QDict *options;
|
|
|
902636 |
Error *local_err = NULL;
|
|
|
902636 |
int flags;
|
|
|
902636 |
int64_t size;
|
|
|
902636 |
bool set_backing_hd = false;
|
|
|
902636 |
+ int ret;
|
|
|
902636 |
|
|
|
902636 |
assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);
|
|
|
902636 |
backup = common->action->u.drive_backup.data;
|
|
|
902636 |
@@ -1868,6 +1880,21 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp)
|
|
|
902636 |
goto out;
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
+ /* Honor bdrv_try_set_aio_context() context acquisition requirements. */
|
|
|
902636 |
+ old_context = bdrv_get_aio_context(target_bs);
|
|
|
902636 |
+ aio_context_release(aio_context);
|
|
|
902636 |
+ aio_context_acquire(old_context);
|
|
|
902636 |
+
|
|
|
902636 |
+ ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
|
|
|
902636 |
+ if (ret < 0) {
|
|
|
902636 |
+ bdrv_unref(target_bs);
|
|
|
902636 |
+ aio_context_release(old_context);
|
|
|
902636 |
+ return;
|
|
|
902636 |
+ }
|
|
|
902636 |
+
|
|
|
902636 |
+ aio_context_release(old_context);
|
|
|
902636 |
+ aio_context_acquire(aio_context);
|
|
|
902636 |
+
|
|
|
902636 |
if (set_backing_hd) {
|
|
|
902636 |
bdrv_set_backing_hd(target_bs, source, &local_err);
|
|
|
902636 |
if (local_err) {
|
|
|
902636 |
@@ -1947,6 +1974,8 @@ static void blockdev_backup_prepare(BlkActionState *common, Error **errp)
|
|
|
902636 |
BlockDriverState *bs;
|
|
|
902636 |
BlockDriverState *target_bs;
|
|
|
902636 |
AioContext *aio_context;
|
|
|
902636 |
+ AioContext *old_context;
|
|
|
902636 |
+ int ret;
|
|
|
902636 |
|
|
|
902636 |
assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP);
|
|
|
902636 |
backup = common->action->u.blockdev_backup.data;
|
|
|
902636 |
@@ -1961,7 +1990,18 @@ static void blockdev_backup_prepare(BlkActionState *common, Error **errp)
|
|
|
902636 |
return;
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
+ /* Honor bdrv_try_set_aio_context() context acquisition requirements. */
|
|
|
902636 |
aio_context = bdrv_get_aio_context(bs);
|
|
|
902636 |
+ old_context = bdrv_get_aio_context(target_bs);
|
|
|
902636 |
+ aio_context_acquire(old_context);
|
|
|
902636 |
+
|
|
|
902636 |
+ ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
|
|
|
902636 |
+ if (ret < 0) {
|
|
|
902636 |
+ aio_context_release(old_context);
|
|
|
902636 |
+ return;
|
|
|
902636 |
+ }
|
|
|
902636 |
+
|
|
|
902636 |
+ aio_context_release(old_context);
|
|
|
902636 |
aio_context_acquire(aio_context);
|
|
|
902636 |
state->bs = bs;
|
|
|
902636 |
|
|
|
902636 |
@@ -3562,7 +3602,6 @@ static BlockJob *do_backup_common(BackupCommon *backup,
|
|
|
902636 |
BlockJob *job = NULL;
|
|
|
902636 |
BdrvDirtyBitmap *bmap = NULL;
|
|
|
902636 |
int job_flags = JOB_DEFAULT;
|
|
|
902636 |
- int ret;
|
|
|
902636 |
|
|
|
902636 |
if (!backup->has_speed) {
|
|
|
902636 |
backup->speed = 0;
|
|
|
902636 |
@@ -3586,11 +3625,6 @@ static BlockJob *do_backup_common(BackupCommon *backup,
|
|
|
902636 |
backup->compress = false;
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
- ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
|
|
|
902636 |
- if (ret < 0) {
|
|
|
902636 |
- return NULL;
|
|
|
902636 |
- }
|
|
|
902636 |
-
|
|
|
902636 |
if ((backup->sync == MIRROR_SYNC_MODE_BITMAP) ||
|
|
|
902636 |
(backup->sync == MIRROR_SYNC_MODE_INCREMENTAL)) {
|
|
|
902636 |
/* done before desugaring 'incremental' to print the right message */
|
|
|
902636 |
@@ -3825,6 +3859,7 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
|
|
|
902636 |
BlockDriverState *bs;
|
|
|
902636 |
BlockDriverState *source, *target_bs;
|
|
|
902636 |
AioContext *aio_context;
|
|
|
902636 |
+ AioContext *old_context;
|
|
|
902636 |
BlockMirrorBackingMode backing_mode;
|
|
|
902636 |
Error *local_err = NULL;
|
|
|
902636 |
QDict *options = NULL;
|
|
|
902636 |
@@ -3937,12 +3972,22 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
|
|
|
902636 |
(arg->mode == NEW_IMAGE_MODE_EXISTING ||
|
|
|
902636 |
!bdrv_has_zero_init(target_bs)));
|
|
|
902636 |
|
|
|
902636 |
+
|
|
|
902636 |
+ /* Honor bdrv_try_set_aio_context() context acquisition requirements. */
|
|
|
902636 |
+ old_context = bdrv_get_aio_context(target_bs);
|
|
|
902636 |
+ aio_context_release(aio_context);
|
|
|
902636 |
+ aio_context_acquire(old_context);
|
|
|
902636 |
+
|
|
|
902636 |
ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
|
|
|
902636 |
if (ret < 0) {
|
|
|
902636 |
bdrv_unref(target_bs);
|
|
|
902636 |
- goto out;
|
|
|
902636 |
+ aio_context_release(old_context);
|
|
|
902636 |
+ return;
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
+ aio_context_release(old_context);
|
|
|
902636 |
+ aio_context_acquire(aio_context);
|
|
|
902636 |
+
|
|
|
902636 |
blockdev_mirror_common(arg->has_job_id ? arg->job_id : NULL, bs, target_bs,
|
|
|
902636 |
arg->has_replaces, arg->replaces, arg->sync,
|
|
|
902636 |
backing_mode, zero_target,
|
|
|
902636 |
@@ -3984,6 +4029,7 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
|
|
|
902636 |
BlockDriverState *bs;
|
|
|
902636 |
BlockDriverState *target_bs;
|
|
|
902636 |
AioContext *aio_context;
|
|
|
902636 |
+ AioContext *old_context;
|
|
|
902636 |
BlockMirrorBackingMode backing_mode = MIRROR_LEAVE_BACKING_CHAIN;
|
|
|
902636 |
Error *local_err = NULL;
|
|
|
902636 |
bool zero_target;
|
|
|
902636 |
@@ -4001,10 +4047,16 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
|
|
|
902636 |
|
|
|
902636 |
zero_target = (sync == MIRROR_SYNC_MODE_FULL);
|
|
|
902636 |
|
|
|
902636 |
+ /* Honor bdrv_try_set_aio_context() context acquisition requirements. */
|
|
|
902636 |
+ old_context = bdrv_get_aio_context(target_bs);
|
|
|
902636 |
aio_context = bdrv_get_aio_context(bs);
|
|
|
902636 |
- aio_context_acquire(aio_context);
|
|
|
902636 |
+ aio_context_acquire(old_context);
|
|
|
902636 |
|
|
|
902636 |
ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
|
|
|
902636 |
+
|
|
|
902636 |
+ aio_context_release(old_context);
|
|
|
902636 |
+ aio_context_acquire(aio_context);
|
|
|
902636 |
+
|
|
|
902636 |
if (ret < 0) {
|
|
|
902636 |
goto out;
|
|
|
902636 |
}
|
|
|
902636 |
--
|
|
|
902636 |
1.8.3.1
|
|
|
902636 |
|