qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC] block: Removed coroutine ownership assumption
@ 2012-06-22  6:44 Peter A. G. Crosthwaite
  2012-06-22  7:49 ` Kevin Wolf
  2012-06-22  7:50 ` Jan Kiszka
  0 siblings, 2 replies; 38+ messages in thread
From: Peter A. G. Crosthwaite @ 2012-06-22  6:44 UTC (permalink / raw)
  To: qemu-devel, kwolf, stefanha
  Cc: peter.crosthwaite, edgar.iglesias, john.williams

The block layer assumes that it is the only user of coroutines -
The qemu_in_coroutine() is used to determine if a function is in one of the
block layers coroutines, which is flawed. I.E. If a client (e.g. a device or
a machine model) of the block layer uses couroutine itself, the block layer
will identify the callers coroutines as its own, and may falsely yield the
calling coroutine (instead of creating its own to yield).

AFAICT, there are no conflicts in the QEMU master here yet, but its kind of an
issue, as anyone who comes along and used coroutines and the block layer
together is going to run into some very obscure and hard to debug race
conditions.

Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
---
 block.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/block.c b/block.c
index 0acdcac..b50af15 100644
--- a/block.c
+++ b/block.c
@@ -380,7 +380,7 @@ int bdrv_create(BlockDriver *drv, const char* filename,
         return -ENOTSUP;
     }
 
-    if (qemu_in_coroutine()) {
+    if (0) {
         /* Fast-path if already in coroutine context */
         bdrv_create_co_entry(&cco);
     } else {
@@ -1590,7 +1590,7 @@ static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,
         bdrv_io_limits_disable(bs);
     }
 
-    if (qemu_in_coroutine()) {
+    if (0) {
         /* Fast-path if already in coroutine context */
         bdrv_rw_co_entry(&rwco);
     } else {
@@ -3813,7 +3813,7 @@ int bdrv_flush(BlockDriverState *bs)
         .ret = NOT_DONE,
     };
 
-    if (qemu_in_coroutine()) {
+    if (0) {
         /* Fast-path if already in coroutine context */
         bdrv_flush_co_entry(&rwco);
     } else {
@@ -3874,7 +3874,7 @@ int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors)
         .ret = NOT_DONE,
     };
 
-    if (qemu_in_coroutine()) {
+    if (0) {
         /* Fast-path if already in coroutine context */
         bdrv_discard_co_entry(&rwco);
     } else {
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2012-07-13  8:35 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-22  6:44 [Qemu-devel] [RFC] block: Removed coroutine ownership assumption Peter A. G. Crosthwaite
2012-06-22  7:49 ` Kevin Wolf
2012-06-22  8:20   ` Peter Crosthwaite
2012-06-22  8:31     ` Peter Maydell
2012-06-22  8:34       ` Stefan Hajnoczi
2012-06-22  8:53     ` Kevin Wolf
2012-06-22 10:59       ` Peter Crosthwaite
     [not found]         ` <CAEgOgz4+5FsFUZT796chTADOXcRps0+74T4whfmdEsh_dO96VA@mail.gmail.com>
     [not found]           ` <CAJSP0QWVJTb9jPZC_mdWpd4OwLz4VOuxGBZ_=2M4HNeexEC96Q@mail.gmail.com>
     [not found]             ` <CAFEAcA_cX_jxZMSjjT=yBA1Hmf2VpWbGyDBZ8z9mqq5rVNsWWw@mail.gmail.com>
     [not found]               ` <CAJSP0QV=BsRhdD_tVE9Cav-bhGiF-R3+Ab2aTtun6nSoPh0EmQ@mail.gmail.com>
     [not found]                 ` <m3vcidw3v3.fsf@blackfin.pond.sub.org>
     [not found]                   ` <CAEgOgz6Mai7PvBkHwN0EjhFsAFMU8W=V1B1X0ZLN3c1YHRaWKA@mail.gmail.com>
     [not found]                     ` <CAJSP0QWJcuEOmxhoAceqU2WYQkGT+fsizf-kdx_irq97j3pw4Q@mail.gmail.com>
     [not found]                       ` <CAEgOgz51jauHzvEk0Pk+oNQ0qPekjKatvNivv4vxQsQR_6nOVQ@mail.gmail.com>
     [not found]                         ` <CAJSP0QXnaw2HV7M+U=0S-ApGGnrGtt1w0P5w5gpmv7h-7bMs9g@mail.gmail.com>
     [not found]                           ` <CAEgOgz65h2baE0ufvSgfow-B5fGVwJKgNwsf3C2r65HNGdiQxg@mail.gmail.com>
     [not found]                             ` <4FED6638.90703@redhat.com>
     [not found]                               ` <CAEgOgz6sUREnwNuiSM=344ZTNq_4xMJDFU29Sn+6dTeVww4rhA@mail.gmail.com>
     [not found]                                 ` <m3y5n61hl5.fsf@blackfin.pond.sub.org>
     [not found]                                   ` <CAEgOgz7oPPsMexuzsYwc2LOGGOC4EM9NvHjXAp0TT2T8kOyirQ@mail.gmail.com>
2012-07-02  8:50                                     ` Stefan Hajnoczi
2012-07-02  8:57                                       ` Peter Crosthwaite
2012-07-02  9:04                                         ` Kevin Wolf
2012-07-02  9:42                                           ` Peter Crosthwaite
2012-07-02 10:01                                             ` Kevin Wolf
2012-07-02 10:18                                               ` Peter Maydell
2012-07-02 10:44                                                 ` Kevin Wolf
2012-07-02 10:59                                                   ` Peter Maydell
2012-07-02 11:03                                                     ` Peter Crosthwaite
2012-07-02 11:12                                                   ` Peter Crosthwaite
2012-07-02 11:19                                                     ` Kevin Wolf
2012-07-02 11:25                                                       ` Peter Crosthwaite
2012-07-02 10:18                                               ` Peter Crosthwaite
2012-07-02 10:52                                                 ` Kevin Wolf
2012-07-02 10:57                                                   ` Peter Crosthwaite
2012-07-02 11:04                                                     ` Kevin Wolf
2012-07-12 13:42                                               ` Markus Armbruster
2012-07-13  1:21                                                 ` Peter Crosthwaite
2012-07-13  8:33                                                   ` Markus Armbruster
2012-06-22  7:50 ` Jan Kiszka
2012-06-22  8:00   ` Peter Crosthwaite
2012-06-22  8:06     ` Kevin Wolf
2012-06-22  8:16     ` Peter Maydell
2012-06-22  8:23       ` Peter Crosthwaite
2012-06-22  8:33       ` Stefan Hajnoczi
2012-06-22  8:45       ` Kevin Wolf
2012-06-22  8:48       ` Markus Armbruster
2012-06-22  9:06         ` Peter Maydell
2012-06-22 12:04           ` Markus Armbruster
2012-06-22 12:30             ` Peter Maydell
2012-06-22 13:36               ` Markus Armbruster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).