From nobody Fri Oct 24 09:53:11 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151943053197167.29780415467224; Fri, 23 Feb 2018 16:02:11 -0800 (PST) Received: from localhost ([::1]:47927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epNI3-0005zt-46 for importer@patchew.org; Fri, 23 Feb 2018 19:02:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epN8Q-0005yC-VG for qemu-devel@nongnu.org; Fri, 23 Feb 2018 18:52:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1epN8N-00062g-NX for qemu-devel@nongnu.org; Fri, 23 Feb 2018 18:52:14 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33452 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 1epN8F-0005kw-Gy; Fri, 23 Feb 2018 18:52:03 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5221FA27F1; Fri, 23 Feb 2018 23:51:56 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-231.bos.redhat.com [10.18.17.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20C32104947C; Fri, 23 Feb 2018 23:51:56 +0000 (UTC) From: John Snow To: qemu-block@nongnu.org Date: Fri, 23 Feb 2018 18:51:42 -0500 Message-Id: <20180223235142.21501-22-jsnow@redhat.com> In-Reply-To: <20180223235142.21501-1-jsnow@redhat.com> References: <20180223235142.21501-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 23 Feb 2018 23:51:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 23 Feb 2018 23:51:56 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC v4 21/21] blockjobs: add manual_mgmt option to transactions 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 , pkrempa@redhat.com, jtc@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This allows us to easily force the option for all jobs belonging to a transaction to ensure consistency with how all those jobs will be handled. This is purely a convenience. Signed-off-by: John Snow --- blockdev.c | 7 ++++++- blockjob.c | 10 +++++++--- include/block/blockjob.h | 5 ++++- qapi/transaction.json | 3 ++- tests/test-blockjob-txn.c | 6 +++--- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/blockdev.c b/blockdev.c index 2eddb0e726..34181c41c2 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2225,6 +2225,11 @@ static TransactionProperties *get_transaction_proper= ties( props->completion_mode =3D ACTION_COMPLETION_MODE_INDIVIDUAL; } =20 + if (!props->has_manual_mgmt) { + props->has_manual_mgmt =3D true; + props->manual_mgmt =3D false; + } + return props; } =20 @@ -2250,7 +2255,7 @@ void qmp_transaction(TransactionActionList *dev_list, */ props =3D get_transaction_properties(props); if (props->completion_mode !=3D ACTION_COMPLETION_MODE_INDIVIDUAL) { - block_job_txn =3D block_job_txn_new(); + block_job_txn =3D block_job_txn_new(props->manual_mgmt); } =20 /* drain all i/o before any operations */ diff --git a/blockjob.c b/blockjob.c index f9e8a64261..eaaa2aea65 100644 --- a/blockjob.c +++ b/blockjob.c @@ -136,6 +136,9 @@ struct BlockJobTxn { =20 /* Reference count */ int refcnt; + + /* Participating jobs must use manual completion */ + bool manual; }; =20 static QLIST_HEAD(, BlockJob) block_jobs =3D QLIST_HEAD_INITIALIZER(block_= jobs); @@ -176,11 +179,12 @@ BlockJob *block_job_get(const char *id) return NULL; } =20 -BlockJobTxn *block_job_txn_new(void) +BlockJobTxn *block_job_txn_new(bool manual_mgmt) { BlockJobTxn *txn =3D g_new0(BlockJobTxn, 1); QLIST_INIT(&txn->jobs); txn->refcnt =3D 1; + txn->manual =3D manual_mgmt; return txn; } =20 @@ -944,7 +948,7 @@ void *block_job_create(const char *job_id, const BlockJ= obDriver *driver, job->paused =3D true; job->pause_count =3D 1; job->refcnt =3D 1; - job->manual =3D (flags & BLOCK_JOB_MANUAL); + job->manual =3D (flags & BLOCK_JOB_MANUAL) || (txn && txn->manu= al); job->status =3D BLOCK_JOB_STATUS_CREATED; block_job_state_transition(job, BLOCK_JOB_STATUS_CREATED); aio_timer_init(qemu_get_aio_context(), &job->sleep_timer, @@ -978,7 +982,7 @@ void *block_job_create(const char *job_id, const BlockJ= obDriver *driver, /* Single jobs are modeled as single-job transactions for sake of * consolidating the job management logic */ if (!txn) { - txn =3D block_job_txn_new(); + txn =3D block_job_txn_new(false); block_job_txn_add_job(txn, job); block_job_txn_unref(txn); } else { diff --git a/include/block/blockjob.h b/include/block/blockjob.h index e09064c342..f3d026f13d 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -371,8 +371,11 @@ void block_job_iostatus_reset(BlockJob *job); * All jobs in the transaction either complete successfully or fail/cancel= as a * group. Jobs wait for each other before completing. Cancelling one job * cancels all jobs in the transaction. + * + * @manual_mgmt: whether or not jobs that belong to this transaction will = be + * forced to use 2.12+ job management semantics */ -BlockJobTxn *block_job_txn_new(void); +BlockJobTxn *block_job_txn_new(bool manual_mgmt); =20 /** * block_job_ref: diff --git a/qapi/transaction.json b/qapi/transaction.json index bd312792da..9611758cb6 100644 --- a/qapi/transaction.json +++ b/qapi/transaction.json @@ -79,7 +79,8 @@ ## { 'struct': 'TransactionProperties', 'data': { - '*completion-mode': 'ActionCompletionMode' + '*completion-mode': 'ActionCompletionMode', + '*manual-mgmt': 'bool' } } =20 diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c index 34f09ef8c1..2d84f9a41e 100644 --- a/tests/test-blockjob-txn.c +++ b/tests/test-blockjob-txn.c @@ -119,7 +119,7 @@ static void test_single_job(int expected) BlockJobTxn *txn; int result =3D -EINPROGRESS; =20 - txn =3D block_job_txn_new(); + txn =3D block_job_txn_new(false); job =3D test_block_job_start(1, true, expected, &result, txn); block_job_start(job); =20 @@ -158,7 +158,7 @@ static void test_pair_jobs(int expected1, int expected2) int result1 =3D -EINPROGRESS; int result2 =3D -EINPROGRESS; =20 - txn =3D block_job_txn_new(); + txn =3D block_job_txn_new(false); job1 =3D test_block_job_start(1, true, expected1, &result1, txn); job2 =3D test_block_job_start(2, true, expected2, &result2, txn); block_job_start(job1); @@ -220,7 +220,7 @@ static void test_pair_jobs_fail_cancel_race(void) int result1 =3D -EINPROGRESS; int result2 =3D -EINPROGRESS; =20 - txn =3D block_job_txn_new(); + txn =3D block_job_txn_new(false); job1 =3D test_block_job_start(1, true, -ECANCELED, &result1, txn); job2 =3D test_block_job_start(2, false, 0, &result2, txn); block_job_start(job1); --=20 2.14.3