[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 10/14] block: Fix order in bdrv_replace_child()
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 10/14] block: Fix order in bdrv_replace_child() |
Date: |
Tue, 18 Jun 2019 17:23:14 +0200 |
From: Max Reitz <address@hidden>
We have to start by applying the permission restrictions to new_bs
before we can loosen them on old_bs. See the comment for the
explanation.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/block.c b/block.c
index 013369851b..b7d4149c2f 100644
--- a/block.c
+++ b/block.c
@@ -2240,6 +2240,19 @@ static void bdrv_replace_child(BdrvChild *child,
BlockDriverState *new_bs)
bdrv_replace_child_noperm(child, new_bs);
+ /*
+ * Start with the new node's permissions. If @new_bs is a (direct
+ * or indirect) child of @old_bs, we must complete the permission
+ * update on @new_bs before we loosen the restrictions on @old_bs.
+ * Otherwise, bdrv_check_perm() on @old_bs would re-initiate
+ * updating the permissions of @new_bs, and thus not purely loosen
+ * restrictions.
+ */
+ if (new_bs) {
+ bdrv_get_cumulative_perm(new_bs, &perm, &shared_perm);
+ bdrv_set_perm(new_bs, perm, shared_perm);
+ }
+
if (old_bs) {
/* Update permissions for old node. This is guaranteed to succeed
* because we're just taking a parent away, so we're loosening
@@ -2252,11 +2265,6 @@ static void bdrv_replace_child(BdrvChild *child,
BlockDriverState *new_bs)
* node moves back to the main AioContext */
bdrv_try_set_aio_context(old_bs, qemu_get_aio_context(), NULL);
}
-
- if (new_bs) {
- bdrv_get_cumulative_perm(new_bs, &perm, &shared_perm);
- bdrv_set_perm(new_bs, perm, shared_perm);
- }
}
/*
--
2.20.1
- [Qemu-block] [PULL 02/14] block/replication: drop usage of bs->job, (continued)
- [Qemu-block] [PULL 02/14] block/replication: drop usage of bs->job, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 09/14] block/commit: Drop bdrv_child_try_set_perm(), Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 08/14] block/mirror: Fix child permissions, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 05/14] block: drop bs->job, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 06/14] file-posix: Update open_flags in raw_set_perm(), Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 07/14] block: Add bdrv_child_refresh_perms(), Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 11/14] block: Add *tighten_restrictions to *check*_perm(), Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 04/14] blockdev: blockdev_mark_auto_del: drop usage of bs->job, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 13/14] iotests: Test failure to loosen restrictions, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 12/14] block: Ignore loosening perm restrictions failures, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 10/14] block: Fix order in bdrv_replace_child(),
Kevin Wolf <=
- [Qemu-block] [PULL 14/14] block/null: Expose read-zeroes option in QAPI schema, Kevin Wolf, 2019/06/18
- Re: [Qemu-block] [Qemu-devel] [PULL 00/14] Block layer patches, Peter Maydell, 2019/06/18