diff options
author | Kevin Wolf <kwolf@redhat.com> | 2018-04-24 16:13:52 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2018-05-23 14:30:51 +0200 |
commit | 3d70ff53b6bf90d9eec6f97024ec9895f6799d9e (patch) | |
tree | 947adf7d4422c78235ff4b8f2a31fac0085efc9a /blockjob.c | |
parent | 7eaa8fb57da96301f4a8ce176ad503f80efc7cc0 (diff) | |
download | qemu-3d70ff53b6bf90d9eec6f97024ec9895f6799d9e.zip qemu-3d70ff53b6bf90d9eec6f97024ec9895f6799d9e.tar.gz qemu-3d70ff53b6bf90d9eec6f97024ec9895f6799d9e.tar.bz2 |
job: Move completion and cancellation to Job
This moves the top-level job completion and cancellation functions from
BlockJob to Job.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockjob.c')
-rw-r--r-- | blockjob.c | 76 |
1 files changed, 0 insertions, 76 deletions
@@ -255,63 +255,6 @@ void block_job_dismiss(BlockJob **jobptr, Error **errp) *jobptr = NULL; } -void block_job_cancel(BlockJob *job, bool force) -{ - if (job->job.status == JOB_STATUS_CONCLUDED) { - job_do_dismiss(&job->job); - return; - } - job_cancel_async(&job->job, force); - if (!job_started(&job->job)) { - block_job_completed(job, -ECANCELED); - } else if (job->job.deferred_to_main_loop) { - job_completed_txn_abort(&job->job); - } else { - block_job_enter(job); - } -} - -void block_job_user_cancel(BlockJob *job, bool force, Error **errp) -{ - if (job_apply_verb(&job->job, JOB_VERB_CANCEL, errp)) { - return; - } - block_job_cancel(job, force); -} - -/* A wrapper around block_job_cancel() taking an Error ** parameter so it may be - * used with job_finish_sync() without the need for (rather nasty) function - * pointer casts there. */ -static void block_job_cancel_err(Job *job, Error **errp) -{ - BlockJob *bjob = container_of(job, BlockJob, job); - assert(is_block_job(job)); - block_job_cancel(bjob, false); -} - -int block_job_cancel_sync(BlockJob *job) -{ - return job_finish_sync(&job->job, &block_job_cancel_err, NULL); -} - -void block_job_cancel_sync_all(void) -{ - BlockJob *job; - AioContext *aio_context; - - while ((job = block_job_next(NULL))) { - aio_context = blk_get_aio_context(job->blk); - aio_context_acquire(aio_context); - block_job_cancel_sync(job); - aio_context_release(aio_context); - } -} - -int block_job_complete_sync(BlockJob *job, Error **errp) -{ - return job_finish_sync(&job->job, job_complete, errp); -} - void block_job_progress_update(BlockJob *job, uint64_t done) { job->offset += done; @@ -488,25 +431,6 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver, return job; } -void block_job_completed(BlockJob *job, int ret) -{ - assert(job && job->job.txn && !job_is_completed(&job->job)); - assert(blk_bs(job->blk)->job == job); - job->job.ret = ret; - job_update_rc(&job->job); - trace_block_job_completed(job, ret, job->job.ret); - if (job->job.ret) { - job_completed_txn_abort(&job->job); - } else { - job_completed_txn_success(&job->job); - } -} - -void block_job_enter(BlockJob *job) -{ - job_enter_cond(&job->job, NULL); -} - void block_job_yield(BlockJob *job) { assert(job->job.busy); |