[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/30] block: bdrv_set_perm() drop redundant parameters.
From: |
Max Reitz |
Subject: |
[PULL 02/30] block: bdrv_set_perm() drop redundant parameters. |
Date: |
Fri, 18 Dec 2020 16:12:21 +0100 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
We should never set permissions other than cumulative permissions of
parents. During bdrv_reopen_multiple() we _check_ for synthetic
permissions but when we do _set_ the graph is already updated.
Add an assertion to bdrv_reopen_multiple(), other cases are more
obvious.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20201106124241.16950-6-vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
block.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/block.c b/block.c
index 3a07693608..66ab6caa7d 100644
--- a/block.c
+++ b/block.c
@@ -2112,9 +2112,9 @@ static void bdrv_abort_perm_update(BlockDriverState *bs)
}
}
-static void bdrv_set_perm(BlockDriverState *bs, uint64_t cumulative_perms,
- uint64_t cumulative_shared_perms)
+static void bdrv_set_perm(BlockDriverState *bs)
{
+ uint64_t cumulative_perms, cumulative_shared_perms;
BlockDriver *drv = bs->drv;
BdrvChild *c;
@@ -2122,6 +2122,8 @@ static void bdrv_set_perm(BlockDriverState *bs, uint64_t
cumulative_perms,
return;
}
+ bdrv_get_cumulative_perm(bs, &cumulative_perms, &cumulative_shared_perms);
+
/* Update this node */
if (drv->bdrv_set_perm) {
drv->bdrv_set_perm(bs, cumulative_perms, cumulative_shared_perms);
@@ -2304,16 +2306,12 @@ static int bdrv_child_check_perm(BdrvChild *c,
BlockReopenQueue *q,
static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared)
{
- uint64_t cumulative_perms, cumulative_shared_perms;
-
c->has_backup_perm = false;
c->perm = perm;
c->shared_perm = shared;
- bdrv_get_cumulative_perm(c->bs, &cumulative_perms,
- &cumulative_shared_perms);
- bdrv_set_perm(c->bs, cumulative_perms, cumulative_shared_perms);
+ bdrv_set_perm(c->bs);
}
static void bdrv_child_abort_perm_update(BdrvChild *c)
@@ -2340,7 +2338,7 @@ static int bdrv_refresh_perms(BlockDriverState *bs, bool
*tighten_restrictions,
bdrv_abort_perm_update(bs);
return ret;
}
- bdrv_set_perm(bs, perm, shared_perm);
+ bdrv_set_perm(bs);
return 0;
}
@@ -2641,7 +2639,6 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs)
{
BlockDriverState *old_bs = child->bs;
- uint64_t perm, shared_perm;
/* Asserts that child->frozen == false */
bdrv_replace_child_noperm(child, new_bs);
@@ -2655,8 +2652,7 @@ static void bdrv_replace_child(BdrvChild *child,
BlockDriverState *new_bs)
* restrictions.
*/
if (new_bs) {
- bdrv_get_cumulative_perm(new_bs, &perm, &shared_perm);
- bdrv_set_perm(new_bs, perm, shared_perm);
+ bdrv_set_perm(new_bs);
}
if (old_bs) {
@@ -3874,7 +3870,13 @@ cleanup_perm:
}
if (ret == 0) {
- bdrv_set_perm(state->bs, state->perm, state->shared_perm);
+ uint64_t perm, shared;
+
+ bdrv_get_cumulative_perm(state->bs, &perm, &shared);
+ assert(perm == state->perm);
+ assert(shared == state->shared_perm);
+
+ bdrv_set_perm(state->bs);
} else {
bdrv_abort_perm_update(state->bs);
if (state->replace_backing_bs && state->new_backing_bs) {
@@ -4644,8 +4646,7 @@ static void bdrv_replace_node_common(BlockDriverState
*from,
bdrv_unref(from);
}
- bdrv_get_cumulative_perm(to, &perm, &shared);
- bdrv_set_perm(to, perm, shared);
+ bdrv_set_perm(to);
out:
g_slist_free(list);
--
2.29.2
- [PULL 00/30] Block patches, Max Reitz, 2020/12/18
- [PULL 01/30] block: add bdrv_refresh_perms() helper, Max Reitz, 2020/12/18
- [PULL 03/30] block: bdrv_child_set_perm() drop redundant parameters., Max Reitz, 2020/12/18
- [PULL 02/30] block: bdrv_set_perm() drop redundant parameters.,
Max Reitz <=
- [PULL 04/30] block: drop tighten_restrictions, Max Reitz, 2020/12/18
- [PULL 06/30] block/io.c: drop assertion on double waiting for request serialisation, Max Reitz, 2020/12/18
- [PULL 07/30] block/io: split out bdrv_find_conflicting_request, Max Reitz, 2020/12/18
- [PULL 08/30] block/io: bdrv_wait_serialising_requests_locked: drop extra bs arg, Max Reitz, 2020/12/18
- [PULL 09/30] block: bdrv_mark_request_serialising: split non-waiting function, Max Reitz, 2020/12/18
- [PULL 11/30] block: bdrv_check_perm(): process children anyway, Max Reitz, 2020/12/18
- [PULL 05/30] block: simplify comment to BDRV_REQ_SERIALISING, Max Reitz, 2020/12/18
- [PULL 10/30] block: introduce BDRV_REQ_NO_WAIT flag, Max Reitz, 2020/12/18
- [PULL 14/30] iotests: qemu_io_silent: support --image-opts, Max Reitz, 2020/12/18
- [PULL 13/30] qemu-io: add preallocate mode parameter for truncate command, Max Reitz, 2020/12/18