From nobody Mon Feb 9 05:01:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1567502728; cv=none; d=zoho.com; s=zohoarc; b=QKi5PRu3r2Mno0LuhBBoz7QxeAV4Xdfe1UyBhuHU0Ib9P4YweGjBtzvxWyTb9NSYMWQ3K1J/JSGpqmqjH8+BJXIhBZ89lNwoVgaq0sboGdCz3NHtmTy72/oDeQye9PjuGHPuZ07S7eMTJShLTnhUTE+1dDLDo6P5e4yvxO+jADs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567502728; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=StrSknx6n99IGCCLmE47Oz4F/g14X+eup5MCfJZbsrw=; b=aeExmzWY3LiIF0AVlfT6Owvk1Pc0KrEFrtlw8UPmDGmtxx21OE6KxQVLXDITFsSAGSNszJN5zBtDVju9xc5JEFTlUozkpLVNM3+Sl2t+jf1lRcbkTkOhJmNPsbsDGG0kLDjE3XQQMW8Wo6v2gajftP3ijFTWtUCvQ7H9f3u54Gk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1567502728717839.8355853682907; Tue, 3 Sep 2019 02:25:28 -0700 (PDT) Received: from localhost ([::1]:43246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i553y-0002eM-CU for importer@patchew.org; Tue, 03 Sep 2019 05:25:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33543) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i54zW-00083o-Fs for qemu-devel@nongnu.org; Tue, 03 Sep 2019 05:20:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i54zV-0002Q6-8n for qemu-devel@nongnu.org; Tue, 03 Sep 2019 05:20:46 -0400 Received: from mout.web.de ([212.227.15.3]:35737) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i54zU-0002PF-Vf for qemu-devel@nongnu.org; Tue, 03 Sep 2019 05:20:45 -0400 Received: from luklap ([88.130.61.78]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0M3k9J-1iNA2F2unJ-00rLNi; Tue, 03 Sep 2019 11:20:26 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1567502426; bh=1aMK3WcfXGtXkTJdGeILldP4LKkJ6RJ1Yf8zxuMXcY0=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=Mz5u+SGsiV9KfRIGchX1DGjWSZiHo9wlfX4KBXGTPRqTVv7w3hJ9WT1pPatZv7UDb M0OKL5ylfTEghIfTPxDu3aFZsBKr2E5BBnGkf4GNHDsgLOZY+fR+YelEumRvpK+K/T mssEtkUMfmEM/3ypA1f92gy7QiZru6Kahgv3UDX4= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Date: Tue, 3 Sep 2019 11:20:21 +0200 From: Lukas Straub To: qemu-devel Message-ID: <5305f30b0f798adfc3883bbcebbfc5030661dbe9.1567500411.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:6n7NUftyhGnsv3QHpJPJcpP7cONMly5SDtg4EveHA7CKukumlVU kkaEnL/EzNYE/fecpU94pqUmzucidGS3VXpCBlaloKmvHMVAjHy3DAFBjARlOVnx88Q0yjr Wz+IFJ1WC5QvrpADRwgNoF83JAgtKSFBD0oXyUDEWnk7rqj4OA+90C0yyQzqkooPfehMVM2 8W8yMneAidMWlMDqnGKlw== X-UI-Out-Filterresults: notjunk:1;V03:K0:Qf8/f9fOP8k=:fiQ0/c/PWc8JeIvNEadnsz aYlpVdKv51IbRNBwBNdNJPaTRF4LSj5FhihVn/e4lsaDgqCZSfujVoyB8g/Iaw5TuX2m/YZxo tpYwUcCTIotbYdCuJrOh9yGbB9Irrb2JS18jDgw9PmTsR0wU9CaphBbPxQV0WfPJQDyRTLr8R +8iauT+F5P5TDgQt1xTt5PhKwPeeC/FYJxqL4Mz/9w8Fv5XCxOOlaTKdpQIkFeMaE0ud/bNnW DcMpMO3tOL9JIZbjYHZULIYbFf/ah05AYeSN9Si+9vGTln52H1jE3fTVqEKSxzbolWjje/FG7 fpQ5wRQd+JQkC3uEI+QX3Z9tu/dYEfek6w5/G2RgKqbmedlIAa9G4ns8mJlbH0WnZRTDrFF6H EQ3kJuX2K+kl0xskiksJ7fNzJFEF2PUn/HkMga6tXm4mcfBPu9IHGgW9sqFr1hwFZTyiuKtus 2AngeNaLJbhSAjRB6jhNwfgarjKiVPjs/uwzzTdPLIOwPeHx6pvBeUzj8M3YO+hw3R/rPP/E1 9V8ZbQzNEHHYtxBsoHD+NfOUcwnEmhDdATQTLqVzjhkWDoPGahLFExRMFzGzkX34Ns5jzNblW GKMjToXAtLO6GinX2cGhZBRaDfcEVxsrCX27PoP/7ISwATT7rkJyhK1kANpMGdDmd6Gm5uxPW JfNn/3eYFKVCu1sz+QuyBv49JV/JKYWn5VmmQ0RT+T8RZram7dFRTvjgHklAzO5oXbl4wRoT1 sWriopiKWUIaRJHbv1NFgQMKJsMt6HkkNuDebIYKj6v9Ec4uio17fT5wOmHA6T+an2Q855iJl vE6v7Y4W9L3SJ587Jf6leNMFSkweXhej4CnFQCLRdmfIFI5IzCrYPCMdmCv1LZd/4v0es2362 G6tBxX57SQ5WxONMElFgsVwqdoSKMmcRiAFbzA/ii04Ix0eyq8FmvN5NrzEaUtRV712DcC4ZP Ck3wTu0FywaoXJehWXOXvW4arv814LRU7SLrgMcRxkpnhIJ6lhlIC04MeZ4BbNtAYYeQ0Nr/L c8EFsYUn5VqrGct5JG6SGs6I4NBJ1G7szHW9uHePw88SHd3FytBwi1fEYI+No5Y4GeBxuz1hK wbUgOLXz4Z95RWK9vkOJcNk5gi1bgO0vvafWYNXX5Qu771q0UcBkrmd8cUKO/ZXveYndTM2zw KT2g0s+uYa54NYb/2VRgwKj9npE6KnGwDwTre6f9NLk2fLIg== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.3 Subject: [Qemu-devel] [PATCH v3 1/4] block/replication.c: 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: kwolf@redhat.com, Wen Congyang , Jason Wang , mreitz@redhat.com, Zhang Chen , Xie Changlong Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" After failover the Secondary side of replication shouldn't change state, be= cause 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 acti= ve and hidden images into the base image). Signed-off-by: Lukas Straub --- block/replication.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) 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, Re= plicationMode 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); @@ -529,8 +540,7 @@ static void replication_start(ReplicationState *rs, Rep= licationMode mode, "Block device is in use by internal backup job"); top_bs =3D 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 =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 +614,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 +656,17 @@ static void replication_stop(ReplicationState *rs, boo= l 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); -- 2.20.1