[pve-devel] [PATCH 19/31] PVE: backup: modify job api

Dietmar Maurer dietmar at proxmox.com
Fri Mar 6 12:29:59 CET 2020


From: Wolfgang Bumiller <w.bumiller at proxmox.com>

Introduce a pause_count parameter to start a backup in
paused mode. This way backups of multiple drives can be
started up sequentially via the completion callback while
having been started at the same point in time.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 block/backup.c            | 3 +++
 block/replication.c       | 2 +-
 blockdev.c                | 3 ++-
 include/block/block_int.h | 1 +
 job.c                     | 2 +-
 5 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/block/backup.c b/block/backup.c
index cf62b1a38c..c155081de2 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -347,6 +347,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
                   BlockdevOnError on_target_error,
                   int creation_flags,
                   BlockCompletionFunc *cb, void *opaque,
+                  int pause_count,
                   JobTxn *txn, Error **errp)
 {
     int64_t len;
@@ -468,6 +469,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
     block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL,
                        &error_abort);
 
+    job->common.job.pause_count += pause_count;
+
     return &job->common;
 
  error:
diff --git a/block/replication.c b/block/replication.c
index 99532ce521..ec8de7b427 100644
--- a/block/replication.c
+++ b/block/replication.c
@@ -546,7 +546,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
                                 0, MIRROR_SYNC_MODE_NONE, NULL, 0, false, NULL,
                                 BLOCKDEV_ON_ERROR_REPORT,
                                 BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL,
-                                backup_job_completed, bs, NULL, &local_err);
+                                backup_job_completed, bs, 0, NULL, &local_err);
         if (local_err) {
             error_propagate(errp, local_err);
             backup_job_cleanup(bs);
diff --git a/blockdev.c b/blockdev.c
index 8e029e9c01..c7fa663ebf 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3583,7 +3583,8 @@ static BlockJob *do_backup_common(BackupCommon *backup,
                             backup->filter_node_name,
                             backup->on_source_error,
                             backup->on_target_error,
-                            job_flags, NULL, NULL, txn, errp);
+                            job_flags, NULL, NULL, 0, txn, errp);
+
     return job;
 }
 
diff --git a/include/block/block_int.h b/include/block/block_int.h
index dd033d0b37..b0d5eb9485 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -1215,6 +1215,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
                             BlockdevOnError on_target_error,
                             int creation_flags,
                             BlockCompletionFunc *cb, void *opaque,
+                            int pause_count,
                             JobTxn *txn, Error **errp);
 
 void hmp_drive_add_node(Monitor *mon, const char *optstr);
diff --git a/job.c b/job.c
index 04409b40aa..7554f735e3 100644
--- a/job.c
+++ b/job.c
@@ -888,7 +888,7 @@ void job_start(Job *job)
     job->co = qemu_coroutine_create(job_co_entry, job);
     job->pause_count--;
     job->busy = true;
-    job->paused = false;
+    job->paused = job->pause_count > 0;
     job_state_transition(job, JOB_STATUS_RUNNING);
     aio_co_enter(job->aio_context, job->co);
 }
-- 
2.20.1




More information about the pve-devel mailing list