[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 09/21] quorum: Add QuorumChild.to_be_replaced
From: |
Max Reitz |
Subject: |
[PATCH v3 09/21] quorum: Add QuorumChild.to_be_replaced |
Date: |
Thu, 30 Jan 2020 22:44:19 +0100 |
We will need this to verify that Quorum can let one of its children be
replaced without breaking anything else.
Signed-off-by: Max Reitz <address@hidden>
---
block/quorum.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/block/quorum.c b/block/quorum.c
index 59cd524502..6a7224c9e4 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -67,6 +67,13 @@ typedef struct QuorumVotes {
typedef struct QuorumChild {
BdrvChild *child;
+
+ /*
+ * If set, check whether this node can be replaced without any
+ * other parent noticing: Unshare CONSISTENT_READ, and take the
+ * WRITE permission.
+ */
+ bool to_be_replaced;
} QuorumChild;
/* the following structure holds the state of one quorum instance */
@@ -1128,6 +1135,18 @@ static void quorum_child_perm(BlockDriverState *bs,
BdrvChild *c,
uint64_t perm, uint64_t shared,
uint64_t *nperm, uint64_t *nshared)
{
+ BDRVQuorumState *s = bs->opaque;
+ int child_i = -1;
+
+ if (c) {
+ for (child_i = 0; child_i < s->num_children; child_i++) {
+ if (s->children[child_i].child == c) {
+ break;
+ }
+ }
+ assert(child_i < s->num_children);
+ }
+
*nperm = perm & DEFAULT_PERM_PASSTHROUGH;
/*
@@ -1137,6 +1156,12 @@ static void quorum_child_perm(BlockDriverState *bs,
BdrvChild *c,
*nshared = (shared & (BLK_PERM_CONSISTENT_READ |
BLK_PERM_WRITE_UNCHANGED))
| DEFAULT_PERM_UNCHANGED;
+
+ if (child_i >= 0 && s->children[child_i].to_be_replaced) {
+ /* Prepare for sudden data changes */
+ *nperm |= BLK_PERM_WRITE;
+ *nshared &= ~BLK_PERM_CONSISTENT_READ;
+ }
}
static const char *const quorum_strong_runtime_opts[] = {
--
2.24.1
- [PATCH v3 00/21] block: Fix check_to_replace_node(), Max Reitz, 2020/01/30
- [PATCH v3 01/21] blockdev: Allow external snapshots everywhere, Max Reitz, 2020/01/30
- [PATCH v3 02/21] blockdev: Allow resizing everywhere, Max Reitz, 2020/01/30
- [PATCH v3 04/21] iotests: Let 041 use -blockdev for quorum children, Max Reitz, 2020/01/30
- [PATCH v3 03/21] block: Drop bdrv_is_first_non_filter(), Max Reitz, 2020/01/30
- [PATCH v3 05/21] quorum: Fix child permissions, Max Reitz, 2020/01/30
- [PATCH v3 06/21] block: Add bdrv_recurse_can_replace(), Max Reitz, 2020/01/30
- [PATCH v3 07/21] blkverify: Implement .bdrv_recurse_can_replace(), Max Reitz, 2020/01/30
- [PATCH v3 09/21] quorum: Add QuorumChild.to_be_replaced,
Max Reitz <=
- [PATCH v3 08/21] quorum: Store children in own structure, Max Reitz, 2020/01/30
- [PATCH v3 10/21] quorum: Implement .bdrv_recurse_can_replace(), Max Reitz, 2020/01/30
- [PATCH v3 11/21] block: Use bdrv_recurse_can_replace(), Max Reitz, 2020/01/30
- [PATCH v3 12/21] block: Remove bdrv_recurse_is_first_non_filter(), Max Reitz, 2020/01/30
- [PATCH v3 13/21] mirror: Double-check immediately before replacing, Max Reitz, 2020/01/30
- [PATCH v3 14/21] quorum: Stop marking it as a filter, Max Reitz, 2020/01/30
- [PATCH v3 16/21] iotests: Add VM.assert_block_path(), Max Reitz, 2020/01/30
- [PATCH v3 18/21] iotests: Resolve TODOs in 041, Max Reitz, 2020/01/30
- [PATCH v3 15/21] iotests: Use complete_and_wait() in 155, Max Reitz, 2020/01/30
- [PATCH v3 17/21] iotests/041: Drop superfluous shutdowns, Max Reitz, 2020/01/30