[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/17] mirror: auto complete active commit
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 10/17] mirror: auto complete active commit |
Date: |
Mon, 12 Sep 2016 15:08:47 +0100 |
From: Wen Congyang <address@hidden>
Auto complete mirror job in background to prevent from
blocking synchronously
Signed-off-by: Wen Congyang <address@hidden>
Signed-off-by: Changlong Xie <address@hidden>
Signed-off-by: Wang WeiWei <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/mirror.c | 13 +++++++++----
blockdev.c | 2 +-
include/block/block_int.h | 3 ++-
qemu-img.c | 2 +-
4 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
index e0b3f41..f9d1fec 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -916,7 +916,8 @@ static void mirror_start_job(const char *job_id,
BlockDriverState *bs,
BlockCompletionFunc *cb,
void *opaque, Error **errp,
const BlockJobDriver *driver,
- bool is_none_mode, BlockDriverState *base)
+ bool is_none_mode, BlockDriverState *base,
+ bool auto_complete)
{
MirrorBlockJob *s;
@@ -952,6 +953,9 @@ static void mirror_start_job(const char *job_id,
BlockDriverState *bs,
s->granularity = granularity;
s->buf_size = ROUND_UP(buf_size, granularity);
s->unmap = unmap;
+ if (auto_complete) {
+ s->should_complete = true;
+ }
s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp);
if (!s->dirty_bitmap) {
@@ -990,14 +994,15 @@ void mirror_start(const char *job_id, BlockDriverState
*bs,
mirror_start_job(job_id, bs, target, replaces,
speed, granularity, buf_size, backing_mode,
on_source_error, on_target_error, unmap, cb, opaque, errp,
- &mirror_job_driver, is_none_mode, base);
+ &mirror_job_driver, is_none_mode, base, false);
}
void commit_active_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *base, int64_t speed,
BlockdevOnError on_error,
BlockCompletionFunc *cb,
- void *opaque, Error **errp)
+ void *opaque, Error **errp,
+ bool auto_complete)
{
int64_t length, base_length;
int orig_base_flags;
@@ -1038,7 +1043,7 @@ void commit_active_start(const char *job_id,
BlockDriverState *bs,
mirror_start_job(job_id, bs, base, NULL, speed, 0, 0,
MIRROR_LEAVE_BACKING_CHAIN,
on_error, on_error, false, cb, opaque, &local_err,
- &commit_active_job_driver, false, base);
+ &commit_active_job_driver, false, base, auto_complete);
if (local_err) {
error_propagate(errp, local_err);
goto error_restore_flags;
diff --git a/blockdev.c b/blockdev.c
index 97062e3..1399fbd 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3090,7 +3090,7 @@ void qmp_block_commit(bool has_job_id, const char
*job_id, const char *device,
goto out;
}
commit_active_start(has_job_id ? job_id : NULL, bs, base_bs, speed,
- on_error, block_job_cb, bs, &local_err);
+ on_error, block_job_cb, bs, &local_err, false);
} else {
commit_start(has_job_id ? job_id : NULL, bs, base_bs, top_bs, speed,
on_error, block_job_cb, bs,
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 0ca6a78..713cea6 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -702,13 +702,14 @@ void commit_start(const char *job_id, BlockDriverState
*bs,
* @cb: Completion function for the job.
* @opaque: Opaque pointer value passed to @cb.
* @errp: Error object.
+ * @auto_complete: Auto complete the job.
*
*/
void commit_active_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *base, int64_t speed,
BlockdevOnError on_error,
BlockCompletionFunc *cb,
- void *opaque, Error **errp);
+ void *opaque, Error **errp, bool auto_complete);
/*
* mirror_start:
* @job_id: The id of the newly-created job, or %NULL to use the
diff --git a/qemu-img.c b/qemu-img.c
index 1090286..ea52486 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -921,7 +921,7 @@ static int img_commit(int argc, char **argv)
};
commit_active_start("commit", bs, base_bs, 0, BLOCKDEV_ON_ERROR_REPORT,
- common_block_job_cb, &cbi, &local_err);
+ common_block_job_cb, &cbi, &local_err, false);
if (local_err) {
goto done;
}
--
2.7.4
- [Qemu-devel] [PULL 00/17] Block patches, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 01/17] linux-aio: consume events in userspace instead of calling io_getevents, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 02/17] linux-aio: split processing events function, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 04/17] virtio-blk: rename virtio_device_info to virtio_blk_info, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 03/17] linux-aio: process completions from ioq_submit(), Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 05/17] block: unblock backup operations in backing file, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 06/17] Backup: clear all bitmap when doing block checkpoint, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 07/17] Backup: export interfaces for extra serialization, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 09/17] docs: block replication's description, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 08/17] block: Link backup into block core, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 10/17] mirror: auto complete active commit,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 11/17] configure: support replication, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 12/17] replication: Introduce new APIs to do replication operation, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 14/17] tests: add unit test case for replication, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 13/17] replication: Implement new driver for block replication, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 15/17] support replication driver in blockdev-add, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 16/17] MAINTAINERS: add maintainer for replication, Stefan Hajnoczi, 2016/09/12
- [Qemu-devel] [PULL 17/17] tests: fix qvirtqueue_kick, Stefan Hajnoczi, 2016/09/12
- Re: [Qemu-devel] [PULL 00/17] Block patches, Peter Maydell, 2016/09/12