Blame SOURCES/kvm-block-Add-reopen_queue-to-bdrv_child_perm.patch

4a2fec
From 4233c105ab4dc42ea8252717a0b68ee387ef8ed8 Mon Sep 17 00:00:00 2001
4a2fec
From: Kevin Wolf <kwolf@redhat.com>
4a2fec
Date: Mon, 4 Dec 2017 12:10:01 +0100
4a2fec
Subject: [PATCH 30/36] block: Add reopen_queue to bdrv_child_perm()
4a2fec
4a2fec
RH-Author: Kevin Wolf <kwolf@redhat.com>
4a2fec
Message-id: <20171204121007.12964-3-kwolf@redhat.com>
4a2fec
Patchwork-id: 78105
4a2fec
O-Subject: [RHV-7.5 qemu-kvm-rhev PATCH v2 2/8] block: Add reopen_queue to bdrv_child_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 e0995dc3da0894d0a8260bddaa200a4cd7809ba4)
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 block.c                   | 19 ++++++++++++-------
4a2fec
 block/commit.c            |  1 +
4a2fec
 block/mirror.c            |  1 +
4a2fec
 block/replication.c       |  1 +
4a2fec
 block/vvfat.c             |  1 +
4a2fec
 include/block/block_int.h |  7 +++++++
4a2fec
 6 files changed, 23 insertions(+), 7 deletions(-)
4a2fec
4a2fec
diff --git a/block.c b/block.c
4a2fec
index 6fb4e98..ab67062 100644
4a2fec
--- a/block.c
4a2fec
+++ b/block.c
4a2fec
@@ -1535,16 +1535,17 @@ 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
 
4a2fec
 static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_bs,
4a2fec
-                            BdrvChild *c,
4a2fec
-                            const BdrvChildRole *role,
4a2fec
+                            BdrvChild *c, const BdrvChildRole *role,
4a2fec
+                            BlockReopenQueue *reopen_queue,
4a2fec
                             uint64_t parent_perm, uint64_t parent_shared,
4a2fec
                             uint64_t *nperm, uint64_t *nshared)
