diff mbox series

[05/22] quorum: Fix child permissions

Message ID 20190920152804.12875-6-mreitz@redhat.com (mailing list archive)
State New, archived
Headers show
Series block: Fix check_to_replace_node() | expand

Commit Message

Max Reitz Sept. 20, 2019, 3:27 p.m. UTC
Quorum is not actually a filter.  It cannot share WRITE or RESIZE on its
children.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/quorum.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Vladimir Sementsov-Ogievskiy Sept. 25, 2019, 11:56 a.m. UTC | #1
20.09.2019 18:27, Max Reitz wrote:
> Quorum is not actually a filter.  It cannot share WRITE or RESIZE on its
> children.

Hmm, backup-top don't want to share WRITE or RESIZE too, but it's a filter still..
May it be just "Quorum cannot share WRITE or RESIZE on its children." ?

> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Max Reitz Sept. 26, 2019, 11:02 a.m. UTC | #2
On 25.09.19 13:56, Vladimir Sementsov-Ogievskiy wrote:
> 20.09.2019 18:27, Max Reitz wrote:
>> Quorum is not actually a filter.  It cannot share WRITE or RESIZE on its
>> children.
> 
> Hmm, backup-top don't want to share WRITE or RESIZE too, but it's a filter still..
> May it be just "Quorum cannot share WRITE or RESIZE on its children." ?

I suppose the original reason for sharing it was just “It’s a filter, so
let’s make it use bdrv_filter_default_perms().”  So that’s what I was
trying to hint at.  I’ll try to be a bit more verbose.  Or less,
depending on what I find looks better. :-)

Max

>> Signed-off-by: Max Reitz <mreitz@redhat.com>
> 
> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> 
> 
>
diff mbox series

Patch

diff --git a/block/quorum.c b/block/quorum.c
index df68adcfaa..17b439056f 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -1114,6 +1114,23 @@  static char *quorum_dirname(BlockDriverState *bs, Error **errp)
     return NULL;
 }
 
+static void quorum_child_perm(BlockDriverState *bs, BdrvChild *c,
+                              const BdrvChildRole *role,
+                              BlockReopenQueue *reopen_queue,
+                              uint64_t perm, uint64_t shared,
+                              uint64_t *nperm, uint64_t *nshared)
+{
+    *nperm = perm & DEFAULT_PERM_PASSTHROUGH;
+
+    /*
+     * We cannot share RESIZE or WRITE, as this would make the
+     * children differ from each other.
+     */
+    *nshared = (shared & (BLK_PERM_CONSISTENT_READ |
+                          BLK_PERM_WRITE_UNCHANGED))
+             | DEFAULT_PERM_UNCHANGED;
+}
+
 static const char *const quorum_strong_runtime_opts[] = {
     QUORUM_OPT_VOTE_THRESHOLD,
     QUORUM_OPT_BLKVERIFY,
@@ -1143,7 +1160,7 @@  static BlockDriver bdrv_quorum = {
     .bdrv_add_child                     = quorum_add_child,
     .bdrv_del_child                     = quorum_del_child,
 
-    .bdrv_child_perm                    = bdrv_filter_default_perms,
+    .bdrv_child_perm                    = quorum_child_perm,
 
     .is_filter                          = true,
     .bdrv_recurse_is_first_non_filter   = quorum_recurse_is_first_non_filter,