Skip to content

Commit

Permalink
blockjob: implement and use block_job_get_aio_context
Browse files Browse the repository at this point in the history
We are going to drop BlockJob.blk. So let's retrieve block job context
from underlying job instead of main node.

Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Nikita Lapshin <[email protected]>
  • Loading branch information
Vladimir Sementsov-Ogievskiy committed Dec 28, 2021
1 parent 252f409 commit df9a316
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions blockdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -3315,7 +3315,7 @@ static BlockJob *find_block_job(const char *id, AioContext **aio_context,
return NULL;
}

*aio_context = blk_get_aio_context(job->blk);
*aio_context = block_job_get_aio_context(job);
aio_context_acquire(*aio_context);

return job;
Expand Down Expand Up @@ -3420,7 +3420,7 @@ void qmp_block_job_finalize(const char *id, Error **errp)
* automatically acquires the new one), so make sure we release the correct
* one.
*/
aio_context = blk_get_aio_context(job->blk);
aio_context = block_job_get_aio_context(job);
job_unref(&job->job);
aio_context_release(aio_context);
}
Expand Down Expand Up @@ -3711,7 +3711,7 @@ BlockJobInfoList *qmp_query_block_jobs(Error **errp)
if (block_job_is_internal(job)) {
continue;
}
aio_context = blk_get_aio_context(job->blk);
aio_context = block_job_get_aio_context(job);
aio_context_acquire(aio_context);
value = block_job_query(job, errp);
aio_context_release(aio_context);
Expand Down
5 changes: 5 additions & 0 deletions blockjob.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,3 +547,8 @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockdevOnError on_err,
}
return action;
}

AioContext *block_job_get_aio_context(BlockJob *job)
{
return job->job.aio_context;
}
7 changes: 7 additions & 0 deletions include/block/blockjob.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,11 @@ bool block_job_is_internal(BlockJob *job);
*/
const BlockJobDriver *block_job_driver(BlockJob *job);

/*
* block_job_get_aio_context:
*
* Returns aio context associated with a block job.
*/
AioContext *block_job_get_aio_context(BlockJob *job);

#endif
2 changes: 1 addition & 1 deletion qemu-img.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ static void common_block_job_cb(void *opaque, int ret)
static void run_block_job(BlockJob *job, Error **errp)
{
uint64_t progress_current, progress_total;
AioContext *aio_context = blk_get_aio_context(job->blk);
AioContext *aio_context = block_job_get_aio_context(job);
int ret = 0;

aio_context_acquire(aio_context);
Expand Down

0 comments on commit df9a316

Please sign in to comment.