Blame SOURCES/kvm-blockdev-abort-transactions-in-reverse-order.patch

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