[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 1/7] backup: Copy only dirty areas
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PULL v2 1/7] backup: Copy only dirty areas |
Date: |
Tue, 6 Aug 2019 13:59:46 +0200 |
The backup job must only copy areas that the copy_bitmap reports as
dirty. This is always the case when using traditional non-offloading
backup, because it copies each cluster separately. When offloading the
copy operation, we sometimes copy more than one cluster at a time, but
we only check whether the first one is dirty.
Therefore, whenever copy offloading is possible, the backup job
currently produces wrong output when the guest writes to an area of
which an inner part has already been backed up, because that inner part
will be re-copied.
Fixes: 9ded4a0114968e98b41494fc035ba14f84cdf700
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Message-id: address@hidden
Cc: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
block/backup.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/block/backup.c b/block/backup.c
index 715e1d3be8..1ee271f9f1 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -202,22 +202,31 @@ static int coroutine_fn backup_do_cow(BackupBlockJob *job,
cow_request_begin(&cow_request, job, start, end);
while (start < end) {
+ int64_t dirty_end;
+
if (!hbitmap_get(job->copy_bitmap, start)) {
trace_backup_do_cow_skip(job, start);
start += job->cluster_size;
continue; /* already copied */
}
+ dirty_end = hbitmap_next_zero(job->copy_bitmap, start, (end - start));
+ if (dirty_end < 0) {
+ dirty_end = end;
+ }
+
trace_backup_do_cow_process(job, start);
if (job->use_copy_range) {
- ret = backup_cow_with_offload(job, start, end, is_write_notifier);
+ ret = backup_cow_with_offload(job, start, dirty_end,
+ is_write_notifier);
if (ret < 0) {
job->use_copy_range = false;
}
}
if (!job->use_copy_range) {
- ret = backup_cow_with_bounce_buffer(job, start, end,
is_write_notifier,
+ ret = backup_cow_with_bounce_buffer(job, start, dirty_end,
+ is_write_notifier,
error_is_read, &bounce_buffer);
}
if (ret < 0) {
--
2.21.0
- [Qemu-devel] [PULL v2 0/7] Block patches for 4.1.0-rc4, Max Reitz, 2019/08/06
- [Qemu-devel] [PULL v2 1/7] backup: Copy only dirty areas,
Max Reitz <=
- [Qemu-devel] [PULL v2 2/7] iotests: Test backup job with two guest writes, Max Reitz, 2019/08/06
- [Qemu-devel] [PULL v2 3/7] util/hbitmap: update orig_size on truncate, Max Reitz, 2019/08/06
- [Qemu-devel] [PULL v2 4/7] iotests: Test incremental backup after truncation, Max Reitz, 2019/08/06
- [Qemu-devel] [PULL v2 5/7] mirror: Only mirror granularity-aligned chunks, Max Reitz, 2019/08/06
- [Qemu-devel] [PULL v2 7/7] block/backup: disable copy_range for compressed backup, Max Reitz, 2019/08/06
- [Qemu-devel] [PULL v2 6/7] iotests: Test unaligned blocking mirror write, Max Reitz, 2019/08/06
- Re: [Qemu-devel] [PULL v2 0/7] Block patches for 4.1.0-rc4, Peter Maydell, 2019/08/06