mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
job: Move transactions to Job
This moves the logic that implements job transactions from BlockJob to Job. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
62c9e4162a
commit
7eaa8fb57d
8 changed files with 303 additions and 324 deletions
|
@ -33,7 +33,6 @@
|
|||
#define BLOCK_JOB_SLICE_TIME 100000000ULL /* ns */
|
||||
|
||||
typedef struct BlockJobDriver BlockJobDriver;
|
||||
typedef struct JobTxn JobTxn;
|
||||
|
||||
/**
|
||||
* BlockJob:
|
||||
|
@ -84,8 +83,6 @@ typedef struct BlockJob {
|
|||
|
||||
/** BlockDriverStates that are involved in this block job */
|
||||
GSList *nodes;
|
||||
|
||||
JobTxn *txn;
|
||||
} BlockJob;
|
||||
|
||||
/**
|
||||
|
@ -152,22 +149,6 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp);
|
|||
*/
|
||||
void block_job_cancel(BlockJob *job, bool force);
|
||||
|
||||
/**
|
||||
* block_job_finalize:
|
||||
* @job: The job to fully commit and finish.
|
||||
* @errp: Error object.
|
||||
*
|
||||
* For jobs that have finished their work and are pending
|
||||
* awaiting explicit acknowledgement to commit their work,
|
||||
* This will commit that work.
|
||||
*
|
||||
* FIXME: Make the below statement universally true:
|
||||
* For jobs that support the manual workflow mode, all graph
|
||||
* changes that occur as a result will occur after this command
|
||||
* and before a successful reply.
|
||||
*/
|
||||
void block_job_finalize(BlockJob *job, Error **errp);
|
||||
|
||||
/**
|
||||
* block_job_dismiss:
|
||||
* @job: The job to be dismissed.
|
||||
|
@ -259,41 +240,6 @@ int block_job_complete_sync(BlockJob *job, Error **errp);
|
|||
*/
|
||||
void block_job_iostatus_reset(BlockJob *job);
|
||||
|
||||
/**
|
||||
* block_job_txn_new:
|
||||
*
|
||||
* Allocate and return a new block job transaction. Jobs can be added to the
|
||||
* transaction using block_job_txn_add_job().
|
||||
*
|
||||
* The transaction is automatically freed when the last job completes or is
|
||||
* cancelled.
|
||||
*
|
||||
* All jobs in the transaction either complete successfully or fail/cancel as a
|
||||
* group. Jobs wait for each other before completing. Cancelling one job
|
||||
* cancels all jobs in the transaction.
|
||||
*/
|
||||
JobTxn *block_job_txn_new(void);
|
||||
|
||||
/**
|
||||
* block_job_txn_unref:
|
||||
*
|
||||
* Release a reference that was previously acquired with block_job_txn_add_job
|
||||
* or block_job_txn_new. If it's the last reference to the object, it will be
|
||||
* freed.
|
||||
*/
|
||||
void block_job_txn_unref(JobTxn *txn);
|
||||
|
||||
/**
|
||||
* block_job_txn_add_job:
|
||||
* @txn: The transaction (may be NULL)
|
||||
* @job: Job to add to the transaction
|
||||
*
|
||||
* Add @job to the transaction. The @job must not already be in a transaction.
|
||||
* The caller must call either block_job_txn_unref() or block_job_completed()
|
||||
* to release the reference that is automatically grabbed here.
|
||||
*/
|
||||
void block_job_txn_add_job(JobTxn *txn, BlockJob *job);
|
||||
|
||||
/**
|
||||
* block_job_is_internal:
|
||||
* @job: The job to determine if it is user-visible or not.
|
||||
|
|
|
@ -38,16 +38,6 @@ struct BlockJobDriver {
|
|||
/** Generic JobDriver callbacks and settings */
|
||||
JobDriver job_driver;
|
||||
|
||||
/**
|
||||
* If the callback is not NULL, prepare will be invoked when all the jobs
|
||||
* belonging to the same transaction complete; or upon this job's completion
|
||||
* if it is not in a transaction.
|
||||
*
|
||||
* This callback will not be invoked if the job has already failed.
|
||||
* If it fails, abort and then clean will be called.
|
||||
*/
|
||||
int (*prepare)(BlockJob *job);
|
||||
|
||||
/*
|
||||
* If the callback is not NULL, it will be invoked before the job is
|
||||
* resumed in a new AioContext. This is the place to move any resources
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue