[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 09/23] block: don't keep AioContext acquired after
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL v2 09/23] block: don't keep AioContext acquired after drive_backup_prepare() |
Date: |
Tue, 19 Dec 2017 15:11:30 +0000 |
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
blockdev.c | 42 ++++++++++++++++++++++++++++++++++--------
1 file changed, 34 insertions(+), 8 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 3b598f8f0e..5a56a1abf2 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1845,7 +1845,6 @@ static void external_snapshot_clean(BlkActionState
*common)
typedef struct DriveBackupState {
BlkActionState common;
BlockDriverState *bs;
- AioContext *aio_context;
BlockJob *job;
} DriveBackupState;
@@ -1857,6 +1856,7 @@ static void drive_backup_prepare(BlkActionState *common,
Error **errp)
DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
BlockDriverState *bs;
DriveBackup *backup;
+ AioContext *aio_context;
Error *local_err = NULL;
assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP);
@@ -1867,24 +1867,36 @@ static void drive_backup_prepare(BlkActionState
*common, Error **errp)
return;
}
- /* AioContext is released in .clean() */
- state->aio_context = bdrv_get_aio_context(bs);
- aio_context_acquire(state->aio_context);
+ aio_context = bdrv_get_aio_context(bs);
+ aio_context_acquire(aio_context);
+
+ /* Paired with .clean() */
bdrv_drained_begin(bs);
+
state->bs = bs;
state->job = do_drive_backup(backup, common->block_job_txn, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- return;
+ goto out;
}
+
+out:
+ aio_context_release(aio_context);
}
static void drive_backup_commit(BlkActionState *common)
{
DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
+ AioContext *aio_context;
+
+ aio_context = bdrv_get_aio_context(state->bs);
+ aio_context_acquire(aio_context);
+
assert(state->job);
block_job_start(state->job);
+
+ aio_context_release(aio_context);
}
static void drive_backup_abort(BlkActionState *common)
@@ -1892,18 +1904,32 @@ static void drive_backup_abort(BlkActionState *common)
DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
if (state->job) {
+ AioContext *aio_context;
+
+ aio_context = bdrv_get_aio_context(state->bs);
+ aio_context_acquire(aio_context);
+
block_job_cancel_sync(state->job);
+
+ aio_context_release(aio_context);
}
}
static void drive_backup_clean(BlkActionState *common)
{
DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common);
+ AioContext *aio_context;
- if (state->aio_context) {
- bdrv_drained_end(state->bs);
- aio_context_release(state->aio_context);
+ if (!state->bs) {
+ return;
}
+
+ aio_context = bdrv_get_aio_context(state->bs);
+ aio_context_acquire(aio_context);
+
+ bdrv_drained_end(state->bs);
+
+ aio_context_release(aio_context);
}
typedef struct BlockdevBackupState {
--
2.14.3
- [Qemu-devel] [PULL v2 01/23] coroutine: simplify co_aio_sleep_ns() prototype, (continued)
- [Qemu-devel] [PULL v2 01/23] coroutine: simplify co_aio_sleep_ns() prototype, Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 02/23] hw/block/nvme: Convert to realize, Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 03/23] hw/block: Fix the return type, Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 04/23] hw/block: Use errp directly rather than local_err, Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 05/23] dev-storage: Fix the unusual function name, Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 06/23] qdev: drop unused #include "sysemu/iothread.h", Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 07/23] blockdev: hold AioContext for bdrv_unref() in external_snapshot_clean(), Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 08/23] block: don't keep AioContext acquired after external_snapshot_prepare(), Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 10/23] block: don't keep AioContext acquired after blockdev_backup_prepare(), Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 11/23] block: don't keep AioContext acquired after internal_snapshot_prepare(), Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 09/23] block: don't keep AioContext acquired after drive_backup_prepare(),
Stefan Hajnoczi <=
- [Qemu-devel] [PULL v2 12/23] block: drop unused BlockDirtyBitmapState->aio_context field, Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 13/23] iothread: add iothread_by_id() API, Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 14/23] blockdev: add x-blockdev-set-iothread testing command, Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 15/23] qemu-iotests: add 202 external snapshots IOThread test, Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 18/23] block: avoid recursive AioContext acquire in bdrv_inactivate_all(), Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 16/23] virtio-blk: make queue size configurable, Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 17/23] virtio-blk: reject configs with logical block size > physical block size, Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 20/23] blockdev: add x-blockdev-set-iothread force boolean, Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 19/23] docs: mark nested AioContext locking as a legacy API, Stefan Hajnoczi, 2017/12/19
- [Qemu-devel] [PULL v2 21/23] iotests: add VM.add_object(), Stefan Hajnoczi, 2017/12/19