block/backup: teach TOP to never copy unallocated regions
commit7e30dd618ebfe3ab1ed54f2e98ba75d799c0be20
authorJohn Snow <jsnow@redhat.com>
Mon, 29 Jul 2019 20:35:55 +0000 (29 16:35 -0400)
committerJohn Snow <jsnow@redhat.com>
Fri, 16 Aug 2019 20:28:03 +0000 (16 16:28 -0400)
tree8f6c4d6398603583e13417c75229c76758ee13d6
parentdba8700f16ebda0632977c303f66021407971081
block/backup: teach TOP to never copy unallocated regions

Presently, If sync=TOP is selected, we mark the entire bitmap as dirty.
In the write notifier handler, we dutifully copy out such regions.

Fix this in three parts:

1. Mark the bitmap as being initialized before the first yield.
2. After the first yield but before the backup loop, interrogate the
allocation status asynchronously and initialize the bitmap.
3. Teach the write notifier to interrogate allocation status if it is
invoked during bitmap initialization.

As an effect of this patch, the job progress for TOP backups
now behaves like this:

- total progress starts at bdrv_length.
- As allocation status is interrogated, total progress decreases.
- As blocks are copied, current progress increases.

Taken together, the floor and ceiling move to meet each other.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20190716000117.25219-10-jsnow@redhat.com
[Remove ret = -ECANCELED change. --js]
[Squash in conflict resolution based on Max's patch --js]
Message-id: c8b0ab36-79c8-0b4b-3193-4e12ed8c848b@redhat.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
block/backup.c
block/trace-events