qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com,
	Jeff Cody <jcody@redhat.com>,
	qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] block: Avoid bogus flags during mirroring
Date: Sun, 12 Jun 2016 10:15:13 +0800	[thread overview]
Message-ID: <20160612021513.GB27167@ad.usersys.redhat.com> (raw)
In-Reply-To: <1465694320-13500-1-git-send-email-eblake@redhat.com>

On Sat, 06/11 19:18, Eric Blake wrote:
> Commit e253f4b8 converted mirroring from sector-based bdrv_aio_*
> to byte-based blk_aio_*, but failed to account for the subtle
> difference in signatures (the former takes a semi-redundant length,
> the latter takes a flags parameter).  Since all of our flags are
> currently smaller in size than BDRV_SECTOR_SIZE, it has no ill
> effects until we either perform sub-sector mirroring, or we start
> asserting that no unexpected flags are set.  I found it while
> testing new asserts when qemu-iotests 132 started warning about an
> unknown flag 0x200000.
> 
> Add an assert to help us catch any other improper flags.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  block/block-backend.c | 2 ++
>  block/mirror.c        | 6 ++----
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/block/block-backend.c b/block/block-backend.c
> index 34500e6..a5dc6e3 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -945,6 +945,8 @@ static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes,
>      acb->bh = NULL;
>      acb->has_returned = false;
> 
> +    assert(flags <= 0x1f);
> +

Maybe define BDRV_REQ_FLAGS_MAX in include/block/block.h so it's easier to keep
this assertion valid when we introduce more flags in the future?

Otherwise the patch looks good.

Fam

>      co = qemu_coroutine_create(co_entry);
>      qemu_coroutine_enter(co, acb);
> 
> diff --git a/block/mirror.c b/block/mirror.c
> index fbbc496..41848b2 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -157,8 +157,7 @@ static void mirror_read_complete(void *opaque, int ret)
>          return;
>      }
>      blk_aio_pwritev(s->target, op->sector_num * BDRV_SECTOR_SIZE, &op->qiov,
> -                    op->nb_sectors * BDRV_SECTOR_SIZE,
> -                    mirror_write_complete, op);
> +                    0, mirror_write_complete, op);
>  }
> 
>  static inline void mirror_clip_sectors(MirrorBlockJob *s,
> @@ -275,8 +274,7 @@ static int mirror_do_read(MirrorBlockJob *s, int64_t sector_num,
>      s->sectors_in_flight += nb_sectors;
>      trace_mirror_one_iteration(s, sector_num, nb_sectors);
> 
> -    blk_aio_preadv(source, sector_num * BDRV_SECTOR_SIZE, &op->qiov,
> -                   nb_sectors * BDRV_SECTOR_SIZE,
> +    blk_aio_preadv(source, sector_num * BDRV_SECTOR_SIZE, &op->qiov, 0,
>                     mirror_read_complete, op);
>      return ret;
>  }
> -- 
> 2.5.5
> 
> 

  reply	other threads:[~2016-06-12  2:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-12  1:18 [Qemu-devel] [PATCH] block: Avoid bogus flags during mirroring Eric Blake
2016-06-12  2:15 ` Fam Zheng [this message]
2016-06-13 12:39   ` Eric Blake

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=20160612021513.GB27167@ad.usersys.redhat.com \
    --to=famz@redhat.com \
    --cc=eblake@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).