From patchwork Thu Jan 17 15:33:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 10768441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 752DC746 for ; Thu, 17 Jan 2019 15:39:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 651BA300A5 for ; Thu, 17 Jan 2019 15:39:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59AC2300EA; Thu, 17 Jan 2019 15:39:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 04FFD300A5 for ; Thu, 17 Jan 2019 15:39:31 +0000 (UTC) Received: from localhost ([127.0.0.1]:46750 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gk9lS-0005uV-At for patchwork-qemu-devel@patchwork.kernel.org; Thu, 17 Jan 2019 10:39:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gk9gj-0001ld-GF for qemu-devel@nongnu.org; Thu, 17 Jan 2019 10:34:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gk9gh-0007bq-Kx for qemu-devel@nongnu.org; Thu, 17 Jan 2019 10:34:37 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:59811) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gk9gf-0007Im-Oi; Thu, 17 Jan 2019 10:34:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=e0GUrF7JL82rFLYaMP6oxS+DoRuyZI2A+aRkyKp9Afg=; b=MJRRiAV1FQGUViIkerh5QRbgAy9slOVB9Ks1JivKrQCHjscVfN17pg+1uiyN09WU50o8OOVFMT8Ry/tUmw7xUwhxtGVXzEKlk2h1e1L1ozbjEKKfmP3NbBQn/fnSLsUFNU/E6Q2fLFIImNBuTW2zupN56G9ZTqw0/H+9p4reyQj6QodSI0PvfQPL7/73kP4pZfOaIxPQBh1uZ66woCS8o182dmF7E9cz60gXgMaTESgMCTRhx0GlkrjyIWPuBF5vyjk7L4xpFhgiQw/PU7eLjJqAuny7ONvNBvzf25Ry4My2jfE1p6cbhxAkovkFhcDoB6/EAR1iS2Ys5BuCFnCGNA==; Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1gk9gY-0003bX-H6; Thu, 17 Jan 2019 16:34:26 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1gk9gI-0007RD-T6; Thu, 17 Jan 2019 17:34:10 +0200 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 17 Jan 2019 17:33:55 +0200 Message-Id: <5c04485949b8cc3f63c6500b2bf6f70f4faaba4a.1547739122.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH 04/13] 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alberto Garcia --- block/stream.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/block/stream.c b/block/stream.c index 7a49ac0992..39a2e10892 100644 --- a/block/stream.c +++ b/block/stream.c @@ -54,6 +54,14 @@ static int coroutine_fn stream_populate(BlockBackend *blk, return blk_co_preadv(blk, offset, qiov.size, &qiov, BDRV_REQ_COPY_ON_READ); } +static void stream_abort(Job *job) +{ + StreamBlockJob *s = container_of(job, StreamBlockJob, common.job); + BlockJob *bjob = &s->common; + + bdrv_unfreeze_backing_chain(blk_bs(bjob->blk), s->base); +} + static int stream_prepare(Job *job) { StreamBlockJob *s = container_of(job, StreamBlockJob, common.job); @@ -63,6 +71,8 @@ static int stream_prepare(Job *job) Error *local_err = NULL; int ret = 0; + bdrv_unfreeze_backing_chain(bs, base); + if (bs->backing) { const char *base_id = NULL, *base_fmt = NULL; if (base) { @@ -213,6 +223,7 @@ static const BlockJobDriver stream_job_driver = { .free = block_job_free, .run = stream_run, .prepare = stream_prepare, + .abort = stream_abort, .clean = stream_clean, .user_resume = block_job_user_resume, .drain = block_job_drain, @@ -259,6 +270,11 @@ void stream_start(const char *job_id, BlockDriverState *bs, &error_abort); } + if (bdrv_freeze_backing_chain(bs, base, errp) < 0) { + job_early_fail(&s->common.job); + goto fail; + } + s->base = base; s->backing_file_str = g_strdup(backing_file_str); s->bs_read_only = bs_read_only;