|
|
9bac43 |
From a9ef5c84766a00677204474b0f8d8e845b9d4d3f Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
Date: Fri, 22 Dec 2017 11:08:53 +0100
|
|
|
9bac43 |
Subject: [PATCH 35/42] block: don't keep AioContext acquired after
|
|
|
9bac43 |
internal_snapshot_prepare()
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
Message-id: <20171222110900.24813-14-stefanha@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 78499
|
|
|
9bac43 |
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 13/20] block: don't keep AioContext acquired after internal_snapshot_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-6-stefanha@redhat.com
|
|
|
9bac43 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
(cherry picked from commit a36e458cdda0196911c1cbe7cfe6f9530f2280e3)
|
|
|
9bac43 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
---
|
|
|
9bac43 |
blockdev.c | 47 +++++++++++++++++++++++++++++++----------------
|
|
|
9bac43 |
1 file changed, 31 insertions(+), 16 deletions(-)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
9bac43 |
index 6efae53..f118444 100644
|
|
|
9bac43 |
--- a/blockdev.c
|
|
|
9bac43 |
+++ b/blockdev.c
|
|
|
9bac43 |
@@ -1497,7 +1497,6 @@ struct BlkActionState {
|
|
|
9bac43 |
typedef struct InternalSnapshotState {
|
|
|
9bac43 |
BlkActionState common;
|
|
|
9bac43 |
BlockDriverState *bs;
|
|
|
9bac43 |
- AioContext *aio_context;
|
|
|
9bac43 |
QEMUSnapshotInfo sn;
|
|
|
9bac43 |
bool created;
|
|
|
9bac43 |
} InternalSnapshotState;
|
|
|
9bac43 |
@@ -1528,6 +1527,7 @@ static void internal_snapshot_prepare(BlkActionState *common,
|
|
|
9bac43 |
qemu_timeval tv;
|
|
|
9bac43 |
BlockdevSnapshotInternal *internal;
|
|
|
9bac43 |
InternalSnapshotState *state;
|
|
|
9bac43 |
+ AioContext *aio_context;
|
|
|
9bac43 |
int ret1;
|
|
|
9bac43 |
|
|
|
9bac43 |
g_assert(common->action->type ==
|
|
|
9bac43 |
@@ -1549,32 +1549,33 @@ static void internal_snapshot_prepare(BlkActionState *common,
|
|
|
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 |
state->bs = bs;
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ /* Paired with .clean() */
|
|
|
9bac43 |
bdrv_drained_begin(bs);
|
|
|
9bac43 |
|
|
|
9bac43 |
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_INTERNAL_SNAPSHOT, errp)) {
|
|
|
9bac43 |
- return;
|
|
|
9bac43 |
+ goto out;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
if (bdrv_is_read_only(bs)) {
|
|
|
9bac43 |
error_setg(errp, "Device '%s' is read only", device);
|
|
|
9bac43 |
- return;
|
|
|
9bac43 |
+ goto out;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
if (!bdrv_can_snapshot(bs)) {
|
|
|
9bac43 |
error_setg(errp, "Block format '%s' used by device '%s' "
|
|
|
9bac43 |
"does not support internal snapshots",
|
|
|
9bac43 |
bs->drv->format_name, device);
|
|
|
9bac43 |
- return;
|
|
|
9bac43 |
+ goto out;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
if (!strlen(name)) {
|
|
|
9bac43 |
error_setg(errp, "Name is empty");
|
|
|
9bac43 |
- return;
|
|
|
9bac43 |
+ goto out;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
/* check whether a snapshot with name exist */
|
|
|
9bac43 |
@@ -1582,12 +1583,12 @@ static void internal_snapshot_prepare(BlkActionState *common,
|
|
|
9bac43 |
&local_err);
|
|
|
9bac43 |
if (local_err) {
|
|
|
9bac43 |
error_propagate(errp, local_err);
|
|
|
9bac43 |
- return;
|
|
|
9bac43 |
+ goto out;
|
|
|
9bac43 |
} else if (ret) {
|
|
|
9bac43 |
error_setg(errp,
|
|
|
9bac43 |
"Snapshot with name '%s' already exists on device '%s'",
|
|
|
9bac43 |
name, device);
|
|
|
9bac43 |
- return;
|
|
|
9bac43 |
+ goto out;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
/* 3. take the snapshot */
|
|
|
9bac43 |
@@ -1603,11 +1604,14 @@ static void internal_snapshot_prepare(BlkActionState *common,
|
|
|
9bac43 |
error_setg_errno(errp, -ret1,
|
|
|
9bac43 |
"Failed to create snapshot '%s' on device '%s'",
|
|
|
9bac43 |
name, device);
|
|
|
9bac43 |
- return;
|
|
|
9bac43 |
+ goto out;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
/* 4. succeed, mark a snapshot is created */
|
|
|
9bac43 |
state->created = true;
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+out:
|
|
|
9bac43 |
+ aio_context_release(aio_context);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
static void internal_snapshot_abort(BlkActionState *common)
|
|
|
9bac43 |
@@ -1616,12 +1620,16 @@ static void internal_snapshot_abort(BlkActionState *common)
|
|
|
9bac43 |
DO_UPCAST(InternalSnapshotState, common, common);
|
|
|
9bac43 |
BlockDriverState *bs = state->bs;
|
|
|
9bac43 |
QEMUSnapshotInfo *sn = &state->sn;
|
|
|
9bac43 |
+ AioContext *aio_context;
|
|
|
9bac43 |
Error *local_error = NULL;
|
|
|
9bac43 |
|
|
|
9bac43 |
if (!state->created) {
|
|
|
9bac43 |
return;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
+ aio_context = bdrv_get_aio_context(state->bs);
|
|
|
9bac43 |
+ aio_context_acquire(aio_context);
|
|
|
9bac43 |
+
|
|
|
9bac43 |
if (bdrv_snapshot_delete(bs, sn->id_str, sn->name, &local_error) < 0) {
|
|
|
9bac43 |
error_reportf_err(local_error,
|
|
|
9bac43 |
"Failed to delete snapshot with id '%s' and "
|
|
|
9bac43 |
@@ -1629,19 +1637,26 @@ static void internal_snapshot_abort(BlkActionState *common)
|
|
|
9bac43 |
sn->id_str, sn->name,
|
|
|
9bac43 |
bdrv_get_device_name(bs));
|
|
|
9bac43 |
}
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ aio_context_release(aio_context);
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
static void internal_snapshot_clean(BlkActionState *common)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
InternalSnapshotState *state = DO_UPCAST(InternalSnapshotState,
|
|
|
9bac43 |
common, common);
|
|
|
9bac43 |
+ AioContext *aio_context;
|
|
|
9bac43 |
|
|
|
9bac43 |
- if (state->aio_context) {
|
|
|
9bac43 |
- if (state->bs) {
|
|
|
9bac43 |
- bdrv_drained_end(state->bs);
|
|
|
9bac43 |
- }
|
|
|
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 |
/* external snapshot private data */
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|