Blame SOURCES/kvm-block-Add-reopen-queue-to-bdrv_check_perm.patch

4a2fec
From 6c5f6c4a5d6471c620c905ec911b2a0cbb5687c8 Mon Sep 17 00:00:00 2001
4a2fec
From: Kevin Wolf <kwolf@redhat.com>
4a2fec
Date: Mon, 4 Dec 2017 12:10:02 +0100
4a2fec
Subject: [PATCH 31/36] block: Add reopen queue to bdrv_check_perm()
4a2fec
4a2fec
RH-Author: Kevin Wolf <kwolf@redhat.com>
4a2fec
Message-id: <20171204121007.12964-4-kwolf@redhat.com>
4a2fec
Patchwork-id: 78110
4a2fec
O-Subject: [RHV-7.5 qemu-kvm-rhev PATCH v2 3/8] block: Add reopen queue to bdrv_check_perm()
4a2fec
Bugzilla: 1492178
4a2fec
RH-Acked-by: Fam Zheng <famz@redhat.com>
4a2fec
RH-Acked-by: Max Reitz <mreitz@redhat.com>
4a2fec
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
4a2fec
4a2fec
In the context of bdrv_reopen(), we'll have to look at the state of the
4a2fec
graph as it will be after the reopen. This interface addition is in
4a2fec
preparation for the change.
4a2fec
4a2fec
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4a2fec
Reviewed-by: Eric Blake <eblake@redhat.com>
4a2fec
(cherry picked from commit 3121fb45b004ea85fb3589368ea699f32e6ef832)
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 block.c | 34 +++++++++++++++++++---------------
4a2fec
 1 file changed, 19 insertions(+), 15 deletions(-)
4a2fec
4a2fec
diff --git a/block.c b/block.c
4a2fec
index ab67062..5ce773a 100644
4a2fec
--- a/block.c
4a2fec
+++ b/block.c
4a2fec
@@ -1529,7 +1529,8 @@ static int bdrv_fill_options(QDict **options, const char *filename,
4a2fec
     return 0;
4a2fec
 }
4a2fec
 
4a2fec
-static int bdrv_child_check_perm(BdrvChild *c, uint64_t perm, uint64_t shared,
4a2fec
+static int bdrv_child_check_perm(BdrvChild *c, BlockReopenQueue *q,
4a2fec
+                                 uint64_t perm, uint64_t shared,
4a2fec
                                  GSList *ignore_children, Error **errp);
4a2fec
 static void bdrv_child_abort_perm_update(BdrvChild *c);
4a2fec
 static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared);
4a2fec
@@ -1560,7 +1561,8 @@ static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_bs,
4a2fec
  * A call to this function must always be followed by a call to bdrv_set_perm()
4a2fec
  * or bdrv_abort_perm_update().
4a2fec
  */
4a2fec
-static int bdrv_check_perm(BlockDriverState *bs, uint64_t cumulative_perms,
4a2fec
+static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q,
4a2fec
+                           uint64_t cumulative_perms,
4a2fec
                            uint64_t cumulative_shared_perms,
4a2fec
                            GSList *ignore_children, Error **errp)
