|
|
7711c0 |
From 68dbabe0167538bcf3996692b3dc3dce01e34f74 Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Date: Thu, 24 Jan 2019 00:55:10 +0100
|
|
|
7711c0 |
Subject: [PATCH 5/8] blockdev: abort transactions in reverse order
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Message-id: <20190124005511.27662-2-jsnow@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 84105
|
|
|
7711c0 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 1/2] blockdev: abort transactions in reverse order
|
|
|
7711c0 |
Bugzilla: 1658426
|
|
|
7711c0 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Presently, we abort transactions in the same order they were processed in.
|
|
|
7711c0 |
Bitmap commands, though, attempt to restore backup data structures on abort.
|
|
|
7711c0 |
|
|
|
7711c0 |
That's not valid, they need to be aborted in reverse chronological order.
|
|
|
7711c0 |
|
|
|
7711c0 |
Replace the QSIMPLEQ data structure with a QTAILQ one, so we can iterate
|
|
|
7711c0 |
in reverse for the abort phase of the transaction.
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
7711c0 |
Message-Id: <20181221093529.23855-2-jsnow@redhat.com>
|
|
|
7711c0 |
[eblake: rebase]
|
|
|
7711c0 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit f4de0f8c40b70c4c9308b4670e0a6ad9faed0262)
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
blockdev.c | 14 +++++++-------
|
|
|
7711c0 |
1 file changed, 7 insertions(+), 7 deletions(-)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
7711c0 |
index 3eb1880..f25ab15 100644
|
|
|
7711c0 |
--- a/blockdev.c
|
|
|
7711c0 |
+++ b/blockdev.c
|
|
|
7711c0 |
@@ -1491,7 +1491,7 @@ struct BlkActionState {
|
|
|
7711c0 |
const BlkActionOps *ops;
|
|
|
7711c0 |
JobTxn *block_job_txn;
|
|
|
7711c0 |
TransactionProperties *txn_props;
|
|
|
7711c0 |
- QSIMPLEQ_ENTRY(BlkActionState) entry;
|
|
|
7711c0 |
+ QTAILQ_ENTRY(BlkActionState) entry;
|
|
|
7711c0 |
};
|
|
|
7711c0 |
|
|
|
7711c0 |
/* internal snapshot private data */
|
|
|
7711c0 |
@@ -2376,8 +2376,8 @@ void qmp_transaction(TransactionActionList *dev_list,
|
|
|
7711c0 |
BlkActionState *state, *next;
|
|
|
7711c0 |
Error *local_err = NULL;
|
|
|
7711c0 |
|
|
|
7711c0 |
- QSIMPLEQ_HEAD(snap_bdrv_states, BlkActionState) snap_bdrv_states;
|
|
|
7711c0 |
- QSIMPLEQ_INIT(&snap_bdrv_states);
|
|
|
7711c0 |
+ QTAILQ_HEAD(snap_bdrv_states, BlkActionState) snap_bdrv_states;
|
|
|
7711c0 |
+ QTAILQ_INIT(&snap_bdrv_states);
|
|
|
7711c0 |
|
|
|
7711c0 |
/* Does this transaction get canceled as a group on failure?
|
|
|
7711c0 |
* If not, we don't really need to make a JobTxn.
|
|
|
7711c0 |
@@ -2408,7 +2408,7 @@ void qmp_transaction(TransactionActionList *dev_list,
|
|
|
7711c0 |
state->action = dev_info;
|
|
|
7711c0 |
state->block_job_txn = block_job_txn;
|
|
|
7711c0 |
state->txn_props = props;
|
|
|
7711c0 |
- QSIMPLEQ_INSERT_TAIL(&snap_bdrv_states, state, entry);
|
|
|
7711c0 |
+ QTAILQ_INSERT_TAIL(&snap_bdrv_states, state, entry);
|
|
|
7711c0 |
|
|
|
7711c0 |
state->ops->prepare(state, &local_err);
|
|
|
7711c0 |
if (local_err) {
|
|
|
7711c0 |
@@ -2417,7 +2417,7 @@ void qmp_transaction(TransactionActionList *dev_list,
|
|
|
7711c0 |
}
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
- QSIMPLEQ_FOREACH(state, &snap_bdrv_states, entry) {
|
|
|
7711c0 |
+ QTAILQ_FOREACH(state, &snap_bdrv_states, entry) {
|
|
|
7711c0 |
if (state->ops->commit) {
|
|
|
7711c0 |
state->ops->commit(state);
|
|
|
7711c0 |
}
|
|
|
7711c0 |
@@ -2428,13 +2428,13 @@ void qmp_transaction(TransactionActionList *dev_list,
|
|
|
7711c0 |
|
|
|
7711c0 |
delete_and_fail:
|
|
|
7711c0 |
/* failure, and it is all-or-none; roll back all operations */
|
|
|
7711c0 |
- QSIMPLEQ_FOREACH(state, &snap_bdrv_states, entry) {
|
|
|
7711c0 |
+ QTAILQ_FOREACH_REVERSE(state, &snap_bdrv_states, snap_bdrv_states, entry) {
|
|
|
7711c0 |
if (state->ops->abort) {
|
|
|
7711c0 |
state->ops->abort(state);
|
|
|
7711c0 |
}
|
|
|
7711c0 |
}
|
|
|
7711c0 |
exit:
|
|
|
7711c0 |
- QSIMPLEQ_FOREACH_SAFE(state, &snap_bdrv_states, entry, next) {
|
|
|
7711c0 |
+ QTAILQ_FOREACH_SAFE(state, &snap_bdrv_states, entry, next) {
|
|
|
7711c0 |
if (state->ops->clean) {
|
|
|
7711c0 |
state->ops->clean(state);
|
|
|
7711c0 |
}
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|