[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/36] quorum: Implement .bdrv_recurse_can_replace()
From: |
Kevin Wolf |
Subject: |
[PULL 25/36] quorum: Implement .bdrv_recurse_can_replace() |
Date: |
Tue, 18 Feb 2020 15:07:11 +0100 |
From: Max Reitz <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/quorum.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/block/quorum.c b/block/quorum.c
index 17b439056f..3ece6e4382 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -813,6 +813,59 @@ static bool
quorum_recurse_is_first_non_filter(BlockDriverState *bs,
return false;
}
+static bool quorum_recurse_can_replace(BlockDriverState *bs,
+ BlockDriverState *to_replace)
+{
+ BDRVQuorumState *s = bs->opaque;
+ int i;
+
+ for (i = 0; i < s->num_children; i++) {
+ /*
+ * We have no idea whether our children show the same data as
+ * this node (@bs). It is actually highly likely that
+ * @to_replace does not, because replacing a broken child is
+ * one of the main use cases here.
+ *
+ * We do know that the new BDS will match @bs, so replacing
+ * any of our children by it will be safe. It cannot change
+ * the data this quorum node presents to its parents.
+ *
+ * However, replacing @to_replace by @bs in any of our
+ * children's chains may change visible data somewhere in
+ * there. We therefore cannot recurse down those chains with
+ * bdrv_recurse_can_replace().
+ * (More formally, bdrv_recurse_can_replace() requires that
+ * @to_replace will be replaced by something matching the @bs
+ * passed to it. We cannot guarantee that.)
+ *
+ * Thus, we can only check whether any of our immediate
+ * children matches @to_replace.
+ *
+ * (In the future, we might add a function to recurse down a
+ * chain that checks that nothing there cares about a change
+ * in data from the respective child in question. For
+ * example, most filters do not care when their child's data
+ * suddenly changes, as long as their parents do not care.)
+ */
+ if (s->children[i]->bs == to_replace) {
+ /*
+ * We now have to ensure that there is no other parent
+ * that cares about replacing this child by a node with
+ * potentially different data.
+ * We do so by checking whether there are any other parents
+ * at all, which is stricter than necessary, but also very
+ * simple. (We may decide to implement something more
+ * complex and permissive when there is an actual need for
+ * it.)
+ */
+ return QLIST_FIRST(&to_replace->parents) == s->children[i] &&
+ QLIST_NEXT(s->children[i], next_parent) == NULL;
+ }
+ }
+
+ return false;
+}
+
static int quorum_valid_threshold(int threshold, int num_children, Error
**errp)
{
@@ -1164,6 +1217,7 @@ static BlockDriver bdrv_quorum = {
.is_filter = true,
.bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter,
+ .bdrv_recurse_can_replace = quorum_recurse_can_replace,
.strong_runtime_opts = quorum_strong_runtime_opts,
};
--
2.20.1
- [PULL 14/36] commit: Expose on-error option in QMP, (continued)
- [PULL 14/36] commit: Expose on-error option in QMP, Kevin Wolf, 2020/02/18
- [PULL 17/36] block/io_uring: Remove superfluous semicolon, Kevin Wolf, 2020/02/18
- [PULL 16/36] block: Remove superfluous semicolons, Kevin Wolf, 2020/02/18
- [PULL 19/36] blockdev: Allow resizing everywhere, Kevin Wolf, 2020/02/18
- [PULL 18/36] blockdev: Allow external snapshots everywhere, Kevin Wolf, 2020/02/18
- [PULL 21/36] iotests: Let 041 use -blockdev for quorum children, Kevin Wolf, 2020/02/18
- [PULL 15/36] iotests: Test error handling policies with block-commit, Kevin Wolf, 2020/02/18
- [PULL 22/36] quorum: Fix child permissions, Kevin Wolf, 2020/02/18
- [PULL 20/36] block: Drop bdrv_is_first_non_filter(), Kevin Wolf, 2020/02/18
- [PULL 24/36] blkverify: Implement .bdrv_recurse_can_replace(), Kevin Wolf, 2020/02/18
- [PULL 25/36] quorum: Implement .bdrv_recurse_can_replace(),
Kevin Wolf <=
- [PULL 26/36] block: Use bdrv_recurse_can_replace(), Kevin Wolf, 2020/02/18
- [PULL 23/36] block: Add bdrv_recurse_can_replace(), Kevin Wolf, 2020/02/18
- [PULL 29/36] quorum: Stop marking it as a filter, Kevin Wolf, 2020/02/18
- [PULL 27/36] block: Remove bdrv_recurse_is_first_non_filter(), Kevin Wolf, 2020/02/18
- [PULL 28/36] mirror: Double-check immediately before replacing, Kevin Wolf, 2020/02/18
- [PULL 31/36] iotests: Add VM.assert_block_path(), Kevin Wolf, 2020/02/18
- [PULL 30/36] iotests: Use complete_and_wait() in 155, Kevin Wolf, 2020/02/18
- [PULL 33/36] iotests: Resolve TODOs in 041, Kevin Wolf, 2020/02/18
- [PULL 35/36] iotests: Add tests for invalid Quorum @replaces, Kevin Wolf, 2020/02/18
- [PULL 34/36] iotests: Use self.image_len in TestRepairQuorum, Kevin Wolf, 2020/02/18