From: Kevin Wolf <kwolf@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: qemu-block@nongnu.org, pkrempa@redhat.com, jtc@redhat.com,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC v3 05/14] blockjobs: add block_job_dismiss
Date: Mon, 29 Jan 2018 18:38:02 +0100 [thread overview]
Message-ID: <20180129173802.GN6141@localhost.localdomain> (raw)
In-Reply-To: <20180127020515.27137-6-jsnow@redhat.com>
Am 27.01.2018 um 03:05 hat John Snow geschrieben:
> For jobs that have reached their terminal state, prior to having their
> last reference put down (meaning jobs that have completed successfully,
> unsuccessfully, or have been canceled), allow the user to dismiss the
> job's lingering status report via block-job-dismiss.
>
> This gives management APIs the chance to conclusively determine if a job
> failed or succeeded, even if the event broadcast was missed.
>
> Note that jobs do not yet linger in any such state, they are freed
> immediately upon reaching this previously-unnamed state. such a state is
> added immediately in the next commit.
>
> Valid objects:
> Concluded: (added in a future commit); dismisses the concluded job.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
> block/trace-events | 1 +
> blockdev.c | 14 ++++++++++++++
> blockjob.c | 30 ++++++++++++++++++++++++++++++
> include/block/blockjob.h | 9 +++++++++
> qapi/block-core.json | 19 +++++++++++++++++++
> 5 files changed, 73 insertions(+)
>
> diff --git a/block/trace-events b/block/trace-events
> index 11c8d5f590..8f61566770 100644
> --- a/block/trace-events
> +++ b/block/trace-events
> @@ -46,6 +46,7 @@ qmp_block_job_cancel(void *job) "job %p"
> qmp_block_job_pause(void *job) "job %p"
> qmp_block_job_resume(void *job) "job %p"
> qmp_block_job_complete(void *job) "job %p"
> +qmp_block_job_dismiss(void *job) "job %p"
> qmp_block_stream(void *bs, void *job) "bs %p job %p"
>
> # block/file-win32.c
> diff --git a/blockdev.c b/blockdev.c
> index 2c0773bba7..5e8edff322 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -3849,6 +3849,20 @@ void qmp_block_job_complete(const char *device, Error **errp)
> aio_context_release(aio_context);
> }
>
> +void qmp_block_job_dismiss(const char *id, Error **errp)
> +{
> + AioContext *aio_context;
> + BlockJob *job = find_block_job(id, &aio_context, errp);
> +
> + if (!job) {
> + return;
> + }
> +
> + trace_qmp_block_job_dismiss(job);
> + block_job_dismiss(&job, errp);
> + aio_context_release(aio_context);
> +}
> +
> void qmp_change_backing_file(const char *device,
> const char *image_node_name,
> const char *backing_file,
> diff --git a/blockjob.c b/blockjob.c
> index ea216aca5e..5531f5c2ab 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -58,6 +58,7 @@ enum BlockJobVerb {
> BLOCK_JOB_VERB_RESUME,
> BLOCK_JOB_VERB_SET_SPEED,
> BLOCK_JOB_VERB_COMPLETE,
> + BLOCK_JOB_VERB_DISMISS,
> BLOCK_JOB_VERB__MAX
> };
>
> @@ -68,6 +69,7 @@ bool BlockJobVerb[BLOCK_JOB_VERB__MAX][BLOCK_JOB_STATUS__MAX] = {
> [BLOCK_JOB_VERB_RESUME] = {0, 0, 0, 1, 0},
> [BLOCK_JOB_VERB_SET_SPEED] = {0, 1, 1, 1, 1},
> [BLOCK_JOB_VERB_COMPLETE] = {0, 0, 0, 0, 1},
> + [BLOCK_JOB_VERB_DISMISS] = {0, 0, 0, 0, 0},
This makes it very obvious that the patches should probably be
reordered.
> };
>
> static void block_job_state_transition(BlockJob *job, BlockJobStatus s1)
> @@ -426,6 +428,13 @@ static void block_job_cancel_async(BlockJob *job)
> job->cancelled = true;
> }
>
> +static void block_job_do_dismiss(BlockJob *job)
> +{
> + assert(job && job->manual == true);
> + block_job_state_transition(job, BLOCK_JOB_STATUS_UNDEFINED);
I don't think you made that an allowed transition from anywhere?
> + block_job_unref(job);
> +}
> +
> static int block_job_finish_sync(BlockJob *job,
> void (*finish)(BlockJob *, Error **errp),
> Error **errp)
> @@ -455,6 +464,9 @@ static int block_job_finish_sync(BlockJob *job,
> aio_poll(qemu_get_aio_context(), true);
> }
> ret = (job->cancelled && job->ret == 0) ? -ECANCELED : job->ret;
> + if (job->manual) {
> + block_job_do_dismiss(job);
> + }
> block_job_unref(job);
> return ret;
> }
> @@ -570,6 +582,24 @@ void block_job_complete(BlockJob *job, Error **errp)
> job->driver->complete(job, errp);
> }
>
> +void block_job_dismiss(BlockJob **jobptr, Error **errp)
> +{
> + BlockJob *job = *jobptr;
> + /* similarly to _complete, this is QMP-interface only. */
> + assert(job->id);
> + if (!job->manual) {
> + error_setg(errp, "The active block job '%s' was not started with "
> + "\'manual\': true, and so cannot be dismissed as it will "
> + "clean up after itself automatically", job->id);
> + return;
> + }
If you check instead that the job is in the right state to be dismissed
(CONCLUDED), the job->manual check wouldn't be needed any more because
the user can never catch an automatically completed job in CONCLUDED.
> + error_setg(errp, "unimplemented");
This should hopefully go away when you reorder the patches.
> + block_job_do_dismiss(job);
> + *jobptr = NULL;
> +}
Kevin
next prev parent reply other threads:[~2018-01-29 17:38 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-27 2:05 [Qemu-devel] [RFC v3 00/14] blockjobs: add explicit job management John Snow
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 01/14] blockjobs: add manual property John Snow
2018-01-29 16:59 ` Kevin Wolf
2018-01-29 17:34 ` John Snow
2018-01-29 17:46 ` Kevin Wolf
2018-01-29 17:52 ` John Snow
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 02/14] blockjobs: Add status enum John Snow
2018-01-29 17:04 ` Kevin Wolf
2018-01-29 17:38 ` John Snow
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 03/14] blockjobs: add state transition table John Snow
2018-01-29 17:17 ` Kevin Wolf
2018-01-29 19:07 ` John Snow
2018-01-29 19:56 ` Kevin Wolf
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 04/14] blockjobs: RFC add block_job_verb permission table John Snow
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 05/14] blockjobs: add block_job_dismiss John Snow
2018-01-29 17:38 ` Kevin Wolf [this message]
2018-01-29 20:33 ` John Snow
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 06/14] blockjobs: add CONCLUDED state John Snow
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 07/14] blockjobs: ensure abort is called for cancelled jobs John Snow
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 08/14] blockjobs: add commit, abort, clean helpers John Snow
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 09/14] blockjobs: add prepare callback John Snow
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 10/14] blockjobs: Add waiting event John Snow
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 11/14] blockjobs: add PENDING status and event John Snow
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 12/14] blockjobs: add block-job-finalize John Snow
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 13/14] blockjobs: Expose manual property John Snow
2018-01-27 2:05 ` [Qemu-devel] [RFC v3 14/14] iotests: test manual job dismissal John Snow
2018-01-27 2:25 ` [Qemu-devel] [RFC v3 00/14] blockjobs: add explicit job management no-reply
2018-02-01 0:08 ` John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180129173802.GN6141@localhost.localdomain \
--to=kwolf@redhat.com \
--cc=jsnow@redhat.com \
--cc=jtc@redhat.com \
--cc=pkrempa@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).