[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 5/7] mirror: Only mirror granularity-aligned chunks
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PULL 5/7] mirror: Only mirror granularity-aligned chunks |
Date: |
Mon, 5 Aug 2019 18:37:38 +0200 |
In write-blocking mode, all writes to the top node directly go to the
target. We must only mirror chunks of data that are aligned to the
job's granularity, because that is how the dirty bitmap works.
Therefore, the request alignment for writes must be the job's
granularity (in write-blocking mode).
Unfortunately, this forces all reads and writes to have the same
granularity (we only need this alignment for writes to the target, not
the source), but that is something to be fixed another time.
Cc: address@hidden
Signed-off-by: Max Reitz <address@hidden>
Message-id: address@hidden
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Fixes: d06107ade0ce74dc39739bac80de84b51ec18546
Signed-off-by: Max Reitz <address@hidden>
---
block/mirror.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/block/mirror.c b/block/mirror.c
index 8cb75fb409..9f5c59ece1 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1481,6 +1481,15 @@ static void bdrv_mirror_top_child_perm(BlockDriverState
*bs, BdrvChild *c,
*nshared = BLK_PERM_ALL;
}
+static void bdrv_mirror_top_refresh_limits(BlockDriverState *bs, Error **errp)
+{
+ MirrorBDSOpaque *s = bs->opaque;
+
+ if (s && s->job && s->job->copy_mode == MIRROR_COPY_MODE_WRITE_BLOCKING) {
+ bs->bl.request_alignment = s->job->granularity;
+ }
+}
+
/* Dummy node that provides consistent read to its users without requiring it
* from its backing file and that allows writes on the backing file chain. */
static BlockDriver bdrv_mirror_top = {
@@ -1493,6 +1502,7 @@ static BlockDriver bdrv_mirror_top = {
.bdrv_co_block_status = bdrv_co_block_status_from_backing,
.bdrv_refresh_filename = bdrv_mirror_top_refresh_filename,
.bdrv_child_perm = bdrv_mirror_top_child_perm,
+ .bdrv_refresh_limits = bdrv_mirror_top_refresh_limits,
};
static BlockJob *mirror_start_job(
@@ -1637,6 +1647,25 @@ static BlockJob *mirror_start_job(
s->should_complete = true;
}
+ /*
+ * Must be called before we start tracking writes, but after
+ *
+ * ((MirrorBlockJob *)
+ * ((MirrorBDSOpaque *)
+ * mirror_top_bs->opaque
+ * )->job
+ * )->copy_mode
+ *
+ * has the correct value.
+ * (We start tracking writes as of the following
+ * bdrv_create_dirty_bitmap() call.)
+ */
+ bdrv_refresh_limits(mirror_top_bs, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ goto fail;
+ }
+
s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp);
if (!s->dirty_bitmap) {
goto fail;
--
2.21.0
- [Qemu-devel] [PULL 0/7] Block patches for 4.1.0-rc4, Max Reitz, 2019/08/05
- [Qemu-devel] [PULL 1/7] backup: Copy only dirty areas, Max Reitz, 2019/08/05
- [Qemu-devel] [PULL 2/7] iotests: Test backup job with two guest writes, Max Reitz, 2019/08/05
- [Qemu-devel] [PULL 3/7] util/hbitmap: update orig_size on truncate, Max Reitz, 2019/08/05
- [Qemu-devel] [PULL 4/7] iotests: Test incremental backup after truncation, Max Reitz, 2019/08/05
- [Qemu-devel] [PULL 5/7] mirror: Only mirror granularity-aligned chunks,
Max Reitz <=
- [Qemu-devel] [PULL 6/7] iotests: Test unaligned blocking mirror write, Max Reitz, 2019/08/05
- [Qemu-devel] [PULL 7/7] block/backup: disable copy_range for compressed backup, Max Reitz, 2019/08/05
- Re: [Qemu-devel] [PULL 0/7] Block patches for 4.1.0-rc4, Vladimir Sementsov-Ogievskiy, 2019/08/05
Re: [Qemu-devel] [PULL 0/7] Block patches for 4.1.0-rc4, Peter Maydell, 2019/08/05