|
|
1bdc94 |
From cf8f50fd39b467c3f23f78e7bec351e07b826344 Mon Sep 17 00:00:00 2001
|
|
|
1bdc94 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
1bdc94 |
Date: Tue, 26 Jun 2018 09:48:21 +0200
|
|
|
1bdc94 |
Subject: [PATCH 52/89] job: Switch transactions to JobTxn
|
|
|
1bdc94 |
|
|
|
1bdc94 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
1bdc94 |
Message-id: <20180626094856.6924-39-kwolf@redhat.com>
|
|
|
1bdc94 |
Patchwork-id: 81086
|
|
|
1bdc94 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 38/73] job: Switch transactions to JobTxn
|
|
|
1bdc94 |
Bugzilla: 1513543
|
|
|
1bdc94 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
1bdc94 |
|
|
|
1bdc94 |
This doesn't actually move any transaction code to Job yet, but it
|
|
|
1bdc94 |
renames the type for transactions from BlockJobTxn to JobTxn and makes
|
|
|
1bdc94 |
them contain Jobs rather than BlockJobs
|
|
|
1bdc94 |
|
|
|
1bdc94 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1bdc94 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
(cherry picked from commit 62c9e4162a7bc26a1389e50d17d3b2637028bbc3)
|
|
|
1bdc94 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1bdc94 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
1bdc94 |
---
|
|
|
1bdc94 |
block/backup.c | 2 +-
|
|
|
1bdc94 |
blockdev.c | 14 +++++------
|
|
|
1bdc94 |
blockjob.c | 60 +++++++++++++++++++++++---------------------
|
|
|
1bdc94 |
include/block/block_int.h | 2 +-
|
|
|
1bdc94 |
include/block/blockjob.h | 11 ++++----
|
|
|
1bdc94 |
include/block/blockjob_int.h | 2 +-
|
|
|
1bdc94 |
include/qemu/job.h | 3 +++
|
|
|
1bdc94 |
tests/test-blockjob-txn.c | 8 +++---
|
|
|
1bdc94 |
8 files changed, 54 insertions(+), 48 deletions(-)
|
|
|
1bdc94 |
|
|
|
1bdc94 |
diff --git a/block/backup.c b/block/backup.c
|
|
|
1bdc94 |
index ca7d990..6172f90 100644
|
|
|
1bdc94 |
--- a/block/backup.c
|
|
|
1bdc94 |
+++ b/block/backup.c
|
|
|
1bdc94 |
@@ -547,7 +547,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
|
|
1bdc94 |
BlockdevOnError on_target_error,
|
|
|
1bdc94 |
int creation_flags,
|
|
|
1bdc94 |
BlockCompletionFunc *cb, void *opaque,
|
|
|
1bdc94 |
- BlockJobTxn *txn, Error **errp)
|
|
|
1bdc94 |
+ JobTxn *txn, Error **errp)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
int64_t len;
|
|
|
1bdc94 |
BlockDriverInfo bdi;
|
|
|
1bdc94 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
1bdc94 |
index c2b2be1..b6f3e92 100644
|
|
|
1bdc94 |
--- a/blockdev.c
|
|
|
1bdc94 |
+++ b/blockdev.c
|
|
|
1bdc94 |
@@ -1488,7 +1488,7 @@ typedef struct BlkActionOps {
|
|
|
1bdc94 |
struct BlkActionState {
|
|
|
1bdc94 |
TransactionAction *action;
|
|
|
1bdc94 |
const BlkActionOps *ops;
|
|
|
1bdc94 |
- BlockJobTxn *block_job_txn;
|
|
|
1bdc94 |
+ JobTxn *block_job_txn;
|
|
|
1bdc94 |
TransactionProperties *txn_props;
|
|
|
1bdc94 |
QSIMPLEQ_ENTRY(BlkActionState) entry;
|
|
|
1bdc94 |
};
|
|
|
1bdc94 |
@@ -1906,7 +1906,7 @@ typedef struct DriveBackupState {
|
|
|
1bdc94 |
BlockJob *job;
|
|
|
1bdc94 |
} DriveBackupState;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
-static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn,
|
|
|
1bdc94 |
+static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
|
|
|
1bdc94 |
Error **errp);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
static void drive_backup_prepare(BlkActionState *common, Error **errp)
|
|
|
1bdc94 |
@@ -1996,7 +1996,7 @@ typedef struct BlockdevBackupState {
|
|
|
1bdc94 |
BlockJob *job;
|
|
|
1bdc94 |
} BlockdevBackupState;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
-static BlockJob *do_blockdev_backup(BlockdevBackup *backup, BlockJobTxn *txn,
|
|
|
1bdc94 |
+static BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
|
|
|
1bdc94 |
Error **errp);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
static void blockdev_backup_prepare(BlkActionState *common, Error **errp)
|
|
|
1bdc94 |
@@ -2285,7 +2285,7 @@ void qmp_transaction(TransactionActionList *dev_list,
|
|
|
1bdc94 |
Error **errp)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
TransactionActionList *dev_entry = dev_list;
|
|
|
1bdc94 |
- BlockJobTxn *block_job_txn = NULL;
|
|
|
1bdc94 |
+ JobTxn *block_job_txn = NULL;
|
|
|
1bdc94 |
BlkActionState *state, *next;
|
|
|
1bdc94 |
Error *local_err = NULL;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
@@ -2293,7 +2293,7 @@ void qmp_transaction(TransactionActionList *dev_list,
|
|
|
1bdc94 |
QSIMPLEQ_INIT(&snap_bdrv_states);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/* Does this transaction get canceled as a group on failure?
|
|
|
1bdc94 |
- * If not, we don't really need to make a BlockJobTxn.
|
|
|
1bdc94 |
+ * If not, we don't really need to make a JobTxn.
|
|
|
1bdc94 |
*/
|
|
|
1bdc94 |
props = get_transaction_properties(props);
|
|
|
1bdc94 |
if (props->completion_mode != ACTION_COMPLETION_MODE_INDIVIDUAL) {
|
|
|
1bdc94 |
@@ -3311,7 +3311,7 @@ out:
|
|
|
1bdc94 |
aio_context_release(aio_context);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
-static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn,
|
|
|
1bdc94 |
+static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
|
|
|
1bdc94 |
Error **errp)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
BlockDriverState *bs;
|
|
|
1bdc94 |
@@ -3481,7 +3481,7 @@ BlockDeviceInfoList *qmp_query_named_block_nodes(Error **errp)
|
|
|
1bdc94 |
return bdrv_named_nodes_list(errp);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
-BlockJob *do_blockdev_backup(BlockdevBackup *backup, BlockJobTxn *txn,
|
|
|
1bdc94 |
+BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
|
|
|
1bdc94 |
Error **errp)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
BlockDriverState *bs;
|
|
|
1bdc94 |
diff --git a/blockjob.c b/blockjob.c
|
|
|
1bdc94 |
index 1ed3e9c..bd35c4f 100644
|
|
|
1bdc94 |
--- a/blockjob.c
|
|
|
1bdc94 |
+++ b/blockjob.c
|
|
|
1bdc94 |
@@ -37,13 +37,13 @@
|
|
|
1bdc94 |
#include "qemu/timer.h"
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/* Transactional group of block jobs */
|
|
|
1bdc94 |
-struct BlockJobTxn {
|
|
|
1bdc94 |
+struct JobTxn {
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/* Is this txn being cancelled? */
|
|
|
1bdc94 |
bool aborting;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/* List of jobs */
|
|
|
1bdc94 |
- QLIST_HEAD(, BlockJob) jobs;
|
|
|
1bdc94 |
+ QLIST_HEAD(, Job) jobs;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/* Reference count */
|
|
|
1bdc94 |
int refcnt;
|
|
|
1bdc94 |
@@ -94,27 +94,27 @@ BlockJob *block_job_get(const char *id)
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
-BlockJobTxn *block_job_txn_new(void)
|
|
|
1bdc94 |
+JobTxn *block_job_txn_new(void)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
- BlockJobTxn *txn = g_new0(BlockJobTxn, 1);
|
|
|
1bdc94 |
+ JobTxn *txn = g_new0(JobTxn, 1);
|
|
|
1bdc94 |
QLIST_INIT(&txn->jobs);
|
|
|
1bdc94 |
txn->refcnt = 1;
|
|
|
1bdc94 |
return txn;
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
-static void block_job_txn_ref(BlockJobTxn *txn)
|
|
|
1bdc94 |
+static void block_job_txn_ref(JobTxn *txn)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
txn->refcnt++;
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
-void block_job_txn_unref(BlockJobTxn *txn)
|
|
|
1bdc94 |
+void block_job_txn_unref(JobTxn *txn)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
if (txn && --txn->refcnt == 0) {
|
|
|
1bdc94 |
g_free(txn);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
-void block_job_txn_add_job(BlockJobTxn *txn, BlockJob *job)
|
|
|
1bdc94 |
+void block_job_txn_add_job(JobTxn *txn, BlockJob *job)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
if (!txn) {
|
|
|
1bdc94 |
return;
|
|
|
1bdc94 |
@@ -123,14 +123,14 @@ void block_job_txn_add_job(BlockJobTxn *txn, BlockJob *job)
|
|
|
1bdc94 |
assert(!job->txn);
|
|
|
1bdc94 |
job->txn = txn;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
- QLIST_INSERT_HEAD(&txn->jobs, job, txn_list);
|
|
|
1bdc94 |
+ QLIST_INSERT_HEAD(&txn->jobs, &job->job, txn_list);
|
|
|
1bdc94 |
block_job_txn_ref(txn);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
void block_job_txn_del_job(BlockJob *job)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
if (job->txn) {
|
|
|
1bdc94 |
- QLIST_REMOVE(job, txn_list);
|
|
|
1bdc94 |
+ QLIST_REMOVE(&job->job, txn_list);
|
|
|
1bdc94 |
block_job_txn_unref(job->txn);
|
|
|
1bdc94 |
job->txn = NULL;
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
@@ -285,18 +285,22 @@ static void job_cancel_async(Job *job, bool force)
|
|
|
1bdc94 |
job->force_cancel |= force;
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
-static int block_job_txn_apply(BlockJobTxn *txn, int fn(BlockJob *), bool lock)
|
|
|
1bdc94 |
+static int block_job_txn_apply(JobTxn *txn, int fn(BlockJob *), bool lock)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
AioContext *ctx;
|
|
|
1bdc94 |
- BlockJob *job, *next;
|
|
|
1bdc94 |
+ Job *job, *next;
|
|
|
1bdc94 |
+ BlockJob *bjob;
|
|
|
1bdc94 |
int rc = 0;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
QLIST_FOREACH_SAFE(job, &txn->jobs, txn_list, next) {
|
|
|
1bdc94 |
+ assert(is_block_job(job));
|
|
|
1bdc94 |
+ bjob = container_of(job, BlockJob, job);
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
if (lock) {
|
|
|
1bdc94 |
- ctx = blk_get_aio_context(job->blk);
|
|
|
1bdc94 |
+ ctx = job->aio_context;
|
|
|
1bdc94 |
aio_context_acquire(ctx);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
- rc = fn(job);
|
|
|
1bdc94 |
+ rc = fn(bjob);
|
|
|
1bdc94 |
if (lock) {
|
|
|
1bdc94 |
aio_context_release(ctx);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
@@ -310,8 +314,8 @@ static int block_job_txn_apply(BlockJobTxn *txn, int fn(BlockJob *), bool lock)
|
|
|
1bdc94 |
static void block_job_completed_txn_abort(BlockJob *job)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
AioContext *ctx;
|
|
|
1bdc94 |
- BlockJobTxn *txn = job->txn;
|
|
|
1bdc94 |
- BlockJob *other_job;
|
|
|
1bdc94 |
+ JobTxn *txn = job->txn;
|
|
|
1bdc94 |
+ Job *other_job;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
if (txn->aborting) {
|
|
|
1bdc94 |
/*
|
|
|
1bdc94 |
@@ -324,7 +328,7 @@ static void block_job_completed_txn_abort(BlockJob *job)
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/* We are the first failed job. Cancel other jobs. */
|
|
|
1bdc94 |
QLIST_FOREACH(other_job, &txn->jobs, txn_list) {
|
|
|
1bdc94 |
- ctx = blk_get_aio_context(other_job->blk);
|
|
|
1bdc94 |
+ ctx = other_job->aio_context;
|
|
|
1bdc94 |
aio_context_acquire(ctx);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
@@ -332,18 +336,18 @@ static void block_job_completed_txn_abort(BlockJob *job)
|
|
|
1bdc94 |
* them; this job, however, may or may not be cancelled, depending
|
|
|
1bdc94 |
* on the caller, so leave it. */
|
|
|
1bdc94 |
QLIST_FOREACH(other_job, &txn->jobs, txn_list) {
|
|
|
1bdc94 |
- if (other_job != job) {
|
|
|
1bdc94 |
- job_cancel_async(&other_job->job, false);
|
|
|
1bdc94 |
+ if (other_job != &job->job) {
|
|
|
1bdc94 |
+ job_cancel_async(other_job, false);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
while (!QLIST_EMPTY(&txn->jobs)) {
|
|
|
1bdc94 |
other_job = QLIST_FIRST(&txn->jobs);
|
|
|
1bdc94 |
- ctx = blk_get_aio_context(other_job->blk);
|
|
|
1bdc94 |
- if (!job_is_completed(&other_job->job)) {
|
|
|
1bdc94 |
- assert(job_is_cancelled(&other_job->job));
|
|
|
1bdc94 |
- job_finish_sync(&other_job->job, NULL, NULL);
|
|
|
1bdc94 |
+ ctx = other_job->aio_context;
|
|
|
1bdc94 |
+ if (!job_is_completed(other_job)) {
|
|
|
1bdc94 |
+ assert(job_is_cancelled(other_job));
|
|
|
1bdc94 |
+ job_finish_sync(other_job, NULL, NULL);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
- job_finalize_single(&other_job->job);
|
|
|
1bdc94 |
+ job_finalize_single(other_job);
|
|
|
1bdc94 |
aio_context_release(ctx);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
@@ -385,8 +389,8 @@ static int block_job_transition_to_pending(BlockJob *job)
|
|
|
1bdc94 |
|
|
|
1bdc94 |
static void block_job_completed_txn_success(BlockJob *job)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
- BlockJobTxn *txn = job->txn;
|
|
|
1bdc94 |
- BlockJob *other_job;
|
|
|
1bdc94 |
+ JobTxn *txn = job->txn;
|
|
|
1bdc94 |
+ Job *other_job;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
job_state_transition(&job->job, JOB_STATUS_WAITING);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
@@ -395,10 +399,10 @@ static void block_job_completed_txn_success(BlockJob *job)
|
|
|
1bdc94 |
* txn.
|
|
|
1bdc94 |
*/
|
|
|
1bdc94 |
QLIST_FOREACH(other_job, &txn->jobs, txn_list) {
|
|
|
1bdc94 |
- if (!job_is_completed(&other_job->job)) {
|
|
|
1bdc94 |
+ if (!job_is_completed(other_job)) {
|
|
|
1bdc94 |
return;
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
- assert(other_job->job.ret == 0);
|
|
|
1bdc94 |
+ assert(other_job->ret == 0);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
block_job_txn_apply(txn, block_job_transition_to_pending, false);
|
|
|
1bdc94 |
@@ -628,7 +632,7 @@ static void block_job_event_pending(Notifier *n, void *opaque)
|
|
|
1bdc94 |
*/
|
|
|
1bdc94 |
|
|
|
1bdc94 |
void *block_job_create(const char *job_id, const BlockJobDriver *driver,
|
|
|
1bdc94 |
- BlockJobTxn *txn, BlockDriverState *bs, uint64_t perm,
|
|
|
1bdc94 |
+ JobTxn *txn, BlockDriverState *bs, uint64_t perm,
|
|
|
1bdc94 |
uint64_t shared_perm, int64_t speed, int flags,
|
|
|
1bdc94 |
BlockCompletionFunc *cb, void *opaque, Error **errp)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
|
|
1bdc94 |
index d913ed1..ad2b852 100644
|
|
|
1bdc94 |
--- a/include/block/block_int.h
|
|
|
1bdc94 |
+++ b/include/block/block_int.h
|
|
|
1bdc94 |
@@ -1018,7 +1018,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
|
|
1bdc94 |
BlockdevOnError on_target_error,
|
|
|
1bdc94 |
int creation_flags,
|
|
|
1bdc94 |
BlockCompletionFunc *cb, void *opaque,
|
|
|
1bdc94 |
- BlockJobTxn *txn, Error **errp);
|
|
|
1bdc94 |
+ JobTxn *txn, Error **errp);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
void hmp_drive_add_node(Monitor *mon, const char *optstr);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
|
|
|
1bdc94 |
index 85ce18a..44df025 100644
|
|
|
1bdc94 |
--- a/include/block/blockjob.h
|
|
|
1bdc94 |
+++ b/include/block/blockjob.h
|
|
|
1bdc94 |
@@ -33,7 +33,7 @@
|
|
|
1bdc94 |
#define BLOCK_JOB_SLICE_TIME 100000000ULL /* ns */
|
|
|
1bdc94 |
|
|
|
1bdc94 |
typedef struct BlockJobDriver BlockJobDriver;
|
|
|
1bdc94 |
-typedef struct BlockJobTxn BlockJobTxn;
|
|
|
1bdc94 |
+typedef struct JobTxn JobTxn;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/**
|
|
|
1bdc94 |
* BlockJob:
|
|
|
1bdc94 |
@@ -85,8 +85,7 @@ typedef struct BlockJob {
|
|
|
1bdc94 |
/** BlockDriverStates that are involved in this block job */
|
|
|
1bdc94 |
GSList *nodes;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
- BlockJobTxn *txn;
|
|
|
1bdc94 |
- QLIST_ENTRY(BlockJob) txn_list;
|
|
|
1bdc94 |
+ JobTxn *txn;
|
|
|
1bdc94 |
} BlockJob;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/**
|
|
|
1bdc94 |
@@ -273,7 +272,7 @@ void block_job_iostatus_reset(BlockJob *job);
|
|
|
1bdc94 |
* group. Jobs wait for each other before completing. Cancelling one job
|
|
|
1bdc94 |
* cancels all jobs in the transaction.
|
|
|
1bdc94 |
*/
|
|
|
1bdc94 |
-BlockJobTxn *block_job_txn_new(void);
|
|
|
1bdc94 |
+JobTxn *block_job_txn_new(void);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/**
|
|
|
1bdc94 |
* block_job_txn_unref:
|
|
|
1bdc94 |
@@ -282,7 +281,7 @@ BlockJobTxn *block_job_txn_new(void);
|
|
|
1bdc94 |
* or block_job_txn_new. If it's the last reference to the object, it will be
|
|
|
1bdc94 |
* freed.
|
|
|
1bdc94 |
*/
|
|
|
1bdc94 |
-void block_job_txn_unref(BlockJobTxn *txn);
|
|
|
1bdc94 |
+void block_job_txn_unref(JobTxn *txn);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/**
|
|
|
1bdc94 |
* block_job_txn_add_job:
|
|
|
1bdc94 |
@@ -293,7 +292,7 @@ void block_job_txn_unref(BlockJobTxn *txn);
|
|
|
1bdc94 |
* The caller must call either block_job_txn_unref() or block_job_completed()
|
|
|
1bdc94 |
* to release the reference that is automatically grabbed here.
|
|
|
1bdc94 |
*/
|
|
|
1bdc94 |
-void block_job_txn_add_job(BlockJobTxn *txn, BlockJob *job);
|
|
|
1bdc94 |
+void block_job_txn_add_job(JobTxn *txn, BlockJob *job);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/**
|
|
|
1bdc94 |
* block_job_is_internal:
|
|
|
1bdc94 |
diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h
|
|
|
1bdc94 |
index b8ca7bb..ce66a9b 100644
|
|
|
1bdc94 |
--- a/include/block/blockjob_int.h
|
|
|
1bdc94 |
+++ b/include/block/blockjob_int.h
|
|
|
1bdc94 |
@@ -91,7 +91,7 @@ struct BlockJobDriver {
|
|
|
1bdc94 |
* called from a wrapper that is specific to the job type.
|
|
|
1bdc94 |
*/
|
|
|
1bdc94 |
void *block_job_create(const char *job_id, const BlockJobDriver *driver,
|
|
|
1bdc94 |
- BlockJobTxn *txn, BlockDriverState *bs, uint64_t perm,
|
|
|
1bdc94 |
+ JobTxn *txn, BlockDriverState *bs, uint64_t perm,
|
|
|
1bdc94 |
uint64_t shared_perm, int64_t speed, int flags,
|
|
|
1bdc94 |
BlockCompletionFunc *cb, void *opaque, Error **errp);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
diff --git a/include/qemu/job.h b/include/qemu/job.h
|
|
|
1bdc94 |
index 17e2cec..d4aa7fa 100644
|
|
|
1bdc94 |
--- a/include/qemu/job.h
|
|
|
1bdc94 |
+++ b/include/qemu/job.h
|
|
|
1bdc94 |
@@ -132,6 +132,9 @@ typedef struct Job {
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/** Element of the list of jobs */
|
|
|
1bdc94 |
QLIST_ENTRY(Job) job_list;
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ /** Element of the list of jobs in a job transaction */
|
|
|
1bdc94 |
+ QLIST_ENTRY(Job) txn_list;
|
|
|
1bdc94 |
} Job;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/**
|
|
|
1bdc94 |
diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c
|
|
|
1bdc94 |
index 1572f8d..ec5d592 100644
|
|
|
1bdc94 |
--- a/tests/test-blockjob-txn.c
|
|
|
1bdc94 |
+++ b/tests/test-blockjob-txn.c
|
|
|
1bdc94 |
@@ -93,7 +93,7 @@ static const BlockJobDriver test_block_job_driver = {
|
|
|
1bdc94 |
*/
|
|
|
1bdc94 |
static BlockJob *test_block_job_start(unsigned int iterations,
|
|
|
1bdc94 |
bool use_timer,
|
|
|
1bdc94 |
- int rc, int *result, BlockJobTxn *txn)
|
|
|
1bdc94 |
+ int rc, int *result, JobTxn *txn)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
BlockDriverState *bs;
|
|
|
1bdc94 |
TestBlockJob *s;
|
|
|
1bdc94 |
@@ -122,7 +122,7 @@ static BlockJob *test_block_job_start(unsigned int iterations,
|
|
|
1bdc94 |
static void test_single_job(int expected)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
BlockJob *job;
|
|
|
1bdc94 |
- BlockJobTxn *txn;
|
|
|
1bdc94 |
+ JobTxn *txn;
|
|
|
1bdc94 |
int result = -EINPROGRESS;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
txn = block_job_txn_new();
|
|
|
1bdc94 |
@@ -160,7 +160,7 @@ static void test_pair_jobs(int expected1, int expected2)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
BlockJob *job1;
|
|
|
1bdc94 |
BlockJob *job2;
|
|
|
1bdc94 |
- BlockJobTxn *txn;
|
|
|
1bdc94 |
+ JobTxn *txn;
|
|
|
1bdc94 |
int result1 = -EINPROGRESS;
|
|
|
1bdc94 |
int result2 = -EINPROGRESS;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
@@ -222,7 +222,7 @@ static void test_pair_jobs_fail_cancel_race(void)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
BlockJob *job1;
|
|
|
1bdc94 |
BlockJob *job2;
|
|
|
1bdc94 |
- BlockJobTxn *txn;
|
|
|
1bdc94 |
+ JobTxn *txn;
|
|
|
1bdc94 |
int result1 = -EINPROGRESS;
|
|
|
1bdc94 |
int result2 = -EINPROGRESS;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
--
|
|
|
1bdc94 |
1.8.3.1
|
|
|
1bdc94 |
|