[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 33/37] block: Add "drained begin/end" for transaction
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 33/37] block: Add "drained begin/end" for transactional external snapshot |
Date: |
Fri, 23 Oct 2015 19:01:20 +0200 |
From: Fam Zheng <address@hidden>
This ensures the atomicity of the transaction by avoiding processing of
external requests such as those from ioeventfd.
Signed-off-by: Fam Zheng <address@hidden>
Reviewed-by: Jeff Cody <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
blockdev.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 35e5719..e4a5eb4 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1569,6 +1569,7 @@ static void external_snapshot_prepare(BlkTransactionState
*common,
/* Acquire AioContext now so any threads operating on old_bs stop */
state->aio_context = bdrv_get_aio_context(state->old_bs);
aio_context_acquire(state->aio_context);
+ bdrv_drained_begin(state->old_bs);
if (!bdrv_is_inserted(state->old_bs)) {
error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
@@ -1638,8 +1639,6 @@ static void external_snapshot_commit(BlkTransactionState
*common)
* don't want to abort all of them if one of them fails the reopen */
bdrv_reopen(state->old_bs, state->old_bs->open_flags & ~BDRV_O_RDWR,
NULL);
-
- aio_context_release(state->aio_context);
}
static void external_snapshot_abort(BlkTransactionState *common)
@@ -1649,7 +1648,14 @@ static void external_snapshot_abort(BlkTransactionState
*common)
if (state->new_bs) {
bdrv_unref(state->new_bs);
}
+}
+
+static void external_snapshot_clean(BlkTransactionState *common)
+{
+ ExternalSnapshotState *state =
+ DO_UPCAST(ExternalSnapshotState, common, common);
if (state->aio_context) {
+ bdrv_drained_end(state->old_bs);
aio_context_release(state->aio_context);
}
}
@@ -1809,6 +1815,7 @@ static const BdrvActionOps actions[] = {
.prepare = external_snapshot_prepare,
.commit = external_snapshot_commit,
.abort = external_snapshot_abort,
+ .clean = external_snapshot_clean,
},
[TRANSACTION_ACTION_KIND_DRIVE_BACKUP] = {
.instance_size = sizeof(DriveBackupState),
--
1.8.3.1
- [Qemu-block] [PULL 25/37] blockdev: Pull out blockdev option extraction, (continued)
- [Qemu-block] [PULL 25/37] blockdev: Pull out blockdev option extraction, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 31/37] aio: introduce aio_{disable, enable}_external, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 32/37] block: Introduce "drained begin/end" API, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 29/37] nbd: Mark fd handlers client type as "external", Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 36/37] block: Add "drained begin/end" for internal snapshot, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 30/37] dataplane: Mark host notifiers' client type as "external", Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 28/37] aio: Add "is_external" flag for event handlers, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 34/37] block: Add "drained begin/end" for transactional backup, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 37/37] tests: Add test case for aio_disable_external, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 35/37] block: Add "drained begin/end" for transactional blockdev-backup, Kevin Wolf, 2015/10/23
- [Qemu-block] [PULL 33/37] block: Add "drained begin/end" for transactional external snapshot,
Kevin Wolf <=
- Re: [Qemu-block] [Qemu-devel] [PULL 00/37] Block layer patches, Peter Maydell, 2015/10/26