qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 02/27] mirror: Fix permission problem with 'replaces'
Date: Tue,  7 Mar 2017 16:40:26 +0100	[thread overview]
Message-ID: <1488901251-16214-3-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1488901251-16214-1-git-send-email-kwolf@redhat.com>

The 'replaces' option of drive-mirror can be used to mirror a Quorum
node to a new image and then let the target image replace one of the
Quorum children. In order for this graph modification to succeed, the
mirror job needs to lift its restrictions on the target node first
before actually replacing the child.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/mirror.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/block/mirror.c b/block/mirror.c
index 57f26c3..c9185b3 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -509,6 +509,13 @@ static void mirror_exit(BlockJob *job, void *opaque)
      * block_job_completed(). */
     bdrv_ref(src);
     bdrv_ref(mirror_top_bs);
+    bdrv_ref(target_bs);
+
+    /* Remove target parent that still uses BLK_PERM_WRITE/RESIZE before
+     * inserting target_bs at s->to_replace, where we might not be able to get
+     * these permissions. */
+    blk_unref(s->target);
+    s->target = NULL;
 
     /* We don't access the source any more. Dropping any WRITE/RESIZE is
      * required before it could become a backing file of target_bs. */
@@ -555,8 +562,7 @@ static void mirror_exit(BlockJob *job, void *opaque)
         aio_context_release(replace_aio_context);
     }
     g_free(s->replaces);
-    blk_unref(s->target);
-    s->target = NULL;
+    bdrv_unref(target_bs);
 
     /* Remove the mirror filter driver from the graph. Before this, get rid of
      * the blockers on the intermediate nodes so that the resulting state is
-- 
1.8.3.1

  parent reply	other threads:[~2017-03-07 15:41 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-07 15:40 [Qemu-devel] [PULL 00/27] Block layer fixes for 2.9.0-rc0 Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 01/27] commit: Fix error handling Kevin Wolf
2017-03-07 15:40 ` Kevin Wolf [this message]
2017-03-07 15:40 ` [Qemu-devel] [PULL 03/27] mirror: Fix permissions for removing mirror_top_bs Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 04/27] mirror: Fix error path for dirty bitmap creation Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 05/27] block: Fix blockdev-snapshot error handling Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 06/27] block: Factor out should_update_child() Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 07/27] block: Factor out bdrv_replace_child_noperm() Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 08/27] block: Ignore multiple children in bdrv_check_update_perm() Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 09/27] block: Handle permission errors in change_parent_backing_link() Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 10/27] block: Fix error handling in bdrv_replace_in_backing_chain() Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 11/27] sheepdog: Defuse time bomb in sd_open() error handling Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 12/27] sheepdog: Fix error handling in sd_snapshot_delete() Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 13/27] sheepdog: Fix error handling sd_create() Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 14/27] sheepdog: Mark sd_snapshot_delete() lossage FIXME Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 15/27] sheepdog: Fix snapshot ID parsing in _open(), _create, _goto() Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 16/27] sheepdog: Don't truncate long VDI name in _open(), _create() Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 17/27] sheepdog: Report errors in pseudo-filename more usefully Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 18/27] sheepdog: Use SocketAddress and socket_connect() Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 19/27] sheepdog: Implement bdrv_parse_filename() Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 20/27] gluster: Drop assumptions on SocketTransport names Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 21/27] gluster: Don't duplicate qapi-util.c's qapi_enum_parse() Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 22/27] gluster: Plug memory leaks in qemu_gluster_parse_json() Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 23/27] qapi-schema: Rename GlusterServer to SocketAddressFlat Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 24/27] qapi-schema: Rename SocketAddressFlat's variant tcp to inet Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 25/27] sheepdog: Support blockdev-add Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 26/27] block: Don't use error_abort in blk_new_open Kevin Wolf
2017-03-07 15:40 ` [Qemu-devel] [PULL 27/27] commit: Don't use error_abort in commit_start Kevin Wolf
2017-03-08 14:49 ` [Qemu-devel] [PULL 00/27] Block layer fixes for 2.9.0-rc0 Peter Maydell

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=1488901251-16214-3-git-send-email-kwolf@redhat.com \
    --to=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 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).