[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v2 3/3] blockjob: add devops to blockjob backend
From: |
Jeff Cody |
Subject: |
Re: [Qemu-block] [PATCH v2 3/3] blockjob: add devops to blockjob backends |
Date: |
Wed, 22 Mar 2017 12:11:56 -0400 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Thu, Mar 16, 2017 at 05:23:51PM -0400, John Snow wrote:
> This lets us hook into drained_begin and drained_end requests from the
> backend level, which is particularly useful for making sure that all
> jobs associated with a particular node (whether the source or the target)
> receive a drain request.
>
> Suggested-by: Kevin Wolf <address@hidden>
> Signed-off-by: John Snow <address@hidden>
> ---
> blockjob.c | 29 ++++++++++++++++++++++++-----
> 1 file changed, 24 insertions(+), 5 deletions(-)
>
> diff --git a/blockjob.c b/blockjob.c
> index 69b4ec6..a11d5ce 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -68,6 +68,23 @@ static const BdrvChildRole child_job = {
> .stay_at_node = true,
> };
>
> +static void block_job_drained_begin(void *opaque)
> +{
> + BlockJob *job = opaque;
> + block_job_pause(job);
> +}
> +
> +static void block_job_drained_end(void *opaque)
> +{
> + BlockJob *job = opaque;
> + block_job_resume(job);
> +}
> +
> +static const BlockDevOps block_job_dev_ops = {
> + .drained_begin = block_job_drained_begin,
> + .drained_end = block_job_drained_end,
> +};
> +
> BlockJob *block_job_next(BlockJob *job)
> {
> if (!job) {
> @@ -205,11 +222,6 @@ void *block_job_create(const char *job_id, const
> BlockJobDriver *driver,
> }
>
> job = g_malloc0(driver->instance_size);
> - error_setg(&job->blocker, "block device is in use by block job: %s",
> - BlockJobType_lookup[driver->job_type]);
> - block_job_add_bdrv(job, "main node", bs, 0, BLK_PERM_ALL, &error_abort);
> - bdrv_op_unblock(bs, BLOCK_OP_TYPE_DATAPLANE, job->blocker);
> -
> job->driver = driver;
> job->id = g_strdup(job_id);
> job->blk = blk;
> @@ -219,8 +231,15 @@ void *block_job_create(const char *job_id, const
> BlockJobDriver *driver,
> job->paused = true;
> job->pause_count = 1;
> job->refcnt = 1;
> +
> + error_setg(&job->blocker, "block device is in use by block job: %s",
> + BlockJobType_lookup[driver->job_type]);
> + block_job_add_bdrv(job, "main node", bs, 0, BLK_PERM_ALL, &error_abort);
> bs->job = job;
>
> + blk_set_dev_ops(blk, &block_job_dev_ops, job);
> + bdrv_op_unblock(bs, BLOCK_OP_TYPE_DATAPLANE, job->blocker);
> +
> QLIST_INSERT_HEAD(&block_jobs, job, job_list);
>
> blk_add_aio_context_notifier(blk, block_job_attached_aio_context,
> --
> 2.9.3
>
Reviewed-by: Jeff Cody <address@hidden>
Re: [Qemu-block] [PATCH v2 0/3] block: pause block jobs for bdrv_drain_begin/end, Stefan Hajnoczi, 2017/03/23