From patchwork Sun Jul 18 14:48:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 12384373 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=-10.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 1D6BCC636CA for ; Sun, 18 Jul 2021 14:50:14 +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 832CB61183 for ; Sun, 18 Jul 2021 14:50:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 832CB61183 Authentication-Results: mail.kernel.org; dmarc=fail (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]:37942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m587Q-0007dv-OY for qemu-devel@archiver.kernel.org; Sun, 18 Jul 2021 10:50:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5860-00053b-NJ; Sun, 18 Jul 2021 10:48:44 -0400 Received: from mout.web.de ([212.227.15.4]:47927) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m585y-0006al-Sk; Sun, 18 Jul 2021 10:48:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1626619707; bh=mo37842ZcCneXuNNELXoRfP7tT44+hgbDC62XN80mMU=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=XUwo9oggSiAMsYxP8asLkP6hZGYza4LIRz+qfDr61XO4nqtDEFjIaHiLbvb5/LMyU i7cOr/K7CRi9gPA/7u9WDjTosDA8J20A7rK/PW8I0RCPtjwa7rIp1+cUfKnNi0C/ne mwvZRBF9vB+FYH+Ruh12USakZsqGbGsD45YjtiWw= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from gecko.fritz.box ([89.247.255.49]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MPKB7-1lkXlW0FPJ-00PIqG; Sun, 18 Jul 2021 16:48:27 +0200 Date: Sun, 18 Jul 2021 16:48:24 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 1/4] replication: Remove s->active_disk Message-ID: <2534f867ea9be5b666dfce19744b7d4e2b96c976.1626619393.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:Whbm+Lof7bDsksclQHIInhM+nScSx2lpC6nl3JmEnWMbi28QxZd mD4kYCIKr0Cv9JTP2Cch8knH0NMDO9GyDkRlILlnUIPNzNp7f3ElFwDL32e8PyydOfv01Qh mkrkv+TgKfGVo04uJl2N7JNDmyeoYRec1TTlbQDVHCY1ZrsQgTrTu33nQAa9/6FvYFL5DaR fnlOKY1IfN1ljo52cPRRQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:cDLnOfe6/g8=:E+Ug47lBxiUMdji9+C2kk1 Ddp2u/GvxNKRvDKoKFNvHkQr+HzlHcNkvSZaECALc/QTo4Brz1AFzNvf1NOUrogzpGN4hFvTJ 04zKH/kUlz8U7GIITjESGLQuP9krmmE9RcyMmHxl5okl104mLbW4b7Fur1M8Lr6BKPPObEDwC 7NfJkC6asOrM0CWiCHInBMcfWUq1fBMBFJzmRofwDFU67rhvy0oAqPMp+XHPR5UxWZpIHg4HI e7E0mUd6gv/Q5fd1yZzP2P8OxLjbBrSXpNUAPYvodQQ1XXL7tBGnfNMRdF7FB2hxQEq6Mw2BN ZNeO7U/0Ti5kUJGXNMUeJD6iwFgVp1ztfpcA+0ltF2XuPYSf+fqVlLkUZ7bTVaJLDPtHL5XKx nPttV5NkGuCmwllwk3r418Yjr2VzLFtDhRR0RGC6r3YO4TIMqBaZ8x/Se7fY3YLgobadj7XTZ b6wFDgWAsMTiLHRccRmZgWe1zHObKcoCyTPmlYQapABXJsiJW5b+dSdN/ak+vy9sa2J4tcb7D d3Ar3Tu0JCuXVMfUiy6JSwrRKpdGjaZ0iyKTAy7OMOa2aSDzZsSbfYjIGjxiu2IED5RUMP0+M NQSg2IBd+PK62wEASVdbx85Gn15KsVBqGxJXbIK8pXQjeoj1R6vJRkKzJz+FN9rVl0qE7Z7xp CVIJNQg88spx9BSvvb54G7Qvf88/SrJj6HCNR7DXfRF0sy55Vh+sAOVVJ0PbY6j2suEtf495W G5zD5VtpVClHnuU+CBPD+n4ILZl0nXo4DID3Px+nKateyYhZlltk2StcGAUlUK+7dDNkkIgpc /QlJMBSTuAbyKwEoIgcDDdp2OGCEcfE8dvx2GVlVXJjdWMHP8z4nnSx/3vjJm8y3G/gaYnmTw k7+RlSxHRXSzbPUug0ZLy+pbC+gqWDorajxpiMyyEksXIkkDACtXqhp7hUGEXHJ7AoSRmqRHl rVK3b2+KHmZgU/BVu4zUfeBNsSW6FYSArtZAxqi1WD7Zr8Qrvvs7DcD3EAAdQ/SvlXg87WiU1 cYf5PlNZMYy7/h9uLcOFnotPfiUcySlyBEdObKoO35e1VKPWgOaVF0doXQAmH4ccKbOB/Xlc3 cNl/1bzjQ3XwLsNtKpuD/M2PVciX1bKU8NE Received-SPF: pass client-ip=212.227.15.4; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 , Vladimir Sementsov-Ogievskiy , qemu-block , Wen Congyang , Xie Changlong , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" s->active_disk is bs->file. Remove it and use local variables instead. Signed-off-by: Lukas Straub Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Zhang Chen --- block/replication.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) -- 2.20.1 diff --git a/block/replication.c b/block/replication.c index 774e15df16..9ad2dfdc69 100644 --- a/block/replication.c +++ b/block/replication.c @@ -35,7 +35,6 @@ typedef enum { typedef struct BDRVReplicationState { ReplicationMode mode; ReplicationStage stage; - BdrvChild *active_disk; BlockJob *commit_job; BdrvChild *hidden_disk; BdrvChild *secondary_disk; @@ -307,8 +306,10 @@ out: return ret; } -static void secondary_do_checkpoint(BDRVReplicationState *s, Error **errp) +static void secondary_do_checkpoint(BlockDriverState *bs, Error **errp) { + BDRVReplicationState *s = bs->opaque; + BdrvChild *active_disk = bs->file; Error *local_err = NULL; int ret; @@ -323,13 +324,13 @@ static void secondary_do_checkpoint(BDRVReplicationState *s, Error **errp) return; } - if (!s->active_disk->bs->drv) { + if (!active_disk->bs->drv) { error_setg(errp, "Active disk %s is ejected", - s->active_disk->bs->node_name); + active_disk->bs->node_name); return; } - ret = bdrv_make_empty(s->active_disk, errp); + ret = bdrv_make_empty(active_disk, errp); if (ret < 0) { return; } @@ -458,6 +459,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, BlockDriverState *bs = rs->opaque; BDRVReplicationState *s; BlockDriverState *top_bs; + BdrvChild *active_disk; int64_t active_length, hidden_length, disk_length; AioContext *aio_context; Error *local_err = NULL; @@ -495,15 +497,14 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, case REPLICATION_MODE_PRIMARY: break; case REPLICATION_MODE_SECONDARY: - s->active_disk = bs->file; - if (!s->active_disk || !s->active_disk->bs || - !s->active_disk->bs->backing) { + active_disk = bs->file; + if (!active_disk || !active_disk->bs || !active_disk->bs->backing) { error_setg(errp, "Active disk doesn't have backing file"); aio_context_release(aio_context); return; } - s->hidden_disk = s->active_disk->bs->backing; + s->hidden_disk = active_disk->bs->backing; if (!s->hidden_disk->bs || !s->hidden_disk->bs->backing) { error_setg(errp, "Hidden disk doesn't have backing file"); aio_context_release(aio_context); @@ -518,7 +519,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, } /* verify the length */ - active_length = bdrv_getlength(s->active_disk->bs); + active_length = bdrv_getlength(active_disk->bs); hidden_length = bdrv_getlength(s->hidden_disk->bs); disk_length = bdrv_getlength(s->secondary_disk->bs); if (active_length < 0 || hidden_length < 0 || disk_length < 0 || @@ -530,9 +531,9 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, } /* Must be true, or the bdrv_getlength() calls would have failed */ - assert(s->active_disk->bs->drv && s->hidden_disk->bs->drv); + assert(active_disk->bs->drv && s->hidden_disk->bs->drv); - if (!s->active_disk->bs->drv->bdrv_make_empty || + if (!active_disk->bs->drv->bdrv_make_empty || !s->hidden_disk->bs->drv->bdrv_make_empty) { error_setg(errp, "Active disk or hidden disk doesn't support make_empty"); @@ -586,7 +587,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, s->stage = BLOCK_REPLICATION_RUNNING; if (s->mode == REPLICATION_MODE_SECONDARY) { - secondary_do_checkpoint(s, errp); + secondary_do_checkpoint(bs, errp); } s->error = 0; @@ -615,7 +616,7 @@ static void replication_do_checkpoint(ReplicationState *rs, Error **errp) } if (s->mode == REPLICATION_MODE_SECONDARY) { - secondary_do_checkpoint(s, errp); + secondary_do_checkpoint(bs, errp); } aio_context_release(aio_context); } @@ -652,7 +653,6 @@ static void replication_done(void *opaque, int ret) if (ret == 0) { s->stage = BLOCK_REPLICATION_DONE; - s->active_disk = NULL; s->secondary_disk = NULL; s->hidden_disk = NULL; s->error = 0; @@ -705,7 +705,7 @@ static void replication_stop(ReplicationState *rs, bool failover, Error **errp) } if (!failover) { - secondary_do_checkpoint(s, errp); + secondary_do_checkpoint(bs, errp); s->stage = BLOCK_REPLICATION_DONE; aio_context_release(aio_context); return; @@ -713,7 +713,7 @@ static void replication_stop(ReplicationState *rs, bool failover, Error **errp) s->stage = BLOCK_REPLICATION_FAILOVER; s->commit_job = commit_active_start( - NULL, s->active_disk->bs, s->secondary_disk->bs, + NULL, bs->file->bs, s->secondary_disk->bs, JOB_INTERNAL, 0, BLOCKDEV_ON_ERROR_REPORT, NULL, replication_done, bs, true, errp); break; From patchwork Sun Jul 18 14:48:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 12384379 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=-10.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 79D56C636CA for ; Sun, 18 Jul 2021 14:52:47 +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 1108461183 for ; Sun, 18 Jul 2021 14:52:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1108461183 Authentication-Results: mail.kernel.org; dmarc=fail (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]:45132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m589t-0004I2-9E for qemu-devel@archiver.kernel.org; Sun, 18 Jul 2021 10:52:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5864-0005BP-5C; Sun, 18 Jul 2021 10:48:48 -0400 Received: from mout.web.de ([212.227.15.3]:55767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5862-0006da-99; Sun, 18 Jul 2021 10:48:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1626619711; bh=RcT51x0uGvx/VXymThtSy6KzgjNEbcTDd+d3Y151Mok=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=rMV0RUsYCuvZv/V4by3epUl0DS0jtshrg0aXxKGWhbja9HGdjRCCdbIZvgwTjIiaW 043t4odiAvqI7QcMUAPdz2gY252a88xGqSH0xSenZxuil+YIiXawRXc3pvAmy5zM0G FFmkV5f+QRj5HP8yNedu94YnlvBc0ruuqxl3wNQw= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from gecko.fritz.box ([89.247.255.49]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LaTtv-1lP91c2AN5-00mKW9; Sun, 18 Jul 2021 16:48:31 +0200 Date: Sun, 18 Jul 2021 16:48:29 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 2/4] replication: Reduce usage of s->hidden_disk and s->secondary_disk Message-ID: <1eb9dc179267207d9c7eccaeb30761758e32e9ab.1626619393.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:ZbTro+QLBFe86VqB8VcX1ZNfSVZgFvoEvwiEeU8d4TIPGu+DiM8 JbRLPhv+7xi2kecP/klKp3BF+d9loAyFaQOnsZYUIFNs5CWRtxSp7LikCNO057dCqCROykJ hBsTqPXq2/t0aTm+I/n3FgADGYlOQuW/djA5aKhcHDVVpk/hPLhohcYUH6N8O9Ccoz8fqFJ Ttetmks4kJxDxAyQhRv8Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:qN293fo1s2g=:niBsgR8yaGaPR7sbIEj+m5 gDlUCkYLvPG2JSBsRi8umC8h5mQtLKUjxPCI02xmXO/MFhecrfzkcvNNmP7XaclLdx4zISKSP SK6B1L/EncwoAO22Va3hxaOEHXDxzeV2sexCrtL1FKU3E4Yjpr3/2JTPVs+l1X76xNs3OWv92 jCquDPwvAl0Dp3GovKHaEwF6sT+nXB7vQ3BcKtFm5P+DxawdUfK5b5+ao1vIFGInXeYYdrQ3h SM8L7TXj/UPGXXuUwC6yfbBT1lrvVa9AhukdtH8Ld+i1Scc/AnyCaVpMc1nwaM+Sr2pwS16UK EeOhC27hBOYzJWFV2lLPSCZIivcvmS9JMVYhaqhOSEvayR2C119wY3OoU5dchQOcXpZlvZ8s6 0m1DXA/+oqv7Y/9QJuEhgiL/joIgYCLNzxbynbGYSFCk37GMb4BRo+rmHIXcxWHdfUUfEei8i 5I+7LOiN9Pk8VEE8rvn0gABT0pFAWSjai5FnJpC2S7Mu8S7p/HmCghvukzUGGHuY9KYIX/M3F zl/ysrXjC7CYAUidWRoFtdINZernBPRnudKABA/cLRMvglyvcnphMRKmjQddJgSfj56fD/a1g es98Uij3vkNnxBuDZuRFSu40dEU4gM2dzuGNgXd84cXpM0JINYkdZT2HAXmhAHQAUfgX1+uET k9a0I2EZpKmHoWOGzDNyODQawAbb0/6YEF4Ug3XilbqWqj+ExkdfhNJU58I/5o08zZH+clC7v tjNYVUcvCzC5ypuyK43UseA4/uOIxNP5o9009J1YGDkXecKxkPv3zYrfDT20Lla3ZrcSZ4v1G n6f+CqDnV+UZN9VnHQBOcJdYYYwILw8HVDgbvt1YGirPNP/Fa8H/EhMTfBwONb/podWUwjEeE YTx+hw8g0zlGXQC8yf2OHFQpB8VwhuNrGxdNML/zlB7QfVSTYhTgADlR4s6DBu9QXmW30VfdX yUOZE4ycXFQi2phHrHtwpZR1QU1jxvVXHv1JG6OK5WOo6OOt81eKw+ULR/WXLowDXo3t8rI0g qTyFho6ST55VfucSDVYj6hGS47QTFtxf3M/TEGHKBKzBcbMdu23gT2pGSR3N/1LHtxrySiXEW 805GWn9DccuCpBY5gpHacHKFfacepUM0F7j Received-SPF: pass client-ip=212.227.15.3; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 , Vladimir Sementsov-Ogievskiy , qemu-block , Wen Congyang , Xie Changlong , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In preparation for the next patch, initialize s->hidden_disk and s->secondary_disk later and replace access to them with local variables in the places where they aren't initialized yet. Signed-off-by: Lukas Straub Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/replication.c | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) -- 2.20.1 diff --git a/block/replication.c b/block/replication.c index 9ad2dfdc69..25bbdf5d4b 100644 --- a/block/replication.c +++ b/block/replication.c @@ -366,27 +366,35 @@ static void reopen_backing_file(BlockDriverState *bs, bool writable, Error **errp) { BDRVReplicationState *s = bs->opaque; + BdrvChild *hidden_disk, *secondary_disk; BlockReopenQueue *reopen_queue = NULL; + /* + * s->hidden_disk and s->secondary_disk may not be set yet, as they will + * only be set after the children are writable. + */ + hidden_disk = bs->file->bs->backing; + secondary_disk = hidden_disk->bs->backing; + if (writable) { - s->orig_hidden_read_only = bdrv_is_read_only(s->hidden_disk->bs); - s->orig_secondary_read_only = bdrv_is_read_only(s->secondary_disk->bs); + s->orig_hidden_read_only = bdrv_is_read_only(hidden_disk->bs); + s->orig_secondary_read_only = bdrv_is_read_only(secondary_disk->bs); } - bdrv_subtree_drained_begin(s->hidden_disk->bs); - bdrv_subtree_drained_begin(s->secondary_disk->bs); + bdrv_subtree_drained_begin(hidden_disk->bs); + bdrv_subtree_drained_begin(secondary_disk->bs); if (s->orig_hidden_read_only) { QDict *opts = qdict_new(); qdict_put_bool(opts, BDRV_OPT_READ_ONLY, !writable); - reopen_queue = bdrv_reopen_queue(reopen_queue, s->hidden_disk->bs, + reopen_queue = bdrv_reopen_queue(reopen_queue, hidden_disk->bs, opts, true); } if (s->orig_secondary_read_only) { QDict *opts = qdict_new(); qdict_put_bool(opts, BDRV_OPT_READ_ONLY, !writable); - reopen_queue = bdrv_reopen_queue(reopen_queue, s->secondary_disk->bs, + reopen_queue = bdrv_reopen_queue(reopen_queue, secondary_disk->bs, opts, true); } @@ -401,8 +409,8 @@ static void reopen_backing_file(BlockDriverState *bs, bool writable, } } - bdrv_subtree_drained_end(s->hidden_disk->bs); - bdrv_subtree_drained_end(s->secondary_disk->bs); + bdrv_subtree_drained_end(hidden_disk->bs); + bdrv_subtree_drained_end(secondary_disk->bs); } static void backup_job_cleanup(BlockDriverState *bs) @@ -459,7 +467,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, BlockDriverState *bs = rs->opaque; BDRVReplicationState *s; BlockDriverState *top_bs; - BdrvChild *active_disk; + BdrvChild *active_disk, *hidden_disk, *secondary_disk; int64_t active_length, hidden_length, disk_length; AioContext *aio_context; Error *local_err = NULL; @@ -504,15 +512,15 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, return; } - s->hidden_disk = active_disk->bs->backing; - if (!s->hidden_disk->bs || !s->hidden_disk->bs->backing) { + hidden_disk = active_disk->bs->backing; + if (!hidden_disk->bs || !hidden_disk->bs->backing) { error_setg(errp, "Hidden disk doesn't have backing file"); aio_context_release(aio_context); return; } - s->secondary_disk = s->hidden_disk->bs->backing; - if (!s->secondary_disk->bs || !bdrv_has_blk(s->secondary_disk->bs)) { + secondary_disk = hidden_disk->bs->backing; + if (!secondary_disk->bs || !bdrv_has_blk(secondary_disk->bs)) { error_setg(errp, "The secondary disk doesn't have block backend"); aio_context_release(aio_context); return; @@ -520,8 +528,8 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, /* verify the length */ active_length = bdrv_getlength(active_disk->bs); - hidden_length = bdrv_getlength(s->hidden_disk->bs); - disk_length = bdrv_getlength(s->secondary_disk->bs); + hidden_length = bdrv_getlength(hidden_disk->bs); + disk_length = bdrv_getlength(secondary_disk->bs); if (active_length < 0 || hidden_length < 0 || disk_length < 0 || active_length != hidden_length || hidden_length != disk_length) { error_setg(errp, "Active disk, hidden disk, secondary disk's length" @@ -531,10 +539,10 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, } /* Must be true, or the bdrv_getlength() calls would have failed */ - assert(active_disk->bs->drv && s->hidden_disk->bs->drv); + assert(active_disk->bs->drv && hidden_disk->bs->drv); if (!active_disk->bs->drv->bdrv_make_empty || - !s->hidden_disk->bs->drv->bdrv_make_empty) { + !hidden_disk->bs->drv->bdrv_make_empty) { error_setg(errp, "Active disk or hidden disk doesn't support make_empty"); aio_context_release(aio_context); @@ -549,6 +557,9 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, return; } + s->hidden_disk = hidden_disk; + s->secondary_disk = secondary_disk; + /* start backup job now */ error_setg(&s->blocker, "Block device is in use by internal backup job"); From patchwork Sun Jul 18 14:48:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 12384377 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=-10.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 76A15C636C8 for ; Sun, 18 Jul 2021 14:52:30 +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 08DF661184 for ; Sun, 18 Jul 2021 14:52:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08DF661184 Authentication-Results: mail.kernel.org; dmarc=fail (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]:44654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m589d-0003xd-8S for qemu-devel@archiver.kernel.org; Sun, 18 Jul 2021 10:52:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5865-0005Fp-Sg; Sun, 18 Jul 2021 10:48:49 -0400 Received: from mout.web.de ([212.227.15.4]:47097) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5864-0006ee-1W; Sun, 18 Jul 2021 10:48:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1626619716; bh=N5lx1n+FmWrGGPFXhrHbEwqzKxw+96SNpsfYoSYG6C0=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=s5j4yscwKAVSHFAuNN7/23veKi09SH4k8OWa6njWqaX7drGyA4iIzL+L6I1bOsFP2 /mqW138Q8wnd93DjUGG9VcxHiWiq+V5/LgxKJ0FJrPt+4ITemjiNjH9PqRmWVQJ9rh BSBzyASsGqI4FyZYj6rh4HQPAXyjs8sAuVX7VebM= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from gecko.fritz.box ([89.247.255.49]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LZvfZ-1lOb5K37NN-00lmGG; Sun, 18 Jul 2021 16:48:35 +0200 Date: Sun, 18 Jul 2021 16:48:33 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 3/4] replication: Properly attach children Message-ID: <5d0539d729afb8072d0d7cde977c5066285591b4.1626619393.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:QKPLLz5zud7s6bdSttrgjU8/h72t8FIWxow1Eroiu1v/TyeCnBd qBHBrx9qE+S4DFBh8ragN2FKhHuDwUNbVCqUm5G2h3oXMd/t3jloI7DD24WQUORxSKohoml uqp8avkPqMdIsg3FUEIisSJ+MFSH+6l+iH9Bt+CrxGNUI6RTSeNLCnZHZp8Yla1mzETeiTs 5Ms8B8r8XFoBKAXT2g2/Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:XLGM+kjdlc0=:Vb3kZ1wvAI08aE3ODw99Fo syW5asjcGEPX0rWn+gAUahBEcJw2f5iurahTtYtG2csnmOHpgg3g8uKwRvbZ0vF4ysLtx8pAv nXfKb4y/+Z9A2yN+kYJpPz12OO4FK20pIu2vkbNzAvTgI2DG/ZwvXVd60HB/8DKVaggLuCzj6 RZuTKHicoiiYZQka/lGvp/X4a1fXKiIL/ksHXhz6r8gjefsvbkpPArlfNIrylpmS4KneXfm8E AeBQ4ChdBio5io9P6QHQZHpei5/Pov7W9pREHB3JoO9lLX3weu1Bzh3+JKsaDJiT2Eq3YhFtq 1Bai88HQtA7xOtca/QQvxgNSOf4FdmRZ45r5HwV+FlaSUtpyaz53SRBLRHcnmzlpIq3D6bztf 3VDVocm0pYGb/InhyjXTuI/GFGN/XE3fmntc5nX0IOoT8ZAm2O+D58d0xs8UFvAb/Xnqmi74t bN56aGMwxggyi2a5wZCMIUKqMZQU2FkGqTCXsc2lrdLp7bY0emvub+gBzVZECR9qzT0m3kzbC D+0oQaau5q5ONQt/aQBdZH97f3yq6RZrFzvsOeBoYfchVbKrd5Isdtb2UgAzHxJYMiEj4plsO LloW0FjnRysFVV3pVs6NeG4EuMAnbd7aCY4OvxiNtihVVj6AFcu0YL11qzOKWOcFDp/Tjp69Q 7iWHnfWbBCDhHgrHv7ZjmRYvjULUOvQEW2ULhDodgnvGeX8TqFUXmL9hJoCTBOnCSwodcrLvl g3Iu0+sPwYtK38pZ4W4IWXJe0OEJ3Uw6F/6BNXiCmyaGE8EQY7sUqf0/4sCqC6RvDkKDyyKpH pp9HwquwDQnmJxAXBOq+BuTzSMTobEwWAEk6Zkb3nB1f/lHmqZLRIgez71zphLpCtdiPB5sv0 Oiwql8ojTlZBDCgIdn/ic+64+Z2ELWK0P5eQZJg2UDC0qsX2UzgMb8OZ6VyfOr8t3/o3/2+Jz EQpex9RVgSp77PKC8606Lv4CgZE2xZOQdE2qBPoxjL74QGTjSkPkmnU6BiPPe6RUuhKgbDWmJ W6ce6+EAymtLTja53NtlWQT5iPSkMkdu+vQyQySVRGkUY21fzLfrDOUSKDAXQ26N4y6/nhYaP H6HPueD7bKfF/cRL136hqdw7th+QJbhs16e Received-SPF: pass client-ip=212.227.15.4; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 , Vladimir Sementsov-Ogievskiy , qemu-block , Wen Congyang , Xie Changlong , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The replication driver needs access to the children block-nodes of it's child so it can issue bdrv_make_empty() and bdrv_co_pwritev() to manage the replication. However, it does this by directly copying the BdrvChilds, which is wrong. Fix this by properly attaching the block-nodes with bdrv_attach_child() and requesting the required permissions. This ultimatively fixes a potential crash in replication_co_writev(), because it may write to s->secondary_disk if it is in state BLOCK_REPLICATION_FAILOVER_FAILED, without requesting write permissions first. And now the workaround in secondary_do_checkpoint() can be removed. Signed-off-by: Lukas Straub Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/replication.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/block/replication.c b/block/replication.c index 25bbdf5d4b..b74192f795 100644 --- a/block/replication.c +++ b/block/replication.c @@ -165,7 +165,12 @@ static void replication_child_perm(BlockDriverState *bs, BdrvChild *c, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { - *nperm = BLK_PERM_CONSISTENT_READ; + if (role & BDRV_CHILD_PRIMARY) { + *nperm = BLK_PERM_CONSISTENT_READ; + } else { + *nperm = 0; + } + if ((bs->open_flags & (BDRV_O_INACTIVE | BDRV_O_RDWR)) == BDRV_O_RDWR) { *nperm |= BLK_PERM_WRITE; } @@ -557,8 +562,25 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, return; } - s->hidden_disk = hidden_disk; - s->secondary_disk = secondary_disk; + bdrv_ref(hidden_disk->bs); + s->hidden_disk = bdrv_attach_child(bs, hidden_disk->bs, "hidden disk", + &child_of_bds, BDRV_CHILD_DATA, + &local_err); + if (local_err) { + error_propagate(errp, local_err); + aio_context_release(aio_context); + return; + } + + bdrv_ref(secondary_disk->bs); + s->secondary_disk = bdrv_attach_child(bs, secondary_disk->bs, + "secondary disk", &child_of_bds, + BDRV_CHILD_DATA, &local_err); + if (local_err) { + error_propagate(errp, local_err); + aio_context_release(aio_context); + return; + } /* start backup job now */ error_setg(&s->blocker, @@ -664,7 +686,9 @@ static void replication_done(void *opaque, int ret) if (ret == 0) { s->stage = BLOCK_REPLICATION_DONE; + bdrv_unref_child(bs, s->secondary_disk); s->secondary_disk = NULL; + bdrv_unref_child(bs, s->hidden_disk); s->hidden_disk = NULL; s->error = 0; } else { From patchwork Sun Jul 18 14:48:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 12384375 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=-10.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 B6E84C636C8 for ; Sun, 18 Jul 2021 14:51:23 +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 4937761183 for ; Sun, 18 Jul 2021 14:51:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4937761183 Authentication-Results: mail.kernel.org; dmarc=fail (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]:40884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m588Y-0001LB-Et for qemu-devel@archiver.kernel.org; Sun, 18 Jul 2021 10:51:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m586H-0005gk-Tg; Sun, 18 Jul 2021 10:49:03 -0400 Received: from mout.web.de ([212.227.15.4]:51017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m586G-0006mI-8P; Sun, 18 Jul 2021 10:49:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1626619723; bh=Xdx3AT1ta8Wzmt0uIMYWRw/wFZ/Bqr7Zn6wzhDeMz9o=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=hp+6xkmUvLvuKCZsXXapS1/QBQb9l9HcJa90V2AKtElK8FHaKMRKw/P9dKCxIJQ6k iPzrcaELGGE5lQSqLqQbZIwAKt9MiwS2CzSXM2YyZqqhmqktKnUms3HnRYUdH0vGwG DTrd6KYRxRNZF1oc5R37FVSO2ETOfyRxbB2JDWrU= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from gecko.fritz.box ([89.247.255.49]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MA4fW-1lz2ED0YVW-00Bwda; Sun, 18 Jul 2021 16:48:43 +0200 Date: Sun, 18 Jul 2021 16:48:42 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v6 4/4] replication: Remove workaround Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:Yhxfm+ArU7RCDaVik9FSrL60zGp7Iqkc4RWho90BBULkAIbYFQk DPF70S9Uu158e2EC7bN62fjQ+vZnS5qNchZapMzbLwyJTvYw/j0JdWcwQ+ECv5WrbbceoXX m0Czjt2mFtVcAnv7z60BvxiClNO/Aqe4EAApbAmHjX21t+yRdEKL2irzkNsi6g6QL5GBTgq 5NnP3uSFUGYcYOaHbKeXA== X-UI-Out-Filterresults: notjunk:1;V03:K0:t/VMsmKmKrA=:hCqMZyeRkmkI6bJmbfRAHd zFXYqO6mLLEhK/6di51a26KG/ejGSlW9umAseTalSPcswbOnab8oDiBI4eYFR0ynspz+gmuFU TfqYOmQoVi+0kkcRMqm9J2w+HWqYsyju71r3RH41vHU2LLQiPtVdzxrChTgdlwsiKZKG116Ul HpoOmmR6KH7EOmPejqAPm7wYhbCWk08p7dyYitKuk6URCmZ8e+SE6LnT/FcdNQuzPlFy6D5dC To3Xz+SHCMllF1fLVOcZlYM9W/5p1AaBsXtkxcHQA0xBoCJ9S4/bmeSnrPgKsbqz+LjmYyQHh imJ2aqKuBfXNKbOzVoFd71S1Ulxc6QutggNiO1y8HdsvNRzhojoD2zfM1N5KQvGjetpcqD/40 f2mpZNAqcG5gQdObzhjBs9mgtAZ0zinE6XKwRPBrtpMh4D4P3ct7wg9LSyE/wVET/ef250tUs ewbmWsva9l5zscv2hQyEAwVME/U1i0Od38Mm8fuk0iiFDRbCcGHUNVaFHDsPUZHZ6cuMMMyNT q/oMX8KZIZtWd7Dt021249Ecz+/VBkyJoa2FpTtFqlxWD/tpap+TsrH0ZhArMlIs7NQJuLB2S Uv+1sva1K2uPvuadnQ0U8bydfU4hdffPaCIz8OGmrgsWzRc/rzzqxArfJ3LlmTIOK6OoZNacW evDq7sQnqz+Gikrd3dbr4poFp1dJau3A88HVAmYRo5iEYyyr7ChtjMZ7ryxb881hztfrIrUcb Ht2XJaX+yeKTLs/aA0fEegsnuajnH2XfWrRYj7nurzdp2QV9wbbR0T6xPvC2t2zOzcSGZ8FAj pRhGyaqSg54XAZbYQENMQV/FrfqiuMADP/TKUQdICIxxU0n348f3PxH6yCHKoxXYO5t0xjtxC ggbDSUKLvPL4nj6oB+LQIySoN/4+97QjqhmiKSwxgaqRB+I7RYzvBLJGJ6XqK7JiqCvG3Afg6 HI1vFStoOS7mE3+pR5S4D86q7PbyEg/kvzy6Dwrqhr3MvpnWaak4NNXXAQ4yVQePrwD5A5SK4 HM0Q9Thqr/GR/QFG5aIMRKHLyicZOa7IYfYlFThftRDkYSjKU2qYbfIHZmhVA3PB3EmNRbeb/ z2OKM0EXzXJP1xrBeksPdYrs/l/O/lUFeeo Received-SPF: pass client-ip=212.227.15.4; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 , Vladimir Sementsov-Ogievskiy , qemu-block , Wen Congyang , Xie Changlong , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Remove the workaround introduced in commit 6ecbc6c52672db5c13805735ca02784879ce8285 "replication: Avoid blk_make_empty() on read-only child". It is not needed anymore since s->hidden_disk is guaranteed to be writable when secondary_do_checkpoint() runs. Because replication_start(), _do_checkpoint() and _stop() are only called by COLO migration code and COLO-migration activates all disks via bdrv_invalidate_cache_all() before it calls these functions. Signed-off-by: Lukas Straub Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/replication.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) -- 2.20.1 diff --git a/block/replication.c b/block/replication.c index b74192f795..32444b9a8f 100644 --- a/block/replication.c +++ b/block/replication.c @@ -346,17 +346,7 @@ static void secondary_do_checkpoint(BlockDriverState *bs, Error **errp) return; } - BlockBackend *blk = blk_new(qemu_get_current_aio_context(), - BLK_PERM_WRITE, BLK_PERM_ALL); - blk_insert_bs(blk, s->hidden_disk->bs, &local_err); - if (local_err) { - error_propagate(errp, local_err); - blk_unref(blk); - return; - } - - ret = blk_make_empty(blk, errp); - blk_unref(blk); + ret = bdrv_make_empty(s->hidden_disk, errp); if (ret < 0) { return; }