[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 04/21] backup: use copy_bitmap in incremental backup
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-block] [PATCH 04/21] backup: use copy_bitmap in incremental backup |
Date: |
Fri, 23 Dec 2016 17:28:47 +0300 |
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 <address@hidden>
---
block/backup.c | 58 +++++++++++++++++++---------------------------------------
1 file changed, 19 insertions(+), 39 deletions(-)
diff --git a/block/backup.c b/block/backup.c
index f1f87f6..938b7df 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -376,50 +376,30 @@ static bool coroutine_fn yield_and_check(BackupBlockJob
*job)
static int coroutine_fn backup_run_incremental(BackupBlockJob *job)
{
+ int ret;
bool error_is_read;
- int ret = 0;
- int clusters_per_iter;
- uint32_t granularity;
- int64_t sector;
- int64_t cluster;
- int64_t end;
int64_t sectors_per_cluster = cluster_size_sectors(job);
- BdrvDirtyBitmapIter *dbi;
-
- granularity = bdrv_dirty_bitmap_granularity(job->sync_bitmap);
- clusters_per_iter = MAX((granularity / job->cluster_size), 1);
- dbi = bdrv_dirty_iter_new(job->sync_bitmap, 0);
-
- /* Find the next dirty sector(s) */
- while ((sector = bdrv_dirty_iter_next(dbi)) != -1) {
- cluster = sector / sectors_per_cluster;
-
- for (end = cluster + clusters_per_iter; cluster < end; cluster++) {
- do {
- if (yield_and_check(job)) {
- goto out;
- }
- ret = backup_do_cow(job, cluster * sectors_per_cluster,
- sectors_per_cluster, &error_is_read,
- false);
- if ((ret < 0) &&
- backup_error_action(job, error_is_read, -ret) ==
- BLOCK_ERROR_ACTION_REPORT) {
- goto out;
- }
- } while (ret < 0);
- }
+ int64_t cluster;
+ HBitmapIter hbi;
- /* 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 * sectors_per_cluster);
- }
+ hbitmap_iter_init(&hbi, job->copy_bitmap, 0);
+ while ((cluster = hbitmap_iter_next(&hbi)) != -1) {
+ do {
+ if (yield_and_check(job)) {
+ return 0;
+ }
+ ret = backup_do_cow(job, cluster * sectors_per_cluster,
+ sectors_per_cluster, &error_is_read,
+ false);
+ if ((ret < 0) &&
+ backup_error_action(job, error_is_read, -ret) ==
+ BLOCK_ERROR_ACTION_REPORT) {
+ return ret;
+ }
+ } while (ret < 0);
}
-out:
- bdrv_dirty_iter_free(dbi);
- return ret;
+ return 0;
}
/* init copy_bitmap from sync_bitmap */
--
1.8.3.1
- [Qemu-block] [PATCH 00/21] new backup architecture, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 21/21] backup: refactor: remove backup_do_cow(), Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 20/21] backup: move bitmap handling from backup_do_cow to get_work, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 01/21] backup: move from done_bitmap to copy_bitmap, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 05/21] hbitmap: improve dirty iter, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 18/21] backup: new async architecture, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 15/21] bitmap: add bitmap_count_between() function, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 17/21] backup: make all reads not serializing, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 16/21] hbitmap: add hbitmap_count_between() function, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 04/21] backup: use copy_bitmap in incremental backup,
Vladimir Sementsov-Ogievskiy <=
- [Qemu-block] [PATCH 03/21] backup: improve non-dirty bits progress processing, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 06/21] backup: rewrite top mode cluster skipping, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 02/21] backup: init copy_bitmap from sync_bitmap for incremental, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 07/21] backup: refactor: merge top/full/incremental backup code, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 14/21] block: add trace point on bdrv_close_all, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 12/21] iotests: add supported_cache_modes to main function, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 10/21] backup: refactor backup_copy_cluster(), Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 09/21] backup: separate copy function, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 08/21] backup: skip unallocated clusters for full mode, Vladimir Sementsov-Ogievskiy, 2016/12/23
- [Qemu-block] [PATCH 13/21] coroutine: add qemu_coroutine_add_next, Vladimir Sementsov-Ogievskiy, 2016/12/23