backup: use copy_bitmap in incremental backup
We can use copy_bitmap instead of sync_bitmap. copy_bitmap is initialized from sync_bitmap and it is more informative: we will not try to process data, that is already in progress (by write notifier). Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Message-id: 20171012135313.227864-6-vsementsov@virtuozzo.com Signed-off-by: Jeff Cody <jcody@redhat.com>
This commit is contained in:
parent
085bd08e6f
commit
53f1c8794f
|
@ -362,49 +362,28 @@ static bool coroutine_fn yield_and_check(BackupBlockJob *job)
|
||||||
|
|
||||||
static int coroutine_fn backup_run_incremental(BackupBlockJob *job)
|
static int coroutine_fn backup_run_incremental(BackupBlockJob *job)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
bool error_is_read;
|
bool error_is_read;
|
||||||
int ret = 0;
|
|
||||||
int clusters_per_iter;
|
|
||||||
uint32_t granularity;
|
|
||||||
int64_t offset;
|
|
||||||
int64_t cluster;
|
int64_t cluster;
|
||||||
int64_t end;
|
HBitmapIter hbi;
|
||||||
BdrvDirtyBitmapIter *dbi;
|
|
||||||
|
|
||||||
granularity = bdrv_dirty_bitmap_granularity(job->sync_bitmap);
|
hbitmap_iter_init(&hbi, job->copy_bitmap, 0);
|
||||||
clusters_per_iter = MAX((granularity / job->cluster_size), 1);
|
while ((cluster = hbitmap_iter_next(&hbi)) != -1) {
|
||||||
dbi = bdrv_dirty_iter_new(job->sync_bitmap);
|
do {
|
||||||
|
if (yield_and_check(job)) {
|
||||||
/* Find the next dirty sector(s) */
|
return 0;
|
||||||
while ((offset = bdrv_dirty_iter_next(dbi)) >= 0) {
|
}
|
||||||
cluster = offset / job->cluster_size;
|
ret = backup_do_cow(job, cluster * job->cluster_size,
|
||||||
|
job->cluster_size, &error_is_read, false);
|
||||||
for (end = cluster + clusters_per_iter; cluster < end; cluster++) {
|
if (ret < 0 && backup_error_action(job, error_is_read, -ret) ==
|
||||||
do {
|
BLOCK_ERROR_ACTION_REPORT)
|
||||||
if (yield_and_check(job)) {
|
{
|
||||||
goto out;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = backup_do_cow(job, cluster * job->cluster_size,
|
} while (ret < 0);
|
||||||
job->cluster_size, &error_is_read,
|
|
||||||
false);
|
|
||||||
if ((ret < 0) &&
|
|
||||||
backup_error_action(job, error_is_read, -ret) ==
|
|
||||||
BLOCK_ERROR_ACTION_REPORT) {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
} while (ret < 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the bitmap granularity is smaller than the backup granularity,
|
|
||||||
* we need to advance the iterator pointer to the next cluster. */
|
|
||||||
if (granularity < job->cluster_size) {
|
|
||||||
bdrv_set_dirty_iter(dbi, cluster * job->cluster_size);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
return 0;
|
||||||
bdrv_dirty_iter_free(dbi);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* init copy_bitmap from sync_bitmap */
|
/* init copy_bitmap from sync_bitmap */
|
||||||
|
|
Loading…
Reference in a new issue