b8d43c594b
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
100 lines
4.3 KiB
Diff
100 lines
4.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
|
Date: Wed, 9 Dec 2015 15:04:57 +0100
|
|
Subject: [PATCH] PVE: backup: modify job api
|
|
|
|
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@proxmox.com>
|
|
---
|
|
block/backup.c | 2 ++
|
|
block/replication.c | 2 +-
|
|
blockdev.c | 4 ++--
|
|
include/block/block_int.h | 1 +
|
|
job.c | 2 +-
|
|
5 files changed, 7 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/block/backup.c b/block/backup.c
|
|
index 381659d5ef..9ee43981e8 100644
|
|
--- a/block/backup.c
|
|
+++ b/block/backup.c
|
|
@@ -560,6 +560,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;
|
|
@@ -677,6 +678,7 @@ 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->len = len;
|
|
+ job->common.job.pause_count += pause_count;
|
|
|
|
return &job->common;
|
|
|
|
diff --git a/block/replication.c b/block/replication.c
|
|
index 3d4dedddfc..0a265db1b5 100644
|
|
--- a/block/replication.c
|
|
+++ b/block/replication.c
|
|
@@ -543,7 +543,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
|
|
0, MIRROR_SYNC_MODE_NONE, NULL, false,
|
|
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 d358169995..a3542db57a 100644
|
|
--- a/blockdev.c
|
|
+++ b/blockdev.c
|
|
@@ -3546,7 +3546,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
|
|
job = backup_job_create(backup->job_id, bs, target_bs, backup->speed,
|
|
backup->sync, bmap, backup->compress,
|
|
backup->on_source_error, backup->on_target_error,
|
|
- job_flags, NULL, NULL, txn, &local_err);
|
|
+ job_flags, NULL, NULL, 0, txn, &local_err);
|
|
bdrv_unref(target_bs);
|
|
if (local_err != NULL) {
|
|
error_propagate(errp, local_err);
|
|
@@ -3656,7 +3656,7 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
|
|
job = backup_job_create(backup->job_id, bs, target_bs, backup->speed,
|
|
backup->sync, bmap, backup->compress,
|
|
backup->on_source_error, backup->on_target_error,
|
|
- job_flags, NULL, NULL, txn, &local_err);
|
|
+ job_flags, NULL, NULL, 0, txn, &local_err);
|
|
if (local_err != NULL) {
|
|
error_propagate(errp, local_err);
|
|
}
|
|
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
|
index 01e855a066..b409e02be8 100644
|
|
--- a/include/block/block_int.h
|
|
+++ b/include/block/block_int.h
|
|
@@ -1157,6 +1157,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 da8e4b7bf2..86161bd9f3 100644
|
|
--- a/job.c
|
|
+++ b/job.c
|
|
@@ -899,7 +899,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);
|
|
}
|