[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v2 09/13] block/backup: remove yield_and_check
From: |
Max Reitz |
Subject: |
Re: [Qemu-block] [PATCH v2 09/13] block/backup: remove yield_and_check |
Date: |
Wed, 7 Feb 2018 23:33:31 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 |
On 2018-01-19 21:58, John Snow wrote:
> This is a respin of the same functionality as mirror_throttle,
> so trash this and replace it with the generic version.
>
> yield_and_check returned true if canceled, false otherwise.
> block_job_relax returns -ECANCELED if canceled, 0 otherwise.
>
> Signed-off-by: John Snow <address@hidden>
> ---
> block/backup.c | 20 ++++----------------
> 1 file changed, 4 insertions(+), 16 deletions(-)
>
> diff --git a/block/backup.c b/block/backup.c
> index b4204c0ee4..0624c3b322 100644
> --- a/block/backup.c
> +++ b/block/backup.c
> @@ -334,29 +334,17 @@ static void backup_complete(BlockJob *job, void *opaque)
> g_free(data);
> }
>
> -static bool coroutine_fn yield_and_check(BackupBlockJob *job)
> +static uint64_t get_delay_ns(BackupBlockJob *job)
> {
> uint64_t delay_ns = 0;
>
> - if (block_job_is_cancelled(&job->common)) {
> - return true;
> - }
> -
> - /* we need to yield so that bdrv_drain_all() returns.
> - * (without, VM does not reboot)
> - */
> if (job->common.speed) {
> delay_ns = ratelimit_calculate_delay(&job->limit,
> job->bytes_read);
> job->bytes_read = 0;
> }
>
> - block_job_relax(&job->common, delay_ns);
> - if (block_job_is_cancelled(&job->common)) {
> - return true;
> - }
> -
> - return false;
> + return delay_ns;
> }
>
> static int coroutine_fn backup_run_incremental(BackupBlockJob *job)
> @@ -369,7 +357,7 @@ static int coroutine_fn
> backup_run_incremental(BackupBlockJob *job)
> hbitmap_iter_init(&hbi, job->copy_bitmap, 0);
> while ((cluster = hbitmap_iter_next(&hbi)) != -1) {
> do {
> - if (yield_and_check(job)) {
> + if (block_job_relax(&job->common, get_delay_ns(job))) {
> return 0;
> }
> ret = backup_do_cow(job, cluster * job->cluster_size,
> @@ -465,7 +453,7 @@ static void coroutine_fn backup_run(void *opaque)
> bool error_is_read;
> int alloced = 0;
>
> - if (yield_and_check(job)) {
> + if (block_job_relax(&job->common, get_delay_ns(job))) {
> break;
> }
>
>
I'd very much prefer an explicit block_job_relax(...) == -ECANCELED, I
have to say.
If you coerce me, I can give an R-b, but you'll have to wrest it from me
by force!
Max
signature.asc
Description: OpenPGP digital signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-block] [PATCH v2 09/13] block/backup: remove yield_and_check,
Max Reitz <=