|
|
ae23c9 |
From 2327f8fa6d0f917cf4ced7385aa27e1bb45b08ec Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Date: Tue, 25 Sep 2018 22:34:13 +0100
|
|
|
ae23c9 |
Subject: [PATCH 10/28] block/backup: make function variables consistently
|
|
|
ae23c9 |
named
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180925223431.24791-8-jsnow@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 82272
|
|
|
ae23c9 |
O-Subject: [RHEL8/rhel qemu-kvm PATCH 07/25] block/backup: make function variables consistently named
|
|
|
ae23c9 |
Bugzilla: 1632939
|
|
|
ae23c9 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Rename opaque_job to job to be consistent with other job implementations.
|
|
|
ae23c9 |
Rename 'job', the BackupBlockJob object, to 's' to also be consistent.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Suggested-by: Eric Blake <eblake@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Message-id: 20180830015734.19765-8-jsnow@redhat.com
|
|
|
ae23c9 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit 6870277535493fea31761d8d11ec23add2de0fb0)
|
|
|
ae23c9 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
block/backup.c | 62 +++++++++++++++++++++++++++++-----------------------------
|
|
|
ae23c9 |
1 file changed, 31 insertions(+), 31 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/block/backup.c b/block/backup.c
|
|
|
ae23c9 |
index 08a5b74..524e0ff 100644
|
|
|
ae23c9 |
--- a/block/backup.c
|
|
|
ae23c9 |
+++ b/block/backup.c
|
|
|
ae23c9 |
@@ -468,59 +468,59 @@ static void backup_incremental_init_copy_bitmap(BackupBlockJob *job)
|
|
|
ae23c9 |
bdrv_dirty_iter_free(dbi);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
-static int coroutine_fn backup_run(Job *opaque_job, Error **errp)
|
|
|
ae23c9 |
+static int coroutine_fn backup_run(Job *job, Error **errp)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
- BackupBlockJob *job = container_of(opaque_job, BackupBlockJob, common.job);
|
|
|
ae23c9 |
- BlockDriverState *bs = blk_bs(job->common.blk);
|
|
|
ae23c9 |
+ BackupBlockJob *s = container_of(job, BackupBlockJob, common.job);
|
|
|
ae23c9 |
+ BlockDriverState *bs = blk_bs(s->common.blk);
|
|
|
ae23c9 |
int64_t offset, nb_clusters;
|
|
|
ae23c9 |
int ret = 0;
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- QLIST_INIT(&job->inflight_reqs);
|
|
|
ae23c9 |
- qemu_co_rwlock_init(&job->flush_rwlock);
|
|
|
ae23c9 |
+ QLIST_INIT(&s->inflight_reqs);
|
|
|
ae23c9 |
+ qemu_co_rwlock_init(&s->flush_rwlock);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- nb_clusters = DIV_ROUND_UP(job->len, job->cluster_size);
|
|
|
ae23c9 |
- job_progress_set_remaining(&job->common.job, job->len);
|
|
|
ae23c9 |
+ nb_clusters = DIV_ROUND_UP(s->len, s->cluster_size);
|
|
|
ae23c9 |
+ job_progress_set_remaining(job, s->len);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- job->copy_bitmap = hbitmap_alloc(nb_clusters, 0);
|
|
|
ae23c9 |
- if (job->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
|
|
|
ae23c9 |
- backup_incremental_init_copy_bitmap(job);
|
|
|
ae23c9 |
+ s->copy_bitmap = hbitmap_alloc(nb_clusters, 0);
|
|
|
ae23c9 |
+ if (s->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
|
|
|
ae23c9 |
+ backup_incremental_init_copy_bitmap(s);
|
|
|
ae23c9 |
} else {
|
|
|
ae23c9 |
- hbitmap_set(job->copy_bitmap, 0, nb_clusters);
|
|
|
ae23c9 |
+ hbitmap_set(s->copy_bitmap, 0, nb_clusters);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- job->before_write.notify = backup_before_write_notify;
|
|
|
ae23c9 |
- bdrv_add_before_write_notifier(bs, &job->before_write);
|
|
|
ae23c9 |
+ s->before_write.notify = backup_before_write_notify;
|
|
|
ae23c9 |
+ bdrv_add_before_write_notifier(bs, &s->before_write);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- if (job->sync_mode == MIRROR_SYNC_MODE_NONE) {
|
|
|
ae23c9 |
+ if (s->sync_mode == MIRROR_SYNC_MODE_NONE) {
|
|
|
ae23c9 |
/* All bits are set in copy_bitmap to allow any cluster to be copied.
|
|
|
ae23c9 |
* This does not actually require them to be copied. */
|
|
|
ae23c9 |
- while (!job_is_cancelled(&job->common.job)) {
|
|
|
ae23c9 |
+ while (!job_is_cancelled(job)) {
|
|
|
ae23c9 |
/* Yield until the job is cancelled. We just let our before_write
|
|
|
ae23c9 |
* notify callback service CoW requests. */
|
|
|
ae23c9 |
- job_yield(&job->common.job);
|
|
|
ae23c9 |
+ job_yield(job);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
- } else if (job->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
|
|
|
ae23c9 |
- ret = backup_run_incremental(job);
|
|
|
ae23c9 |
+ } else if (s->sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
|
|
|
ae23c9 |
+ ret = backup_run_incremental(s);
|
|
|
ae23c9 |
} else {
|
|
|
ae23c9 |
/* Both FULL and TOP SYNC_MODE's require copying.. */
|
|
|
ae23c9 |
- for (offset = 0; offset < job->len;
|
|
|
ae23c9 |
- offset += job->cluster_size) {
|
|
|
ae23c9 |
+ for (offset = 0; offset < s->len;
|
|
|
ae23c9 |
+ offset += s->cluster_size) {
|
|
|
ae23c9 |
bool error_is_read;
|
|
|
ae23c9 |
int alloced = 0;
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- if (yield_and_check(job)) {
|
|
|
ae23c9 |
+ if (yield_and_check(s)) {
|
|
|
ae23c9 |
break;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- if (job->sync_mode == MIRROR_SYNC_MODE_TOP) {
|
|
|
ae23c9 |
+ if (s->sync_mode == MIRROR_SYNC_MODE_TOP) {
|
|
|
ae23c9 |
int i;
|
|
|
ae23c9 |
int64_t n;
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/* Check to see if these blocks are already in the
|
|
|
ae23c9 |
* backing file. */
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- for (i = 0; i < job->cluster_size;) {
|
|
|
ae23c9 |
+ for (i = 0; i < s->cluster_size;) {
|
|
|
ae23c9 |
/* bdrv_is_allocated() only returns true/false based
|
|
|
ae23c9 |
* on the first set of sectors it comes across that
|
|
|
ae23c9 |
* are are all in the same state.
|
|
|
ae23c9 |
@@ -529,7 +529,7 @@ static int coroutine_fn backup_run(Job *opaque_job, Error **errp)
|
|
|
ae23c9 |
* needed but at some point that is always the case. */
|
|
|
ae23c9 |
alloced =
|
|
|
ae23c9 |
bdrv_is_allocated(bs, offset + i,
|
|
|
ae23c9 |
- job->cluster_size - i, &n);
|
|
|
ae23c9 |
+ s->cluster_size - i, &n);
|
|
|
ae23c9 |
i += n;
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (alloced || n == 0) {
|
|
|
ae23c9 |
@@ -547,29 +547,29 @@ static int coroutine_fn backup_run(Job *opaque_job, Error **errp)
|
|
|
ae23c9 |
if (alloced < 0) {
|
|
|
ae23c9 |
ret = alloced;
|
|
|
ae23c9 |
} else {
|
|
|
ae23c9 |
- ret = backup_do_cow(job, offset, job->cluster_size,
|
|
|
ae23c9 |
+ ret = backup_do_cow(s, offset, s->cluster_size,
|
|
|
ae23c9 |
&error_is_read, false);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
/* Depending on error action, fail now or retry cluster */
|
|
|
ae23c9 |
BlockErrorAction action =
|
|
|
ae23c9 |
- backup_error_action(job, error_is_read, -ret);
|
|
|
ae23c9 |
+ backup_error_action(s, error_is_read, -ret);
|
|
|
ae23c9 |
if (action == BLOCK_ERROR_ACTION_REPORT) {
|
|
|
ae23c9 |
break;
|
|
|
ae23c9 |
} else {
|
|
|
ae23c9 |
- offset -= job->cluster_size;
|
|
|
ae23c9 |
+ offset -= s->cluster_size;
|
|
|
ae23c9 |
continue;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- notifier_with_return_remove(&job->before_write);
|
|
|
ae23c9 |
+ notifier_with_return_remove(&s->before_write);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/* wait until pending backup_do_cow() calls have completed */
|
|
|
ae23c9 |
- qemu_co_rwlock_wrlock(&job->flush_rwlock);
|
|
|
ae23c9 |
- qemu_co_rwlock_unlock(&job->flush_rwlock);
|
|
|
ae23c9 |
- hbitmap_free(job->copy_bitmap);
|
|
|
ae23c9 |
+ qemu_co_rwlock_wrlock(&s->flush_rwlock);
|
|
|
ae23c9 |
+ qemu_co_rwlock_unlock(&s->flush_rwlock);
|
|
|
ae23c9 |
+ hbitmap_free(s->copy_bitmap);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|