4a2fec
 {
4a2fec
     if (bs->drv && bs->drv->bdrv_child_perm) {
4a2fec
-        bs->drv->bdrv_child_perm(bs, c, role,
4a2fec
+        bs->drv->bdrv_child_perm(bs, c, role, reopen_queue,
4a2fec
                                  parent_perm, parent_shared,
4a2fec
                                  nperm, nshared);
4a2fec
     }
4a2fec
+    /* TODO Take force_share from reopen_queue */
4a2fec
     if (child_bs && child_bs->force_share) {
4a2fec
         *nshared = BLK_PERM_ALL;
4a2fec
     }
4a2fec
@@ -1594,7 +1595,7 @@ 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,
4a2fec
+        bdrv_child_perm(bs, c->bs, c, c->role, NULL,
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
@@ -1656,7 +1657,7 @@ static void bdrv_set_perm(BlockDriverState *bs, uint64_t cumulative_perms,
4a2fec
     /* Update 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,
4a2fec
+        bdrv_child_perm(bs, c->bs, c, c->role, NULL,
4a2fec
                         cumulative_perms, cumulative_shared_perms,
4a2fec
                         &cur_perm, &cur_shared);
4a2fec
         bdrv_child_set_perm(c, cur_perm, cur_shared);
4a2fec
@@ -1825,6 +1826,7 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared,
4a2fec
 
4a2fec
 void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
4a2fec
                                const BdrvChildRole *role,
4a2fec
+                               BlockReopenQueue *reopen_queue,
4a2fec
                                uint64_t perm, uint64_t shared,
4a2fec
                                uint64_t *nperm, uint64_t *nshared)
4a2fec
 {
4a2fec
@@ -1842,6 +1844,7 @@ void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
4a2fec
 
4a2fec
 void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
4a2fec
                                const BdrvChildRole *role,
4a2fec
+                               BlockReopenQueue *reopen_queue,
4a2fec
                                uint64_t perm, uint64_t shared,
4a2fec
                                uint64_t *nperm, uint64_t *nshared)
4a2fec
 {
4a2fec
@@ -1851,9 +1854,11 @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
4a2fec
     if (!backing) {
4a2fec
         /* Apart from the modifications below, the same permissions are
4a2fec
          * forwarded and left alone as for filters */
4a2fec
-        bdrv_filter_default_perms(bs, c, role, perm, shared, &perm, &shared);
4a2fec
+        bdrv_filter_default_perms(bs, c, role, reopen_queue, perm, shared,
4a2fec
+                                  &perm, &shared);
4a2fec
 
4a2fec
         /* Format drivers may touch metadata even if the guest doesn't write */
4a2fec
+        /* TODO Take flags from reopen_queue */
4a2fec
         if (bdrv_is_writable(bs)) {
4a2fec
             perm |= BLK_PERM_WRITE | BLK_PERM_RESIZE;
4a2fec
         }
4a2fec
@@ -1997,7 +2002,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
4a2fec
 
4a2fec
     assert(parent_bs->drv);
4a2fec
     assert(bdrv_get_aio_context(parent_bs) == bdrv_get_aio_context(child_bs));
4a2fec
-    bdrv_child_perm(parent_bs, child_bs, NULL, child_role,
4a2fec
+    bdrv_child_perm(parent_bs, child_bs, NULL, child_role, NULL,
4a2fec
                     perm, shared_perm, &perm, &shared_perm);
4a2fec
 
4a2fec
     child = bdrv_root_attach_child(child_bs, child_name, child_role,
4a2fec
diff --git a/block/commit.c b/block/commit.c
4a2fec
index c7857c3..834084b 100644
4a2fec
--- a/block/commit.c
4a2fec
+++ b/block/commit.c
4a2fec
@@ -267,6 +267,7 @@ static void bdrv_commit_top_close(BlockDriverState *bs)
4a2fec
 
4a2fec
 static void bdrv_commit_top_child_perm(BlockDriverState *bs, BdrvChild *c,
4a2fec
                                        const BdrvChildRole *role,
4a2fec
+                                       BlockReopenQueue *reopen_queue,
4a2fec
                                        uint64_t perm, uint64_t shared,
4a2fec
                                        uint64_t *nperm, uint64_t *nshared)
4a2fec
 {
4a2fec
diff --git a/block/mirror.c b/block/mirror.c
4a2fec
index 429751b..17278db 100644
4a2fec
--- a/block/mirror.c
4a2fec
+++ b/block/mirror.c
4a2fec
@@ -1094,6 +1094,7 @@ static void bdrv_mirror_top_close(BlockDriverState *bs)
4a2fec
 
4a2fec
 static void bdrv_mirror_top_child_perm(BlockDriverState *bs, BdrvChild *c,
4a2fec
                                        const BdrvChildRole *role,
4a2fec
+                                       BlockReopenQueue *reopen_queue,
4a2fec
                                        uint64_t perm, uint64_t shared,
4a2fec
                                        uint64_t *nperm, uint64_t *nshared)
4a2fec
 {
4a2fec
diff --git a/block/replication.c b/block/replication.c
4a2fec
index bf4462c..3a4e682 100644
4a2fec
--- a/block/replication.c
4a2fec
+++ b/block/replication.c
4a2fec
@@ -157,6 +157,7 @@ static void replication_close(BlockDriverState *bs)
4a2fec
 
4a2fec
 static void replication_child_perm(BlockDriverState *bs, BdrvChild *c,
4a2fec
                                    const BdrvChildRole *role,
4a2fec
+                                   BlockReopenQueue *reopen_queue,
4a2fec
                                    uint64_t perm, uint64_t shared,
4a2fec
                                    uint64_t *nperm, uint64_t *nshared)
4a2fec
 {
4a2fec
diff --git a/block/vvfat.c b/block/vvfat.c
4a2fec
index a9e207f..e9110a9 100644
4a2fec
--- a/block/vvfat.c
4a2fec
+++ b/block/vvfat.c
4a2fec
@@ -3210,6 +3210,7 @@ err:
4a2fec
 
4a2fec
 static void vvfat_child_perm(BlockDriverState *bs, BdrvChild *c,
4a2fec
                              const BdrvChildRole *role,
4a2fec
+                             BlockReopenQueue *reopen_queue,
4a2fec
                              uint64_t perm, uint64_t shared,
4a2fec
                              uint64_t *nperm, uint64_t *nshared)
4a2fec
 {
4a2fec
diff --git a/include/block/block_int.h b/include/block/block_int.h
4a2fec
index 7571c0a..a6faf1b 100644
4a2fec
--- a/include/block/block_int.h
4a2fec
+++ b/include/block/block_int.h
4a2fec
@@ -377,9 +377,14 @@ struct BlockDriver {
4a2fec
      *
4a2fec
      * If @c is NULL, return the permissions for attaching a new child for the
4a2fec
      * given @role.
4a2fec
+     *
4a2fec
+     * If @reopen_queue is non-NULL, don't return the currently needed
4a2fec
+     * permissions, but those that will be needed after applying the
4a2fec
+     * @reopen_queue.
4a2fec
      */
4a2fec
      void (*bdrv_child_perm)(BlockDriverState *bs, BdrvChild *c,
4a2fec
                              const BdrvChildRole *role,
4a2fec
+                             BlockReopenQueue *reopen_queue,
4a2fec
                              uint64_t parent_perm, uint64_t parent_shared,
4a2fec
                              uint64_t *nperm, uint64_t *nshared);
4a2fec
 
4a2fec
@@ -949,6 +954,7 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared,
4a2fec
  * all children */
4a2fec
 void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
4a2fec
                                const BdrvChildRole *role,
4a2fec
+                               BlockReopenQueue *reopen_queue,
4a2fec
                                uint64_t perm, uint64_t shared,
4a2fec
                                uint64_t *nperm, uint64_t *nshared);
4a2fec
 
4a2fec
@@ -958,6 +964,7 @@ void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
4a2fec
  * CONSISTENT_READ and doesn't share WRITE. */
4a2fec
 void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
4a2fec
                                const BdrvChildRole *role,
4a2fec
+                               BlockReopenQueue *reopen_queue,
4a2fec
                                uint64_t perm, uint64_t shared,
4a2fec
                                uint64_t *nperm, uint64_t *nshared);
4a2fec
 
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec