* [Qemu-devel] [PATCH] mirror: correct buf_size
@ 2015-05-14 10:07 Wen Congyang
2015-05-14 10:20 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Wen Congyang @ 2015-05-14 10:07 UTC (permalink / raw)
To: qemu-devl, Kevin Wolf, Jeff Cody, Fam Zheng
If buf_size % granularity is not 0, mirror_free_init() will
do dangerous things.
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
block/mirror.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/block/mirror.c b/block/mirror.c
index 58f391a..bb6bc27 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -686,6 +686,10 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
s->granularity = granularity;
s->buf_size = MAX(buf_size, granularity);
+ if (s->buf_size % granularity != 0) {
+ s->buf_size = ROUND_UP(s->buf_size, granularity);
+ }
+
s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp);
if (!s->dirty_bitmap) {
return;
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] mirror: correct buf_size
2015-05-14 10:07 [Qemu-devel] [PATCH] mirror: correct buf_size Wen Congyang
@ 2015-05-14 10:20 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2015-05-14 10:20 UTC (permalink / raw)
To: Wen Congyang, qemu-devl, Kevin Wolf, Jeff Cody, Fam Zheng
On 14/05/2015 12:07, Wen Congyang wrote:
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
> block/mirror.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/block/mirror.c b/block/mirror.c
> index 58f391a..bb6bc27 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -686,6 +686,10 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
> s->granularity = granularity;
> s->buf_size = MAX(buf_size, granularity);
>
> + if (s->buf_size % granularity != 0) {
> + s->buf_size = ROUND_UP(s->buf_size, granularity);
> + }
> +
Good catch! But I think the "if" is not needed, and also this removes
the need for the s->buf_size assignment before.
The ROUND_UP is really the only thing that is needed.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-14 10:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-14 10:07 [Qemu-devel] [PATCH] mirror: correct buf_size Wen Congyang
2015-05-14 10:20 ` Paolo Bonzini
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).