From patchwork Mon Aug 22 16:46:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Harper X-Patchwork-Id: 110955 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1B069B6F65 for ; Tue, 23 Aug 2011 02:46:24 +1000 (EST) Received: from localhost ([::1]:44671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvXdf-0002op-Us for incoming@patchwork.ozlabs.org; Mon, 22 Aug 2011 12:46:15 -0400 Received: from eggs.gnu.org ([140.186.70.92]:54847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvXda-0002mr-5Y for qemu-devel@nongnu.org; Mon, 22 Aug 2011 12:46:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QvXdZ-00069m-2F for qemu-devel@nongnu.org; Mon, 22 Aug 2011 12:46:10 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:42948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvXdY-00069h-Rw for qemu-devel@nongnu.org; Mon, 22 Aug 2011 12:46:09 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e9.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p7MGCOXZ012353 for ; Mon, 22 Aug 2011 12:12:24 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p7MGk7Lf2920468 for ; Mon, 22 Aug 2011 12:46:07 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p7MCjsEb000688 for ; Mon, 22 Aug 2011 09:45:54 -0300 Received: from localhost.localdomain (frylock.austin.ibm.com [9.53.41.12]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p7MCjrgG000660; Mon, 22 Aug 2011 09:45:53 -0300 Received: by localhost.localdomain (Postfix, from userid 1000) id C941D1BF7D; Mon, 22 Aug 2011 11:46:00 -0500 (CDT) Date: Mon, 22 Aug 2011 11:46:00 -0500 From: Ryan Harper To: Christoph Hellwig Message-ID: <20110822164600.GU5792@us.ibm.com> References: <20110821222547.GA22046@lst.de> <20110822145916.GS5792@us.ibm.com> <20110822151208.GB4130@lst.de> <20110822152911.GT5792@us.ibm.com> <20110822153514.GA4749@lst.de> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110822153514.GA4749@lst.de> User-Agent: Mutt/1.5.6+20040907i X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 32.97.182.139 Cc: Ryan Harper , qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH 0/3] better I/O accounting V2 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 * Christoph Hellwig [2011-08-22 10:37]: > On Mon, Aug 22, 2011 at 10:29:11AM -0500, Ryan Harper wrote: > > (gdb) frame 0 > > #0 0x00000000004200c1 in bdrv_acct_done (bs=0x12310b0, cookie=0x1c68810) at /root/git/qemu/block_int.h:239 239 bs->nr_bytes[cookie->type] += cookie->bytes; > > (gdb) p *cookie > > $3 = {bytes = 72057589759737855, start_time_ns = 72057589759737855, type = 16777215} > > So it is indeed corrupted. I'll try to figure out how that could have > happened. So, I believe this is how it's happening. we start accounting on a write which is turned into a multiwrite via virtio_blk_handle_write() which calls virtio_submit_multiwrite(). Then when the multiwrite completes, we invoke virtio_blk_rw_complete() on each part of the multiwrite. None of these requests have had their acct structure initialized since there was just *one* initial write. We could do a bdrv_acct_start() on each req, but that would break the concept of hiding the additional writes under the initial request. So ensuring that the acct field is initialed when the request is allocated will fix the issue. With this patch, I don't see the crash anymore. Signed-off-by: Ryan Harper diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 2660d1d..e746917 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -123,6 +123,7 @@ static VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s) req->dev = s; req->qiov.size = 0; req->next = NULL; + memset(&req->acct, 0, sizeof(BlockAcctCookie)); return req; }