All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	qemu-stable@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 1/5] blockdev-mirror: Sanity check before moving target_bs AioContext
Date: Wed, 28 Sep 2016 18:37:01 +0200	[thread overview]
Message-ID: <6d56ac2d-aa76-f323-085b-54f0dd4e519c@redhat.com> (raw)
In-Reply-To: <1474958276-7715-2-git-send-email-famz@redhat.com>

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

On 27.09.2016 08:37, Fam Zheng wrote:
> Similar to blockdev-backup, if the target was already moved to a
> different AioContext, bad things can happen. This happens when the
> target belongs to a data plane device. It's a very unlikely case, but
> let's check it anyway.

You didn't implement it for blockdev-mirror, though, but for
drive-mirror (which I don't think needs this check).

Max

> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  blockdev.c | 35 ++++++++++++++++++++++++-----------
>  1 file changed, 24 insertions(+), 11 deletions(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 29c6561..a4960b9 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -3281,6 +3281,21 @@ BlockDeviceInfoList *qmp_query_named_block_nodes(Error **errp)
>      return bdrv_named_nodes_list(errp);
>  }
>  
> +static void blockdev_set_aio_context(BlockDriverState *bs, AioContext *ctx,
> +                                     Error **errp)
> +{
> +    if (bdrv_get_aio_context(bs) != ctx) {
> +        if (!bdrv_has_blk(bs)) {
> +            /* The target BDS is not attached, we can safely move it to another
> +             * AioContext. */
> +            bdrv_set_aio_context(bs, ctx);
> +        } else {
> +            error_setg(errp, "Target is attached to a different thread from "
> +                             "source.");
> +        }
> +    }
> +}
> +
>  void do_blockdev_backup(BlockdevBackup *backup, BlockJobTxn *txn, Error **errp)
>  {
>      BlockDriverState *bs;
> @@ -3317,16 +3332,10 @@ void do_blockdev_backup(BlockdevBackup *backup, BlockJobTxn *txn, Error **errp)
>          goto out;
>      }
>  
> -    if (bdrv_get_aio_context(target_bs) != aio_context) {
> -        if (!bdrv_has_blk(target_bs)) {
> -            /* The target BDS is not attached, we can safely move it to another
> -             * AioContext. */
> -            bdrv_set_aio_context(target_bs, aio_context);
> -        } else {
> -            error_setg(errp, "Target is attached to a different thread from "
> -                             "source.");
> -            goto out;
> -        }
> +    blockdev_set_aio_context(target_bs, aio_context, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        goto out;
>      }
>      backup_start(backup->job_id, bs, target_bs, backup->speed, backup->sync,
>                   NULL, backup->compress, backup->on_source_error,
> @@ -3538,7 +3547,11 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
>          goto out;
>      }
>  
> -    bdrv_set_aio_context(target_bs, aio_context);
> +    blockdev_set_aio_context(target_bs, aio_context, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        goto out;
> +    }
>  
>      blockdev_mirror_common(arg->has_job_id ? arg->job_id : NULL, bs, target_bs,
>                             arg->has_replaces, arg->replaces, arg->sync,
> 



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

  reply	other threads:[~2016-09-28 16:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-27  6:37 [Qemu-devel] [PATCH v2 0/5] block: keep AioContext pointer in BlockBackend Fam Zheng
2016-09-27  6:37 ` [Qemu-devel] [PATCH v2 1/5] blockdev-mirror: Sanity check before moving target_bs AioContext Fam Zheng
2016-09-28 16:37   ` Max Reitz [this message]
2016-09-29  3:14     ` Fam Zheng
2016-09-27  6:37 ` [Qemu-devel] [PATCH v2 2/5] blockdev: Move BDS AioContext before inserting to BB Fam Zheng
2016-09-28 17:09   ` Max Reitz
2016-09-27  6:37 ` [Qemu-devel] [PATCH v2 3/5] block: Introduce and make use of blk_new_with_root Fam Zheng
2016-09-28 17:21   ` Max Reitz
2016-09-27  6:37 ` [Qemu-devel] [PATCH v2 4/5] migration: Set correct AioContext to BlockBackend Fam Zheng
2016-09-28 17:26   ` Max Reitz
2016-09-27  6:37 ` [Qemu-devel] [PATCH v2 5/5] block: keep AioContext pointer in BlockBackend Fam Zheng
2016-09-28 17:47   ` Max Reitz
2016-09-29  3:05     ` Fam Zheng
2016-09-29  7:47       ` Paolo Bonzini
2016-09-30  5:22         ` Fam Zheng

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=6d56ac2d-aa76-f323-085b-54f0dd4e519c@redhat.com \
    --to=mreitz@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@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 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.