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 <kw...@redhat.com> > Signed-off-by: Fam Zheng <f...@redhat.com>
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