From patchwork Fri Sep 20 15:27:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 11154597 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD8AD15E6 for ; Fri, 20 Sep 2019 15:45:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE24120882 for ; Fri, 20 Sep 2019 15:45:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE24120882 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:32784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBL5y-0007Oj-H2 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 20 Sep 2019 11:45:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43945) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBKpj-0000pL-TE for qemu-devel@nongnu.org; Fri, 20 Sep 2019 11:28:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBKpi-0004Uu-N1 for qemu-devel@nongnu.org; Fri, 20 Sep 2019 11:28:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11115) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iBKpg-0004SF-Fa; Fri, 20 Sep 2019 11:28:28 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8ED03082E10; Fri, 20 Sep 2019 15:28:27 +0000 (UTC) Received: from localhost (unknown [10.40.205.102]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5244D60606; Fri, 20 Sep 2019 15:28:27 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 09/22] quorum: Add QuorumChild.to_be_replaced Date: Fri, 20 Sep 2019 17:27:51 +0200 Message-Id: <20190920152804.12875-10-mreitz@redhat.com> In-Reply-To: <20190920152804.12875-1-mreitz@redhat.com> References: <20190920152804.12875-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 20 Sep 2019 15:28:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- block/quorum.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index cf2171cc74..207054a64e 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; + + for (i = 0; i < s->num_children; i++) { + if (s->children[i].child == c) { + break; + } + } + assert(!c || 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[] = {