From patchwork Sun Jul 11 20:55:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 12369343 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.6 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 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 96786C07E9C for ; Sun, 11 Jul 2021 20:57:00 +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 DBFD560724 for ; Sun, 11 Jul 2021 20:56:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBFD560724 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]:57668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2gVW-0000ka-TM for qemu-devel@archiver.kernel.org; Sun, 11 Jul 2021 16:56:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2gUb-0006mQ-VQ; Sun, 11 Jul 2021 16:56:01 -0400 Received: from mout.web.de ([212.227.17.12]:43731) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2gUY-00053w-Nx; Sun, 11 Jul 2021 16:56:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1626036945; bh=9vP1SKJ2ByWb1U3MxjQ6zjQS4zHEBen1kSDRHnvAZ2c=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=CXFWcsN5v30l4XNvV5iRFCS8qmb/39y9ksiGAzfP0COl2gvNdkRTcEttuJ8qojL52 i1FO98wDlKbrE1m+VYuCNj9asONEtCyOafTTdG3Ym40kFs6ogK9Wkff7ZuS054CUlZ NPovTL5IG7evE0M5O+QHDvAg+C0Q45rDN8jwLsVg= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from gecko.fritz.box ([89.247.255.236]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1M7Nig-1m5xk43dyG-007mjQ; Sun, 11 Jul 2021 22:55:44 +0200 Date: Sun, 11 Jul 2021 22:55:43 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v4 1/4] replication: Remove s->active_disk Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:iRp18u+vyncm7Erpt1Jl2SjpxcwlVtmSIkrkWAaEmM66YFNC4OZ Ms5NKAlCY1M/lcBXQz4c/kZyQjS+9jKkFCw7onNZ0qsCgUXesYE6rNcv1+uEjmNlFCaclqL drsx+871nA1KdLRdKUoaXgTDg+KhtILYd9I64eAVTK5T0Tc3VYDe5LU1T08o1gGNGfXaAwV iFp3NsINchPCzQsCN9yVQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:8mntAEo56rw=:smWngTYPTGbrCFh5AAYi5B HpeHEG31y06LxPCrJX6cka0m1v8HgZj/AMFXJu7+Womgjg0sSFBFSmTFvq6QkoKD3UwVLmhtp o5vG6UmpYuNlt+0ACcfwCRufa+M44dt1s5TRN3y+YKmGSe04wyf3LC2tGQXL+AH4AM2pucSzc 4fUrPYF56P4e8OwGFUwO4KSBTu4O05qjpGzH3gLxWENZ/Tkwhdmj70YnuYkfzpPfLEMBKHVl3 ez56nwvDWQSy+wokUNt4UKsArjEO5Ok6u1A1Ro3+Y4SMNXPBeVwfy5JU5Nc1ftEVjYKeLg5LU Yp02C386YxdJZGtWxHRebaN0J0RtXXLVGEgHnFYiElKZ7xal98LU/QHzxuCENoZEOXd4iv66E BMjWbXbQkCmxy0NMWHbKFd1xHdkSD+TnVCt5dIHZDz2pWv8J0QIhXkWqMtIDgHAv2/0ev73v/ olhvimbdT9IGnyN8TNtPgLU2eC+MdrMCQgY+M12XBLYRJXK1R9HUNCGfeLofNQasrM9KfgoSJ m0ublvtzAzwtqGSEcXnB8e6/JJ7zi01lk+DpnoSfJwCIpqHRhNAz0FbUajSSfLr4K49NyySLG jRIwEU87o4Op/JcFZArF2IvfzY7wYLIJB5voyTISZFOvGYKDMZkcTqAC5aywesHZxWqi2XN1j YunE6JX+k93rCSv55RCmikb+h2jlB2FwSB+hdIAXcFructJZSXE/spwzU0+Zx2+HuGb+9p0lA QWU0t0VQUDygx4vlNGeJPq0vWQSYHmzHJRUvmvxnNxZ188v0ybr6OM7jDzmeS7+e50jD9KI42 MGSKRvWz6JCY9ZEt+HllapR1MFZRkLDbAkYve89HTeBq4xebApNeoaEH2lRaJ/vusMlnKcZ3Q 5wlis3MeerqVQC+Ru+S5c3GpS955MDpsy7sajjr6D1iqb/Tz8advU1lqzrLaLyqmQII628T1d c1rIm6oCgqcC70XpAiG70vhkcNnoLzKyk6ZOmGHoI9GtiGFn1W41GUxRLgm/SHUbqqFPh3Jv3 SLBrLoJ1XDZZ986vFNTpm45cmq11wxkCL1ye+BD9qlLhFm72vuCQg0J81z7HRlfQ5G4QAAfUw VgQ9kaBQD4tSilFV5oGO069DiObeKB7Rlwu Received-SPF: pass client-ip=212.227.17.12; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_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 --- 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 11 20:55:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 12369349 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.6 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 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 CB901C07E96 for ; Sun, 11 Jul 2021 21:00:27 +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 431A460FDB for ; Sun, 11 Jul 2021 21:00:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 431A460FDB 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]:36126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2gYs-0005bY-4K for qemu-devel@archiver.kernel.org; Sun, 11 Jul 2021 17:00:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2gUd-0006p8-VW; Sun, 11 Jul 2021 16:56:04 -0400 Received: from mout.web.de ([212.227.17.12]:42337) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2gUc-00056A-3m; Sun, 11 Jul 2021 16:56:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1626036949; bh=mmt3HbfkTVy5HTBlhSqrOQDBD0vuxo3OiXHbwdj2bJ4=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=OFGQU+YOCOH7mbTh6rvkmHudI8TXGJC06mqn35kFc7fnef+24a3Ms8tyGlrtOB7dh C1+cDXTQnitfbW+uhPn/pzv2AI+DlkltU06aCaKb4HvHe7aB8b8Ypm7wlQpj4jwny/ QWrsgE2tB9O8C0m7oQA1HVaEMXZ0StpQ4ZTG6Y1A= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from gecko.fritz.box ([89.247.255.236]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MXHOz-1lhSqW1tEz-00WBt6; Sun, 11 Jul 2021 22:55:49 +0200 Date: Sun, 11 Jul 2021 22:55:46 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v4 2/4] replication: Reduce usage of s->hidden_disk and s->secondary_disk Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:ngMQiIXqLt+05Yh8mSpHQdoT5y7eV9ZfM64lFn3Te6Ncsxfh0d9 QNEcXtjpd7USdAk2AkMD11AKvywso2Tmnddsm7zWLFqBqupDmGD4ZvsZK0TDfRfG/ADS1l6 A/XltXDS1hvXnsSGi3tZyQOMwXpKt+nMD5Ua1jsTiPPaLTSB56gpsTKVhQosY1l//Rhx9Hm 8tVwMHqBcJa+7foIGxsog== X-UI-Out-Filterresults: notjunk:1;V03:K0:Xtzbft4ZQpo=:L8JoqDzOEjEwyhQr3t4BYb 40WanGBK4PHYsGyWKnxGgq2J9a7XRQIn96BOhFtbzRCOjll1/EL0XhWDitkcaDwIoPY82AuQW D+3FB95hL/JhtivbnrWAX2bh0IgT379l8z0nHg1wCalnVpQRnmkFPaeFU2AhM/wM8rZY8c4Ab TEO987n67zIKGn5UCFL3rPRat2JIFZVxScFgZeSumVBhGOBinLTEtRnOWLV8qr70JpTdT6Snx FKLx1VxjOwNy4LAiGXRbdwip7Nvod5tuNf2swtNDkr37fJqDvXHUuQMgVvpfDZrZ/YOmkJlAy nuQvxSItq4wSuKbJ4dBugESjw7SjnYM+MeKptUj4W+PMQ3+jOyFFM9DCm8X6jbihRqLP1kzK+ Gb2yGTAvi/zPG+H/GW1Tql5oGm7mlX+sDDwdLtdEm1AFT1JeMW4Ph+AGk+34/jmTWNNurBxjp Cb79cyFIe2p4iBv+s4ZUGGuOxX6qHZ8gUG9pqkMYHdKNH6qNZqM0nX6qUGMTu2nG4rCrwJxMm esdZbLc0mhDFtrJi54tjov6mWLe51g/mzCjlaxu8DLwxSi46ysFjcIGI+tWQfssIUMOjg3CVL NgHwkQCFY+5sBCKgTgBUPns6uvnfI9TPJHREGNL60+IJdanDKWNJetiNPoLFGUl79p6e8FFl4 Kw4vmRecn2sFSjw4eDXmpPc2ARGt/S2K5F0wSNX1/qvalw5uD7R+FgqX0uCr7tDYgn5D0Yvjt 64rmGCReRCBGmC7dUHC5mZTnNTmkj0WXNGyPJYjEYwlgaB2D0HQ+7In0j75WZf5HSCWNBISGm 3SKnXXcxEJoOSirR2XerOLAYfyUAZkDNyg3UxLjTudQXWbe9qNOGz3Wj2P6dmPoIkWnRwDW7Y ekQeo84FUbz2H+mVCgSCHi+iRGQa5k21LjGMgFeoHpo5QkylNV4FqppbbbJ1q/5tjc5GAC1ke ny+zwSTTMCvPF5TfevjpO/ToZ+WpiaEXnNys3Zd9rvU/uM67J68vwvTf0Uisiji8QtGh0OALr gXzGk18MD4csDtC3yflt0y2Tvt6H6jp5B5deq2VJoby8Uf51g0f/McuUPI5D+1hfPhGCUrGnw JkH2ObAayeOyikpkT7DaPvlNjMtZDO/f2qT Received-SPF: pass client-ip=212.227.17.12; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_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 11 20:55:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 12369345 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.6 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 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 DC928C07E96 for ; Sun, 11 Jul 2021 20:57:05 +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 5779360724 for ; Sun, 11 Jul 2021 20:57:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5779360724 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]:58108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2gVc-00011g-Cb for qemu-devel@archiver.kernel.org; Sun, 11 Jul 2021 16:57:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2gUg-0006wm-VQ; Sun, 11 Jul 2021 16:56:07 -0400 Received: from mout.web.de ([212.227.17.12]:47605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2gUf-00058P-7Q; Sun, 11 Jul 2021 16:56:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1626036953; bh=A/XRZCfRvwzPtRiTJSh318NsXBJY+L0/cZ01K0pxU5k=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=jSbxUeMejb8xNcsy1FdJFxYASEO1Ie5yzwvasCRiPOQWUGrpAKMY3jCREsodmet8x hja1BsHrPUTxzzwesG/f+wLOvTnxYkcpVm9PXjMGVnog8mWzfhWm07K4fLGFvP49H/ 2/lCgLWD0TVyx4m2B+3+NHPJfIzzks8S7+biI+K8= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from gecko.fritz.box ([89.247.255.236]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MGzXS-1lxkXy3Lzm-00DnFY; Sun, 11 Jul 2021 22:55:52 +0200 Date: Sun, 11 Jul 2021 22:55:51 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v4 3/4] replication: Properly attach children Message-ID: <4555f4074e16ed97e134ebd91ac5d9012f30fc70.1626036515.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:sQZqj2APq6HqL297bqEvNA0c/OxFWuKU/PJAo+GNYdsZIwEO1/Q Bz4NZaqB1lnljcS60N6nnyFb/t5yRimVL5sWHcuKHkJivRfNj4DK8IYGrxo+TRu2M3UyjMT t7Qk+krw5zf2nPAa0X7eVXmGU6Q8x0FEJgQ0Y1IR8BK2R0Xjyo/tIu6Lo0RcAd0YcguyZMa pkzCqG3wCjbJ86oy5tpYw== X-UI-Out-Filterresults: notjunk:1;V03:K0:kVuFb9JrXEw=:bvVNDOI30QQujB9FP3BmbN dTkB2k4thyx6YemeF/BkJQQQeNLxrHisEgL+JGx3QnUPocoq34T/Iigomnr+BAB76vSd6Kb/7 p7tYN4JCUF2LB9Xu9IbwsTajEIeLBFR2bJ2+Ogo5H9R4/eRsEuDz6nPZHmwuMyKn3mHi4ttOf zDMf0sXt5/hXQAdETUJLSRhN360GE/xDZ2KR5MNe/+WUD0nDQzRb1vYpB2pJpvfMQKELxtO/L IvN6iTB9fOESkX0IpuGneSWNXYyFkvZNjSoG2fbziDqmnM8nLZKAWD3Lq5BaEboiI6PBep9z3 alSFf519u9kBcJPcXs/M7gHdX0utwW+iP8lCRpfz+2rtUK2HrrDeFdZmNn/TlyoCdWBHu+LEK BjTWTf9rq81bVsp8MfagAYg4KHfyJ3Yg5jcjO79ArJIl3JQD37L1+H13F9f2/1Mc6ivRuWEHL y/ReBnz1D13OGMrFnK/mB05gR+zmL512kcLrDeVz4HtUrnGGOwkhM0TAdGbHdRhBCbUH7UJLc O+8yr0XtDciyk4hndpwMBw0dwwpLHs8oZZxSH0EXxzTMz6BcP7WXMhD/I4349sh8GPnMgrq4G qhOy0j20YY1b0f2QMK8A7tj9kMMILdpFQ1Q8skCUKv7Bk2TVmFhyT7pom+PJ2KFZ6BC3S+9Us X/pU9KHmsoaxNqmkHepmcpi8MJ6UGViQJ47q9ovvCLPyeICXZDVT7OWcv88y5ciS0ZlpuHk4A 8OXs5uujhrTdr/ZAMIPomIc4gzW/LsEWb7cOVejOaaFpEZJxIixICDDcGrC2V8JQkhpPnHWRX LfqdwWJiJHMNoKPOqMAYw9T5qHMfLrHwDAUVuyad4dAUoaV6C0OjVtstW3oo3QYB/p/5uMBeJ ebt2/mgPa6NF4wuh6kP2Y3zLKXjhQpx1C9mzeB8jy5PfD3GpuByRMKW6rP1eN3zXxV9AiHfs3 9LuiGHNMwVaeobHd6kG0tx4mkAR3qvLyhLkvKkWj8QLk7alWawJSPdTX5DM/lnfp+BhCoPP+7 tF6m0k4zQUNE18AT3DyF79a/OnfezUQ2JQsVBaA2XXZg6kSmG3S3dS7Q/+4RT1KgIECo/ARFO b3PNkH+AhwdiBUJmHeN74bcWGrt67Q06P7d Received-SPF: pass client-ip=212.227.17.12; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_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 11 20:55:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 12369347 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.6 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 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 11FA0C07E96 for ; Sun, 11 Jul 2021 20:59:54 +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 A595F60551 for ; Sun, 11 Jul 2021 20:59:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A595F60551 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]:36028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2gYK-0005Xm-PS for qemu-devel@archiver.kernel.org; Sun, 11 Jul 2021 16:59:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2gUj-00074U-Bf; Sun, 11 Jul 2021 16:56:09 -0400 Received: from mout.web.de ([212.227.17.12]:45719) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2gUg-00059h-Qx; Sun, 11 Jul 2021 16:56:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1626036956; bh=1CyQhAyjZy9LKblChQKEHzEaXA2rG7Ry5mkVRG6fGCw=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=tCo10HmuGyOd3eKacU/qudTpCjIRA9NXL9CfZitw81NRLZiHDtDpZsnIUMDXGwHb6 obXgtUQGry+O8i3XCeW03slAo2JQ6n3tvW24KF7vBP2BtM+r772jssNDMskRuFYpAL cHICdBPyRKYkOGfVsqNJvnB+JQwbz3HlhXpZ4VyE= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from gecko.fritz.box ([89.247.255.236]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MnX5T-1lLgm90bw5-00jcbR; Sun, 11 Jul 2021 22:55:56 +0200 Date: Sun, 11 Jul 2021 22:55:54 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v4 4/4] replication: Remove workaround Message-ID: <97b80632101e468607e82739bf126d64f441b219.1626036515.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:80lgmErf6I1MoOk14D0CtUHtRU2OFRCDiRXzIeqIp7n5iEVZ7NG r8upWkgoIXAppEY2AzP0jjofsxOsgLwqPG6pv2vk4AQShAgtPyEl2oa782J9keUmsr4J4il SUPjXPVaJ/z966Ixtnm3LPKzQ3xP1B8LBqeBni3a4qsRFL3LX8gCc0v7Z6Hq8OFotTQF1Id hv1/m6yrtAvDWLeAWQuHg== X-UI-Out-Filterresults: notjunk:1;V03:K0:g0yI19AgsfA=:Pq4jZWwjdMKb/q1B7A4n0J VNhtpsYSwHePoKrNLipCtmOGvoMp8pLemi0UIa3kuDhpqumyrsbwJCvJg8y19mMMpFyPjIAxi OVnZHYpSwzf0mn+2AdM/jCl8KGIq95NKTCkqP+lj6K3sYqdsum0BV6RIhuPgPiTK+aJ6XNWB/ KrFEdIjxzK+6q7DIL8yTWtbB52UWovKJpugldW5gC075Zvfuoky1TJc2VvOJmRPmORuTdb1DI NR6j25q7qMZ3LXI+MqzmqdZ2wHg7BpR7+X/sVP0/awAoJcscWCwOgMC0Qhzxa0kg6EyCRm5NW bQL18x2S83aCju8KwGuk0s7Ue/DikRTyYgAWaiLNIgRJEJxdF2pbuqccw7M9760kcqMzPreMO wQvNrEedGYPfL+Gh5NY6SqL1LJUDjTH2LUNu/8jUxSPxF5h8y8639xGkE5k+P/8iojo0Av3Mt dtbbHr+ldMoKXMnVCI96UekCTC57nDsiRX6y251QLzCNeyMBLonL+Zn+N0o03tXVH9dgh6Ni8 5FPWyQ1xpKNfseEJfwnMWrpGPpms3geaIu7Z+qqtZDn3jQb97q6+KJUA/WyBvWDAvbbeu/VE8 HvXsoZcEXBPPCfPO9HMMaRqrOgGVHSNBinszTn1Hk60mT/ralfXlPT+0JPn8CprdYi9kn+ad/ p59xu0TRELmZjWBc9uabXLyt8IuM5kFSwAWHX+cH/cMjPhllNpMqEJQX9y+h6GlzzwWVsWp6f NuYhWgVfFgGAxiOdX1PXjO3w0+axEUBQ+aUfRMD+7HhQbYYH7QycraiPJMQ5tzPwanqZIV8j3 DMPAwFI6Dt8zKYRG2CUuTVMOGXHJm7vxr2C01Fk2bYF6WDbzugG07H2g0tO1SmtE4YiVkD+3o qonbEuUZnVaSiuoBfMaCGF2M4hvHPtewfigLKZyYHhw02prlXnrJO9uubvtAQj23wl/EJ+gvC 7CGH93bFHp7+eLMpvrY+vFtHELdaWPUANVXAn4qC7vkyD2o4MAh+4Td3LREV9AmYr45EwDiMl yB5ZnqfVqVOfcXPDC5uiTeSEQALfxXqdgSeBaQyIPyqN+RmlO+Tt6bpEs23/dWwdq7XAOdWSk RsqT/9PqVa1tnEPiu+vKE7qNKuW09vfgDkM Received-SPF: pass client-ip=212.227.17.12; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_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 --- 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; }