blockjob: Introduce block_job_ratelimit_get_delay()

This gets us rid of more direct accesses to BlockJob fields from the
job drivers.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
This commit is contained in:
Kevin Wolf 2018-01-18 21:19:38 +01:00
parent 18bb69287e
commit dee81d5111
6 changed files with 29 additions and 19 deletions

View file

@ -165,6 +165,14 @@ void block_job_sleep_ns(BlockJob *job, int64_t ns);
*/
void block_job_yield(BlockJob *job);
/**
* block_job_ratelimit_get_delay:
*
* Calculate and return delay for the next request in ns. See the documentation
* of ratelimit_calculate_delay() for details.
*/
int64_t block_job_ratelimit_get_delay(BlockJob *job, uint64_t n);
/**
* block_job_early_fail:
* @bs: The block device.