aboutsummaryrefslogtreecommitdiff
path: root/block/backup.c
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2019-09-20 17:20:44 +0300
committerMax Reitz <mreitz@redhat.com>2019-10-10 10:56:17 +0200
commit0bd0c44372868432c6bde5b0022974f65241f105 (patch)
tree22fbe298c9d5929ae8e25aa43db2c5bd91fe0079 /block/backup.c
parent1048ddf0a32dcdaa952e581bd503d49adad527cc (diff)
block/backup: split shareable copying part from backup_do_cow
Split copying logic which will be shared with backup-top filter. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 20190920142056.12778-4-vsementsov@virtuozzo.com Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/backup.c')
-rw-r--r--block/backup.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/block/backup.c b/block/backup.c
index 99177f03f8..98d7f7a905 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -248,26 +248,18 @@ static int64_t backup_bitmap_reset_unallocated(BackupBlockJob *s,
return ret;
}
-static int coroutine_fn backup_do_cow(BackupBlockJob *job,
- int64_t offset, uint64_t bytes,
- bool *error_is_read,
- bool is_write_notifier)
+static int coroutine_fn backup_do_copy(BackupBlockJob *job,
+ int64_t start, uint64_t bytes,
+ bool *error_is_read,
+ bool is_write_notifier)
{
- CowRequest cow_request;
int ret = 0;
- int64_t start, end; /* bytes */
+ int64_t end = bytes + start; /* bytes */
void *bounce_buffer = NULL;
int64_t status_bytes;
- qemu_co_rwlock_rdlock(&job->flush_rwlock);
-
- start = QEMU_ALIGN_DOWN(offset, job->cluster_size);
- end = QEMU_ALIGN_UP(bytes + offset, job->cluster_size);
-
- trace_backup_do_cow_enter(job, start, offset, bytes);
-
- wait_for_overlapping_requests(job, start, end);
- cow_request_begin(&cow_request, job, start, end);
+ assert(QEMU_IS_ALIGNED(start, job->cluster_size));
+ assert(QEMU_IS_ALIGNED(end, job->cluster_size));
while (start < end) {
int64_t dirty_end;
@@ -326,6 +318,31 @@ static int coroutine_fn backup_do_cow(BackupBlockJob *job,
qemu_vfree(bounce_buffer);
}
+ return ret;
+}
+
+static int coroutine_fn backup_do_cow(BackupBlockJob *job,
+ int64_t offset, uint64_t bytes,
+ bool *error_is_read,
+ bool is_write_notifier)
+{
+ CowRequest cow_request;
+ int ret = 0;
+ int64_t start, end; /* bytes */
+
+ qemu_co_rwlock_rdlock(&job->flush_rwlock);
+
+ start = QEMU_ALIGN_DOWN(offset, job->cluster_size);
+ end = QEMU_ALIGN_UP(bytes + offset, job->cluster_size);
+
+ trace_backup_do_cow_enter(job, start, offset, bytes);
+
+ wait_for_overlapping_requests(job, start, end);
+ cow_request_begin(&cow_request, job, start, end);
+
+ ret = backup_do_copy(job, start, end - start, error_is_read,
+ is_write_notifier);
+
cow_request_end(&cow_request);
trace_backup_do_cow_return(job, offset, bytes, ret);