4a2fec
 {
4a2fec
@@ -1595,11 +1597,11 @@ static int bdrv_check_perm(BlockDriverState *bs, uint64_t cumulative_perms,
4a2fec
     /* Check all children */
4a2fec
     QLIST_FOREACH(c, &bs->children, next) {
4a2fec
         uint64_t cur_perm, cur_shared;
4a2fec
-        bdrv_child_perm(bs, c->bs, c, c->role, NULL,
4a2fec
+        bdrv_child_perm(bs, c->bs, c, c->role, q,
4a2fec
                         cumulative_perms, cumulative_shared_perms,
4a2fec
                         &cur_perm, &cur_shared);
4a2fec
-        ret = bdrv_child_check_perm(c, cur_perm, cur_shared, ignore_children,
4a2fec
-                                    errp);
4a2fec
+        ret = bdrv_child_check_perm(c, q, cur_perm, cur_shared,
4a2fec
+                                    ignore_children, errp);
4a2fec
         if (ret < 0) {
4a2fec
             return ret;
4a2fec
         }
4a2fec
@@ -1725,7 +1727,8 @@ char *bdrv_perm_names(uint64_t perm)
4a2fec
  *
4a2fec
  * Needs to be followed by a call to either bdrv_set_perm() or
4a2fec
  * bdrv_abort_perm_update(). */
4a2fec
-static int bdrv_check_update_perm(BlockDriverState *bs, uint64_t new_used_perm,
4a2fec
+static int bdrv_check_update_perm(BlockDriverState *bs, BlockReopenQueue *q,
4a2fec
+                                  uint64_t new_used_perm,
4a2fec
                                   uint64_t new_shared_perm,
4a2fec
                                   GSList *ignore_children, Error **errp)
4a2fec
 {
4a2fec
@@ -1767,19 +1770,20 @@ static int bdrv_check_update_perm(BlockDriverState *bs, uint64_t new_used_perm,
4a2fec
         cumulative_shared_perms &= c->shared_perm;
4a2fec
     }
4a2fec
 
4a2fec
-    return bdrv_check_perm(bs, cumulative_perms, cumulative_shared_perms,
4a2fec
+    return bdrv_check_perm(bs, q, cumulative_perms, cumulative_shared_perms,
4a2fec
                            ignore_children, errp);
4a2fec
 }
4a2fec
 
4a2fec
 /* Needs to be followed by a call to either bdrv_child_set_perm() or
4a2fec
  * bdrv_child_abort_perm_update(). */
4a2fec
-static int bdrv_child_check_perm(BdrvChild *c, uint64_t perm, uint64_t shared,
4a2fec
+static int bdrv_child_check_perm(BdrvChild *c, BlockReopenQueue *q,
4a2fec
+                                 uint64_t perm, uint64_t shared,
4a2fec
                                  GSList *ignore_children, Error **errp)
4a2fec
 {
4a2fec
     int ret;
4a2fec
 
4a2fec
     ignore_children = g_slist_prepend(g_slist_copy(ignore_children), c);
4a2fec
-    ret = bdrv_check_update_perm(c->bs, perm, shared, ignore_children, errp);
4a2fec
+    ret = bdrv_check_update_perm(c->bs, q, perm, shared, ignore_children, errp);
4a2fec
     g_slist_free(ignore_children);
4a2fec
 
4a2fec
     return ret;
4a2fec
@@ -1807,7 +1811,7 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared,
4a2fec
 {
4a2fec
     int ret;
4a2fec
 
4a2fec
-    ret = bdrv_child_check_perm(c, perm, shared, NULL, errp);
4a2fec
+    ret = bdrv_child_check_perm(c, NULL, perm, shared, NULL, errp);
4a2fec
     if (ret < 0) {
4a2fec
         bdrv_child_abort_perm_update(c);
4a2fec
         return ret;
4a2fec
@@ -1948,7 +1952,7 @@ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs)
4a2fec
          * because we're just taking a parent away, so we're loosening
4a2fec
          * restrictions. */
4a2fec
         bdrv_get_cumulative_perm(old_bs, &perm, &shared_perm);
4a2fec
-        bdrv_check_perm(old_bs, perm, shared_perm, NULL, &error_abort);
4a2fec
+        bdrv_check_perm(old_bs, NULL, perm, shared_perm, NULL, &error_abort);
4a2fec
         bdrv_set_perm(old_bs, perm, shared_perm);
4a2fec
     }
4a2fec
 
4a2fec
@@ -1967,7 +1971,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
4a2fec
     BdrvChild *child;
4a2fec
     int ret;
4a2fec
 
4a2fec
-    ret = bdrv_check_update_perm(child_bs, perm, shared_perm, NULL, errp);
4a2fec
+    ret = bdrv_check_update_perm(child_bs, NULL, perm, shared_perm, NULL, errp);
4a2fec
     if (ret < 0) {
4a2fec
         bdrv_abort_perm_update(child_bs);
4a2fec
         return NULL;
4a2fec
@@ -3183,7 +3187,7 @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
4a2fec
 
4a2fec
     /* Check whether the required permissions can be granted on @to, ignoring
4a2fec
      * all BdrvChild in @list so that they can't block themselves. */
4a2fec
-    ret = bdrv_check_update_perm(to, perm, shared, list, errp);
4a2fec
+    ret = bdrv_check_update_perm(to, NULL, perm, shared, list, errp);
4a2fec
     if (ret < 0) {
4a2fec
         bdrv_abort_perm_update(to);
4a2fec
         goto out;
4a2fec
@@ -4040,7 +4044,7 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp)
4a2fec
 
4a2fec
     /* Update permissions, they may differ for inactive nodes */
4a2fec
     bdrv_get_cumulative_perm(bs, &perm, &shared_perm);
4a2fec
-    ret = bdrv_check_perm(bs, perm, shared_perm, NULL, &local_err);
4a2fec
+    ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, &local_err);
4a2fec
     if (ret < 0) {
4a2fec
         bs->open_flags |= BDRV_O_INACTIVE;
4a2fec
         error_propagate(errp, local_err);
4a2fec
@@ -4107,7 +4111,7 @@ static int bdrv_inactivate_recurse(BlockDriverState *bs,
4a2fec
 
4a2fec
         /* Update permissions, they may differ for inactive nodes */
4a2fec
         bdrv_get_cumulative_perm(bs, &perm, &shared_perm);
4a2fec
-        bdrv_check_perm(bs, perm, shared_perm, NULL, &error_abort);
4a2fec
+        bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, &error_abort);
4a2fec
         bdrv_set_perm(bs, perm, shared_perm);
4a2fec
     }
4a2fec
 
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec