From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1assje-0004XK-T9 for qemu-devel@nongnu.org; Wed, 20 Apr 2016 10:04:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1assjZ-0007Td-AY for qemu-devel@nongnu.org; Wed, 20 Apr 2016 10:04:06 -0400 Date: Wed, 20 Apr 2016 16:03:52 +0200 From: Kevin Wolf Message-ID: <20160420140352.GM6517@noname.str.redhat.com> References: <1461120516-14569-1-git-send-email-famz@redhat.com> <1461120516-14569-2-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1461120516-14569-2-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH for-2.6 v2 1/3] mirror: Don't extend the last sub-chunk List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: qemu-devel@nongnu.org, Jeff Cody , Max Reitz , qemu-block@nongnu.org Am 20.04.2016 um 04:48 hat Fam Zheng geschrieben: > The last sub-chunk is rounded up to the copy granularity in the target > image, resulting in a larger size than the source. > > Add a function to clip the copied sectors to the end. > > This undoes the "wrong" changes to tests/qemu-iotests/109.out in > e5b43573e28. The remaining two offset changes are okay. > > Reported-by: Kevin Wolf > Signed-off-by: Fam Zheng I think you're missing at least one place where we need DIV_ROUND_UP now. Specifically I'm talking about the calculation of nb_chunks in mirror_iteration_done(), which causes the partial last cluster to stay marked as in-flight forever. I would also have used DIV_ROUND_UP in mirror_iteration(), but there we have a sector_num < end check which saves us from an endless loop. In order to reproduce the bug, this hangs for me without DIV_ROUND_UP: $ ls -l /tmp/test.raw -rw-r--r--. 1 kwolf kwolf 1049600 20. Apr 15:57 /tmp/test.raw $ (echo -e "drive_mirror none0 /tmp/copy.raw raw\n"; sleep 1; echo -e 'qemu-io none0 "write 1M 512"\nblock_job_complete none0\nquit') | x86_64-softmmu/qemu-system-x86_64 -drive if=none,file=/tmp/test.raw -monitor stdio Kevin