From patchwork Thu Aug 15 18:48:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 1147770 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=web.de header.i=@web.de header.b="P+EWcm6t"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 468bBG529Mz9sDB for ; Fri, 16 Aug 2019 04:50:46 +1000 (AEST) Received: from localhost ([::1]:46306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyKpf-0004Br-6h for incoming@patchwork.ozlabs.org; Thu, 15 Aug 2019 14:50:43 -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 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 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 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 X-Provags-ID: V03:K1:XQIUXgVxtTTP+gnNFrDF7pKHWUhHtD0MetyfahPJ/KNbrEYPCYD e+nA2H/GjV9EnQHFitx/3nISTb5AwvJaz85XZ+SNrFoP/F148vCwh9RZ3H2cJUwv+d+6hTb s3JF78BC9/C7jkEFxvRmPxV5rRMuicHI9UPaMd/dLxdJktsI2s5/TFUuLkeifUsG8Q57a0U oM6/AxEBbVZ+YlTv/he+w== X-UI-Out-Filterresults: notjunk:1; V03:K0:sqRi+eHfCxw=:fNrT2wuUE8cHT6GIP5X6Cz FbMHX2zE54crVy1PS2T8oFNjj6/3x767CUsv5icfJqewPMrGgxcFinsXtcK3311ah8ksNgZQk vqLaILrtsyXfvq2MM1Rz0b6nUxF8gvtmQA+UVnC4FWlrCxxwbInaxxp45iVOpl8g4qzns3rjX bfZmYWtVZmGojN6a7w1nHXjf9yiFh+EbtoPFif8vLq6pvayI+ztAZOa+Zm3UaxJVYdLrvqNsH mdlJsLjriIsY7UEAYAN/qIR4aLKen3Mk320a47Vl9aE/Q/j7xDehrERZCw6GXJxUULcN/ucaK eLGFfafJ54wUtYS6F7ZAp6dkDK4+W/S75WGSaQF7LJFTXJ1zzoBcfFVNsZQbZMdZ1LqScoPna efUvhP2r1nwQrWlbHqO6kznyoWarzadPeWc3Ht8PJ93Yhj4LEq7Ui5Abmd157Ghk7smQOtE2l zRexQWZkyi8nikQdc+hN40zR8xuNUec61SLnpVGtpCR/zvx8sX+5AxH/T4e6jSp0Lwl+eQVYq jIb9N1dAZRV+YLJXE5L0K9f7lMmqgI3hMOtWZh/7WAMxoM/cyT3D0jgYzfmZhPsMyxgZz8hFI Rlfttq4D8J8IdqcnapfIMnOsZf7ovk3OIBy56vKrhmDIBG1GMbJoxl9wgHi2HBgggc8jXFD6c Pf4U1m3DFoZGIk3DRs/OOPTajKn49KaF+wWnqYbTv1Fxo9KIjlSdQWqWsL3NOPKSIpl3NA74w 8dkLC7/ELqC0/2og7VFOijCp5w3FSwkQQiGqCS4av1CSdOaD1jgyReF9dKNu5iKggWy9yqWzx 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+incoming=patchwork.ozlabs.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 --- 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);