From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21E96CA9EAF for ; Thu, 24 Oct 2019 15:34:19 +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 DEBA020650 for ; Thu, 24 Oct 2019 15:34:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="ECteYd6W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DEBA020650 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNf7x-00017m-Qp for qemu-devel@archiver.kernel.org; Thu, 24 Oct 2019 11:34:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38886) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNe46-0008AA-TK for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:26:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNe45-0002eS-FD for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:26:14 -0400 Received: from mout.web.de ([212.227.17.11]:43101) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNe40-0002RH-07; Thu, 24 Oct 2019 10:26:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1571927139; bh=9FbTgtuzcaCTjHUA8BY5mKaFybBmxQpiWe1iZMpLbP8=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=ECteYd6W7+tp3RAxMUKZ2oADi66QCSQVMtP+Pw595ghY+Rz/s1Idpn3PXaxkT5iO5 Ict4U5HrjWYjyMXkoOFSbRWjUKURK3hDInCIkz3AEcIr6VWeo1ezyPwvHtKSPkA0+d NT7hWX1IqqiSDVhnobU1upEvRUbVNu2+00JFOa6c= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([89.247.255.150]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LbrZ2-1hgZWx132a-00jMnl; Thu, 24 Oct 2019 16:25:39 +0200 Date: Thu, 24 Oct 2019 16:25:35 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v7 1/4] block/replication.c: Ignore requests after failover Message-ID: <039d59f89205824273eef070cdfa7d5e94f95697.1571925699.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:N+uedjqvs76OPbOtDsp0z41+9k3NWKoNkTJgPFrKREuJ21iR//o ewMsA3MGKGDnBKEt3mZbmHUiuvusrrzdw6Y0n2g5zVy+pmlKmMrkzg2jG0d4Wfm23cU2QSG 1PcSZwCQ7XchdE9BZ4ki0HxdQNfRMFwHkCFYqs+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wnnkNfIg6IFjwMNIHDBQxgOZhYkI3iMBg12qY7bficlQDcfSSTEuyWPAKV/am5vl10By 5kehvgvJGKGID55kqqhxqq5pHjZQ6pSZ9pXNflEdJ27kXE5Hwrtd5m7Okk5XRRpTF99QQZYno rP4ZsBe3c5pzxcGXCX2qNJ9bD4CBqdIZ9vboE8XJNbZ0ZFs+vdCCSqj2GsSzqBClFq0qHKVvD k720+tEqLBHpocoAfNYEoVVCNNJMrGEes2mVTh115zxAbfPaSfLSxw29gyPVYaCGJ3+1CeaFo UIQyuewuET2/+mlCBMQcp/A9WemIVPFLN1L115R5an2JfQhgGTWMhoVzCUSE= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.11 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 , qemu-block , Wen Congyang , Wen Congyang , Jason Wang , Max Reitz , Zhang Chen , Xie Changlong Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" After failover the Secondary side of replication shouldn't change state, b= ecause it now functions as our primary disk. In replication_start, replication_do_checkpoint, replication_stop, ignore the request if current state is BLOCK_REPLICATION_DONE (sucessful failover= ) or BLOCK_REPLICATION_FAILOVER (failover in progres i.e. currently merging act= ive and hidden images into the base image). Signed-off-by: Lukas Straub Reviewed-by: Zhang Chen =2D-- block/replication.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/block/replication.c b/block/replication.c index 3d4dedddfc..78234d1a04 100644 =2D-- a/block/replication.c +++ b/block/replication.c @@ -454,6 +454,17 @@ static void replication_start(ReplicationState *rs, R= eplicationMode mode, aio_context_acquire(aio_context); s =3D bs->opaque; + if (s->stage =3D=3D BLOCK_REPLICATION_DONE || + s->stage =3D=3D BLOCK_REPLICATION_FAILOVER) { + /* + * This case happens when a secondary is promoted to primary. + * Ignore the request because the secondary side of replication + * doesn't have to do anything anymore. + */ + aio_context_release(aio_context); + return; + } + if (s->stage !=3D BLOCK_REPLICATION_NONE) { error_setg(errp, "Block replication is running or done"); aio_context_release(aio_context); @@ -577,6 +588,17 @@ static void replication_do_checkpoint(ReplicationStat= e *rs, Error **errp) aio_context_acquire(aio_context); s =3D bs->opaque; + if (s->stage =3D=3D BLOCK_REPLICATION_DONE || + s->stage =3D=3D BLOCK_REPLICATION_FAILOVER) { + /* + * This case happens when a secondary was promoted to primary. + * Ignore the request because the secondary side of replication + * doesn't have to do anything anymore. + */ + aio_context_release(aio_context); + return; + } + if (s->mode =3D=3D REPLICATION_MODE_SECONDARY) { secondary_do_checkpoint(s, errp); } @@ -593,7 +615,7 @@ static void replication_get_error(ReplicationState *rs= , Error **errp) aio_context_acquire(aio_context); s =3D bs->opaque; - if (s->stage !=3D BLOCK_REPLICATION_RUNNING) { + if (s->stage =3D=3D BLOCK_REPLICATION_NONE) { error_setg(errp, "Block replication is not running"); aio_context_release(aio_context); return; @@ -635,6 +657,17 @@ static void replication_stop(ReplicationState *rs, bo= ol failover, Error **errp) aio_context_acquire(aio_context); s =3D bs->opaque; + if (s->stage =3D=3D BLOCK_REPLICATION_DONE || + s->stage =3D=3D BLOCK_REPLICATION_FAILOVER) { + /* + * This case happens when a secondary was promoted to primary. + * Ignore the request because the secondary side of replication + * doesn't have to do anything anymore. + */ + aio_context_release(aio_context); + return; + } + if (s->stage !=3D BLOCK_REPLICATION_RUNNING) { error_setg(errp, "Block replication is not running"); aio_context_release(aio_context); =2D- 2.20.1