[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 20/36] block: split out bdrv_replace_node_noperm()
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v4 20/36] block: split out bdrv_replace_node_noperm() |
Date: |
Wed, 28 Apr 2021 18:17:48 +0300 |
Split part of bdrv_replace_node_common() to be used separately.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 50 +++++++++++++++++++++++++++++++-------------------
1 file changed, 31 insertions(+), 19 deletions(-)
diff --git a/block.c b/block.c
index c74e6e7cc1..9283c8d97b 100644
--- a/block.c
+++ b/block.c
@@ -4991,6 +4991,34 @@ static bool should_update_child(BdrvChild *c,
BlockDriverState *to)
return ret;
}
+static int bdrv_replace_node_noperm(BlockDriverState *from,
+ BlockDriverState *to,
+ bool auto_skip, Transaction *tran,
+ Error **errp)
+{
+ BdrvChild *c, *next;
+
+ QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {
+ assert(c->bs == from);
+ if (!should_update_child(c, to)) {
+ if (auto_skip) {
+ continue;
+ }
+ error_setg(errp, "Should not change '%s' link to '%s'",
+ c->name, from->node_name);
+ return -EINVAL;
+ }
+ if (c->frozen) {
+ error_setg(errp, "Cannot change '%s' link to '%s'",
+ c->name, from->node_name);
+ return -EPERM;
+ }
+ bdrv_replace_child_safe(c, to, tran);
+ }
+
+ return 0;
+}
+
/*
* With auto_skip=true bdrv_replace_node_common skips updating from parents
* if it creates a parent-child relation loop or if parent is block-job.
@@ -5002,7 +5030,6 @@ static int bdrv_replace_node_common(BlockDriverState
*from,
BlockDriverState *to,
bool auto_skip, Error **errp)
{
- BdrvChild *c, *next;
Transaction *tran = tran_new();
g_autoptr(GHashTable) found = NULL;
g_autoptr(GSList) refresh_list = NULL;
@@ -5022,24 +5049,9 @@ static int bdrv_replace_node_common(BlockDriverState
*from,
* permissions based on new graph. If we fail, we'll roll-back the
* replacement.
*/
- QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {
- assert(c->bs == from);
- if (!should_update_child(c, to)) {
- if (auto_skip) {
- continue;
- }
- ret = -EINVAL;
- error_setg(errp, "Should not change '%s' link to '%s'",
- c->name, from->node_name);
- goto out;
- }
- if (c->frozen) {
- ret = -EPERM;
- error_setg(errp, "Cannot change '%s' link to '%s'",
- c->name, from->node_name);
- goto out;
- }
- bdrv_replace_child_safe(c, to, tran);
+ ret = bdrv_replace_node_noperm(from, to, auto_skip, tran, errp);
+ if (ret < 0) {
+ goto out;
}
found = g_hash_table_new(NULL, NULL);
--
2.29.2
- [PATCH v4 04/36] block: bdrv_append(): don't consume reference, (continued)
- [PATCH v4 04/36] block: bdrv_append(): don't consume reference, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 09/36] block: bdrv_refresh_perms: check for parents permissions conflict, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 07/36] block: make bdrv_reopen_{prepare, commit, abort} private, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 10/36] block: refactor bdrv_child* permission functions, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 11/36] block: rewrite bdrv_child_try_set_perm() using bdrv_refresh_perms(), Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 21/36] block: adapt bdrv_append() for inserting filters, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 22/36] block: add bdrv_remove_filter_or_cow transaction action, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 19/36] block: add bdrv_attach_child_noperm() transaction action, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 31/36] block: drop unused permission update functions, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 24/36] block/backup-top: drop .active, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 20/36] block: split out bdrv_replace_node_noperm(),
Vladimir Sementsov-Ogievskiy <=
- [PATCH v4 23/36] block: introduce bdrv_drop_filter(), Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 25/36] block: drop ignore_children for permission update functions, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 27/36] block: make bdrv_refresh_limits() to be a transaction action, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 28/36] block: add bdrv_set_backing_noperm() transaction action, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 26/36] block: make bdrv_unset_inherits_from to be a transaction action, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 33/36] block: inline bdrv_replace_child(), Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 32/36] block: inline bdrv_check_perm_common(), Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 30/36] block: bdrv_reopen_multiple: refresh permissions on updated graph, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 34/36] block: refactor bdrv_child_set_perm_safe() transaction action, Vladimir Sementsov-Ogievskiy, 2021/04/28
- [PATCH v4 29/36] block: bdrv_reopen_multiple(): move bdrv_flush to separate pre-prepare, Vladimir Sementsov-Ogievskiy, 2021/04/28