qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: John Snow <jsnow@redhat.com>, qemu-block@nongnu.org
Cc: kwolf@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org,
	stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 09/13] block/backup: remove yield_and_check
Date: Wed, 7 Feb 2018 23:33:31 +0100	[thread overview]
Message-ID: <cf41be54-9b01-c6cd-e888-e6060dbcec38@redhat.com> (raw)
In-Reply-To: <20180119205847.7141-10-jsnow@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2511 bytes --]

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 <jsnow@redhat.com>
> ---
>  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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

  reply	other threads:[~2018-02-07 22:33 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19 20:58 [Qemu-devel] [PATCH v2 00/13] blockjob: refactor mirror_throttle John Snow
2018-01-19 20:58 ` [Qemu-devel] [PATCH v2 01/13] blockjob: record time of last entrance John Snow
2018-02-07 22:05   ` Max Reitz
2018-01-19 20:58 ` [Qemu-devel] [PATCH v2 02/13] blockjob: consolidate SLICE_TIME definition John Snow
2018-01-19 20:58 ` [Qemu-devel] [PATCH v2 03/13] blockjob: create block_job_relax John Snow
2018-02-07 22:12   ` Max Reitz
2018-01-19 20:58 ` [Qemu-devel] [PATCH v2 04/13] blockjob: allow block_job_throttle to take delay_ns John Snow
2018-02-07 22:17   ` Max Reitz
2018-01-19 20:58 ` [Qemu-devel] [PATCH v2 05/13] block/commit: use block_job_relax John Snow
2018-01-19 20:58 ` [Qemu-devel] [PATCH v2 06/13] block/stream: " John Snow
2018-01-19 20:58 ` [Qemu-devel] [PATCH v2 07/13] block/backup: " John Snow
2018-02-07 22:19   ` Max Reitz
2018-01-19 20:58 ` [Qemu-devel] [PATCH v2 08/13] allow block_job_relax to return -ECANCELED John Snow
2018-02-07 22:27   ` Max Reitz
2018-01-19 20:58 ` [Qemu-devel] [PATCH v2 09/13] block/backup: remove yield_and_check John Snow
2018-02-07 22:33   ` Max Reitz [this message]
2018-01-19 20:58 ` [Qemu-devel] [PATCH v2 10/13] block/mirror: condense cancellation and relax calls John Snow
2018-02-07 22:36   ` Max Reitz
2018-01-19 20:58 ` [Qemu-devel] [PATCH v2 11/13] block/mirror: remove block_job_sleep_ns calls John Snow
2018-02-07 22:46   ` Max Reitz
2018-02-07 22:56     ` Max Reitz
2018-02-09 23:13     ` John Snow
2018-01-19 20:58 ` [Qemu-devel] [PATCH v2 12/13] blockjob: privatize block_job_sleep_ns John Snow
2018-02-07 22:47   ` Max Reitz
2018-01-19 20:58 ` [Qemu-devel] [PATCH v2 13/13] blockjob: remove block_job_pause_point from interface John Snow
2018-02-07 22:50   ` Max Reitz
2018-01-19 21:14 ` [Qemu-devel] [PATCH v2 00/13] blockjob: refactor mirror_throttle no-reply
2018-01-30 20:25 ` 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=cf41be54-9b01-c6cd-e888-e6060dbcec38@redhat.com \
    --to=mreitz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).