From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsqGI-0003Vs-95 for qemu-devel@nongnu.org; Thu, 14 May 2015 06:21:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YsqGE-00015Q-5g for qemu-devel@nongnu.org; Thu, 14 May 2015 06:21:06 -0400 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:34085) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsqGD-00012k-Uv for qemu-devel@nongnu.org; Thu, 14 May 2015 06:21:02 -0400 Received: by wicmc15 with SMTP id mc15so11598433wic.1 for ; Thu, 14 May 2015 03:21:01 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <55547709.2080709@redhat.com> Date: Thu, 14 May 2015 12:20:57 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <555473F4.1070709@cn.fujitsu.com> In-Reply-To: <555473F4.1070709@cn.fujitsu.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] mirror: correct buf_size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 > --- > 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