Block patches:
- (Block) job exit refactoring, part 1 (removing job_defer_to_main_loop()) - test-bdrv-drain leak fix -----BEGIN PGP SIGNATURE----- iQEcBAABAgAGBQJbiVEJAAoJEPQH2wBh1c9AHb4H/0P6yjozmu8J6cQhfXmFsJQk 72Y6Lu9w7kNL43dEBkAU3vzDPUkzHRwpO5pLPKqQh0ojCz45KfTMozh/iMoJtuKP Hev4ZlRlFpcr0NHLQnysxsgV7FYbDEVS9xdQ6KlgFXyDBLgZVGykjq67kwDtXfnp eQof9Nf0T+m3bNJey6C43l4YqPzPIUCfoSgCqkoB1W6QGtfglGx8I4evjjgxv7GT s8IzBg7WSi7h8+mouZcXOs8/w7nJNeSSbMb921NXCWXCzIVHLpw5SImDiQfxEvcy pnBtVttty6pAmQvOC6GphqHPNIeRYLTIxkEzBxZUAePonsEa9zw33pjBGdWtSPU= =60m9 -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/xanclic/tags/pull-block-2018-08-31-v2' into staging Block patches: - (Block) job exit refactoring, part 1 (removing job_defer_to_main_loop()) - test-bdrv-drain leak fix # gpg: Signature made Fri 31 Aug 2018 15:30:33 BST # gpg: using RSA key F407DB0061D5CF40 # gpg: Good signature from "Max Reitz <mreitz@redhat.com>" # Primary key fingerprint: 91BE B60A 30DB 3E88 57D1 1829 F407 DB00 61D5 CF40 * remotes/xanclic/tags/pull-block-2018-08-31-v2: jobs: remove job_defer_to_main_loop jobs: remove ret argument to job_completed; privatize it block/backup: make function variables consistently named jobs: utilize job_exit shim block/mirror: utilize job_exit shim block/commit: utilize job_exit shim jobs: add exit shim jobs: canonize Error object jobs: change start callback to run callback tests: fix bdrv-drain leak Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
d6f71af654
12 changed files with 161 additions and 242 deletions
|
|
@ -124,12 +124,20 @@ typedef struct Job {
|
|||
/** Estimated progress_current value at the completion of the job */
|
||||
int64_t progress_total;
|
||||
|
||||
/** Error string for a failed job (NULL if, and only if, job->ret == 0) */
|
||||
char *error;
|
||||
|
||||
/** ret code passed to job_completed. */
|
||||
/**
|
||||
* Return code from @run and/or @prepare callback(s).
|
||||
* Not final until the job has reached the CONCLUDED status.
|
||||
* 0 on success, -errno on failure.
|
||||
*/
|
||||
int ret;
|
||||
|
||||
/**
|
||||
* Error object for a failed job.
|
||||
* If job->ret is nonzero and an error object was not set, it will be set
|
||||
* to strerror(-job->ret) during job_completed.
|
||||
*/
|
||||
Error *err;
|
||||
|
||||
/** The completion function that will be called when the job completes. */
|
||||
BlockCompletionFunc *cb;
|
||||
|
||||
|
|
@ -168,8 +176,17 @@ struct JobDriver {
|
|||
/** Enum describing the operation */
|
||||
JobType job_type;
|
||||
|
||||
/** Mandatory: Entrypoint for the Coroutine. */
|
||||
CoroutineEntry *start;
|
||||
/**
|
||||
* Mandatory: Entrypoint for the Coroutine.
|
||||
*
|
||||
* This callback will be invoked when moving from CREATED to RUNNING.
|
||||
*
|
||||
* If this callback returns nonzero, the job transaction it is part of is
|
||||
* aborted. If it returns zero, the job moves into the WAITING state. If it
|
||||
* is the last job to complete in its transaction, all jobs in the
|
||||
* transaction move from WAITING to PENDING.
|
||||
*/
|
||||
int coroutine_fn (*run)(Job *job, Error **errp);
|
||||
|
||||
/**
|
||||
* If the callback is not NULL, it will be invoked when the job transitions
|
||||
|
|
@ -204,6 +221,17 @@ struct JobDriver {
|
|||
*/
|
||||
void (*drain)(Job *job);
|
||||
|
||||
/**
|
||||
* If the callback is not NULL, exit will be invoked from the main thread
|
||||
* when the job's coroutine has finished, but before transactional
|
||||
* convergence; before @prepare or @abort.
|
||||
*
|
||||
* FIXME TODO: This callback is only temporary to transition remaining jobs
|
||||
* to prepare/commit/abort/clean callbacks and will be removed before 3.1.
|
||||
* is released.
|
||||
*/
|
||||
void (*exit)(Job *job);
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
@ -481,19 +509,6 @@ void job_early_fail(Job *job);
|
|||
/** Moves the @job from RUNNING to READY */
|
||||
void job_transition_to_ready(Job *job);
|
||||
|
||||
/**
|
||||
* @job: The job being completed.
|
||||
* @ret: The status code.
|
||||
* @error: The error message for a failing job (only with @ret < 0). If @ret is
|
||||
* negative, but NULL is given for @error, strerror() is used.
|
||||
*
|
||||
* Marks @job as completed. If @ret is non-zero, the job transaction it is part
|
||||
* of is aborted. If @ret is zero, the job moves into the WAITING state. If it
|
||||
* is the last job to complete in its transaction, all jobs in the transaction
|
||||
* move from WAITING to PENDING.
|
||||
*/
|
||||
void job_completed(Job *job, int ret, Error *error);
|
||||
|
||||
/** Asynchronously complete the specified @job. */
|
||||
void job_complete(Job *job, Error **errp);
|
||||
|
||||
|
|
@ -553,23 +568,6 @@ void job_finalize(Job *job, Error **errp);
|
|||
*/
|
||||
void job_dismiss(Job **job, Error **errp);
|
||||
|
||||
typedef void JobDeferToMainLoopFn(Job *job, void *opaque);
|
||||
|
||||
/**
|
||||
* @job: The job
|
||||
* @fn: The function to run in the main loop
|
||||
* @opaque: The opaque value that is passed to @fn
|
||||
*
|
||||
* This function must be called by the main job coroutine just before it
|
||||
* returns. @fn is executed in the main loop with the job AioContext acquired.
|
||||
*
|
||||
* Block jobs must call bdrv_unref(), bdrv_close(), and anything that uses
|
||||
* bdrv_drain_all() in the main loop.
|
||||
*
|
||||
* The @job AioContext is held while @fn executes.
|
||||
*/
|
||||
void job_defer_to_main_loop(Job *job, JobDeferToMainLoopFn *fn, void *opaque);
|
||||
|
||||
/**
|
||||
* Synchronously finishes the given @job. If @finish is given, it is called to
|
||||
* trigger completion or cancellation of the job.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue