From patchwork Fri Aug 22 08:17:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 382098 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A41341400E9 for ; Fri, 22 Aug 2014 18:18:52 +1000 (EST) Received: from localhost ([::1]:35630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKk3e-0005il-Qg for incoming@patchwork.ozlabs.org; Fri, 22 Aug 2014 04:18:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKk3K-0005NM-CY for qemu-devel@nongnu.org; Fri, 22 Aug 2014 04:18:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKk3F-0008Hq-Hs for qemu-devel@nongnu.org; Fri, 22 Aug 2014 04:18:30 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:33288) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKk3E-0008HM-Ld for qemu-devel@nongnu.org; Fri, 22 Aug 2014 04:18:25 -0400 Received: from 172.24.2.119 (EHLO szxeml413-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BYM60587; Fri, 22 Aug 2014 16:18:08 +0800 (CST) Received: from localhost (10.177.19.102) by szxeml413-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.158.1; Fri, 22 Aug 2014 16:18:00 +0800 From: To: Date: Fri, 22 Aug 2014 16:17:57 +0800 Message-ID: <1408695477-7868-1-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 1.7.3.1.msysgit.0 MIME-Version: 1.0 X-Originating-IP: [10.177.19.102] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Cc: kwolf@redhat.com, ChenLiang , weidong.huang@huawei.com, quintela@redhat.com, Gonglei , stefanha@redhat.com Subject: [Qemu-devel] [PATCH] mirror: improve io performance X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: ChenLiang 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 Signed-off-by: Gonglei --- 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)