From: ChenLiang <chenlian...@huawei.com> Mirror buffer is split into two pieces to improve io performance. In this way, one piece of buffer can read data from source disk when another one is writing data to dest disk.
previous: io bandwidth: 41MB/s migration time: 8min15s now: io bandwidth: 67MB/s migration time: 5min3s The size of vm image is 20G. Signed-off-by: ChenLiang <chenlian...@huawei.com> Signed-off-by: Gonglei <arei.gong...@huawei.com> --- block/mirror.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/mirror.c b/block/mirror.c index 5e7a166..6596e92 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -51,6 +51,7 @@ typedef struct MirrorBlockJob { uint8_t *buf; QSIMPLEQ_HEAD(, MirrorBuffer) buf_free; int buf_free_count; + int buf_total_count; unsigned long *in_flight_bitmap; int in_flight; @@ -238,6 +239,10 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) break; } + if (s->buf_total_count / 2 < nb_chunks + added_chunks) { + break; + } + /* We have enough free space to copy these sectors. */ bitmap_set(s->in_flight_bitmap, next_chunk, added_chunks); @@ -307,6 +312,7 @@ static void mirror_free_init(MirrorBlockJob *s) buf_size -= granularity; buf += granularity; } + s->buf_total_count = s->buf_free_count; } static void mirror_drain(MirrorBlockJob *s) -- 1.7.12.4