From patchwork Mon Jan 22 22:08:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 10179375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6546B60353 for ; Mon, 22 Jan 2018 22:16:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5743F28573 for ; Mon, 22 Jan 2018 22:16:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A1BA28578; Mon, 22 Jan 2018 22:16:42 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E77FE28573 for ; Mon, 22 Jan 2018 22:16:41 +0000 (UTC) Received: from localhost ([::1]:41533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edkOP-0004JZ-1g for patchwork-qemu-devel@patchwork.kernel.org; Mon, 22 Jan 2018 17:16:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edkIP-0007RD-Gc for qemu-devel@nongnu.org; Mon, 22 Jan 2018 17:10:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1edkIO-0004F1-AD for qemu-devel@nongnu.org; Mon, 22 Jan 2018 17:10:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50062) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1edkIJ-0004C3-Hd; Mon, 22 Jan 2018 17:10:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5BB86A7C8; Mon, 22 Jan 2018 22:10:22 +0000 (UTC) Received: from localhost (ovpn-204-78.brq.redhat.com [10.40.204.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B0AF5EE15; Mon, 22 Jan 2018 22:10:13 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 22 Jan 2018 23:08:03 +0100 Message-Id: <20180122220806.22154-14-mreitz@redhat.com> In-Reply-To: <20180122220806.22154-1-mreitz@redhat.com> References: <20180122220806.22154-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 22 Jan 2018 22:10:22 +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 v2 13/16] block/mirror: Add MirrorBDSOpaque 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This will allow us to access the block job data when the mirror block driver becomes more complex. Signed-off-by: Max Reitz --- block/mirror.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/block/mirror.c b/block/mirror.c index bb46f3c4e9..c1987b0230 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -78,6 +78,10 @@ typedef struct MirrorBlockJob { bool initial_zeroing_ongoing; } MirrorBlockJob; +typedef struct MirrorBDSOpaque { + MirrorBlockJob *job; +} MirrorBDSOpaque; + struct MirrorOp { MirrorBlockJob *s; QEMUIOVector qiov; @@ -607,6 +611,7 @@ static void mirror_exit(BlockJob *job, void *opaque) { MirrorBlockJob *s = container_of(job, MirrorBlockJob, common); MirrorExitData *data = opaque; + MirrorBDSOpaque *bs_opaque = s->mirror_top_bs->opaque; AioContext *replace_aio_context = NULL; BlockDriverState *src = s->mirror_top_bs->backing->bs; BlockDriverState *target_bs = blk_bs(s->target); @@ -699,6 +704,7 @@ static void mirror_exit(BlockJob *job, void *opaque) blk_set_perm(job->blk, 0, BLK_PERM_ALL, &error_abort); blk_insert_bs(job->blk, mirror_top_bs, &error_abort); + bs_opaque->job = NULL; block_job_completed(&s->common, data->ret); g_free(data); @@ -1232,6 +1238,7 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs, Error **errp) { MirrorBlockJob *s; + MirrorBDSOpaque *bs_opaque; BlockDriverState *mirror_top_bs; bool target_graph_mod; bool target_is_backing; @@ -1265,6 +1272,8 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs, mirror_top_bs->implicit = true; } mirror_top_bs->total_sectors = bs->total_sectors; + bs_opaque = g_new0(MirrorBDSOpaque, 1); + mirror_top_bs->opaque = bs_opaque; bdrv_set_aio_context(mirror_top_bs, bdrv_get_aio_context(bs)); /* bdrv_append takes ownership of the mirror_top_bs reference, need to keep @@ -1289,6 +1298,8 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs, if (!s) { goto fail; } + bs_opaque->job = s; + /* The block job now has a reference to this node */ bdrv_unref(mirror_top_bs); @@ -1378,6 +1389,7 @@ fail: g_free(s->replaces); blk_unref(s->target); + bs_opaque->job = NULL; block_job_early_fail(&s->common); }