From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A634CA9EA0 for ; Fri, 18 Oct 2019 18:52:26 +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 4D42921897 for ; Fri, 18 Oct 2019 18:52:26 +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="FH+WV4ej" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D42921897 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+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLXMP-0001Xp-5y for qemu-devel@archiver.kernel.org; Fri, 18 Oct 2019 14:52:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38389) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLXGx-0008Sq-9g for qemu-devel@nongnu.org; Fri, 18 Oct 2019 14:46:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLXGw-0001zg-11 for qemu-devel@nongnu.org; Fri, 18 Oct 2019 14:46:47 -0400 Received: from mout.web.de ([212.227.15.4]:35129) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLXGv-0001xu-Jh; Fri, 18 Oct 2019 14:46:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1571424388; bh=9czTDDpKPA4uzAwvfli8wXLz0Uo2kLx2fFVUmSRI9ug=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=FH+WV4ejt0DzB7yxcnwIaaL01yzF0jc4l4ZimKEuqDF67zTE+p1COCuO3mgGnEGFA jo3qiE+mFAYCL+eZuZLUgloD3Wie30VIbyLnNWbPJyvdCm0vP/f7sIrWq8XSVkjeU8 TEwk0URtI9rAo93qqp77uXQfA7TS4KYnOs3FBKvA= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([87.123.206.121]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MhlP1-1ihLgF1tIZ-00MrMP; Fri, 18 Oct 2019 20:46:28 +0200 Date: Fri, 18 Oct 2019 20:46:26 +0200 From: Lukas Straub To: qemu-devel Subject: Re: [PATCH v6 1/4] block/replication.c: Ignore requests after failover Message-ID: <20191018204626.0559de89@luklap> In-Reply-To: <596a6f07850002a09461f317afa75f3e0c9bb784.1570280098.git.lukasstraub2@web.de> References: <596a6f07850002a09461f317afa75f3e0c9bb784.1570280098.git.lukasstraub2@web.de> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:BnykwpK8Qd+HSNsiTODqg7pLGS9tZ/Z75Jk9VKRp54MQIM8GZ5o +qPy8hdtPsMQzAG1jNppV76WnB/aQaBcF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BtUHMVXMX3wnuzKf3+BsLyhcv6GPYwQO+ckWIThImq5OaKd8jljQqFhorfjlCov+p 4lBDFo4gGBE7WRYYXhnVOUKAPOQF1VA7XHdCIcdRDsB6oVJ5WQHOE+NDNN45S2ZG8U7urr1zc 17VuGX3A9bVjHTQJhKBP40ETkAR/lBW1H8g3PvQM8v+CZW8JGT9rgyVkSkMTSKaDMyw9KjB4C MWFfoz9v44D7PGRbkiQEUruKpxdNoNxCLxQh6ApHlWKXbz6SNwl/oTvKbAm2iz7iqioXho3jm GymW4x3YA9Nm79OnbiR+4rbgbT4jDf59hS8Jh2RU7WDum8B30FILZ97WxXr5nVAwUtFFGTgb+ 52ERxfVToT1HsssFf4IgKqlzOeAUfQynvY2h4I73w7DkAt45nK/7XunKQ8kM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.15.4 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Sat, 5 Oct 2019 15:05:23 +0200 Lukas Straub wrote: > 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, ignor= e > the request if current state is BLOCK_REPLICATION_DONE (sucessful failov= er) or > BLOCK_REPLICATION_FAILOVER (failover in progres i.e. currently merging a= ctive > 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(-) > > 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 =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, = ReplicationMode 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(ReplicationSt= ate *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, = bool 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); Hello Everyone, Could the block people have a look at this patch? Regards, Lukas Straub