From nobody Tue Nov 11 21:18:17 2025 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=1565895157; cv=none; d=zoho.com; s=zohoarc; b=QH+1GK11htGGxF5tr9/xYYA2H+GNYobKmGmdPLdSkp0oVvBcB0jzLePfU6MlMyr9ALLpy8uFPaPO6egk240myIJWqm7KI61P5PDOcgyokD/CZyfZqG+ZKK9255THMz4r0EkqMNsA+wSZGrMNOqGuZ10IOGkvxLbQDR56tJEGa/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565895157; 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=H41WaEKUYyBlpdMraaqVxo39K62qVP5NCggkuRML3zzYXGsrjlPB1chMu3RH2smv0gIxR4M8tRxmcQ2ysvJCReKs8Fq+jMFlqxsU8KlCYS6KawzR3qtJSluf9fz3qpq0eH3uD5aZA0poLfTQt23RwD7vBmJgemvhjS57gTnKu9U= 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 1565895157158810.5755191960635; Thu, 15 Aug 2019 11:52:37 -0700 (PDT) Received: from localhost ([::1]:46336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyKrT-0006In-Ri for importer@patchew.org; Thu, 15 Aug 2019 14:52:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40021) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyKoG-0004BF-UG for qemu-devel@nongnu.org; Thu, 15 Aug 2019 14:49:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyKoE-0006pO-IX for qemu-devel@nongnu.org; Thu, 15 Aug 2019 14:49:16 -0400 Received: from mout.web.de ([212.227.17.12]:37549) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hyKoE-0006oA-AM for qemu-devel@nongnu.org; Thu, 15 Aug 2019 14:49:14 -0400 Received: from luklap ([89.247.255.245]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MKrLo-1hyKnv3PBA-0006xH; Thu, 15 Aug 2019 20:48:55 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1565894936; bh=1aMK3WcfXGtXkTJdGeILldP4LKkJ6RJ1Yf8zxuMXcY0=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=P+EWcm6tPBDbTSgxuA/Ce4H5DITJa7kJcVWQ38l9Ami+5z4EsUR9QV22H4LgPg0vg 34SFZRyWcLcjNsy7HJ1tS0qvJV4Gzl++/KTITYS30TA8Z0O2DsBt0JQKKSoP31dJZ5 0MX55l5J//GokFG0Mq6g72DDFbH8BuPS+4GHsu7A= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Date: Thu, 15 Aug 2019 20:48:55 +0200 From: Lukas Straub To: qemu-devel Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Enc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QiGqCS4av1CSdOaD1jgyReF9dKNu5iKggWy9yqWzx luL/MMyXKy9ofqorTnL76lUNMh2LF3IXZ+PKxtAtAPPJweHgeF7vlyEYVzDVksJARj2jcHVGi B4F9SQYbIqdTzH/XAKm9puBu1KrduZWR/zynnyzq1kG6JzcDMojRa5ywb6VjU3hjghx3fznSj Kkyo+ibewjbbRZAIt0X49rkegAmOcCq/nc5ir6cMLD7AI7Jc7zfOzkZ3h5JF6/NvcIo/r0bSB mbVLBLkmIcEVbrH9vx9D3CbPhy977MYfFqkZ/6gZONM5lOYvE4mrqbemWp3q+rXml7bXQAo4W 6vF64DmuUxQ7a5CuKTkziJBTygPefz/dKJ9ieefQEz4E6n6sP56O/MgKt0+RP384of9sjkViu 23Zkk= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.12 Subject: [Qemu-devel] [PATCH v2 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: Zhang Chen , Jason Wang , Xie Changlong , Wen Congyang 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