[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v20 06/10] auto complete active commit
From: |
Changlong Xie |
Subject: |
[Qemu-devel] [PATCH v20 06/10] auto complete active commit |
Date: |
Wed, 8 Jun 2016 09:11:28 +0800 |
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>
---
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 80fd3c7..40fad19 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -805,7 +805,8 @@ static void mirror_start_job(BlockDriverState *bs,
BlockDriverState *target,
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;
@@ -840,6 +841,9 @@ static void mirror_start_job(BlockDriverState *bs,
BlockDriverState *target,
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) {
@@ -877,14 +881,15 @@ void mirror_start(BlockDriverState *bs, BlockDriverState
*target,
mirror_start_job(bs, target, replaces,
speed, granularity, buf_size,
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(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;
@@ -924,7 +929,7 @@ void commit_active_start(BlockDriverState *bs,
BlockDriverState *base,
mirror_start_job(bs, base, NULL, speed, 0, 0,
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 717785e..734bfb0 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3155,7 +3155,7 @@ void qmp_block_commit(const char *device,
goto out;
}
commit_active_start(bs, base_bs, speed, on_error, block_job_cb,
- bs, &local_err);
+ bs, &local_err, false);
} else {
commit_start(bs, base_bs, top_bs, speed, on_error, block_job_cb, bs,
has_backing_file ? backing_file : NULL, &local_err);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 30a9717..89b66e8 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -653,13 +653,14 @@ void commit_start(BlockDriverState *bs, BlockDriverState
*base,
* @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(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:
* @bs: Block device to operate on.
diff --git a/qemu-img.c b/qemu-img.c
index 4b56ad3..e6a480f 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -911,7 +911,7 @@ static int img_commit(int argc, char **argv)
};
commit_active_start(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;
}
--
1.9.3
- [Qemu-devel] [PATCH v20 01/10] unblock backup operations in backing file, (continued)
- [Qemu-devel] [PATCH v20 01/10] unblock backup operations in backing file, Changlong Xie, 2016/06/07
- [Qemu-devel] [PATCH v20 02/10] Backup: clear all bitmap when doing block checkpoint, Changlong Xie, 2016/06/07
- [Qemu-devel] [PATCH v20 04/10] Link backup into block core, Changlong Xie, 2016/06/07
- [Qemu-devel] [PATCH v20 05/10] docs: block replication's description, Changlong Xie, 2016/06/07
- [Qemu-devel] [PATCH v20 03/10] Backup: export interfaces for extra serialization, Changlong Xie, 2016/06/07
- [Qemu-devel] [PATCH v20 07/10] Introduce new APIs to do replication operation, Changlong Xie, 2016/06/07
- [Qemu-devel] [PATCH v20 09/10] tests: add unit test case for replication, Changlong Xie, 2016/06/07
- [Qemu-devel] [PATCH v20 10/10] support replication driver in blockdev-add, Changlong Xie, 2016/06/07
- [Qemu-devel] [PATCH v20 06/10] auto complete active commit,
Changlong Xie <=
- [Qemu-devel] [PATCH v20 08/10] Implement new driver for block replication, Changlong Xie, 2016/06/07
- Re: [Qemu-devel] [PATCH v20 00/10] Block replication for continuous checkpoints, Eric Blake, 2016/06/08
- Re: [Qemu-devel] [PATCH v20 00/10] Block replication for continuous checkpoints, Michael Tokarev, 2016/06/10