cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-backup-make-function-variables-consistently-na.patch

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