qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v5 19/45] block: refactor bdrv_list_refresh_perms to allow an


From: Hanna Reitz
Subject: Re: [PATCH v5 19/45] block: refactor bdrv_list_refresh_perms to allow any list of nodes
Date: Wed, 8 Jun 2022 13:27:42 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0

On 30.03.22 23:28, Vladimir Sementsov-Ogievskiy wrote:
We are going to increase usage of collecting nodes in a list to then
update, and calling bdrv_topological_dfs() each time is not convenient,
and not correct as we are going to interleave graph modifying with
filling the node list.

So, let's switch to a function that takes any list of nodes, adds all
their subtrees and do topological sort. And finally, refresh
permissions.

While being here, make the function public, as we'll want to use it
from blockdev.c in near future.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
---
  block.c | 51 ++++++++++++++++++++++++++++++++-------------------
  1 file changed, 32 insertions(+), 19 deletions(-)

diff --git a/block.c b/block.c
index f3ed351360..9009f73534 100644
--- a/block.c
+++ b/block.c

[...]

@@ -2510,6 +2514,24 @@ static int bdrv_list_refresh_perms(GSList *list, 
BlockReopenQueue *q,
      return 0;
  }
+/*
+ * @list is any list of nodes. List is completed by all subtreees and

*subtrees

With that fixed:

Reviewed-by: Hanna Reitz <hreitz@redhat.com>

+ * topologically sorted. It's not a problem if some node occurs in the @list
+ * several times.
+ */
+static int bdrv_list_refresh_perms(GSList *list, BlockReopenQueue *q,
+                                   Transaction *tran, Error **errp)
+{
+    g_autoptr(GHashTable) found = g_hash_table_new(NULL, NULL);
+    g_autoptr(GSList) refresh_list = NULL;
+
+    for ( ; list; list = list->next) {
+        refresh_list = bdrv_topological_dfs(refresh_list, found, list->data);
+    }
+
+    return bdrv_do_refresh_perms(refresh_list, q, tran, errp);
+}
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]