From patchwork Fri Jun 22 06:44:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peter A. G. Crosthwaite" X-Patchwork-Id: 166523 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6DA1DB6F86 for ; Fri, 22 Jun 2012 16:44:59 +1000 (EST) Received: from localhost ([::1]:49313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Shxc0-0005Yc-6k for incoming@patchwork.ozlabs.org; Fri, 22 Jun 2012 02:44:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Shxbs-0005YK-5W for qemu-devel@nongnu.org; Fri, 22 Jun 2012 02:44:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Shxbn-0003UD-Qh for qemu-devel@nongnu.org; Fri, 22 Jun 2012 02:44:47 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:45727) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Shxbn-0003Tq-KA for qemu-devel@nongnu.org; Fri, 22 Jun 2012 02:44:43 -0400 Received: by dadn2 with SMTP id n2so1978339dad.4 for ; Thu, 21 Jun 2012 23:44:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=2tlkwh8S3aEt6b3EmHnlO0kU9+/x/5Q46PtXJG40mM0=; b=KLlNk40zlMqYNvCu4PSSwIAED9c6A99k642fvYG+aKBPYhR4UuHGY81zQ3xkEO2d3S 061kDvIyVzracBV8ngqJHNZlrF9iuTlEsSIqjKQR8K27UsCe2rAV/Qf8zEM313rWt9jU iQVRQ1FdmLfDx0zy1hxAqsPt0OEyVwvJWW7+CINmLcQY4G3kQtrwG/Bx/ZJbSblESvC9 T5TkVXMXQbk3Lo2OkWbQKN/8sTNpRKWPqdKkK+9Nc9X0nIQxLF3mj/H0hssGWdEhJKkL yXA7X6y/tJP2/J22MFSuXCNnRExBzVEvFndaf2KU3hHjFJrAZhJHsnte93aa3j3aZob0 JKLw== Received: by 10.68.217.166 with SMTP id oz6mr6377268pbc.136.1340347479825; Thu, 21 Jun 2012 23:44:39 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id og4sm38049221pbb.48.2012.06.21.23.44.36 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 21 Jun 2012 23:44:38 -0700 (PDT) From: "Peter A. G. Crosthwaite" To: qemu-devel@nongnu.org, kwolf@redhat.com, stefanha@linux.vnet.ibm.com Date: Fri, 22 Jun 2012 16:44:19 +1000 Message-Id: <1340347459-29861-1-git-send-email-peter.crosthwaite@petalogix.com> X-Mailer: git-send-email 1.7.3.2 X-Gm-Message-State: ALoCoQliGHXd1AlXZVDrl7E5ODQpmNF9CSPKbwIFq2aYaIGfHPvp6UYhNhGeg6AygBmdL4mS+qY5 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.45 Cc: peter.crosthwaite@petalogix.com, edgar.iglesias@gmail.com, john.williams@petalogix.com Subject: [Qemu-devel] [RFC] block: Removed coroutine ownership assumption 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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 {