[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] block: assert that permission commit sets same permissions
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH 2/2] block: assert that permission commit sets same permissions |
Date: |
Mon, 23 Nov 2020 23:12:13 +0300 |
On permission update commit we must set same permissions as on _check_.
Let's add assertions. Next step may be to drop permission parameters
from _set_.
Note that prior to previous commit, fixing bdrv_drop_intermediate(),
new assertion in bdrv_child_set_perm() crashes on iotests 30 and 40.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
block.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index bd9f4e534b..0f4da59a6c 100644
--- a/block.c
+++ b/block.c
@@ -2105,9 +2105,10 @@ 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,
+ uint64_t _cumulative_shared_perms)
{
+ uint64_t cumulative_perms, cumulative_shared_perms;
BlockDriver *drv = bs->drv;
BdrvChild *c;
@@ -2115,6 +2116,10 @@ static void bdrv_set_perm(BlockDriverState *bs, uint64_t
cumulative_perms,
return;
}
+ bdrv_get_cumulative_perm(bs, &cumulative_perms, &cumulative_shared_perms);
+ assert(_cumulative_perms == cumulative_perms);
+ assert(_cumulative_shared_perms == cumulative_shared_perms);
+
/* Update this node */
if (drv->bdrv_set_perm) {
drv->bdrv_set_perm(bs, cumulative_perms, cumulative_shared_perms);
@@ -2301,6 +2306,8 @@ static void bdrv_child_set_perm(BdrvChild *c, uint64_t
perm, uint64_t shared)
c->has_backup_perm = false;
+ assert(c->perm == perm);
+ assert(c->shared_perm == shared);
c->perm = perm;
c->shared_perm = shared;
--
2.21.3
- [PATCH RFC 00/21] block: update graph permissions update, Vladimir Sementsov-Ogievskiy, 2020/11/23
- [PATCH 1/2] block: make bdrv_drop_intermediate() less wrong, Vladimir Sementsov-Ogievskiy, 2020/11/23
- [PATCH 01/21] tests/test-bdrv-graph-mod: add test_parallel_exclusive_write, Vladimir Sementsov-Ogievskiy, 2020/11/23
- [PATCH 2/2] block: assert that permission commit sets same permissions,
Vladimir Sementsov-Ogievskiy <=
- [PATCH 02/21] tests/test-bdrv-graph-mod: add test_parallel_perm_update, Vladimir Sementsov-Ogievskiy, 2020/11/23
- [PATCH 03/21] util: add transactions.c, Vladimir Sementsov-Ogievskiy, 2020/11/23
- [PATCH 04/21] block: bdrv_refresh_perms: check parents compliance, Vladimir Sementsov-Ogievskiy, 2020/11/23
- [PATCH 06/21] block: rewrite bdrv_child_try_set_perm() using bdrv_refresh_perms(), Vladimir Sementsov-Ogievskiy, 2020/11/23
- [PATCH 07/21] block: inline bdrv_child_*() permission functions calls, Vladimir Sementsov-Ogievskiy, 2020/11/23
- [PATCH 08/21] block: use topological sort for permission update, Vladimir Sementsov-Ogievskiy, 2020/11/23
- [PATCH 05/21] block: refactor bdrv_child* permission functions, Vladimir Sementsov-Ogievskiy, 2020/11/23
- [PATCH 09/21] block: add bdrv_drv_set_perm transaction action, Vladimir Sementsov-Ogievskiy, 2020/11/23