From patchwork Sat Oct 5 13:05:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11175643 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 61D8016B1 for ; Sat, 5 Oct 2019 13:11:13 +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 36A1F222C8 for ; Sat, 5 Oct 2019 13:11:13 +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="ehfGa9U9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36A1F222C8 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:56654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGjq2-0004yz-B6 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 05 Oct 2019 09:11:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56745) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGjkt-0002ki-An for qemu-devel@nongnu.org; Sat, 05 Oct 2019 09:05:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGjks-0005SV-39 for qemu-devel@nongnu.org; Sat, 05 Oct 2019 09:05:51 -0400 Received: from mout.web.de ([217.72.192.78]:52685) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iGjkr-0005Qu-MM for qemu-devel@nongnu.org; Sat, 05 Oct 2019 09:05:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1570280725; bh=R0IRo8VMRmUK4dg5KQRbFBwzAqI8nGg0X+OwDoGxLWM=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=ehfGa9U9l/1J0bEnnjAUzFhCeV8F5HcWz/0jyLMXdMWEwWXUQyPDCZdQGTnh5+lI9 L6D2ljk2rDNaoQ12cWSsMAt20sH0V/FV2PVB1ZTA83pU82BHKZhmlaX731GSgT7DBt a//2Fy6+2WJZSdkMSebYIKWKZeOqT9T8iw3FKEQA= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([87.123.206.231]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MTh6a-1ihErV2C5A-00QTQZ; Sat, 05 Oct 2019 15:05:25 +0200 Date: Sat, 5 Oct 2019 15:05:23 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 1/4] block/replication.c: Ignore requests after failover Message-ID: <596a6f07850002a09461f317afa75f3e0c9bb784.1570280098.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:YOVCmClvx9HEE1dFzp4GHc9NXGOxuebHDtMPBOu9EOhb9psnocK xUjUxlxc3wlDfaMwPRKBshOSW5MDOfpfX89dPkVhGNsxtZ8s3r0DulmbrJv1iRv1HBzdvNQ Ql3pBpIeQzy78d/9sMSIFMaJNiH7WLlMn+4lit3kCV/puC6w8DLaRKaDMsSWSnGCibI9NU9 xRCEnimUZXSCzmEezWmXQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:w0A6Urtw3cA=:UgS6dH2fGSksF4B+YgeDB6 GxxTWEAWlYLtgfnhiIdvm9rvFyNSZDHomiMMdjpmScr1TpCG5SYB9ROHGVG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GDJz8dOBN+Dm8BH9/Ckd9sLT6XI/Ggqx9zAljKA4gKEuW 8162exq47M+No9puzorOSfdwsNNjbYB4nnDXztmRXu3a8q0Tuey68jVneD2Bl0nDXUqHEk1SO YI47H7djA6NPQyapgW6j1/Hl5/YaWdFD7IttmfTNGEisbCS6wb9bwOzdI7dc= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.78 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 , Jason Wang , Max Reitz , Zhang Chen , Xie Changlong Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" After failover the Secondary side of replication shouldn't change state, because 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 active and hidden images into the base image). Signed-off-by: Lukas Straub Reviewed-by: Zhang Chen --- block/replication.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/block/replication.c b/block/replication.c index 3d4dedddfc..97cc65c0cf 100644 --- a/block/replication.c +++ b/block/replication.c @@ -454,6 +454,17 @@ 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 +540,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 +587,17 @@ 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); } @@ -593,7 +614,7 @@ static void replication_get_error(ReplicationState *rs, Error **errp) 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 +656,17 @@ 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);