From nobody Wed Nov 12 11:56:28 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=1570281226; cv=none; d=zoho.com; s=zohoarc; b=YEBH88h1arXufT6KkMgE4Sz6XNra2j3JY/xD7EpjNwNNjB8Fvdz092xOcPXvX46kvibuSky5VC4trIwCArOIKIETdUMTH7Jw/bXXSFPtdDWlfzBBrw3rcpIZltadc9+RLwznqkX1f1PkJYl+77h6B+vAqZyxDs2IGP+pGlRHBx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570281226; 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=dWBV7IEDe7QLQgWbo5dq/itUDwj+Eo+VeT1Sg0u7lm8=; b=BytrVjcVb32ciupUalC7ef96FtEyoy0mIARz4GuvjxpZbL7MTHIN8NweT7Kk4eaCaGiuAAfQi4iXr/0OBa2o3YrfjdaJVuN8A0VJTsZugMadxMNVrBHolOOPF0znzXyWzh9Wze2zMvpGwx3+u5uOGbnVomBN035fTfRIa6A2ITs= 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 1570281226787609.5739243394937; Sat, 5 Oct 2019 06:13:46 -0700 (PDT) Received: from localhost ([::1]:56654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGjsQ-0004yz-QI for importer@patchew.org; Sat, 05 Oct 2019 09:13:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56745) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGjkt-0002ki-An for qemu-devel@nongnu.org; Sat, 05 Oct 2019 09:05:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGjks-0005SV-39 for qemu-devel@nongnu.org; Sat, 05 Oct 2019 09:05:51 -0400 Received: from mout.web.de ([217.72.192.78]:52685) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iGjkr-0005Qu-MM for qemu-devel@nongnu.org; Sat, 05 Oct 2019 09:05:50 -0400 Received: from luklap ([87.123.206.231]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MTh6a-1ihErV2C5A-00QTQZ; Sat, 05 Oct 2019 15:05:25 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1570280725; bh=R0IRo8VMRmUK4dg5KQRbFBwzAqI8nGg0X+OwDoGxLWM=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=ehfGa9U9l/1J0bEnnjAUzFhCeV8F5HcWz/0jyLMXdMWEwWXUQyPDCZdQGTnh5+lI9 L6D2ljk2rDNaoQ12cWSsMAt20sH0V/FV2PVB1ZTA83pU82BHKZhmlaX731GSgT7DBt a//2Fy6+2WJZSdkMSebYIKWKZeOqT9T8iw3FKEQA= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Date: Sat, 5 Oct 2019 15:05:23 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 1/4] block/replication.c: Ignore requests after failover Message-ID: <596a6f07850002a09461f317afa75f3e0c9bb784.1570280098.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:YOVCmClvx9HEE1dFzp4GHc9NXGOxuebHDtMPBOu9EOhb9psnocK xUjUxlxc3wlDfaMwPRKBshOSW5MDOfpfX89dPkVhGNsxtZ8s3r0DulmbrJv1iRv1HBzdvNQ Ql3pBpIeQzy78d/9sMSIFMaJNiH7WLlMn+4lit3kCV/puC6w8DLaRKaDMsSWSnGCibI9NU9 xRCEnimUZXSCzmEezWmXQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:w0A6Urtw3cA=:UgS6dH2fGSksF4B+YgeDB6 GxxTWEAWlYLtgfnhiIdvm9rvFyNSZDHomiMMdjpmScr1TpCG5SYB9ROHGVGbfd0m8YlBdIt1K uWsYY5vuVrvmrCnj1Bg6smzrwaAOexR3+1oMRCxbvstj2+ZfP7mIRaGtziIZROPVb8KNuHzhS nWjx6tJ1TQWgcl1WzeTqQT/AUSZeTYdGjxFpaUGcRGXWuDzv6Ro2LBvEmaHNxMnTL3tWSok1B wp8Bsak4XOXHauPtCV8cl9Uy+sjp41OUaUPB/epabmmqIQfGhmmBZ/dVlg6Dx6BMFvLv4z7oy Y2Wt4UXzoistUzRQ+isxhzwcNTJhjc81nC7NoQXer+lq5+qs0jdaC3CGj8e4UXhao3tvow3Xs tGG4MyY4k2FmhK8+i2PXZuzLlGh9mvBkt5lA8FgAeULlHxLRvtlkUVSyrJlsT6chxgdebErHh XurnaznFFz8hWosHXbmF1c9+qIBzXsnHDS6MBBqM6Hgk7JZs/3aB9pwHH5Ei4gAiwogIR2ccl r+qRA5Dc/I5AFnS/1CvpQ6Z2sYjII+2zrwtsD981ufM2yW6ec+PPipcdUUf82cyYIwS/jLQW/ fsML6XnNtrLTw9xv3muCkEvQvG1rrCgc6p4oopr4apX6On1h5abZWbcwA9LKcZxcDz3hxwG/R j1MLhJ1Su78wamV9G6JOaolnvxFsqQFaw1zzuVQRAIW6Vq+hd2yumt8ivLXn2K/J1GIBslrx+ kySfXj8Ima5tIBX/HV6S6TEhYR28gsv4jND5SZF9iRWDH3MS8xp/nVENqdLv6MI+IlV/rwt6R 2w+lnbzERHqOZQwLscBMK0yQCmTwliADrnl1v65E+9+mNpWhJTuhQLcD7h6KaLZ8qyF0KrjaI ThzobHjvK1nh2XVIlU9rMuxcImBtUhvwV31sGzBUsbQfN4lJfuF+l5iGR+zqpI9gE4HNG7csM NlUNn5DRO/NFBFV3KgVPJTvJR/t5xu0ORU5za1ynPS7sE/938RkxLcZ8L84HfyMtgJsk7F8NS rUlHFVdULOutJvPhS+KJt62y26v+GX+tG4mlujEj9UW7+uuLVUd4kVOWyDBrcQ9DSwW2gZUkc Ozl/stij6jSGWMYD/qYT87SkcxJ9GDJz8dOBN+Dm8BH9/Ckd9sLT6XI/Ggqx9zAljKA4gKEuW 8162exq47M+No9puzorOSfdwsNNjbYB4nnDXztmRXu3a8q0Tuey68jVneD2Bl0nDXUqHEk1SO YI47H7djA6NPQyapgW6j1/Hl5/YaWdFD7IttmfTNGEisbCS6wb9bwOzdI7dc= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.78 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+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 --- 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