From nobody Wed Nov 5 14:32:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1535063315910908.6542217337995; Thu, 23 Aug 2018 15:28:35 -0700 (PDT) Received: from localhost ([::1]:39032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsy5d-0002X5-OF for importer@patchew.org; Thu, 23 Aug 2018 18:28:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsy0O-0005fb-T7 for qemu-devel@nongnu.org; Thu, 23 Aug 2018 18:23:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsy0N-0001JZ-Bk for qemu-devel@nongnu.org; Thu, 23 Aug 2018 18:23:04 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40680 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fsy0I-0001AC-OW; Thu, 23 Aug 2018 18:22:58 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30EA8804BAAC; Thu, 23 Aug 2018 22:22:58 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-97.bos.redhat.com [10.18.17.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5E72B2795; Thu, 23 Aug 2018 22:22:57 +0000 (UTC) From: John Snow To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Thu, 23 Aug 2018 18:22:45 -0400 Message-Id: <20180823222249.13518-10-jsnow@redhat.com> In-Reply-To: <20180823222249.13518-1-jsnow@redhat.com> References: <20180823222249.13518-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 23 Aug 2018 22:22:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 23 Aug 2018 22:22:58 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jsnow@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 09/13] jobs: remove .exit callback 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, John Snow , Jeff Cody , Markus Armbruster , Max Reitz , jtc@redhat.com, "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now that all of the jobs use the component finalization callbacks, there's no use for the heavy-hammer .exit callback anymore. job_exit becomes a glorified type shim so that we can call job_completed from aio_bh_schedule_oneshot. Move these three functions down into job.c to eliminate a forward reference. Signed-off-by: John Snow Reviewed-by: Max Reitz --- include/qemu/job.h | 11 ------- job.c | 77 +++++++++++++++++++++----------------------= ---- tests/test-blockjob-txn.c | 4 +-- 3 files changed, 36 insertions(+), 56 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index 858cc2b37a..c5409c4b2d 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -213,17 +213,6 @@ struct JobDriver { */ void (*drain)(Job *job); =20 - /** - * If the callback is not NULL, exit will be invoked from the main thr= ead - * when the job's coroutine has finished, but before transactional - * convergence; before @prepare or @abort. - * - * FIXME TODO: This callback is only temporary to transition remaining= jobs - * to prepare/commit/abort/clean callbacks and will be removed before = 3.1. - * is released. - */ - void (*exit)(Job *job); - /** * If the callback is not NULL, prepare will be invoked when all the j= obs * belonging to the same transaction complete; or upon this job's comp= letion diff --git a/job.c b/job.c index 01dd97fee3..72f7de1f36 100644 --- a/job.c +++ b/job.c @@ -535,49 +535,6 @@ void job_drain(Job *job) } } =20 -static void job_completed(Job *job); - -static void job_exit(void *opaque) -{ - Job *job =3D (Job *)opaque; - AioContext *aio_context =3D job->aio_context; - - if (job->driver->exit) { - aio_context_acquire(aio_context); - job->driver->exit(job); - aio_context_release(aio_context); - } - job_completed(job); -} - -/** - * All jobs must allow a pause point before entering their job proper. This - * ensures that jobs can be paused prior to being started, then resumed la= ter. - */ -static void coroutine_fn job_co_entry(void *opaque) -{ - Job *job =3D opaque; - - assert(job && job->driver && job->driver->run); - job_pause_point(job); - job->ret =3D job->driver->run(job, &job->err); - job->deferred_to_main_loop =3D true; - aio_bh_schedule_oneshot(qemu_get_aio_context(), job_exit, job); -} - - -void job_start(Job *job) -{ - assert(job && !job_started(job) && job->paused && - job->driver && job->driver->run); - job->co =3D qemu_coroutine_create(job_co_entry, job); - job->pause_count--; - job->busy =3D true; - job->paused =3D false; - job_state_transition(job, JOB_STATUS_RUNNING); - aio_co_enter(job->aio_context, job->co); -} - /* Assumes the block_job_mutex is held */ static bool job_timer_not_pending(Job *job) { @@ -894,6 +851,40 @@ static void job_completed(Job *job) } } =20 +/** Useful only as a type shim for aio_bh_schedule_oneshot. */ +static void job_exit(void *opaque) +{ + Job *job =3D (Job *)opaque; + job_completed(job); +} + +/** + * All jobs must allow a pause point before entering their job proper. This + * ensures that jobs can be paused prior to being started, then resumed la= ter. + */ +static void coroutine_fn job_co_entry(void *opaque) +{ + Job *job =3D opaque; + + assert(job && job->driver && job->driver->run); + job_pause_point(job); + job->ret =3D job->driver->run(job, &job->err); + job->deferred_to_main_loop =3D true; + aio_bh_schedule_oneshot(qemu_get_aio_context(), job_exit, job); +} + +void job_start(Job *job) +{ + assert(job && !job_started(job) && job->paused && + job->driver && job->driver->run); + job->co =3D qemu_coroutine_create(job_co_entry, job); + job->pause_count--; + job->busy =3D true; + job->paused =3D false; + job_state_transition(job, JOB_STATUS_RUNNING); + aio_co_enter(job->aio_context, job->co); +} + void job_cancel(Job *job, bool force) { if (job->status =3D=3D JOB_STATUS_CONCLUDED) { diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c index ef29f35e44..86606f92b3 100644 --- a/tests/test-blockjob-txn.c +++ b/tests/test-blockjob-txn.c @@ -24,7 +24,7 @@ typedef struct { int *result; } TestBlockJob; =20 -static void test_block_job_exit(Job *job) +static void test_block_job_clean(Job *job) { BlockJob *bjob =3D container_of(job, BlockJob, job); BlockDriverState *bs =3D blk_bs(bjob->blk); @@ -73,7 +73,7 @@ static const BlockJobDriver test_block_job_driver =3D { .user_resume =3D block_job_user_resume, .drain =3D block_job_drain, .run =3D test_block_job_run, - .exit =3D test_block_job_exit, + .clean =3D test_block_job_clean, }, }; =20 --=20 2.14.4