From nobody Sun Apr 28 23:00:06 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491913834832607.9101284700621; Tue, 11 Apr 2017 05:30:34 -0700 (PDT) Received: from localhost ([::1]:39044 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxuwL-0007DD-F7 for importer@patchew.org; Tue, 11 Apr 2017 08:30:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxusd-0003zg-Kt for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxusc-0003mO-KI for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57919) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxusc-0003m9-EF for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:42 -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 6AAA56AAC0; Tue, 11 Apr 2017 12:26:41 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-27.pek2.redhat.com [10.72.8.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7329D8764D; Tue, 11 Apr 2017 12:26:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6AAA56AAC0 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6AAA56AAC0 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 11 Apr 2017 20:26:22 +0800 Message-Id: <20170411122632.14050-2-famz@redhat.com> In-Reply-To: <20170411122632.14050-1-famz@redhat.com> References: <20170411122632.14050-1-famz@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.26]); Tue, 11 Apr 2017 12:26:41 +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] [PULL 01/11] block: Make bdrv_parent_drained_begin/end public 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: Peter Maydell , famz@redhat.com 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" Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Acked-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf --- block/io.c | 4 ++-- include/block/block.h | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index 7321dda..9598646 100644 --- a/block/io.c +++ b/block/io.c @@ -44,7 +44,7 @@ static void coroutine_fn bdrv_co_do_rw(void *opaque); static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int count, BdrvRequestFlags flags); =20 -static void bdrv_parent_drained_begin(BlockDriverState *bs) +void bdrv_parent_drained_begin(BlockDriverState *bs) { BdrvChild *c; =20 @@ -55,7 +55,7 @@ static void bdrv_parent_drained_begin(BlockDriverState *b= s) } } =20 -static void bdrv_parent_drained_end(BlockDriverState *bs) +void bdrv_parent_drained_end(BlockDriverState *bs) { BdrvChild *c; =20 diff --git a/include/block/block.h b/include/block/block.h index 3e09222..488a07e 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -573,6 +573,22 @@ void bdrv_io_plug(BlockDriverState *bs); void bdrv_io_unplug(BlockDriverState *bs); =20 /** + * bdrv_parent_drained_begin: + * + * Begin a quiesced section of all users of @bs. This is part of + * bdrv_drained_begin. + */ +void bdrv_parent_drained_begin(BlockDriverState *bs); + +/** + * bdrv_parent_drained_end: + * + * End a quiesced section of all users of @bs. This is part of + * bdrv_drained_end. + */ +void bdrv_parent_drained_end(BlockDriverState *bs); + +/** * bdrv_drained_begin: * * Begin a quiesced section for exclusive access to the BDS, by disabling --=20 2.9.3 From nobody Sun Apr 28 23:00:06 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149191370583764.2678891374303; Tue, 11 Apr 2017 05:28:25 -0700 (PDT) Received: from localhost ([::1]:39030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxuuG-0005H3-FO for importer@patchew.org; Tue, 11 Apr 2017 08:28:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxush-00041b-Nl for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxusg-0003oz-Os for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35369) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxusg-0003nl-Ig for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:46 -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 93F91C04BD24; Tue, 11 Apr 2017 12:26:45 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-27.pek2.redhat.com [10.72.8.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EDA28764D; Tue, 11 Apr 2017 12:26:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 93F91C04BD24 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 93F91C04BD24 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 11 Apr 2017 20:26:23 +0800 Message-Id: <20170411122632.14050-3-famz@redhat.com> In-Reply-To: <20170411122632.14050-1-famz@redhat.com> References: <20170411122632.14050-1-famz@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.31]); Tue, 11 Apr 2017 12:26:45 +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] [PULL 02/11] block: Quiesce old aio context during bdrv_set_aio_context 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: Peter Maydell , famz@redhat.com 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" The fact that the bs->aio_context is changing can confuse the dataplane iothread, because of the now fine granularity aio context lock. bdrv_drain should rather be a bdrv_drained_begin/end pair, but since bs->aio_context is changing, we can just use aio_disable_external and bdrv_parent_drained_begin. Reported-by: Ed Swierk Signed-off-by: Fam Zheng Acked-by: Stefan Hajnoczi Reviewed-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf --- block.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index b8a3011..a995a8e 100644 --- a/block.c +++ b/block.c @@ -4396,11 +4396,12 @@ void bdrv_attach_aio_context(BlockDriverState *bs, =20 void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context) { - AioContext *ctx; + AioContext *ctx =3D bdrv_get_aio_context(bs); =20 + aio_disable_external(ctx); + bdrv_parent_drained_begin(bs); bdrv_drain(bs); /* ensure there are no in-flight requests */ =20 - ctx =3D bdrv_get_aio_context(bs); while (aio_poll(ctx, false)) { /* wait for all bottom halves to execute */ } @@ -4412,6 +4413,8 @@ void bdrv_set_aio_context(BlockDriverState *bs, AioCo= ntext *new_context) */ aio_context_acquire(new_context); bdrv_attach_aio_context(bs, new_context); + bdrv_parent_drained_end(bs); + aio_enable_external(ctx); aio_context_release(new_context); } =20 --=20 2.9.3 From nobody Sun Apr 28 23:00:06 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491913712851246.14036394931122; Tue, 11 Apr 2017 05:28:32 -0700 (PDT) Received: from localhost ([::1]:39031 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxuuN-0005Ns-4K for importer@patchew.org; Tue, 11 Apr 2017 08:28:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxusm-00044s-ID for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxusj-0003qt-GZ for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38137) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxusj-0003qk-AC for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:49 -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 5A417C04B948; Tue, 11 Apr 2017 12:26:48 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-27.pek2.redhat.com [10.72.8.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FF8694881; Tue, 11 Apr 2017 12:26:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5A417C04B948 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5A417C04B948 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 11 Apr 2017 20:26:24 +0800 Message-Id: <20170411122632.14050-4-famz@redhat.com> In-Reply-To: <20170411122632.14050-1-famz@redhat.com> References: <20170411122632.14050-1-famz@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.31]); Tue, 11 Apr 2017 12:26:48 +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] [PULL 03/11] tests/block-job-txn: Don't start block job before adding to txn 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: Peter Maydell , famz@redhat.com 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" Previously, before test_block_job_start returns, the job can already complete, as a result, the transactional state of other jobs added to the same txn later cannot be handled correctly. Move the block_job_start() calls to callers after block_job_txn_add_job() calls. Signed-off-by: Fam Zheng Acked-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf --- tests/test-blockjob-txn.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c index 4ccbda1..0f80194 100644 --- a/tests/test-blockjob-txn.c +++ b/tests/test-blockjob-txn.c @@ -110,7 +110,6 @@ static BlockJob *test_block_job_start(unsigned int iter= ations, s->result =3D result; data->job =3D s; data->result =3D result; - block_job_start(&s->common); return &s->common; } =20 @@ -123,6 +122,7 @@ static void test_single_job(int expected) txn =3D block_job_txn_new(); job =3D test_block_job_start(1, true, expected, &result); block_job_txn_add_job(txn, job); + block_job_start(job); =20 if (expected =3D=3D -ECANCELED) { block_job_cancel(job); @@ -164,6 +164,8 @@ static void test_pair_jobs(int expected1, int expected2) block_job_txn_add_job(txn, job1); job2 =3D test_block_job_start(2, true, expected2, &result2); block_job_txn_add_job(txn, job2); + block_job_start(job1); + block_job_start(job2); =20 if (expected1 =3D=3D -ECANCELED) { block_job_cancel(job1); @@ -223,6 +225,8 @@ static void test_pair_jobs_fail_cancel_race(void) block_job_txn_add_job(txn, job1); job2 =3D test_block_job_start(2, false, 0, &result2); block_job_txn_add_job(txn, job2); + block_job_start(job1); + block_job_start(job2); =20 block_job_cancel(job1); =20 --=20 2.9.3 From nobody Sun Apr 28 23:00:06 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491913850625404.8357031293948; Tue, 11 Apr 2017 05:30:50 -0700 (PDT) Received: from localhost ([::1]:39045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxuwa-0007Pj-Rl for importer@patchew.org; Tue, 11 Apr 2017 08:30:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxusn-00045B-13 for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxusm-0003re-0D for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55057) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxusl-0003rG-NR for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:51 -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 B30243D94E; Tue, 11 Apr 2017 12:26:50 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-27.pek2.redhat.com [10.72.8.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14FD57C12E; Tue, 11 Apr 2017 12:26:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B30243D94E Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B30243D94E From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 11 Apr 2017 20:26:25 +0800 Message-Id: <20170411122632.14050-5-famz@redhat.com> In-Reply-To: <20170411122632.14050-1-famz@redhat.com> References: <20170411122632.14050-1-famz@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.30]); Tue, 11 Apr 2017 12:26:50 +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] [PULL 04/11] coroutine: Extract qemu_aio_coroutine_enter 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: Peter Maydell , famz@redhat.com 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" It's a variant of qemu_coroutine_enter with an explicit AioContext parameter. Signed-off-by: Fam Zheng Acked-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf --- include/qemu/coroutine.h | 5 +++++ util/qemu-coroutine.c | 11 ++++++++--- util/trace-events | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index e60beaf..a4509bd 100644 --- a/include/qemu/coroutine.h +++ b/include/qemu/coroutine.h @@ -77,6 +77,11 @@ void qemu_coroutine_enter(Coroutine *coroutine); void qemu_coroutine_enter_if_inactive(Coroutine *co); =20 /** + * Transfer control to a coroutine and associate it with ctx + */ +void qemu_aio_coroutine_enter(AioContext *ctx, Coroutine *co); + +/** * Transfer control back to a coroutine's caller * * This function does not return until the coroutine is re-entered using diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c index 72412e5..486af9a 100644 --- a/util/qemu-coroutine.c +++ b/util/qemu-coroutine.c @@ -102,12 +102,12 @@ static void coroutine_delete(Coroutine *co) qemu_coroutine_delete(co); } =20 -void qemu_coroutine_enter(Coroutine *co) +void qemu_aio_coroutine_enter(AioContext *ctx, Coroutine *co) { Coroutine *self =3D qemu_coroutine_self(); CoroutineAction ret; =20 - trace_qemu_coroutine_enter(self, co, co->entry_arg); + trace_qemu_aio_coroutine_enter(ctx, self, co, co->entry_arg); =20 if (co->caller) { fprintf(stderr, "Co-routine re-entered recursively\n"); @@ -115,7 +115,7 @@ void qemu_coroutine_enter(Coroutine *co) } =20 co->caller =3D self; - co->ctx =3D qemu_get_current_aio_context(); + co->ctx =3D ctx; =20 /* Store co->ctx before anything that stores co. Matches * barrier in aio_co_wake and qemu_co_mutex_wake. @@ -139,6 +139,11 @@ void qemu_coroutine_enter(Coroutine *co) } } =20 +void qemu_coroutine_enter(Coroutine *co) +{ + qemu_aio_coroutine_enter(qemu_get_current_aio_context(), co); +} + void qemu_coroutine_enter_if_inactive(Coroutine *co) { if (!qemu_coroutine_entered(co)) { diff --git a/util/trace-events b/util/trace-events index ac27d94..b44ef4f 100644 --- a/util/trace-events +++ b/util/trace-events @@ -22,7 +22,7 @@ buffer_move(const char *buf, size_t len, const char *from= ) "%s: %zd bytes from % buffer_free(const char *buf, size_t len) "%s: capacity %zd" =20 # util/qemu-coroutine.c -qemu_coroutine_enter(void *from, void *to, void *opaque) "from %p to %p op= aque %p" +qemu_aio_coroutine_enter(void *ctx, void *from, void *to, void *opaque) "c= tx %p from %p to %p opaque %p" qemu_coroutine_yield(void *from, void *to) "from %p to %p" qemu_coroutine_terminate(void *co) "self %p" =20 --=20 2.9.3 From nobody Sun Apr 28 23:00:06 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491913854588127.93234272604889; Tue, 11 Apr 2017 05:30:54 -0700 (PDT) Received: from localhost ([::1]:39046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxuwf-0007TE-9i for importer@patchew.org; Tue, 11 Apr 2017 08:30:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxuso-00046i-Qi for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxuso-0003uF-1d for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45964) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxusn-0003tH-Ro for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:53 -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 D665E8046C; Tue, 11 Apr 2017 12:26:52 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-27.pek2.redhat.com [10.72.8.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A4FF8E89E; Tue, 11 Apr 2017 12:26:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D665E8046C Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D665E8046C From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 11 Apr 2017 20:26:26 +0800 Message-Id: <20170411122632.14050-6-famz@redhat.com> In-Reply-To: <20170411122632.14050-1-famz@redhat.com> References: <20170411122632.14050-1-famz@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.28]); Tue, 11 Apr 2017 12:26:53 +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] [PULL 05/11] async: Introduce aio_co_enter 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: Peter Maydell , famz@redhat.com 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" They start the coroutine on the specified context. Signed-off-by: Fam Zheng Acked-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf --- include/block/aio.h | 9 +++++++++ util/async.c | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/block/aio.h b/include/block/aio.h index 677b6ff..406e323 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -511,6 +511,15 @@ void aio_co_schedule(AioContext *ctx, struct Coroutine= *co); void aio_co_wake(struct Coroutine *co); =20 /** + * aio_co_enter: + * @ctx: the context to run the coroutine + * @co: the coroutine to run + * + * Enter a coroutine in the specified AioContext. + */ +void aio_co_enter(AioContext *ctx, struct Coroutine *co); + +/** * Return the AioContext whose event loop runs in the current thread. * * If called from an IOThread this will be the IOThread's AioContext. If diff --git a/util/async.c b/util/async.c index 663e297..355af73 100644 --- a/util/async.c +++ b/util/async.c @@ -453,6 +453,11 @@ void aio_co_wake(struct Coroutine *co) smp_read_barrier_depends(); ctx =3D atomic_read(&co->ctx); =20 + aio_co_enter(ctx, co); +} + +void aio_co_enter(AioContext *ctx, struct Coroutine *co) +{ if (ctx !=3D qemu_get_current_aio_context()) { aio_co_schedule(ctx, co); return; @@ -464,7 +469,7 @@ void aio_co_wake(struct Coroutine *co) QSIMPLEQ_INSERT_TAIL(&self->co_queue_wakeup, co, co_queue_next); } else { aio_context_acquire(ctx); - qemu_coroutine_enter(co); + qemu_aio_coroutine_enter(ctx, co); aio_context_release(ctx); } } --=20 2.9.3 From nobody Sun Apr 28 23:00:06 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149191398581487.04356728089067; Tue, 11 Apr 2017 05:33:05 -0700 (PDT) Received: from localhost ([::1]:39055 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxuym-0000xZ-ID for importer@patchew.org; Tue, 11 Apr 2017 08:33:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxuss-0004AL-JE for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxusr-0003v5-Oj for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37634) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxusr-0003ut-Jj for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:57 -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 A21774E35B; Tue, 11 Apr 2017 12:26:56 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-27.pek2.redhat.com [10.72.8.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DC1B8803C; Tue, 11 Apr 2017 12:26:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A21774E35B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A21774E35B From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 11 Apr 2017 20:26:27 +0800 Message-Id: <20170411122632.14050-7-famz@redhat.com> In-Reply-To: <20170411122632.14050-1-famz@redhat.com> References: <20170411122632.14050-1-famz@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.38]); Tue, 11 Apr 2017 12:26:56 +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] [PULL 06/11] block: Introduce bdrv_coroutine_enter 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: Peter Maydell , famz@redhat.com 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" Signed-off-by: Fam Zheng Acked-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf --- block.c | 5 +++++ include/block/block.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/block.c b/block.c index a995a8e..086a12d 100644 --- a/block.c +++ b/block.c @@ -4324,6 +4324,11 @@ AioContext *bdrv_get_aio_context(BlockDriverState *b= s) return bs->aio_context; } =20 +void bdrv_coroutine_enter(BlockDriverState *bs, Coroutine *co) +{ + aio_co_enter(bdrv_get_aio_context(bs), co); +} + static void bdrv_do_remove_aio_context_notifier(BdrvAioNotifier *ban) { QLIST_REMOVE(ban, list); diff --git a/include/block/block.h b/include/block/block.h index 488a07e..97d4330 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -558,6 +558,11 @@ bool bdrv_debug_is_suspended(BlockDriverState *bs, con= st char *tag); AioContext *bdrv_get_aio_context(BlockDriverState *bs); =20 /** + * Transfer control to @co in the aio context of @bs + */ +void bdrv_coroutine_enter(BlockDriverState *bs, Coroutine *co); + +/** * bdrv_set_aio_context: * * Changes the #AioContext used for fd handlers, timers, and BHs by this --=20 2.9.3 From nobody Sun Apr 28 23:00:06 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491913974125432.60864974480467; Tue, 11 Apr 2017 05:32:54 -0700 (PDT) Received: from localhost ([::1]:39054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxuya-0000pC-SD for importer@patchew.org; Tue, 11 Apr 2017 08:32:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxusv-0004DW-Pp for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxusu-0003vZ-2Y for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48740) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxust-0003vR-Sb for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:26:59 -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 E0BFBC05973B; Tue, 11 Apr 2017 12:26:58 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-27.pek2.redhat.com [10.72.8.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C6E77C12E; Tue, 11 Apr 2017 12:26:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E0BFBC05973B Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E0BFBC05973B From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 11 Apr 2017 20:26:28 +0800 Message-Id: <20170411122632.14050-8-famz@redhat.com> In-Reply-To: <20170411122632.14050-1-famz@redhat.com> References: <20170411122632.14050-1-famz@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.32]); Tue, 11 Apr 2017 12:26:59 +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] [PULL 07/11] blockjob: Use bdrv_coroutine_enter to start coroutine 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: Peter Maydell , famz@redhat.com 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" Resuming and especially starting of the block job coroutine, could be issue= d in the main thread. However the coroutine's "home" ctx should be set to the s= ame context as job->blk. Use bdrv_coroutine_enter to ensure that. Signed-off-by: Fam Zheng Acked-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf --- blockjob.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blockjob.c b/blockjob.c index 9b619f385..6e48932 100644 --- a/blockjob.c +++ b/blockjob.c @@ -290,7 +290,7 @@ void block_job_start(BlockJob *job) job->pause_count--; job->busy =3D true; job->paused =3D false; - qemu_coroutine_enter(job->co); + bdrv_coroutine_enter(blk_bs(job->blk), job->co); } =20 void block_job_ref(BlockJob *job) @@ -532,7 +532,7 @@ void block_job_user_resume(BlockJob *job) void block_job_enter(BlockJob *job) { if (job->co && !job->busy) { - qemu_coroutine_enter(job->co); + bdrv_coroutine_enter(blk_bs(job->blk), job->co); } } =20 --=20 2.9.3 From nobody Sun Apr 28 23:00:06 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491913727748795.8098549039909; Tue, 11 Apr 2017 05:28:47 -0700 (PDT) Received: from localhost ([::1]:39032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxuuc-0005bY-4L for importer@patchew.org; Tue, 11 Apr 2017 08:28:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxusx-0004FD-K3 for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxusw-0003xp-Nl for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55386) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxusw-0003xf-Il for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:02 -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 95A8919CF90; Tue, 11 Apr 2017 12:27:01 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-27.pek2.redhat.com [10.72.8.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DB1C88036; Tue, 11 Apr 2017 12:26:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 95A8919CF90 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 95A8919CF90 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 11 Apr 2017 20:26:29 +0800 Message-Id: <20170411122632.14050-9-famz@redhat.com> In-Reply-To: <20170411122632.14050-1-famz@redhat.com> References: <20170411122632.14050-1-famz@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.29]); Tue, 11 Apr 2017 12:27:01 +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] [PULL 08/11] qemu-io-cmds: Use bdrv_coroutine_enter 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: Peter Maydell , famz@redhat.com 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" qemu_coroutine_create associates @co to qemu_aio_context but we poll blk's context below. If the coroutine yields, it may never get resumed again. Use bdrv_coroutine_enter to make sure we are starting the I/O on the right context. Signed-off-by: Fam Zheng Acked-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf --- qemu-io-cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 883f53b..312fc6d 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -521,7 +521,7 @@ static int do_co_pwrite_zeroes(BlockBackend *blk, int64= _t offset, } =20 co =3D qemu_coroutine_create(co_pwrite_zeroes_entry, &data); - qemu_coroutine_enter(co); + bdrv_coroutine_enter(blk_bs(blk), co); while (!data.done) { aio_poll(blk_get_aio_context(blk), true); } --=20 2.9.3 From nobody Sun Apr 28 23:00:06 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491913874267870.1956646612101; Tue, 11 Apr 2017 05:31:14 -0700 (PDT) Received: from localhost ([::1]:39047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxuwy-0007k5-Ux for importer@patchew.org; Tue, 11 Apr 2017 08:31:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxut1-0004IK-24 for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxusz-0003zv-Ce for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48838) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxusz-0003yH-3y for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:05 -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 2C055C059731; Tue, 11 Apr 2017 12:27:04 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-27.pek2.redhat.com [10.72.8.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 895728764D; Tue, 11 Apr 2017 12:27:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2C055C059731 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2C055C059731 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 11 Apr 2017 20:26:30 +0800 Message-Id: <20170411122632.14050-10-famz@redhat.com> In-Reply-To: <20170411122632.14050-1-famz@redhat.com> References: <20170411122632.14050-1-famz@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.32]); Tue, 11 Apr 2017 12:27:04 +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] [PULL 09/11] block: Use bdrv_coroutine_enter to start I/O coroutines 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: Peter Maydell , famz@redhat.com 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" BDRV_POLL_WHILE waits for the started I/O by releasing bs's ctx then polling the main context, which relies on the yielded coroutine continuing on bs->c= tx before notifying qemu_aio_context with bdrv_wakeup(). Thus, using qemu_coroutine_enter to start I/O is wrong because if the corou= tine is entered from main loop, co->ctx will be qemu_aio_context, as a result of= the "release, poll, acquire" loop of BDRV_POLL_WHILE, race conditions happen wh= en both main thread and the iothread access the same BDS: main loop iothread Acked-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf ----------------------------------------------------------------------- blockdev_snapshot aio_context_acquire(bs->ctx) virtio_scsi_data_plane_handle_cmd bdrv_drained_begin(bs->ctx) bdrv_flush(bs) bdrv_co_flush(bs) aio_context_acquire(bs->ctx).e= nter ... qemu_coroutine_yield(co) BDRV_POLL_WHILE() aio_context_release(bs->ctx) aio_context_acquire(bs->ctx).r= eturn ... aio_co_wake(co) aio_poll(qemu_aio_context) ... co_schedule_bh_cb() ... qemu_coroutine_enter(co) ... /* (A) bdrv_co_flush(bs) /* (B) I/O on bs */ continues... */ aio_context_release(bs->ctx) aio_context_acquire(bs->ctx) Note that in above case, bdrv_drained_begin() doesn't do the "release, poll, acquire" in BDRV_POLL_WHILE, because bs->in_flight =3D=3D 0. Fix this by using bdrv_coroutine_enter and enter coroutine in the right context. iotests 109 output is updated because the coroutine reenter flow during mirror job complete is different (now through co_queue_wakeup, instead of the unconditional qemu_coroutine_switch before), making the end job len different. Signed-off-by: Fam Zheng Acked-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf --- block/block-backend.c | 4 ++-- block/io.c | 14 +++++++------- tests/qemu-iotests/109.out | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 18ece99..a8f2b34 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1045,7 +1045,7 @@ static int blk_prw(BlockBackend *blk, int64_t offset,= uint8_t *buf, co_entry(&rwco); } else { Coroutine *co =3D qemu_coroutine_create(co_entry, &rwco); - qemu_coroutine_enter(co); + bdrv_coroutine_enter(blk_bs(blk), co); BDRV_POLL_WHILE(blk_bs(blk), rwco.ret =3D=3D NOT_DONE); } =20 @@ -1152,7 +1152,7 @@ static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, in= t64_t offset, int bytes, acb->has_returned =3D false; =20 co =3D qemu_coroutine_create(co_entry, acb); - qemu_coroutine_enter(co); + bdrv_coroutine_enter(blk_bs(blk), co); =20 acb->has_returned =3D true; if (acb->rwco.ret !=3D NOT_DONE) { diff --git a/block/io.c b/block/io.c index 9598646..00e45ca 100644 --- a/block/io.c +++ b/block/io.c @@ -616,7 +616,7 @@ static int bdrv_prwv_co(BdrvChild *child, int64_t offse= t, bdrv_rw_co_entry(&rwco); } else { co =3D qemu_coroutine_create(bdrv_rw_co_entry, &rwco); - qemu_coroutine_enter(co); + bdrv_coroutine_enter(child->bs, co); BDRV_POLL_WHILE(child->bs, rwco.ret =3D=3D NOT_DONE); } return rwco.ret; @@ -1880,7 +1880,7 @@ int64_t bdrv_get_block_status_above(BlockDriverState = *bs, } else { co =3D qemu_coroutine_create(bdrv_get_block_status_above_co_entry, &data); - qemu_coroutine_enter(co); + bdrv_coroutine_enter(bs, co); BDRV_POLL_WHILE(bs, !data.done); } return data.ret; @@ -2006,7 +2006,7 @@ bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *q= iov, int64_t pos, }; Coroutine *co =3D qemu_coroutine_create(bdrv_co_rw_vmstate_entry, = &data); =20 - qemu_coroutine_enter(co); + bdrv_coroutine_enter(bs, co); while (data.ret =3D=3D -EINPROGRESS) { aio_poll(bdrv_get_aio_context(bs), true); } @@ -2223,7 +2223,7 @@ static BlockAIOCB *bdrv_co_aio_prw_vector(BdrvChild *= child, acb->is_write =3D is_write; =20 co =3D qemu_coroutine_create(bdrv_co_do_rw, acb); - qemu_coroutine_enter(co); + bdrv_coroutine_enter(child->bs, co); =20 bdrv_co_maybe_schedule_bh(acb); return &acb->common; @@ -2254,7 +2254,7 @@ BlockAIOCB *bdrv_aio_flush(BlockDriverState *bs, acb->req.error =3D -EINPROGRESS; =20 co =3D qemu_coroutine_create(bdrv_aio_flush_co_entry, acb); - qemu_coroutine_enter(co); + bdrv_coroutine_enter(bs, co); =20 bdrv_co_maybe_schedule_bh(acb); return &acb->common; @@ -2387,7 +2387,7 @@ int bdrv_flush(BlockDriverState *bs) bdrv_flush_co_entry(&flush_co); } else { co =3D qemu_coroutine_create(bdrv_flush_co_entry, &flush_co); - qemu_coroutine_enter(co); + bdrv_coroutine_enter(bs, co); BDRV_POLL_WHILE(bs, flush_co.ret =3D=3D NOT_DONE); } =20 @@ -2534,7 +2534,7 @@ int bdrv_pdiscard(BlockDriverState *bs, int64_t offse= t, int count) bdrv_pdiscard_co_entry(&rwco); } else { co =3D qemu_coroutine_create(bdrv_pdiscard_co_entry, &rwco); - qemu_coroutine_enter(co); + bdrv_coroutine_enter(bs, co); BDRV_POLL_WHILE(bs, rwco.ret =3D=3D NOT_DONE); } =20 diff --git a/tests/qemu-iotests/109.out b/tests/qemu-iotests/109.out index e5d70d7..55fe536 100644 --- a/tests/qemu-iotests/109.out +++ b/tests/qemu-iotests/109.out @@ -10,7 +10,7 @@ Automatically detecting the format is dangerous for raw i= mages, write operations Specify the 'raw' format explicitly to remove the restrictions. {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 1024, "offset": 0= , "speed": 0, "type": "mirror", "error": "Operation not permitted"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 65536, "offset": = 0, "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -73,7 +73,7 @@ Automatically detecting the format is dangerous for raw i= mages, write operations Specify the 'raw' format explicitly to remove the restrictions. {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 1024, "offset": 0= , "speed": 0, "type": "mirror", "error": "Operation not permitted"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 65536, "offset": = 0, "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -115,7 +115,7 @@ Automatically detecting the format is dangerous for raw= images, write operations Specify the 'raw' format explicitly to remove the restrictions. {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2560, "offset": 0= , "speed": 0, "type": "mirror", "error": "Operation not permitted"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 65536, "offset": = 0, "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -135,7 +135,7 @@ Automatically detecting the format is dangerous for raw= images, write operations Specify the 'raw' format explicitly to remove the restrictions. {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2560, "offset": O= FFSET, "speed": 0, "type": "mirror", "error": "Operation not permitted"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 65536, "offset": = OFFSET, "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -195,7 +195,7 @@ Automatically detecting the format is dangerous for raw= images, write operations Specify the 'raw' format explicitly to remove the restrictions. {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2048, "offset": O= FFSET, "speed": 0, "type": "mirror", "error": "Operation not permitted"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 65536, "offset": = OFFSET, "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) --=20 2.9.3 From nobody Sun Apr 28 23:00:06 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491914104464442.260088646619; Tue, 11 Apr 2017 05:35:04 -0700 (PDT) Received: from localhost ([::1]:39062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxv0h-0002Ow-0O for importer@patchew.org; Tue, 11 Apr 2017 08:35:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxut4-0004LL-Bw for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxut1-00043d-MR for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44892) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxut1-00042J-GY for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:07 -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 887372BA6E1; Tue, 11 Apr 2017 12:27:06 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-27.pek2.redhat.com [10.72.8.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA0FB7C12E; Tue, 11 Apr 2017 12:27:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 887372BA6E1 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 887372BA6E1 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 11 Apr 2017 20:26:31 +0800 Message-Id: <20170411122632.14050-11-famz@redhat.com> In-Reply-To: <20170411122632.14050-1-famz@redhat.com> References: <20170411122632.14050-1-famz@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.27]); Tue, 11 Apr 2017 12:27:06 +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] [PULL 10/11] block: Fix bdrv_co_flush early return 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: Peter Maydell , famz@redhat.com 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" bdrv_inc_in_flight and bdrv_dec_in_flight are mandatory for BDRV_POLL_WHILE to work, even for the shortcut case where flush is unnecessary. Move the if block to below bdrv_dec_in_flight, and BTW fix the variable declaration position. Signed-off-by: Fam Zheng Acked-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf Reviewed-by: Paolo Bonzini --- block/io.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/block/io.c b/block/io.c index 00e45ca..bae6947 100644 --- a/block/io.c +++ b/block/io.c @@ -2278,16 +2278,17 @@ static void coroutine_fn bdrv_flush_co_entry(void *= opaque) =20 int coroutine_fn bdrv_co_flush(BlockDriverState *bs) { - int ret; - - if (!bs || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs) || - bdrv_is_sg(bs)) { - return 0; - } + int current_gen; + int ret =3D 0; =20 bdrv_inc_in_flight(bs); =20 - int current_gen =3D bs->write_gen; + if (!bs || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs) || + bdrv_is_sg(bs)) { + goto early_exit; + } + + current_gen =3D bs->write_gen; =20 /* Wait until any previous flushes are completed */ while (bs->active_flush_req) { @@ -2370,6 +2371,7 @@ out: /* Return value is ignored - it's ok if wait queue is empty */ qemu_co_queue_next(&bs->flush_queue); =20 +early_exit: bdrv_dec_in_flight(bs); return ret; } --=20 2.9.3 From nobody Sun Apr 28 23:00:06 2024 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491914006844823.6912340274184; Tue, 11 Apr 2017 05:33:26 -0700 (PDT) Received: from localhost ([::1]:39056 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxuz7-0001Cm-GI for importer@patchew.org; Tue, 11 Apr 2017 08:33:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxut4-0004Lb-JC for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxut3-00046C-Q6 for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44930) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxut3-00045b-KQ for qemu-devel@nongnu.org; Tue, 11 Apr 2017 08:27:09 -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 AF07E2BA6E1; Tue, 11 Apr 2017 12:27:08 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-27.pek2.redhat.com [10.72.8.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AAAD88036; Tue, 11 Apr 2017 12:27:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AF07E2BA6E1 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AF07E2BA6E1 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 11 Apr 2017 20:26:32 +0800 Message-Id: <20170411122632.14050-12-famz@redhat.com> In-Reply-To: <20170411122632.14050-1-famz@redhat.com> References: <20170411122632.14050-1-famz@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.27]); Tue, 11 Apr 2017 12:27:08 +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] [PULL 11/11] sheepdog: Use bdrv_coroutine_enter before BDRV_POLL_WHILE 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: Peter Maydell , famz@redhat.com 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" When called from main thread, the coroutine should run in the context of bs. Use bdrv_coroutine_enter to ensure that. Signed-off-by: Fam Zheng --- block/sheepdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 1b71fc8..14d6327 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -736,7 +736,7 @@ static int do_req(int sockfd, BlockDriverState *bs, She= epdogReq *hdr, } else { co =3D qemu_coroutine_create(do_co_req, &srco); if (bs) { - qemu_coroutine_enter(co); + bdrv_coroutine_enter(bs, co); BDRV_POLL_WHILE(bs, !srco.finished); } else { qemu_coroutine_enter(co); --=20 2.9.3