[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v3 5/8] block: Fix order in bdrv_replace_child()
From: |
Max Reitz |
Subject: |
[Qemu-block] [PATCH v3 5/8] block: Fix order in bdrv_replace_child() |
Date: |
Wed, 22 May 2019 19:03:49 +0200 |
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>
---
block.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/block.c b/block.c
index 02157e0652..3029f5c302 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
@@ -2248,11 +2261,6 @@ static void bdrv_replace_child(BdrvChild *child,
BlockDriverState *new_bs)
bdrv_check_perm(old_bs, NULL, perm, shared_perm, NULL, &error_abort);
bdrv_set_perm(old_bs, perm, shared_perm);
}
-
- if (new_bs) {
- bdrv_get_cumulative_perm(new_bs, &perm, &shared_perm);
- bdrv_set_perm(new_bs, perm, shared_perm);
- }
}
/*
--
2.21.0
- [Qemu-block] [PATCH v3 0/8] block: Ignore loosening perm restrictions failures, Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 1/8] file-posix: Update open_flags in raw_set_perm(), Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 4/8] block/commit: Drop bdrv_child_try_set_perm(), Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 2/8] block: Add bdrv_child_refresh_perms(), Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 7/8] block: Ignore loosening perm restrictions failures, Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 3/8] block/mirror: Fix child permissions, Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 5/8] block: Fix order in bdrv_replace_child(),
Max Reitz <=
- [Qemu-block] [PATCH v3 6/8] block: Add *tighten_restrictions to *check*_perm(), Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 8/8] iotests: Test failure to loosen restrictions, Max Reitz, 2019/05/22
- Re: [Qemu-block] [Qemu-devel] [PATCH v3 0/8] block: Ignore loosening perm restrictions failures, Eric Blake, 2019/05/22