[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for-5.0 v2 09/23] quorum: Add QuorumChild.to_be_replaced
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
Re: [PATCH for-5.0 v2 09/23] quorum: Add QuorumChild.to_be_replaced |
Date: |
Fri, 29 Nov 2019 09:59:46 +0000 |
11.11.2019 19:02, Max Reitz wrote:
> 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 | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/block/quorum.c b/block/quorum.c
> index 59cd524502..3a824e77e3 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,16 @@ 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 i;
> +
loop is still useless if c == NULL...
if (c) {
> + for (i = 0; i < s->num_children; i++) {
> + if (s->children[i].child == c) {
> + break;
> + }
> + }
assert(i < s->num_children);
}
> +
> *nperm = perm & DEFAULT_PERM_PASSTHROUGH;
>
> /*
> @@ -1137,6 +1154,12 @@ static void quorum_child_perm(BlockDriverState *bs,
> BdrvChild *c,
> *nshared = (shared & (BLK_PERM_CONSISTENT_READ |
> BLK_PERM_WRITE_UNCHANGED))
> | DEFAULT_PERM_UNCHANGED;
> +
> + if (c && s->children[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[] = {
>
with or without "if (c)":
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
--
Best regards,
Vladimir
- Re: [PATCH for-5.0 v2 05/23] quorum: Fix child permissions, (continued)
- [PATCH for-5.0 v2 07/23] blkverify: Implement .bdrv_recurse_can_replace(), Max Reitz, 2019/11/11
- [PATCH for-5.0 v2 08/23] quorum: Store children in own structure, Max Reitz, 2019/11/11
- [PATCH for-5.0 v2 09/23] quorum: Add QuorumChild.to_be_replaced, Max Reitz, 2019/11/11
- Re: [PATCH for-5.0 v2 09/23] quorum: Add QuorumChild.to_be_replaced,
Vladimir Sementsov-Ogievskiy <=
- [PATCH for-5.0 v2 10/23] quorum: Implement .bdrv_recurse_can_replace(), Max Reitz, 2019/11/11
- [PATCH for-5.0 v2 11/23] block: Use bdrv_recurse_can_replace(), Max Reitz, 2019/11/11
- [PATCH for-5.0 v2 12/23] block: Remove bdrv_recurse_is_first_non_filter(), Max Reitz, 2019/11/11
- [PATCH for-5.0 v2 13/23] mirror: Double-check immediately before replacing, Max Reitz, 2019/11/11
- [PATCH for-5.0 v2 14/23] quorum: Stop marking it as a filter, Max Reitz, 2019/11/11
- [PATCH for-5.0 v2 15/23] mirror: Prevent loops, Max Reitz, 2019/11/11