From: Fam Zheng <famz@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
Kevin Wolf <kwolf@redhat.com>, Jeff Cody <jcody@redhat.com>
Subject: Re: [Qemu-devel] [PATCH for-2.6 1/2] block/mirror: Revive dead yielding code
Date: Wed, 20 Apr 2016 13:47:12 +0800 [thread overview]
Message-ID: <20160420054712.GA1404@ad-mail.usersys.redhat.com> (raw)
In-Reply-To: <1461106788-14285-2-git-send-email-mreitz@redhat.com>
On Wed, 04/20 00:59, Max Reitz wrote:
> mirror_iteration() is supposed to wait if the current chunk is subject
> to a still in-flight mirroring operation. However, it mixed checking
> this conflict situation with checking the dirty status of a chunk. A
> simplification for the latter condition (the first chunk encountered is
> always dirty) led to neglecting the former: We just skip the first chunk
> and thus never test whether it conflicts with an in-flight operation.
>
> To fix this, pull out the code which waits for in-flight operations on
> the first chunk of the range to be mirrored to settle.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> block/mirror.c | 23 ++++++++++++-----------
> 1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/block/mirror.c b/block/mirror.c
> index c2cfc1a..2714a77 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -298,7 +298,7 @@ static void mirror_do_zero_or_discard(MirrorBlockJob *s,
> static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)
> {
> BlockDriverState *source = s->common.bs;
> - int64_t sector_num;
> + int64_t sector_num, first_chunk;
> uint64_t delay_ns = 0;
> /* At least the first dirty chunk is mirrored in one iteration. */
> int nb_chunks = 1;
> @@ -313,6 +313,12 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)
> assert(sector_num >= 0);
> }
>
> + first_chunk = sector_num / sectors_per_chunk;
> + while (test_bit(first_chunk, s->in_flight_bitmap)) {
> + trace_mirror_yield_in_flight(s, first_chunk, s->in_flight);
> + mirror_wait_for_io(s);
> + }
> +
> /* Find the number of consective dirty chunks following the first dirty
> * one, and wait for in flight requests in them. */
> while (nb_chunks * sectors_per_chunk < (s->buf_size >> BDRV_SECTOR_BITS)) {
> @@ -324,17 +330,12 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)
> break;
> }
> if (test_bit(next_chunk, s->in_flight_bitmap)) {
Now this can be combiled into the previous if block.
> - if (nb_chunks > 0) {
> - break;
> - }
> - trace_mirror_yield_in_flight(s, next_sector, s->in_flight);
> - mirror_wait_for_io(s);
> - /* Now retry. */
> - } else {
> - hbitmap_next = hbitmap_iter_next(&s->hbi);
> - assert(hbitmap_next == next_sector);
> - nb_chunks++;
> + break;
> }
> +
> + hbitmap_next = hbitmap_iter_next(&s->hbi);
> + assert(hbitmap_next == next_sector);
> + nb_chunks++;
> }
>
> /* Clear dirty bits before querying the block status, because
> --
> 2.8.0
>
Reviewed-by: Fam Zheng <famz@redhat.com>
next prev parent reply other threads:[~2016-04-20 5:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-19 22:59 [Qemu-devel] [PATCH for-2.6 0/2] block/mirror: Fix mirroring with guest I/O load Max Reitz
2016-04-19 22:59 ` [Qemu-devel] [PATCH for-2.6 1/2] block/mirror: Revive dead yielding code Max Reitz
2016-04-20 5:47 ` Fam Zheng [this message]
2016-04-20 12:15 ` Kevin Wolf
2016-04-19 22:59 ` [Qemu-devel] [PATCH for-2.6 2/2] block/mirror: Refresh stale bitmap iterator cache Max Reitz
2016-04-20 8:19 ` Fam Zheng
2016-04-20 12:13 ` Kevin Wolf
2016-04-20 12:51 ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2016-04-20 12:51 ` [Qemu-devel] [PATCH for-2.6 0/2] block/mirror: Fix mirroring with guest I/O load Kevin Wolf
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=20160420054712.GA1404@ad-mail.usersys.redhat.com \
--to=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).