From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M1J6g-0004un-Nx for qemu-devel@nongnu.org; Tue, 05 May 2009 07:46:42 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M1J6c-0004uA-5I for qemu-devel@nongnu.org; Tue, 05 May 2009 07:46:42 -0400 Received: from [199.232.76.173] (port=56617 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M1J6c-0004u7-2h for qemu-devel@nongnu.org; Tue, 05 May 2009 07:46:38 -0400 Received: from mx2.redhat.com ([66.187.237.31]:59923) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M1J6b-0006KX-8C for qemu-devel@nongnu.org; Tue, 05 May 2009 07:46:37 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n45Bka78011719 for ; Tue, 5 May 2009 07:46:36 -0400 Message-ID: <4A002719.6090307@redhat.com> Date: Tue, 05 May 2009 14:46:33 +0300 From: Avi Kivity MIME-Version: 1.0 References: <4A000C74.5020907@redhat.com> <4A001563.1020604@redhat.com> In-Reply-To: <4A001563.1020604@redhat.com> Content-Type: multipart/mixed; boundary="------------050006030105000500030608" Subject: [Qemu-devel] Re: Strange virtio regression on mainline and stable-0.10 List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel This is a multi-part message in MIME format. --------------050006030105000500030608 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit (re-added qemu-devel) Kevin Wolf wrote: > Avi Kivity schrieb: > >> Running the Fedora 10 installer on a virtio disk on current master and >> on v0.10.3 will cause the installer to complain when mounting the >> freshly formatted filesystems. >> > > Could be related to https://bugzilla.redhat.com/show_bug.cgi?id=498405 > > It appears to be the same. > I encountered IO errors with qcow2 and virtio this morning, so I already > wanted to start debugging it. Unfortunately, with current master extboot > seems to be broken for me and so I can't even boot with virtio. Have not > figured out yet what's going wrong here. > I'm using the installer so I don't depend on extboot. Of course the extboot issue needs to be fixed as well. >> I don't understand it, as free_any_clusters() shouldn't be called while >> formatting. Any ideas? >> > > free_any_clusters shouldn't be called at all without snapshots or > backing files. > > qemu-img check notices refcount errors on my broken image though, so > this could still be the same. data point: if I force writes to be serialized in block-qcow2.c, then everything works, and there are no calls to free_any_clusters(). It's likely that there is some lack of serialization in the allocation code, some write that is in flight does not update the global state, only acb-local state. -- error compiling committee.c: too many arguments to function --------------050006030105000500030608 Content-Type: text/x-patch; name="serialize-qcow2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="serialize-qcow2.patch" diff --git a/block-qcow2.c b/block-qcow2.c index c4cd38d..151e688 100644 --- a/block-qcow2.c +++ b/block-qcow2.c @@ -1443,6 +1443,9 @@ static BlockDriverAIOCB *qcow_aio_readv(BlockDriverState *bs, return &acb->common; } +static int nb_writes; +static BlockDriverAIOCB *pending_writes[300]; + static void qcow_aio_write_cb(void *opaque, int ret) { QCowAIOCB *acb = opaque; @@ -1518,6 +1521,18 @@ done: qemu_vfree(acb->orig_buf); acb->common.cb(acb->common.opaque, ret); qemu_aio_release(acb); + + { + int i; + + for (i = 1; i < nb_writes; ++i) { + pending_writes[i - 1] = pending_writes[i]; + } + --nb_writes; + if (nb_writes) { + qcow_aio_write_cb(pending_writes[0], 0); + } + } } static BlockDriverAIOCB *qcow_aio_writev(BlockDriverState *bs, @@ -1535,7 +1550,12 @@ static BlockDriverAIOCB *qcow_aio_writev(BlockDriverState *bs, if (!acb) return NULL; - qcow_aio_write_cb(acb, 0); + pending_writes[nb_writes++] = acb; + + if (nb_writes == 1) { + qcow_aio_write_cb(acb, 0); + } + return &acb->common; } --------------050006030105000500030608--