* [Qemu-devel] [PATCH v3] mirror: Only mirror granularity-aligned chunks
@ 2019-08-05 15:33 Max Reitz
2019-08-05 15:52 ` Vladimir Sementsov-Ogievskiy
2019-08-05 15:57 ` Max Reitz
0 siblings, 2 replies; 3+ messages in thread
From: Max Reitz @ 2019-08-05 15:33 UTC (permalink / raw)
To: qemu-block
Cc: Kevin Wolf, Vladimir Sementsov-Ogievskiy, qemu-stable, qemu-devel,
Max Reitz, John Snow
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: qemu-stable@nongnu.org
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
v3: Handle bdrv_refresh_limits() errors [Vladimir]
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v3] mirror: Only mirror granularity-aligned chunks
2019-08-05 15:33 [Qemu-devel] [PATCH v3] mirror: Only mirror granularity-aligned chunks Max Reitz
@ 2019-08-05 15:52 ` Vladimir Sementsov-Ogievskiy
2019-08-05 15:57 ` Max Reitz
1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-08-05 15:52 UTC (permalink / raw)
To: Max Reitz, qemu-block@nongnu.org
Cc: Kevin Wolf, John Snow, qemu-devel@nongnu.org,
qemu-stable@nongnu.org
05.08.2019 18:33, Max Reitz wrote:
> 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: qemu-stable@nongnu.org
> Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
--
Best regards,
Vladimir
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v3] mirror: Only mirror granularity-aligned chunks
2019-08-05 15:33 [Qemu-devel] [PATCH v3] mirror: Only mirror granularity-aligned chunks Max Reitz
2019-08-05 15:52 ` Vladimir Sementsov-Ogievskiy
@ 2019-08-05 15:57 ` Max Reitz
1 sibling, 0 replies; 3+ messages in thread
From: Max Reitz @ 2019-08-05 15:57 UTC (permalink / raw)
To: qemu-block
Cc: Kevin Wolf, Vladimir Sementsov-Ogievskiy, John Snow, qemu-devel,
qemu-stable
[-- Attachment #1.1: Type: text/plain, Size: 989 bytes --]
On 05.08.19 17:33, Max Reitz wrote:
> 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: qemu-stable@nongnu.org
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> v3: Handle bdrv_refresh_limits() errors [Vladimir]
> ---
> block/mirror.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
Thanks for the review, I’m taking the silence around “fix unaligned
reset” as a sign to take this patch:
https://git.xanclic.moe/XanClic/qemu/commits/branch/block
Max
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-05 15:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-05 15:33 [Qemu-devel] [PATCH v3] mirror: Only mirror granularity-aligned chunks Max Reitz
2019-08-05 15:52 ` Vladimir Sementsov-Ogievskiy
2019-08-05 15:57 ` Max Reitz
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).