From patchwork Wed Sep 13 18:19:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 813561 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xsqnN6k3dz9s9Y for ; Thu, 14 Sep 2017 04:24:24 +1000 (AEST) Received: from localhost ([::1]:44013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsCKk-0002To-W1 for incoming@patchwork.ozlabs.org; Wed, 13 Sep 2017 14:24:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsCH8-0008W0-1T for qemu-devel@nongnu.org; Wed, 13 Sep 2017 14:20:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsCH6-0005Nj-Jw for qemu-devel@nongnu.org; Wed, 13 Sep 2017 14:20:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52700) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsCH0-0005IO-Uz; Wed, 13 Sep 2017 14:20:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1312781DE6; Wed, 13 Sep 2017 18:20:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1312781DE6 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=mreitz@redhat.com Received: from localhost (ovpn-204-23.brq.redhat.com [10.40.204.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9759C61787; Wed, 13 Sep 2017 18:20:29 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 13 Sep 2017 20:19:00 +0200 Message-Id: <20170913181910.29688-9-mreitz@redhat.com> In-Reply-To: <20170913181910.29688-1-mreitz@redhat.com> References: <20170913181910.29688-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 13 Sep 2017 18:20:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 08/18] block/mirror: Use source as a BdrvChild 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 , Fam Zheng , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi , John Snow Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" With this, the mirror_top_bs is no longer just a technically required node in the BDS graph but actually represents the block job operation. Signed-off-by: Max Reitz --- block/mirror.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 2ece38094d..9df4157511 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -43,8 +43,8 @@ typedef struct MirrorBlockJob { RateLimit limit; BlockBackend *target; BlockDriverState *mirror_top_bs; - BlockDriverState *source; BlockDriverState *base; + BdrvChild *source; /* The name of the graph node to replace */ char *replaces; @@ -294,7 +294,6 @@ static void coroutine_fn mirror_co_read(void *opaque) { MirrorOp *op = opaque; MirrorBlockJob *s = op->s; - BlockBackend *source = s->common.blk; int nb_chunks; uint64_t ret; uint64_t max_bytes; @@ -344,7 +343,7 @@ static void coroutine_fn mirror_co_read(void *opaque) s->bytes_in_flight += op->bytes; trace_mirror_one_iteration(s, op->offset, op->bytes); - ret = blk_co_preadv(source, op->offset, op->bytes, &op->qiov, 0); + ret = bdrv_co_preadv(s->source, op->offset, op->bytes, &op->qiov, 0); mirror_read_complete(op, ret); } @@ -416,7 +415,7 @@ static unsigned mirror_perform(MirrorBlockJob *s, int64_t offset, static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) { - BlockDriverState *source = s->source; + BlockDriverState *source = s->source->bs; MirrorOp *pseudo_op; int64_t offset; uint64_t delay_ns = 0, ret = 0; @@ -597,7 +596,7 @@ static void mirror_exit(BlockJob *job, void *opaque) MirrorBlockJob *s = container_of(job, MirrorBlockJob, common); MirrorExitData *data = opaque; AioContext *replace_aio_context = NULL; - BlockDriverState *src = s->source; + BlockDriverState *src = s->source->bs; BlockDriverState *target_bs = blk_bs(s->target); BlockDriverState *mirror_top_bs = s->mirror_top_bs; Error *local_err = NULL; @@ -712,7 +711,7 @@ static int coroutine_fn mirror_dirty_init(MirrorBlockJob *s) { int64_t sector_num, end; BlockDriverState *base = s->base; - BlockDriverState *bs = s->source; + BlockDriverState *bs = s->source->bs; BlockDriverState *target_bs = blk_bs(s->target); int ret, n; int64_t count; @@ -802,7 +801,7 @@ static void coroutine_fn mirror_run(void *opaque) { MirrorBlockJob *s = opaque; MirrorExitData *data; - BlockDriverState *bs = s->source; + BlockDriverState *bs = s->source->bs; BlockDriverState *target_bs = blk_bs(s->target); bool need_drain = true; int64_t length; @@ -1284,7 +1283,7 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs, /* The block job now has a reference to this node */ bdrv_unref(mirror_top_bs); - s->source = bs; + s->source = mirror_top_bs->backing; s->mirror_top_bs = mirror_top_bs; /* No resize for the target either; while the mirror is still running, a @@ -1330,6 +1329,9 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs, s->should_complete = true; } + s->source = mirror_top_bs->backing; + s->mirror_top_bs = mirror_top_bs; + s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp); if (!s->dirty_bitmap) { goto fail;