[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/39] block: rewrite bdrv_child_try_set_perm() using bdrv_refresh
From: |
Kevin Wolf |
Subject: |
[PULL 11/39] block: rewrite bdrv_child_try_set_perm() using bdrv_refresh_perms() |
Date: |
Fri, 30 Apr 2021 12:51:19 +0200 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
We are going to drop recursive bdrv_child_* functions, so stop use them
in bdrv_child_try_set_perm() as a first step.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20210428151804.439460-12-vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/block.c b/block.c
index 0ee0c2f29a..4511766825 100644
--- a/block.c
+++ b/block.c
@@ -2454,11 +2454,16 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t
perm, uint64_t shared,
Error **errp)
{
Error *local_err = NULL;
+ Transaction *tran = tran_new();
int ret;
- ret = bdrv_child_check_perm(c, NULL, perm, shared, NULL, &local_err);
+ bdrv_child_set_perm_safe(c, perm, shared, tran);
+
+ ret = bdrv_refresh_perms(c->bs, &local_err);
+
+ tran_finalize(tran, ret);
+
if (ret < 0) {
- bdrv_child_abort_perm_update(c);
if ((perm & ~c->perm) || (c->shared_perm & ~shared)) {
/* tighten permissions */
error_propagate(errp, local_err);
@@ -2472,12 +2477,9 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm,
uint64_t shared,
error_free(local_err);
ret = 0;
}
- return ret;
}
- bdrv_child_set_perm(c);
-
- return 0;
+ return ret;
}
int bdrv_child_refresh_perms(BlockDriverState *bs, BdrvChild *c, Error **errp)
--
2.30.2
- [PULL 00/39] Block layer patches, Kevin Wolf, 2021/04/30
- [PULL 01/39] tests/test-bdrv-graph-mod: add test_parallel_exclusive_write, Kevin Wolf, 2021/04/30
- [PULL 02/39] tests/test-bdrv-graph-mod: add test_parallel_perm_update, Kevin Wolf, 2021/04/30
- [PULL 04/39] block: bdrv_append(): don't consume reference, Kevin Wolf, 2021/04/30
- [PULL 03/39] tests/test-bdrv-graph-mod: add test_append_greedy_filter, Kevin Wolf, 2021/04/30
- [PULL 06/39] block: drop ctx argument from bdrv_root_attach_child, Kevin Wolf, 2021/04/30
- [PULL 05/39] block: BdrvChildClass: add .get_parent_aio_context handler, Kevin Wolf, 2021/04/30
- [PULL 07/39] block: make bdrv_reopen_{prepare,commit,abort} private, Kevin Wolf, 2021/04/30
- [PULL 08/39] util: add transactions.c, Kevin Wolf, 2021/04/30
- [PULL 09/39] block: bdrv_refresh_perms: check for parents permissions conflict, Kevin Wolf, 2021/04/30
- [PULL 11/39] block: rewrite bdrv_child_try_set_perm() using bdrv_refresh_perms(),
Kevin Wolf <=
- [PULL 10/39] block: refactor bdrv_child* permission functions, Kevin Wolf, 2021/04/30
- [PULL 12/39] block: inline bdrv_child_*() permission functions calls, Kevin Wolf, 2021/04/30
- [PULL 13/39] block: use topological sort for permission update, Kevin Wolf, 2021/04/30
- [PULL 14/39] block: add bdrv_drv_set_perm transaction action, Kevin Wolf, 2021/04/30
- [PULL 15/39] block: add bdrv_list_* permission update functions, Kevin Wolf, 2021/04/30
- [PULL 17/39] block: fix bdrv_replace_node_common, Kevin Wolf, 2021/04/30
- [PULL 19/39] block: add bdrv_attach_child_noperm() transaction action, Kevin Wolf, 2021/04/30
- [PULL 18/39] block: add bdrv_attach_child_common() transaction action, Kevin Wolf, 2021/04/30
- [PULL 20/39] block: split out bdrv_replace_node_noperm(), Kevin Wolf, 2021/04/30