From patchwork Thu Jan 28 11:01:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 8149281 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E5DBF9FBF9 for ; Thu, 28 Jan 2016 11:02:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6360E2035B for ; Thu, 28 Jan 2016 11:02:51 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 836E820154 for ; Thu, 28 Jan 2016 11:02:50 +0000 (UTC) Received: from localhost ([::1]:55328 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOkLh-0007Z4-T4 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Jan 2016 06:02:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOkKh-0005pl-Sy for qemu-devel@nongnu.org; Thu, 28 Jan 2016 06:01:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOkKc-0007FF-TJ for qemu-devel@nongnu.org; Thu, 28 Jan 2016 06:01:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOkKW-0007EP-Vd; Thu, 28 Jan 2016 06:01:37 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 823F5349E45; Thu, 28 Jan 2016 11:01:36 +0000 (UTC) Received: from fam-t430.redhat.com (vpn1-5-202.pek2.redhat.com [10.72.5.202]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0SB1LKH014329; Thu, 28 Jan 2016 06:01:30 -0500 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 28 Jan 2016 19:01:19 +0800 Message-Id: <1453978880-14187-2-git-send-email-famz@redhat.com> In-Reply-To: <1453978880-14187-1-git-send-email-famz@redhat.com> References: <1453978880-14187-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-block@nongnu.org, Jeff Cody , mreitz@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, jsnow@redhat.com Subject: [Qemu-devel] [PATCH v2 1/2] blockjob: Rename block_job_defer_to_main_loop X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The next patch will make this function more restrictive than it is now, rename it and update comment to reflect the change. Signed-off-by: Fam Zheng --- block/backup.c | 2 +- block/commit.c | 2 +- block/mirror.c | 2 +- block/stream.c | 2 +- blockjob.c | 4 ++-- include/block/blockjob.h | 12 +++++++----- tests/test-blockjob-txn.c | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/block/backup.c b/block/backup.c index 00cafdb..b429666 100644 --- a/block/backup.c +++ b/block/backup.c @@ -482,7 +482,7 @@ static void coroutine_fn backup_run(void *opaque) data = g_malloc(sizeof(*data)); data->ret = ret; - block_job_defer_to_main_loop(&job->common, backup_complete, data); + block_job_coroutine_complete(&job->common, backup_complete, data); } void backup_start(BlockDriverState *bs, BlockDriverState *target, diff --git a/block/commit.c b/block/commit.c index 446a3ae..f6b93bd 100644 --- a/block/commit.c +++ b/block/commit.c @@ -181,7 +181,7 @@ out: data = g_malloc(sizeof(*data)); data->ret = ret; - block_job_defer_to_main_loop(&s->common, commit_complete, data); + block_job_coroutine_complete(&s->common, commit_complete, data); } static void commit_set_speed(BlockJob *job, int64_t speed, Error **errp) diff --git a/block/mirror.c b/block/mirror.c index e9e151c..d665f2b 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -626,7 +626,7 @@ immediate_exit: /* Before we switch to target in mirror_exit, make sure data doesn't * change. */ bdrv_drained_begin(s->common.bs); - block_job_defer_to_main_loop(&s->common, mirror_exit, data); + block_job_coroutine_complete(&s->common, mirror_exit, data); } static void mirror_set_speed(BlockJob *job, int64_t speed, Error **errp) diff --git a/block/stream.c b/block/stream.c index cafaa07..9572ce3 100644 --- a/block/stream.c +++ b/block/stream.c @@ -194,7 +194,7 @@ wait: data = g_malloc(sizeof(*data)); data->ret = ret; data->reached_end = sector_num == end; - block_job_defer_to_main_loop(&s->common, stream_complete, data); + block_job_coroutine_complete(&s->common, stream_complete, data); } static void stream_set_speed(BlockJob *job, int64_t speed, Error **errp) diff --git a/blockjob.c b/blockjob.c index 80adb9d..4b16720 100644 --- a/blockjob.c +++ b/blockjob.c @@ -471,7 +471,7 @@ static void block_job_defer_to_main_loop_bh(void *opaque) qemu_bh_delete(data->bh); - /* Prevent race with block_job_defer_to_main_loop() */ + /* Prevent race with block_job_coroutine_complete() */ aio_context_acquire(data->aio_context); /* Fetch BDS AioContext again, in case it has changed */ @@ -487,7 +487,7 @@ static void block_job_defer_to_main_loop_bh(void *opaque) g_free(data); } -void block_job_defer_to_main_loop(BlockJob *job, +void block_job_coroutine_complete(BlockJob *job, BlockJobDeferToMainLoopFn *fn, void *opaque) { diff --git a/include/block/blockjob.h b/include/block/blockjob.h index d84ccd8..de59fc2 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -393,18 +393,20 @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs, typedef void BlockJobDeferToMainLoopFn(BlockJob *job, void *opaque); /** - * block_job_defer_to_main_loop: + * block_job_coroutine_complete: * @job: The job * @fn: The function to run in the main loop * @opaque: The opaque value that is passed to @fn * - * Execute a given function in the main loop with the BlockDriverState - * AioContext acquired. Block jobs must call bdrv_unref(), bdrv_close(), and - * anything that uses bdrv_drain_all() in the main loop. + * Complete the block job coroutine and execute a given function in the main + * loop with the BlockDriverState AioContext acquired. Block jobs must call + * bdrv_unref(), bdrv_close(), and anything that uses bdrv_drain_all() in the + * main loop. After calling this, the block job coroutine should complete right + * away, without doing any heavy operations such as I/O or block_job_yield(). * * The @job AioContext is held while @fn executes. */ -void block_job_defer_to_main_loop(BlockJob *job, +void block_job_coroutine_complete(BlockJob *job, BlockJobDeferToMainLoopFn *fn, void *opaque); diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c index 34747e9..56442f2 100644 --- a/tests/test-blockjob-txn.c +++ b/tests/test-blockjob-txn.c @@ -57,7 +57,7 @@ static void coroutine_fn test_block_job_run(void *opaque) } } - block_job_defer_to_main_loop(job, test_block_job_complete, + block_job_coroutine_complete(job, test_block_job_complete, (void *)(intptr_t)s->rc); }