From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 08/14] block/mirror: Fix child permissions
Date: Tue, 18 Jun 2019 17:23:12 +0200 [thread overview]
Message-ID: <20190618152318.24953-9-kwolf@redhat.com> (raw)
In-Reply-To: <20190618152318.24953-1-kwolf@redhat.com>
From: Max Reitz <mreitz@redhat.com>
We cannot use bdrv_child_try_set_perm() to give up all restrictions on
the child edge, and still have bdrv_mirror_top_child_perm() request
BLK_PERM_WRITE. Fix this by making bdrv_mirror_top_child_perm() return
0/BLK_PERM_ALL when we want to give up all permissions, and replacing
bdrv_child_try_set_perm() by bdrv_child_refresh_perms().
The bdrv_child_try_set_perm() before removing the node with
bdrv_replace_node() is then unnecessary. No permissions have changed
since the previous invocation of bdrv_child_try_set_perm().
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/mirror.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
index b5878ba574..d17be4cdbc 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -85,6 +85,7 @@ typedef struct MirrorBlockJob {
typedef struct MirrorBDSOpaque {
MirrorBlockJob *job;
+ bool stop;
} MirrorBDSOpaque;
struct MirrorOp {
@@ -656,8 +657,9 @@ static int mirror_exit_common(Job *job)
/* We don't access the source any more. Dropping any WRITE/RESIZE is
* 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);
+ bs_opaque->stop = true;
+ bdrv_child_refresh_perms(mirror_top_bs, mirror_top_bs->backing,
+ &error_abort);
if (!abort && s->backing_mode == MIRROR_SOURCE_BACKING_CHAIN) {
BlockDriverState *backing = s->is_none_mode ? src : s->base;
if (backing_bs(target_bs) != backing) {
@@ -704,13 +706,12 @@ static int mirror_exit_common(Job *job)
g_free(s->replaces);
bdrv_unref(target_bs);
- /* Remove the mirror filter driver from the graph. Before this, get rid of
+ /*
+ * 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
- * valid. Also give up permissions on mirror_top_bs->backing, which might
- * block the removal. */
+ * valid.
+ */
block_job_remove_all_bdrv(bjob);
- bdrv_child_try_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL,
- &error_abort);
bdrv_replace_node(mirror_top_bs, backing_bs(mirror_top_bs), &error_abort);
/* We just changed the BDS the job BB refers to (with either or both of the
@@ -1459,6 +1460,18 @@ static void bdrv_mirror_top_child_perm(BlockDriverState *bs, BdrvChild *c,
uint64_t perm, uint64_t shared,
uint64_t *nperm, uint64_t *nshared)
{
+ MirrorBDSOpaque *s = bs->opaque;
+
+ if (s->stop) {
+ /*
+ * If the job is to be stopped, we do not need to forward
+ * anything to the real image.
+ */
+ *nperm = 0;
+ *nshared = BLK_PERM_ALL;
+ return;
+ }
+
/* Must be able to forward guest writes to the real image */
*nperm = 0;
if (perm & BLK_PERM_WRITE) {
@@ -1681,8 +1694,9 @@ fail:
job_early_fail(&s->common.job);
}
- bdrv_child_try_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL,
- &error_abort);
+ bs_opaque->stop = true;
+ bdrv_child_refresh_perms(mirror_top_bs, mirror_top_bs->backing,
+ &error_abort);
bdrv_replace_node(mirror_top_bs, backing_bs(mirror_top_bs), &error_abort);
bdrv_unref(mirror_top_bs);
--
2.20.1
next prev parent reply other threads:[~2019-06-18 16:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-18 15:23 [Qemu-devel] [PULL 00/14] Block layer patches Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 01/14] iotests: Hide timestamps for skipped tests Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 02/14] block/replication: drop usage of bs->job Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 03/14] block/block-backend: blk_iostatus_reset: " Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 04/14] blockdev: blockdev_mark_auto_del: " Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 05/14] block: drop bs->job Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 06/14] file-posix: Update open_flags in raw_set_perm() Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 07/14] block: Add bdrv_child_refresh_perms() Kevin Wolf
2019-06-18 15:23 ` Kevin Wolf [this message]
2019-06-18 15:23 ` [Qemu-devel] [PULL 09/14] block/commit: Drop bdrv_child_try_set_perm() Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 10/14] block: Fix order in bdrv_replace_child() Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 11/14] block: Add *tighten_restrictions to *check*_perm() Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 12/14] block: Ignore loosening perm restrictions failures Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 13/14] iotests: Test failure to loosen restrictions Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 14/14] block/null: Expose read-zeroes option in QAPI schema Kevin Wolf
2019-06-18 16:32 ` [Qemu-devel] [PULL 00/14] Block layer patches 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=20190618152318.24953-9-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).