All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: John Snow <jsnow@redhat.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: jtc@redhat.com, Kevin Wolf <kwolf@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Eric Blake <eblake@redhat.com>, Jeff Cody <jcody@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 05/15] block/mirror: don't install backing chain on abort
Date: Mon, 3 Sep 2018 11:24:46 +0200	[thread overview]
Message-ID: <b79cdffa-a0d4-824c-b9fd-b5aba38e61bd@redhat.com> (raw)
In-Reply-To: <20180831222907.16257-6-jsnow@redhat.com>

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

On 2018-09-01 00:28, John Snow wrote:
> In cases where we abort the block/mirror job, there's no point in
> installing the new backing chain before we finish aborting.
> 
> Move this to the "success" portion of mirror_exit.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  block/mirror.c | 27 ++++++++++++++-------------
>  1 file changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/block/mirror.c b/block/mirror.c
> index cba555b4ef..c164fee883 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -642,16 +642,6 @@ static void mirror_exit(Job *job)
>       * required before it could become a backing file of target_bs. */
>      bdrv_child_try_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL,
>                              &error_abort);
> -    if (s->backing_mode == MIRROR_SOURCE_BACKING_CHAIN) {
> -        BlockDriverState *backing = s->is_none_mode ? src : s->base;
> -        if (backing_bs(target_bs) != backing) {
> -            bdrv_set_backing_hd(target_bs, backing, &local_err);
> -            if (local_err) {
> -                error_report_err(local_err);
> -                ret = -EPERM;
> -            }
> -        }
> -    }
>  
>      if (s->to_replace) {
>          replace_aio_context = bdrv_get_aio_context(s->to_replace);
> @@ -659,9 +649,18 @@ static void mirror_exit(Job *job)
>      }
>  
>      if (s->should_complete && ret == 0) {
> -        BlockDriverState *to_replace = src;
> -        if (s->to_replace) {
> -            to_replace = s->to_replace;
> +        BlockDriverState *to_replace = s->to_replace ? s->to_replace : src;
> +
> +        if (s->backing_mode == MIRROR_SOURCE_BACKING_CHAIN) {
> +            BlockDriverState *backing = s->is_none_mode ? src : s->base;
> +            if (backing_bs(target_bs) != backing) {
> +                bdrv_set_backing_hd(target_bs, backing, &local_err);
> +                if (local_err) {
> +                    error_report_err(local_err);
> +                    ret = -EPERM;
> +                    goto clean;
> +                }
> +            }
>          }
>  
>          if (bdrv_get_flags(target_bs) != bdrv_get_flags(to_replace)) {

Testing shows that on post-READY cancel, s->should_complete is 0 (which
makes sense, because all the rest in this path is about replacing
to_replace by target_bs, which we don't want to do on cancel), so this
would not be executed.

However, I think we do want to give the target the correct backing chain
when the job is canceled this way (as I suppose there are ways to keep
the target around even with drive-mirror).

So we should attach the backing chain whenever ret == 0, not just when
s->should_complete is true.

Max

> @@ -678,6 +677,8 @@ static void mirror_exit(Job *job)
>              ret = -EPERM;
>          }
>      }
> +
> + clean:
>      if (s->to_replace) {
>          bdrv_op_unblock_all(s->to_replace, s->replace_blocker);
>          error_free(s->replace_blocker);
> 



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

  reply	other threads:[~2018-09-03  9:25 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-31 22:28 [Qemu-devel] [PATCH v3 00/15] jobs: Job Exit Refactoring Pt 2 John Snow
2018-08-31 22:28 ` [Qemu-devel] [PATCH v3 01/15] block/commit: add block job creation flags John Snow
2018-09-01  3:17   ` Jeff Cody
2018-08-31 22:28 ` [Qemu-devel] [PATCH v3 02/15] block/mirror: " John Snow
2018-09-01  3:31   ` Jeff Cody
2018-08-31 22:28 ` [Qemu-devel] [PATCH v3 03/15] block/stream: " John Snow
2018-08-31 22:34   ` Eric Blake
2018-09-01  3:33   ` Jeff Cody
2018-08-31 22:28 ` [Qemu-devel] [PATCH v3 04/15] block/commit: refactor commit to use job callbacks John Snow
2018-08-31 22:28 ` [Qemu-devel] [PATCH v3 05/15] block/mirror: don't install backing chain on abort John Snow
2018-09-03  9:24   ` Max Reitz [this message]
2018-09-04 19:15     ` John Snow
2018-09-04 19:30       ` Eric Blake
2018-09-04 20:10         ` John Snow
2018-09-05  9:54         ` Kevin Wolf
2018-09-05 12:59           ` John Snow
2018-08-31 22:28 ` [Qemu-devel] [PATCH v3 06/15] block/mirror: conservative mirror_exit refactor John Snow
2018-09-03  9:32   ` Max Reitz
2018-09-04 16:17     ` John Snow
2018-08-31 22:28 ` [Qemu-devel] [PATCH v3 07/15] block/commit: refactor stream to use job callbacks John Snow
2018-09-03  9:33   ` Max Reitz
2018-08-31 22:29 ` [Qemu-devel] [PATCH v3 08/15] tests/blockjob: replace Blockjob with Job John Snow
2018-08-31 22:29 ` [Qemu-devel] [PATCH v3 09/15] tests/test-blockjob: remove exit callback John Snow
2018-08-31 22:29 ` [Qemu-devel] [PATCH v3 10/15] tests/test-blockjob-txn: move .exit to .clean John Snow
2018-09-03  9:41   ` Max Reitz
2018-08-31 22:29 ` [Qemu-devel] [PATCH v3 11/15] jobs: remove .exit callback John Snow
2018-08-31 22:29 ` [Qemu-devel] [PATCH v3 12/15] qapi/block-commit: expose new job properties John Snow
2018-08-31 22:29 ` [Qemu-devel] [PATCH v3 13/15] qapi/block-mirror: " John Snow
2018-08-31 22:29 ` [Qemu-devel] [PATCH v3 14/15] qapi/block-stream: " John Snow
2018-08-31 22:29 ` [Qemu-devel] [PATCH v3 15/15] block/backup: qapi documentation fixup 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=b79cdffa-a0d4-824c-b9fd-b5aba38e61bd@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=jtc@redhat.com \
    --cc=kwolf@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 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.