From nobody Thu Dec 18 19:32:57 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552416438061774.3626125781783; Tue, 12 Mar 2019 11:47:18 -0700 (PDT) Received: from localhost ([127.0.0.1]:57763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3mQn-0007bu-3F for importer@patchew.org; Tue, 12 Mar 2019 14:47:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3lF4-0001EG-6p for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:31:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3lF1-0000JC-G7 for qemu-devel@nongnu.org; Tue, 12 Mar 2019 13:31:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14019) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3lEx-0000De-Od; Tue, 12 Mar 2019 13:30:59 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD8123003EFB; Tue, 12 Mar 2019 17:30:58 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-52.ams2.redhat.com [10.36.117.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBA8260BF7; Tue, 12 Mar 2019 17:30:57 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 12 Mar 2019 18:30:16 +0100 Message-Id: <20190312173025.3843-20-kwolf@redhat.com> In-Reply-To: <20190312173025.3843-1-kwolf@redhat.com> References: <20190312173025.3843-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 12 Mar 2019 17:30:58 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 19/28] block: Freeze the backing chain for the duration of the stream job X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Alberto Garcia Signed-off-by: Alberto Garcia Signed-off-by: Kevin Wolf --- block/stream.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/block/stream.c b/block/stream.c index e14579ff80..6253c86fae 100644 --- a/block/stream.c +++ b/block/stream.c @@ -35,6 +35,7 @@ typedef struct StreamBlockJob { BlockdevOnError on_error; char *backing_file_str; bool bs_read_only; + bool chain_frozen; } StreamBlockJob; =20 static int coroutine_fn stream_populate(BlockBackend *blk, @@ -49,6 +50,16 @@ static int coroutine_fn stream_populate(BlockBackend *bl= k, return blk_co_preadv(blk, offset, qiov.size, &qiov, BDRV_REQ_COPY_ON_R= EAD); } =20 +static void stream_abort(Job *job) +{ + StreamBlockJob *s =3D container_of(job, StreamBlockJob, common.job); + + if (s->chain_frozen) { + BlockJob *bjob =3D &s->common; + bdrv_unfreeze_backing_chain(blk_bs(bjob->blk), s->base); + } +} + static int stream_prepare(Job *job) { StreamBlockJob *s =3D container_of(job, StreamBlockJob, common.job); @@ -58,6 +69,9 @@ static int stream_prepare(Job *job) Error *local_err =3D NULL; int ret =3D 0; =20 + bdrv_unfreeze_backing_chain(bs, base); + s->chain_frozen =3D false; + if (bs->backing) { const char *base_id =3D NULL, *base_fmt =3D NULL; if (base) { @@ -208,6 +222,7 @@ static const BlockJobDriver stream_job_driver =3D { .free =3D block_job_free, .run =3D stream_run, .prepare =3D stream_prepare, + .abort =3D stream_abort, .clean =3D stream_clean, .user_resume =3D block_job_user_resume, .drain =3D block_job_drain, @@ -254,9 +269,15 @@ void stream_start(const char *job_id, BlockDriverState= *bs, &error_abort); } =20 + if (bdrv_freeze_backing_chain(bs, base, errp) < 0) { + job_early_fail(&s->common.job); + goto fail; + } + s->base =3D base; s->backing_file_str =3D g_strdup(backing_file_str); s->bs_read_only =3D bs_read_only; + s->chain_frozen =3D true; =20 s->on_error =3D on_error; trace_stream_start(bs, base, s); --=20 2.20.1