From patchwork Thu Feb 20 18:13:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 25088 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 59003203C6 for ; Thu, 20 Feb 2014 18:15:36 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id le5sf4069938vcb.7 for ; Thu, 20 Feb 2014 10:15:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=sStZ+fbqoxEe7uQF4tgfSRxqVD6eLa/vekQJix+q/MI=; b=YQR9HATF9w9Tb62bc8eOQ9rUZB2tS+wvwvkgFshIAgOLm71z6Bi572t6JRJiMNSJU1 l/oQVeKNXRj1y2jCI7I/MIdLVKsuLz0NxDcfT2rsJjGOwLc5El4dSUB3/mR8g9h0gMfo FtqdlP3HnNNtKhxeVqcNOc78PgAb4fWTlJg0AAMIv6QiDj8Mf/MxsD12XXEnPmuD21d7 QzgFM558obl5y5ZIM+H9sttJHprrRVYEa4n2Y5pUme2b181lwG6uT+Y0pmI2VF3ATeFK in/g/h8vBAfVj402HxhrA8/R8GgSRP+KL2VhcoyRWgt+vxqYXE4XQlPrnA4sJn/2rqJm BR8w== X-Gm-Message-State: ALoCoQkOT9eW2qvuAExPH2pS5WldFZJMkOxEI0QcKSpyviXSvOISJCrZoWy8u+lfqq4E61hc58JL X-Received: by 10.236.129.41 with SMTP id g29mr1172898yhi.20.1392920136070; Thu, 20 Feb 2014 10:15:36 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.28.6 with SMTP id 6ls664336qgy.16.gmail; Thu, 20 Feb 2014 10:15:35 -0800 (PST) X-Received: by 10.220.92.135 with SMTP id r7mr1813988vcm.11.1392920135912; Thu, 20 Feb 2014 10:15:35 -0800 (PST) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id tr5si1797223vdc.52.2014.02.20.10.15.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Feb 2014 10:15:35 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id oy12so2228407veb.28 for ; Thu, 20 Feb 2014 10:15:35 -0800 (PST) X-Received: by 10.52.246.227 with SMTP id xz3mr1501723vdc.95.1392920135817; Thu, 20 Feb 2014 10:15:35 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp78844vcz; Thu, 20 Feb 2014 10:15:35 -0800 (PST) X-Received: by 10.140.108.116 with SMTP id i107mr3422265qgf.80.1392920134689; Thu, 20 Feb 2014 10:15:34 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id i7si689047qaf.90.2014.02.20.10.15.34 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 20 Feb 2014 10:15:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WGY7w-0000sU-6j; Thu, 20 Feb 2014 18:13:40 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WGY7u-0000sB-Ja for xen-devel@lists.xensource.com; Thu, 20 Feb 2014 18:13:38 +0000 Received: from [85.158.137.68:27341] by server-13.bemta-3.messagelabs.com id E3/72-26923-1D546035; Thu, 20 Feb 2014 18:13:37 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1392920015!3192374!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.9.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28015 invoked from network); 20 Feb 2014 18:13:37 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-6.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 20 Feb 2014 18:13:37 -0000 X-IronPort-AV: E=Sophos;i="4.97,513,1389744000"; d="scan'208";a="104422168" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 20 Feb 2014 18:13:35 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.2.342.4; Thu, 20 Feb 2014 13:13:34 -0500 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1WGY7l-0006dM-AI; Thu, 20 Feb 2014 18:13:29 +0000 From: Stefano Stabellini To: Date: Thu, 20 Feb 2014 18:13:22 +0000 Message-ID: <1392920002-18522-2-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA1 Cc: peter.maydell@linaro.org, olaf@aepfle.de, xen-devel@lists.xensource.com, Stefano Stabellini , qemu-devel@nongnu.org, Anthony.Perard@citrix.com, pbonzini@redhat.com Subject: [Xen-devel] [PULL 2/2] xen_disk: fix io accounting X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stefano.stabellini@eu.citrix.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: From: Olaf Hering bdrv_acct_done was called unconditional. But in case the ioreq has no segments there is no matching bdrv_acct_start call. This could lead to bogus accounting values. Found by code inspection. Signed-off-by: Olaf Hering Signed-off-by: Stefano Stabellini --- hw/block/xen_disk.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c index 098f6c6..7f0f14a 100644 --- a/hw/block/xen_disk.c +++ b/hw/block/xen_disk.c @@ -483,7 +483,18 @@ static void qemu_aio_complete(void *opaque, int ret) ioreq->status = ioreq->aio_errors ? BLKIF_RSP_ERROR : BLKIF_RSP_OKAY; ioreq_unmap(ioreq); ioreq_finish(ioreq); - bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct); + switch (ioreq->req.operation) { + case BLKIF_OP_WRITE: + case BLKIF_OP_FLUSH_DISKCACHE: + if (!ioreq->req.nr_segments) { + break; + } + case BLKIF_OP_READ: + bdrv_acct_done(ioreq->blkdev->bs, &ioreq->acct); + break; + default: + break; + } qemu_bh_schedule(ioreq->blkdev->bh); }