From patchwork Wed Aug 14 20:47:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11094567 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDB74112C for ; Wed, 14 Aug 2019 20:51:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC62B28832 for ; Wed, 14 Aug 2019 20:51:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C094528845; Wed, 14 Aug 2019 20:51:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0414928832 for ; Wed, 14 Aug 2019 20:51:30 +0000 (UTC) Received: from localhost ([::1]:36004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hy0Ez-0002fE-6P for patchwork-qemu-devel@patchwork.kernel.org; Wed, 14 Aug 2019 16:51:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37991) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hy0CZ-00016a-NU for qemu-devel@nongnu.org; Wed, 14 Aug 2019 16:49:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hy0CY-0001Av-Jb for qemu-devel@nongnu.org; Wed, 14 Aug 2019 16:48:59 -0400 Received: from mout.web.de ([212.227.17.11]:33221) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hy0CY-00017U-An for qemu-devel@nongnu.org; Wed, 14 Aug 2019 16:48:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1565815723; bh=NYGEs+J8dG1k1ZGIA2w7kyoxLQCzkxirRfKD/rQess0=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=JwLaA09NWVkUmUrEaGVVaPSF13A82g1POwUGyC8f+VTAcjd27IxpGTtzaDlKeobJj NkGx1viQ7e6p3SZ9jOFE29eV3yr9PTj1//adUKfhvOJkb8EQVjqPugwXvophzVPR9r ILM/CMGzUnnjPUI/ffrRJr+Rh8SdGN69Axtg0nGQ= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([87.123.206.175]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MT8o6-1hoYHc3K0k-00S41t; Wed, 14 Aug 2019 22:48:42 +0200 Date: Wed, 14 Aug 2019 22:47:17 +0200 From: Lukas Straub To: "Zhang, Chen" Message-ID: <1e29ed41743ddf581636ccee0e899c0f3f4680b7.1565814686.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:pqV6qcrevMy+2gvPNMCF/JfEBY+yHtBWer17I1UXxJ10p1tsXrq CqD/GJ+ufVnihK8XgtdUcUVBi9ZWfn1YStGVnG5ScIibvJ9cETNkOp4ShM4K/q1Id0Wiw7N lrUAZ9kQRHNk+CLFrLoNom8T7P1/drpUPlSXxu2Z4fsMCukWoxdc5lamb2b8nJiTJFpQwKl qBDvk/OcXLQryV041+V9w== X-UI-Out-Filterresults: notjunk:1;V03:K0:mM1a7lEkim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xdWBC5hjf0vc4HZ0K2IxCPCxFOUYPDgyrHeWNGMCOlz5QPwF9wVBIk WX/ABqiYNxHWCOZk9QR+oeT8m48qPqT5gehQIhjb31Jf2UXT76MM1vcJuD9Lq7lO0T8oheuKU p3qN7Chd0ERtldw21s8eNk7AT9v0W1gG9kriE69Xt1NX34fg== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.11 Subject: [Qemu-devel] [PATCH 1/3] Replication: Ignore requests after failover 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: "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP After failover, the Secondary side of replication shouldn't change state. Add the necessary checks to ignore requests after failover. Signed-off-by: Lukas Straub --- block/replication.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/block/replication.c b/block/replication.c index 3d4dedddfc..466d463963 100644 --- a/block/replication.c +++ b/block/replication.c @@ -454,6 +454,14 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, aio_context_acquire(aio_context); s = bs->opaque; + if (s->stage == BLOCK_REPLICATION_DONE || s->stage == 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 != BLOCK_REPLICATION_NONE) { error_setg(errp, "Block replication is running or done"); aio_context_release(aio_context); @@ -529,8 +537,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, "Block device is in use by internal backup job"); top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL); - if (!top_bs || !bdrv_is_root_node(top_bs) || - !check_top_bs(top_bs, bs)) { + if (!top_bs || !check_top_bs(top_bs, bs)) { error_setg(errp, "No top_bs or it is invalid"); reopen_backing_file(bs, false, NULL); aio_context_release(aio_context); @@ -577,6 +584,14 @@ static void replication_do_checkpoint(ReplicationState *rs, Error **errp) aio_context_acquire(aio_context); s = bs->opaque; + if (s->stage == BLOCK_REPLICATION_DONE || s->stage == 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 == REPLICATION_MODE_SECONDARY) { secondary_do_checkpoint(s, errp); } @@ -592,8 +607,8 @@ static void replication_get_error(ReplicationState *rs, Error **errp) aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); s = bs->opaque; - - if (s->stage != BLOCK_REPLICATION_RUNNING) { + + if (s->stage == BLOCK_REPLICATION_NONE) { error_setg(errp, "Block replication is not running"); aio_context_release(aio_context); return; @@ -635,6 +650,14 @@ static void replication_stop(ReplicationState *rs, bool failover, Error **errp) aio_context_acquire(aio_context); s = bs->opaque; + if (s->stage == BLOCK_REPLICATION_DONE || s->stage == 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 != BLOCK_REPLICATION_RUNNING) { error_setg(errp, "Block replication is not running"); aio_context_release(aio_context);