From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
Kevin Wolf <kwolf@redhat.com>, John Snow <jsnow@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Jeff Cody <jcody@redhat.com>
Subject: [Qemu-devel] [PATCH v5 13/14] block/mirror: Add copy mode QAPI interface
Date: Wed, 13 Jun 2018 20:18:22 +0200 [thread overview]
Message-ID: <20180613181823.13618-14-mreitz@redhat.com> (raw)
In-Reply-To: <20180613181823.13618-1-mreitz@redhat.com>
This patch allows the user to specify whether to use active or only
background mode for mirror block jobs. Currently, this setting will
remain constant for the duration of the entire block job.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
---
qapi/block-core.json | 11 +++++++++--
include/block/block_int.h | 4 +++-
block/mirror.c | 12 +++++++-----
blockdev.c | 9 ++++++++-
4 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 11b55530b3..8fbee5ee54 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1710,6 +1710,9 @@
# written. Both will result in identical contents.
# Default is true. (Since 2.4)
#
+# @copy-mode: when to copy data to the destination; defaults to 'background'
+# (Since: 3.0)
+#
# Since: 1.3
##
{ 'struct': 'DriveMirror',
@@ -1719,7 +1722,7 @@
'*speed': 'int', '*granularity': 'uint32',
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
'*on-target-error': 'BlockdevOnError',
- '*unmap': 'bool' } }
+ '*unmap': 'bool', '*copy-mode': 'MirrorCopyMode' } }
##
# @BlockDirtyBitmap:
@@ -1982,6 +1985,9 @@
# above @device. If this option is not given, a node name is
# autogenerated. (Since: 2.9)
#
+# @copy-mode: when to copy data to the destination; defaults to 'background'
+# (Since: 3.0)
+#
# Returns: nothing on success.
#
# Since: 2.6
@@ -2002,7 +2008,8 @@
'*speed': 'int', '*granularity': 'uint32',
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
'*on-target-error': 'BlockdevOnError',
- '*filter-node-name': 'str' } }
+ '*filter-node-name': 'str',
+ '*copy-mode': 'MirrorCopyMode' } }
##
# @block_set_io_throttle:
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 327e478a73..fe9950f019 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -1017,6 +1017,7 @@ void commit_active_start(const char *job_id, BlockDriverState *bs,
* @filter_node_name: The node name that should be assigned to the filter
* driver that the mirror job inserts into the graph above @bs. NULL means that
* a node name should be autogenerated.
+ * @copy_mode: When to trigger writes to the target.
* @errp: Error object.
*
* Start a mirroring operation on @bs. Clusters that are allocated
@@ -1030,7 +1031,8 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
MirrorSyncMode mode, BlockMirrorBackingMode backing_mode,
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
- bool unmap, const char *filter_node_name, Error **errp);
+ bool unmap, const char *filter_node_name,
+ MirrorCopyMode copy_mode, Error **errp);
/*
* backup_job_create:
diff --git a/block/mirror.c b/block/mirror.c
index b58d7bbce1..f0c0003d47 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1465,7 +1465,7 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs,
const BlockJobDriver *driver,
bool is_none_mode, BlockDriverState *base,
bool auto_complete, const char *filter_node_name,
- bool is_mirror,
+ bool is_mirror, MirrorCopyMode copy_mode,
Error **errp)
{
MirrorBlockJob *s;
@@ -1573,7 +1573,7 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs,
s->on_target_error = on_target_error;
s->is_none_mode = is_none_mode;
s->backing_mode = backing_mode;
- s->copy_mode = MIRROR_COPY_MODE_BACKGROUND;
+ s->copy_mode = copy_mode;
s->base = base;
s->granularity = granularity;
s->buf_size = ROUND_UP(buf_size, granularity);
@@ -1640,7 +1640,8 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
MirrorSyncMode mode, BlockMirrorBackingMode backing_mode,
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
- bool unmap, const char *filter_node_name, Error **errp)
+ bool unmap, const char *filter_node_name,
+ MirrorCopyMode copy_mode, Error **errp)
{
bool is_none_mode;
BlockDriverState *base;
@@ -1655,7 +1656,7 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
speed, granularity, buf_size, backing_mode,
on_source_error, on_target_error, unmap, NULL, NULL,
&mirror_job_driver, is_none_mode, base, false,
- filter_node_name, true, errp);
+ filter_node_name, true, copy_mode, errp);
}
void commit_active_start(const char *job_id, BlockDriverState *bs,
@@ -1678,7 +1679,8 @@ void commit_active_start(const char *job_id, BlockDriverState *bs,
MIRROR_LEAVE_BACKING_CHAIN,
on_error, on_error, true, cb, opaque,
&commit_active_job_driver, false, base, auto_complete,
- filter_node_name, false, &local_err);
+ filter_node_name, false, MIRROR_COPY_MODE_BACKGROUND,
+ &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto error_restore_flags;
diff --git a/blockdev.c b/blockdev.c
index 4862323012..51536e0d6e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3695,6 +3695,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
bool has_unmap, bool unmap,
bool has_filter_node_name,
const char *filter_node_name,
+ bool has_copy_mode, MirrorCopyMode copy_mode,
Error **errp)
{
@@ -3719,6 +3720,9 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
if (!has_filter_node_name) {
filter_node_name = NULL;
}
+ if (!has_copy_mode) {
+ copy_mode = MIRROR_COPY_MODE_BACKGROUND;
+ }
if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
@@ -3749,7 +3753,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
has_replaces ? replaces : NULL,
speed, granularity, buf_size, sync, backing_mode,
on_source_error, on_target_error, unmap, filter_node_name,
- errp);
+ copy_mode, errp);
}
void qmp_drive_mirror(DriveMirror *arg, Error **errp)
@@ -3895,6 +3899,7 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
arg->has_on_target_error, arg->on_target_error,
arg->has_unmap, arg->unmap,
false, NULL,
+ arg->has_copy_mode, arg->copy_mode,
&local_err);
bdrv_unref(target_bs);
error_propagate(errp, local_err);
@@ -3915,6 +3920,7 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
BlockdevOnError on_target_error,
bool has_filter_node_name,
const char *filter_node_name,
+ bool has_copy_mode, MirrorCopyMode copy_mode,
Error **errp)
{
BlockDriverState *bs;
@@ -3947,6 +3953,7 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
has_on_target_error, on_target_error,
true, true,
has_filter_node_name, filter_node_name,
+ has_copy_mode, copy_mode,
&local_err);
error_propagate(errp, local_err);
--
2.17.1
next prev parent reply other threads:[~2018-06-13 18:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-13 18:18 [Qemu-devel] [PATCH v5 00/14] block/mirror: Add active-sync mirroring Max Reitz
2018-06-13 18:18 ` [Qemu-devel] [PATCH v5 01/14] block/mirror: Pull out mirror_perform() Max Reitz
2018-06-13 18:18 ` [Qemu-devel] [PATCH v5 02/14] block/mirror: Convert to coroutines Max Reitz
2018-06-14 15:22 ` Kevin Wolf
2018-06-18 14:03 ` Max Reitz
2018-06-13 18:18 ` [Qemu-devel] [PATCH v5 03/14] block/mirror: Use CoQueue to wait on in-flight ops Max Reitz
2018-06-13 18:18 ` [Qemu-devel] [PATCH v5 04/14] block/mirror: Wait for in-flight op conflicts Max Reitz
2018-06-13 18:18 ` [Qemu-devel] [PATCH v5 05/14] block/mirror: Use source as a BdrvChild Max Reitz
2018-06-13 18:18 ` [Qemu-devel] [PATCH v5 06/14] block: Generalize should_update_child() rule Max Reitz
2018-06-13 18:18 ` [Qemu-devel] [PATCH v5 07/14] hbitmap: Add @advance param to hbitmap_iter_next() Max Reitz
2018-06-13 18:18 ` [Qemu-devel] [PATCH v5 08/14] test-hbitmap: Add non-advancing iter_next tests Max Reitz
2018-06-13 18:18 ` [Qemu-devel] [PATCH v5 09/14] block/dirty-bitmap: Add bdrv_dirty_iter_next_area Max Reitz
2018-06-13 18:18 ` [Qemu-devel] [PATCH v5 10/14] block/mirror: Add MirrorBDSOpaque Max Reitz
2018-06-13 18:18 ` [Qemu-devel] [PATCH v5 11/14] job: Add job_progress_increase_remaining() Max Reitz
2018-06-14 15:50 ` Kevin Wolf
2018-06-13 18:18 ` [Qemu-devel] [PATCH v5 12/14] block/mirror: Add active mirroring Max Reitz
2018-06-13 18:18 ` Max Reitz [this message]
2018-06-13 18:18 ` [Qemu-devel] [PATCH v5 14/14] iotests: Add test for " Max Reitz
2018-06-18 15:11 ` [Qemu-devel] [PATCH v5 00/14] block/mirror: Add active-sync mirroring Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180613181823.13618-14-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).