From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
Fam Zheng <famz@redhat.com>, Kevin Wolf <kwolf@redhat.com>,
Max Reitz <mreitz@redhat.com>,
"open list:Block layer core" <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PULL 4/6] block: Update open_flags after ->inactivate() callback
Date: Wed, 23 Aug 2017 11:33:47 -0500 [thread overview]
Message-ID: <20170823163349.11663-5-eblake@redhat.com> (raw)
In-Reply-To: <20170823163349.11663-1-eblake@redhat.com>
From: Stefan Hajnoczi <stefanha@redhat.com>
In the ->inactivate() callbacks, permissions are updated, which
typically involves a recursive check of the whole graph. Setting
BDRV_O_INACTIVE right before doing that creates a state that
bdrv_is_writable() returns false, which causes permission update
failure.
Reorder them so the flag is updated after calling the function. Note
that this doesn't break the assert in bdrv_child_cb_inactivate() because
for any specific BDS, we still update its flags first before calling
->inactivate() on it one level deeper in the recursion.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170823134242.12080-5-famz@redhat.com>
Tested-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
block.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/block.c b/block.c
index 3615a6809e..3308814bba 100644
--- a/block.c
+++ b/block.c
@@ -4085,21 +4085,20 @@ static int bdrv_inactivate_recurse(BlockDriverState *bs,
}
}
- if (setting_flag) {
+ if (setting_flag && !(bs->open_flags & BDRV_O_INACTIVE)) {
uint64_t perm, shared_perm;
- bs->open_flags |= BDRV_O_INACTIVE;
-
QLIST_FOREACH(parent, &bs->parents, next_parent) {
if (parent->role->inactivate) {
ret = parent->role->inactivate(parent);
if (ret < 0) {
- bs->open_flags &= ~BDRV_O_INACTIVE;
return ret;
}
}
}
+ bs->open_flags |= BDRV_O_INACTIVE;
+
/* Update permissions, they may differ for inactive nodes */
bdrv_get_cumulative_perm(bs, &perm, &shared_perm);
bdrv_check_perm(bs, perm, shared_perm, NULL, &error_abort);
--
2.13.5
next prev parent reply other threads:[~2017-08-23 16:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-23 16:33 [Qemu-devel] [PULL 0/6] NBD pull request for 2.10-rc4 Eric Blake
2017-08-23 16:33 ` [Qemu-devel] [PULL 1/6] block-backend: Refactor inactivate check Eric Blake
2017-08-23 16:33 ` [Qemu-devel] [PULL 2/6] block-backend: Allow more "can inactivate" cases Eric Blake
2017-08-23 16:33 ` [Qemu-devel] [PULL 3/6] mirror: Mark target BB as "force allow inactivate" Eric Blake
2017-08-23 16:33 ` Eric Blake [this message]
2017-08-23 16:33 ` [Qemu-devel] [PULL 5/6] qemu-iotests: add 194 non-shared storage migration test Eric Blake
2017-08-23 16:33 ` [Qemu-devel] [PULL 6/6] nbd-client: avoid spurious qio_channel_yield() re-entry Eric Blake
2017-08-23 18:52 ` [Qemu-devel] [PULL 0/6] NBD pull request for 2.10-rc4 Peter Maydell
2017-08-23 21:00 ` Christian Ehrhardt
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=20170823163349.11663-5-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@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 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).