From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=59157 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PiPNa-0002cJ-IV for qemu-devel@nongnu.org; Thu, 27 Jan 2011 05:47:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PiPNZ-00062A-Gp for qemu-devel@nongnu.org; Thu, 27 Jan 2011 05:47:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40706) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PiPNZ-000622-7b for qemu-devel@nongnu.org; Thu, 27 Jan 2011 05:47:05 -0500 Message-ID: <4D414D22.6060700@redhat.com> Date: Thu, 27 Jan 2011 12:46:58 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [RFC][PATCH 11/12] qcow2: Convert qcow2 to use coroutines for async I/O References: <1295688567-25496-1-git-send-email-stefanha@linux.vnet.ibm.com> <1295688567-25496-12-git-send-email-stefanha@linux.vnet.ibm.com> <4D40406B.2070302@redhat.com> <20110127100904.GB19191@stefanha-thinkpad.localdomain> In-Reply-To: <20110127100904.GB19191@stefanha-thinkpad.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi , qemu-devel@nongnu.org On 01/27/2011 12:09 PM, Stefan Hajnoczi wrote: > > > > > > The way I thought of doing this is: > > > > qcow_aio_write(...) > > { > > execute_in_coroutine { > > co_mutex_lock(&bs->mutex); > > do_qcow_aio_write(...); // original qcow code > > co_mutex_release(&bs->mutex); > > } > > } > > I think this approach makes sense as the next step towards a > fine-grained strategy. > > Remember that qcow2 is not just: > qcow2_aio_write(...) > { > sync_io(...); > aio_write(...); > complete_request(...); /* in callback */ > } > > It is actually: > qcow2_aio_write(...) > { > sync_io(...); > aio_write(...); > more_sync_io(...); /* in callback */ > complete_request(...); > } > > We need to make sure the synchronous I/O after aio write completion is > also guarded. Correct. Every entry point into qcow2 needs to be wrapped. Maybe the best way forward is to implement it in the block layer. While that makes additional hacking harder, it emphasises the fact that qcow2 logic need not be changed in any way in order to remove vcpu blocking without compromising concurrency. The block layer could examine BlockDriver::not_really_async, and if set, instead of calling BlockDriver::bdrv_aio_writev, it can call a wrapper which schedules a coroutine and returns a fake AIOCB. The wrapper would also wrap the completion with a wrapper, so that it too would execute under a coroutine. The mutex would be managed by the wrapper, and qcow2 would be completely unchanged except for setting not_really_async. -- error compiling committee.c: too many arguments to function