mirror: correct buf_size
PATCH 1/1 mirror: correct buf_size
If buf_size % granularity is not 0, mirror_free_init() will do dangerous things.
Signed-off-by Wen Congyang <[email protected]>
--- block/mirror.c | 4 ++++ 1 file changed, 4 insertions(+)
block/mirror.c +4 -0
@@ -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 ;
Signature · 1 line
2.1.0
Quoted 10 lines · Wen Congyang
Signed-off-by Wen Congyang <[email protected]>--- block/mirror.c | 4 ++++ 1 file changed, 4 insertions(+)block/mirror.c +0
-0
block/mirror.c static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target, · line 692
Quoted 7 lines
block/mirror.c +4
-0@@ -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