[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/51] block: bdrv_refresh_perms(): allow external tran
From: |
Kevin Wolf |
Subject: |
[PULL 03/51] block: bdrv_refresh_perms(): allow external tran |
Date: |
Wed, 14 Dec 2022 14:44:05 +0100 |
From: Vladimir Sementsov-Ogievskiy <vladimir.sementsov-ogievskiy@openvz.org>
Allow passing external Transaction pointer, stop creating extra
Transaction objects.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20221107163558.618889-4-vsementsov@yandex-team.ru>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/block.c b/block.c
index dc761209ac..f2f9178832 100644
--- a/block.c
+++ b/block.c
@@ -2591,15 +2591,24 @@ char *bdrv_perm_names(uint64_t perm)
}
-static int bdrv_refresh_perms(BlockDriverState *bs, Error **errp)
+/* @tran is allowed to be NULL. In this case no rollback is possible */
+static int bdrv_refresh_perms(BlockDriverState *bs, Transaction *tran,
+ Error **errp)
{
int ret;
- Transaction *tran = tran_new();
+ Transaction *local_tran = NULL;
g_autoptr(GSList) list = bdrv_topological_dfs(NULL, NULL, bs);
GLOBAL_STATE_CODE();
+ if (!tran) {
+ tran = local_tran = tran_new();
+ }
+
ret = bdrv_list_refresh_perms(list, NULL, tran, errp);
- tran_finalize(tran, ret);
+
+ if (local_tran) {
+ tran_finalize(local_tran, ret);
+ }
return ret;
}
@@ -2615,7 +2624,7 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm,
uint64_t shared,
bdrv_child_set_perm(c, perm, shared, tran);
- ret = bdrv_refresh_perms(c->bs, &local_err);
+ ret = bdrv_refresh_perms(c->bs, tran, &local_err);
tran_finalize(tran, ret);
@@ -3099,7 +3108,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState
*child_bs,
goto out;
}
- ret = bdrv_refresh_perms(child_bs, errp);
+ ret = bdrv_refresh_perms(child_bs, tran, errp);
out:
tran_finalize(tran, ret);
@@ -3140,7 +3149,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
goto out;
}
- ret = bdrv_refresh_perms(parent_bs, errp);
+ ret = bdrv_refresh_perms(parent_bs, tran, errp);
if (ret < 0) {
goto out;
}
@@ -3168,7 +3177,7 @@ void bdrv_root_unref_child(BdrvChild *child)
* we're loosening restrictions. Errors of permission update are not
* fatal in this case, ignore them.
*/
- bdrv_refresh_perms(child_bs, NULL);
+ bdrv_refresh_perms(child_bs, NULL, NULL);
/*
* When the parent requiring a non-default AioContext is removed, the
@@ -3410,7 +3419,7 @@ int bdrv_set_backing_hd(BlockDriverState *bs,
BlockDriverState *backing_hd,
goto out;
}
- ret = bdrv_refresh_perms(bs, errp);
+ ret = bdrv_refresh_perms(bs, tran, errp);
out:
tran_finalize(tran, ret);
@@ -5223,7 +5232,7 @@ int bdrv_append(BlockDriverState *bs_new,
BlockDriverState *bs_top,
goto out;
}
- ret = bdrv_refresh_perms(bs_new, errp);
+ ret = bdrv_refresh_perms(bs_new, tran, errp);
out:
tran_finalize(tran, ret);
@@ -6523,7 +6532,7 @@ int bdrv_activate(BlockDriverState *bs, Error **errp)
*/
if (bs->open_flags & BDRV_O_INACTIVE) {
bs->open_flags &= ~BDRV_O_INACTIVE;
- ret = bdrv_refresh_perms(bs, errp);
+ ret = bdrv_refresh_perms(bs, NULL, errp);
if (ret < 0) {
bs->open_flags |= BDRV_O_INACTIVE;
return ret;
@@ -6668,7 +6677,7 @@ static int bdrv_inactivate_recurse(BlockDriverState *bs)
* We only tried to loosen restrictions, so errors are not fatal, ignore
* them.
*/
- bdrv_refresh_perms(bs, NULL);
+ bdrv_refresh_perms(bs, NULL, NULL);
/* Recursively inactivate children */
QLIST_FOREACH(child, &bs->children, next) {
--
2.38.1
- [PULL 00/51] Block layer patches, Kevin Wolf, 2022/12/14
- [PULL 03/51] block: bdrv_refresh_perms(): allow external tran,
Kevin Wolf <=
- [PULL 10/51] block: Fix locking for bdrv_reopen_queue_child(), Kevin Wolf, 2022/12/14
- [PULL 01/51] block: Inline bdrv_detach_child(), Kevin Wolf, 2022/12/14
- [PULL 02/51] block: drop bdrv_remove_filter_or_cow_child, Kevin Wolf, 2022/12/14
- [PULL 07/51] block: Revert .bdrv_drained_begin/end to non-coroutine_fn, Kevin Wolf, 2022/12/14
- [PULL 08/51] block: Remove drained_end_counter, Kevin Wolf, 2022/12/14
- [PULL 05/51] qed: Don't yield in bdrv_qed_co_drain_begin(), Kevin Wolf, 2022/12/14
- [PULL 04/51] block: refactor bdrv_list_refresh_perms to allow any list of nodes, Kevin Wolf, 2022/12/14
- [PULL 06/51] test-bdrv-drain: Don't yield in .bdrv_co_drained_begin/end(), Kevin Wolf, 2022/12/14
- [PULL 11/51] block: Drain individual nodes during reopen, Kevin Wolf, 2022/12/14
- [PULL 14/51] block: Remove subtree drains, Kevin Wolf, 2022/12/14