]> git.ipfire.org Git - thirdparty/qemu.git/commit
block/block-copy: fix progress calculation
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Wed, 11 Mar 2020 10:29:57 +0000 (13:29 +0300)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 4 Jun 2020 00:53:27 +0000 (19:53 -0500)
commitc44c4f7229a4c5d2d10efaede2570537cb1e3285
tree7b640da414b5f23e933ad2bbc75beb2bf9cff20e
parenta0dc4d24950ca2cf16eafb7a08df4f534a696623
block/block-copy: fix progress calculation

Assume we have two regions, A and B, and region B is in-flight now,
region A is not yet touched, but it is unallocated and should be
skipped.

Correspondingly, as progress we have

  total = A + B
  current = 0

If we reset unallocated region A and call progress_reset_callback,
it will calculate 0 bytes dirty in the bitmap and call
job_progress_set_remaining, which will set

   total = current + 0 = 0 + 0 = 0

So, B bytes are actually removed from total accounting. When job
finishes we'll have

   total = 0
   current = B

, which doesn't sound good.

This is because we didn't considered in-flight bytes, actually when
calculating remaining, we should have set (in_flight + dirty_bytes)
as remaining, not only dirty_bytes.

To fix it, let's refactor progress calculation, moving it to block-copy
itself instead of fixing callback. And, of course, track in_flight
bytes count.

We still have to keep one callback, to maintain backup job bytes_read
calculation, but it will go on soon, when we turn the whole backup
process into one block_copy call.

Cc: qemu-stable@nongnu.org
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Message-Id: <20200311103004.7649-3-vsementsov@virtuozzo.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
(cherry picked from commit d0ebeca14a585f352938062ef8ddde47fe4d39f9)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
block/backup.c
block/block-copy.c
include/block/block-copy.h