All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: kwolf@redhat.com, den@openvz.org, qemu-devel@nongnu.org,
	qemu-block@nongnu.org, mreitz@redhat.com
Subject: Re: [PATCH 2/3] qcow2: refactor handle_dependencies() loop body
Date: Thu, 19 Aug 2021 12:58:18 -0500	[thread overview]
Message-ID: <20210819175818.v4i4hgdmwknvjp2k@redhat.com> (raw)
In-Reply-To: <20210724133846.64614-3-vsementsov@virtuozzo.com>

On Sat, Jul 24, 2021 at 04:38:45PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> No logic change, just prepare for the following commit.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block/qcow2-cluster.c | 49 ++++++++++++++++++++++++-------------------
>  1 file changed, 28 insertions(+), 21 deletions(-)
> 
> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
> index bd0597842f..967121c7e6 100644
> --- a/block/qcow2-cluster.c
> +++ b/block/qcow2-cluster.c
> @@ -1400,29 +1400,36 @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,
>  
>          if (end <= old_start || start >= old_end) {
>              /* No intersection */
> -        } else {
> -            if (start < old_start) {
> -                /* Stop at the start of a running allocation */
> -                bytes = old_start - start;
> -            } else {
> -                bytes = 0;
> -            }
> +            continue;
> +        }
>  
> -            /* Stop if already an l2meta exists. After yielding, it wouldn't

Pre-existing, but...

> -             * be valid any more, so we'd have to clean up the old L2Metas
> -             * and deal with requests depending on them before starting to
> -             * gather new ones. Not worth the trouble. */
> -            if (bytes == 0 && *m) {
> -                *cur_bytes = 0;
> -                return 0;
> -            }
> +        /* Conflict */
>  
> -            if (bytes == 0) {
> -                /* Wait for the dependency to complete. We need to recheck
> -                 * the free/allocated clusters when we continue. */
> -                qemu_co_queue_wait(&old_alloc->dependent_requests, &s->lock);
> -                return -EAGAIN;
> -            }
> +        if (start < old_start) {
> +            /* Stop at the start of a running allocation */
> +            bytes = old_start - start;
> +        } else {
> +            bytes = 0;
> +        }
> +
> +        /*
> +         * Stop if already an l2meta exists. After yielding, it wouldn't

...might as well fix the grammar:  Stop if an l2meta already exists.

> +         * be valid any more, so we'd have to clean up the old L2Metas
> +         * and deal with requests depending on them before starting to
> +         * gather new ones. Not worth the trouble.
> +         */
> +        if (bytes == 0 && *m) {
> +            *cur_bytes = 0;
> +            return 0;
> +        }
> +
> +        if (bytes == 0) {
> +            /*
> +             * Wait for the dependency to complete. We need to recheck
> +             * the free/allocated clusters when we continue.
> +             */
> +            qemu_co_queue_wait(&old_alloc->dependent_requests, &s->lock);
> +            return -EAGAIN;

So the change adds a short-circuiting 'continue', then reduces the
indentation of the rest of the loop body.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



  reply	other threads:[~2021-08-19 18:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-24 13:38 [PATCH 0/3] qcow2: relax subclusters allocation dependencies Vladimir Sementsov-Ogievskiy
2021-07-24 13:38 ` [PATCH 1/3] simplebench: add img_bench_templater.py Vladimir Sementsov-Ogievskiy
2021-08-19 16:37   ` Hanna Reitz
2021-08-24  8:53     ` Vladimir Sementsov-Ogievskiy
2021-08-24  8:59       ` Hanna Reitz
2021-08-24  9:09         ` Vladimir Sementsov-Ogievskiy
2021-07-24 13:38 ` [PATCH 2/3] qcow2: refactor handle_dependencies() loop body Vladimir Sementsov-Ogievskiy
2021-08-19 17:58   ` Eric Blake [this message]
2021-08-20 11:03   ` Hanna Reitz
2021-07-24 13:38 ` [PATCH 3/3] qcow2: handle_dependencies(): relax conflict detection Vladimir Sementsov-Ogievskiy
2021-08-19 18:02   ` Eric Blake
2021-08-20 13:21   ` Hanna Reitz
2021-08-23 12:24     ` Vladimir Sementsov-Ogievskiy

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=20210819175818.v4i4hgdmwknvjp2k@redhat.com \
    --to=eblake@redhat.com \
    --cc=den@openvz.org \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.