From nobody Mon Feb 9 01:34:58 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=1571931308; cv=none; d=zoho.com; s=zohoarc; b=IsDZU0MVWWlJWhCCJ4QgpVc9tcCAlPrnEVINnpfd/SWnQOQEEQvhJAsFok37a/cbgKfCrYjrqtHluYQqYoeuGeOzw+PoKWNgwqXLHgSp6KT3hN8h5ZLDnhgTfRcQLbLYOdhMfm26N0157qQ0wX3vMDe7C0l7rzVpV/3OhedQh78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571931308; 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; bh=JBBKe8OuXTs+GJBG9sy0EhQS2nuJgWijL2qBdOy1VXE=; b=hO+Bv7V6azlVrnneBYCeQ25GrfY8oljNjLRqt5znhZNSJgQm81Tm6rthecicGTieJNIPJ9xCL0SXYdxFpRrQV9oI6bTrW4rIKKKy9kkzhpZE3nI7b6V329yL+7uoEn4e4f3N1bZewcRFNDXE1gCAOfomnBvt8ObHXdkyHlxCzMs= 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 1571931308422289.70397287663513; Thu, 24 Oct 2019 08:35:08 -0700 (PDT) Received: from localhost ([::1]:45450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNf8i-00017m-6T for importer@patchew.org; Thu, 24 Oct 2019 11:35:04 -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 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 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 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-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:N+uedjqvs76OPbOtDsp0z41+9k3NWKoNkTJgPFrKREuJ21iR//o ewMsA3MGKGDnBKEt3mZbmHUiuvusrrzdw6Y0n2g5zVy+pmlKmMrkzg2jG0d4Wfm23cU2QSG 1PcSZwCQ7XchdE9BZ4ki0HxdQNfRMFwHkCFYqs+yWvPBLMcBAdiYmYU2QRcb5FTzNYyexC6 XyG5WFbow66C0VRrgpFWQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:6iDpevWf7ak=:en4MnMBtuJfdrRM62TmJ0B o9lFzlR8nJUrQgAsMGv13tz6cfXNsp1tLlAy+MAOQj3IxjES9VExNgi/pbgwPxMZhgzC3tzFc UKC9aLLupGenudyQ8DkKglJB2tKIcb/8vlKiOEhsa6/0Vi8VKCDK+9Sy5/u0pzNzcqx9Ia3yi kJNhs1DabApFvxmGE/E7TfyvleRTLduQ6oMuYLxfAwdob6jbk9ys46ocp0n5+kN4yZq38eicu gJIFHKR4rhifIooNlHfCnpHevwB6tL3LNE4d4PO4icU5/kIHXKe4uzOuGnuGcag079W+VEgDu y98CiFnbUYiRa1p0Mfo4A6nQzjhX1FCUIxUIAVMj9xid3b/PsQzRfnCyJqrEqvjG1zNkGcQW+ IC1lKzpxZgmMleZEXDBYjZzsYCdcIAWFqB+4WuE3lCjYXFn7ZEk+VFsQmY1qMeaZQyw32lqUT wrJO2HKe+h6p/qW6DfAvgi4QrJgfghHxgCegcVqPWEJN2V2MU2AuHj9PCYXCUUOXNoT7k3UTc cpowuvCYtQHdPELz+SfZ3hxl7dCL030S+gWoJcWGtSBDQkYPwGsEWt95G+r06N5mNxdjx0AKv atRy4Ouqb9CakS+qSxcwFM84OnqI7Dikjo/te+1Iorv/t2nK7Tco0MTOYD5W7HtodyixHcgwu U1sn4ivjcre5EE/kJazkzeIzHpIRAaHAu1m/4nRj+7m2TsjZOA+sqatlHTlgh9G2rFsaOMhCV uB1F04GIjJo2PEBfXPKH8d7lTzIxBPBJd6DmJvq4rrLvLbArCxILiL6c+RVVd+lER6bjDtlqK hptyIBYmYmvfzKiz38E6qv/TvUWWtVMImfAmgcieHq3HAJXfxwDZo6+aOV65+yWmkbvTvFQRE NHgYylI5bTAVP4cAuy3Ur9lzNc8GlIxxsE+A9yAL47o5vSjaZ3pfIHNNeCe7F5S2ygZtjKsui BgaFLwnnkNfIg6IFjwMNIHDBQxgOZhYkI3iMBg12qY7bficlQDcfSSTEuyWPAKV/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+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 Reviewed-by: Zhang Chen Acked-by: Max Reitz --- 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 --- 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); @@ -577,6 +588,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 +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, 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