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