Patchwork [PULL,02/31] mirror: Use DIV_ROUND_UP

login
register
mail settings
Submitter Kevin Wolf
Date April 30, 2014, 6:23 p.m.
Message ID <1398882243-14783-3-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/344266/
State New
Headers show

Comments

Kevin Wolf - April 30, 2014, 6:23 p.m.
From: Fam Zheng <famz@redhat.com>

Although bdrv_getlength() was just called above this, and checked for
error, it is better to just use the value we already get, and use
DIV_ROUND_UP.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/mirror.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/block/mirror.c b/block/mirror.c
index 36f4f8e..95366ad 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -329,7 +329,7 @@  static void coroutine_fn mirror_run(void *opaque)
         return;
     }
 
-    length = (bdrv_getlength(bs) + s->granularity - 1) / s->granularity;
+    length = DIV_ROUND_UP(s->common.len, s->granularity);
     s->in_flight_bitmap = bitmap_new(length);
 
     /* If we have no backing file yet in the destination, we cannot let