From patchwork Tue Apr 25 19:59:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashijeet Acharya X-Patchwork-Id: 9699567 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A935260245 for ; Tue, 25 Apr 2017 20:05:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9848228676 for ; Tue, 25 Apr 2017 20:05:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B8FC28681; Tue, 25 Apr 2017 20:05:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 35CB028676 for ; Tue, 25 Apr 2017 20:05:05 +0000 (UTC) Received: from localhost ([::1]:51204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36hs-0002R2-GD for patchwork-qemu-devel@patchwork.kernel.org; Tue, 25 Apr 2017 16:05:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36cP-00079h-TP for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d36cP-00043z-5K for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:25 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:34413) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d36cO-00043a-VZ; Tue, 25 Apr 2017 15:59:25 -0400 Received: by mail-pg0-x243.google.com with SMTP id t7so9747186pgt.1; Tue, 25 Apr 2017 12:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XWpjEBu8sMbn6ZIAbzJPE1ZnhTWfURZjL92A+nLwqEg=; b=Faug/Wv4FyTw48CfPH/jbq9lcjbyDFMyBRWCQCAY0MX6atdZa7Ea+fgs3Jy2OzvqyP 0LOJQO4ymj4C0pOOwmpGfyJQurJVJI+u77bvmwTVyexH4RHNXxlfqTQVlh3LuFkhDsAr 3WCkG3dtVdr0XJ8c0lbkTwicF/Ryu8SpR43rbuuEr3cBijnfhCLeP7dkdjerx6TRsUBK zUa5W96xi/UT2sKzkWtXZdsyvINRVe+wCOQemWyfsaYMFQ25OqT6yG+OkZ8Y01HQjJZb WoxfgjTy11ckHXjyrOsAB4o/f6yltZk3azZiZxudPEn2P2HNwMNS65BpC0Yw9ZiqPiGe mqeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XWpjEBu8sMbn6ZIAbzJPE1ZnhTWfURZjL92A+nLwqEg=; b=rfs4b6JKVEdZ2/eqJm98+9wGEMzhAo7wx6uS4BfleJzv4ej84cpHE37pke6IssXAtm eYE52XcHab5doA+25k24vZHFOotV1KAdCF1JnyibG94qa1eIPM3cYS23txHlpeF9QMyC 4MPXLfnkAoSGEObeDum1C9HU2zFc4YyVJQA6zcTo4QMJ3X751UoiNOvKKALZ3o28sSeS OFW6pdwSLDMOWfGpEPzVivA45lRMOrbOZwAx7M17UN1ABSKtzb28VAGdhNw9+deLgYCP HtM6MJkrEAheJmbu5fTmKE42slnrhQGuxIlrnhcppW3DmCMNWcoEoCV8sfU9qY8FNqOJ QGLw== X-Gm-Message-State: AN3rC/6qbCl7nkOu4Icq+LnYYoGJqDa2Ae3Ek6j4C1eRWTEHo8aS/YaJ CSIAD/GDWmBdxA== X-Received: by 10.84.241.65 with SMTP id u1mr39222303plm.28.1493150364080; Tue, 25 Apr 2017 12:59:24 -0700 (PDT) Received: from linux.local ([157.51.23.94]) by smtp.gmail.com with ESMTPSA id y187sm37931530pfy.67.2017.04.25.12.59.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 12:59:23 -0700 (PDT) From: Ashijeet Acharya To: stefanha@gmail.com Date: Wed, 26 Apr 2017 01:29:09 +0530 Message-Id: <1493150351-28918-7-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> References: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v1 6/8] dmg: Handle bz2 compressed/raw/zeroed chunks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, peter@lekensteyn.nl, Ashijeet Acharya , jsnow@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We do not need to cache the access point for these chunks but need to update our various supporting variables like chunk, sectors_read etc. to keep maintaining our code structure. Call cache_access_point() after reading chunks of these types. Signed-off-by: Ashijeet Acharya --- block/dmg.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index 749c151..f643e41 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -680,20 +680,30 @@ update: (char *)s->uncompressed_chunk, (unsigned int) (512 * s->sectorcounts[chunk])); + if (ret < 0) { return ret; } + cache_access_point(drs, NULL, -1, chunk, sectors_read, + sector_offset); break; case 1: /* copy */ - ret = bdrv_pread(bs->file, s->offsets[chunk], - s->uncompressed_chunk, s->lengths[chunk]); - if (ret != s->lengths[chunk]) { - return -1; + if (drs->sectors_read == -1) { + ret = bdrv_pread(bs->file, s->offsets[chunk], + s->uncompressed_chunk, s->lengths[chunk]); + if (ret != s->lengths[chunk]) { + return -1; + } } + cache_access_point(drs, NULL, -1, chunk, sectors_read, + sector_offset); break; case 2: /* zero */ /* see dmg_read, it is treated specially. No buffer needs to be * pre-filled, the zeroes can be set directly. */ + cache_access_point(drs, NULL, -1, chunk, sectors_read, + sector_offset); + break; } s->current_chunk = chunk;