#define BLOCKJOB_INT_H
#include "block/blockjob.h"
-#include "block/block.h"
/**
* BlockJobDriver:
/** Generic JobDriver callbacks and settings */
JobDriver job_driver;
- /**
- * Optional callback for job types whose completion must be triggered
- * manually.
- */
- void (*complete)(BlockJob *job, Error **errp);
-
- /**
- * 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
- * if it is not in a transaction.
+ /*
+ * I/O API functions. These functions are thread-safe.
*
- * This callback will not be invoked if the job has already failed.
- * If it fails, abort and then clean will be called.
+ * See include/block/block-io.h for more information about
+ * the I/O API.
*/
- int (*prepare)(BlockJob *job);
- /**
- * If the callback is not NULL, it will be invoked when all the jobs
- * belonging to the same transaction complete; or upon this job's
- * completion if it is not in a transaction. Skipped if NULL.
- *
- * All jobs will complete with a call to either .commit() or .abort() but
- * never both.
+ /*
+ * Returns whether the job has pending requests for the child or will
+ * submit new requests before the next pause point. This callback is polled
+ * in the context of draining a job node after requesting that the job be
+ * paused, until all activity on the child has stopped.
*/
- void (*commit)(BlockJob *job);
+ bool (*drained_poll)(BlockJob *job);
- /**
- * If the callback is not NULL, it will be invoked when any job in the
- * same transaction fails; or upon this job's failure (due to error or
- * cancellation) if it is not in a transaction. Skipped if NULL.
+ /*
+ * Global state (GS) API. These functions run under the BQL.
*
- * All jobs will complete with a call to either .commit() or .abort() but
- * never both.
- */
- void (*abort)(BlockJob *job);
-
- /**
- * If the callback is not NULL, it will be invoked after a call to either
- * .commit() or .abort(). Regardless of which callback is invoked after
- * completion, .clean() will always be called, even if the job does not
- * belong to a transaction group.
+ * See include/block/block-global-state.h for more information about
+ * the GS API.
*/
- void (*clean)(BlockJob *job);
/*
* If the callback is not NULL, it will be invoked before the job is
*/
void (*attached_aio_context)(BlockJob *job, AioContext *new_context);
- /*
- * If the callback is not NULL, it will be invoked when the job has to be
- * synchronously cancelled or completed; it should drain BlockDriverStates
- * as required to ensure progress.
- */
- void (*drain)(BlockJob *job);
+ void (*set_speed)(BlockJob *job, int64_t speed);
};
+/*
+ * Global state (GS) API. These functions run under the BQL.
+ *
+ * See include/block/block-global-state.h for more information about
+ * the GS API.
+ */
+
/**
* block_job_create:
* @job_id: The id of the newly-created job, or %NULL to have one
* @bs: The block
* @perm, @shared_perm: Permissions to request for @bs
* @speed: The maximum speed, in bytes per second, or 0 for unlimited.
- * @flags: Creation flags for the Block Job.
- * See @BlockJobCreateFlags
+ * @flags: Creation flags for the Block Job. See @JobCreateFlags.
* @cb: Completion function for the job.
* @opaque: Opaque pointer value passed to @cb.
* @errp: Error object.
* called from a wrapper that is specific to the job type.
*/
void *block_job_create(const char *job_id, const BlockJobDriver *driver,
- BlockJobTxn *txn, BlockDriverState *bs, uint64_t perm,
+ JobTxn *txn, BlockDriverState *bs, uint64_t perm,
uint64_t shared_perm, int64_t speed, int flags,
BlockCompletionFunc *cb, void *opaque, Error **errp);
*/
void block_job_user_resume(Job *job);
-/**
- * block_job_yield:
- * @job: The job that calls the function.
+/*
+ * I/O API functions. These functions are thread-safe.
*
- * Yield the block job coroutine.
+ * See include/block/block-io.h for more information about
+ * the I/O API.
*/
-void block_job_yield(BlockJob *job);
/**
* block_job_ratelimit_get_delay:
*/
int64_t block_job_ratelimit_get_delay(BlockJob *job, uint64_t n);
-/**
- * block_job_early_fail:
- * @bs: The block device.
- *
- * The block job could not be started, free it.
- */
-void block_job_early_fail(BlockJob *job);
-
-/**
- * block_job_completed:
- * @job: The job being completed.
- * @ret: The status code.
- *
- * Call the completion function that was registered at creation time, and
- * free @job.
- */
-void block_job_completed(BlockJob *job, int ret);
-
-/**
- * block_job_enter:
- * @job: The job to enter.
- *
- * Continue the specified job by entering the coroutine.
- */
-void block_job_enter(BlockJob *job);
-
-/**
- * block_job_event_ready:
- * @job: The job which is now ready to be completed.
- *
- * Send a BLOCK_JOB_READY event for the specified job.
- */
-void block_job_event_ready(BlockJob *job);
-
/**
* block_job_error_action:
* @job: The job to signal an error for.